Sha256: 1bbcc6a37cb87f0960b067ce2baa83c7407c6e9f56b00e88bb35921de1753bac

Contents?: true

Size: 1.12 KB

Versions: 8

Compression:

Stored size: 1.12 KB

Contents

module Sprinkle
  module Installers
    # This is a abstract class installer that most all the package installers
    # inherit from (deb, *BSD pkg, rpm, etc)
    class PackageInstaller < Installer
      
      # holds the list of packages to be installed
      attr_accessor :packages 

      def initialize(parent, *packages, &block) #:nodoc:
        options = packages.extract_options!
        super parent, options, &block
        @packages = [*packages].flatten
      end
      
      # automatically sets up the api for package installation based on the class name
      #
      # Apt becomes the method `apt`, etc
      def self.auto_api(*args)
        method_name = args.first || self.to_s.underscore.split("/").last
        class_name = self.to_s
        api do
          method="def #{method_name}(*names, &block)
            install #{class_name}.new(self, *names, &block)
          end"
          eval(method)
        end
      end
      
      # called by subclasses of PackageInstaller
      def install_package(*names, &block) #:nodoc:
        install Sprinkle::Installers::class.new(self, *names, &block)
      end

    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
sprinkle-0.7.7 lib/sprinkle/installers/package_installer.rb
sprinkle-0.7.6.2 lib/sprinkle/installers/package_installer.rb
sprinkle-0.7.6.1 lib/sprinkle/installers/package_installer.rb
sprinkle-0.7.6 lib/sprinkle/installers/package_installer.rb
sprinkle-0.7.5 lib/sprinkle/installers/package_installer.rb
sprinkle-0.7.4 lib/sprinkle/installers/package_installer.rb
sprinkle-0.7.3 lib/sprinkle/installers/package_installer.rb
sprinkle-0.7.2 lib/sprinkle/installers/package_installer.rb