Sha256: da03ad1e49f7b949390b1e9c880eb3941d10791001e2a8b8d2b17e98bb3d7f3f

Contents?: true

Size: 1.88 KB

Versions: 6

Compression:

Stored size: 1.88 KB

Contents

module Sprinkle
  module Installers
    # The gem package installer installs Ruby gems.
    #
    # The installer has a single optional configuration: source.
    # By changing source you can specify a given ruby gems
    # repository from which to install.
    # 
    # == Example Usage
    #
    # First, a simple installation of the magic_beans gem:
    #
    #   package :magic_beans do
    #     description "Beans beans they're good for your heart..."
    #     gem 'magic_beans'
    #   end
    #
    # Second, install magic_beans gem from github:
    #
    #   package :magic_beans do
    #     gem 'magic_beans_package' do
    #       source 'http://gems.github.com'
    #     end
    #   end
    #
    # As you can see, setting options is as simple as creating a
    # block and calling the option as a method with the value as 
    # its parameter.
    class Gem < Installer
      
      api do
        def gem(name, options = {}, &block)
          @recommends << :rubygems
          install Gem.new(self, name, options, &block)
        end
      end
      
      attr_accessor :gem #:nodoc:

      def initialize(parent, gem, options = {}, &block) #:nodoc:
        super parent, options, &block
        @gem = gem
      end
      
      attributes :source, :repository, :http_proxy, :build_flags, :version

      protected

        # rubygems 0.9.5+ installs dependencies by default, and does platform selection

        def install_commands #:nodoc:
          cmd = "gem install #{gem}"
          cmd << " --version '#{version}'" if version
          cmd << " --source #{source}" if source
          cmd << " --install-dir #{repository}" if option?(:repository)
          cmd << " --no-rdoc --no-ri" unless option?(:build_docs)
          cmd << " --http-proxy #{http_proxy}" if option?(:http_proxy)
          cmd << " -- #{build_flags}" if option?(:build_flags)
          cmd
        end
        
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
sprinkle-0.7.1 lib/sprinkle/installers/gem.rb
sprinkle-0.7 lib/sprinkle/installers/gem.rb
sprinkle-0.6.2 lib/sprinkle/installers/gem.rb
sprinkle-0.6.1.1 lib/sprinkle/installers/gem.rb
sprinkle-0.6.1 lib/sprinkle/installers/gem.rb
sprinkle-0.6.0 lib/sprinkle/installers/gem.rb