Sha256: 0c4673db804e8fd8764794808201c20cb47aefa8ac15568034527de1609bbefa

Contents?: true

Size: 1.37 KB

Versions: 11

Compression:

Stored size: 1.37 KB

Contents

module Bozo::DependencyResolvers

  # Class for resolving dependencies using Bundler.
  class Bundler

    # Creates a new instance.
    def initialize
      @pre = false
    end

    # Ensures Bundler is installed and then calls installs the gems specified
    # in your Gemfile.
    def execute
      ensure_bundler_installed
      install_gems
    end

    # Decides whether when installing Bundler if the pre version of the gem
    # should be installed.
    #
    # @param [Boolean] pre
    #     Whether the pre version of the Bundler gem should be installed.
    #
    #     The pre version of Bundler will not be used unless explicitly
    #     requested.
    #
    #     Calling the method without any arguments will request that the pre
    #     version should be used.
    def use_pre(pre = true)
      @pre = pre
    end

    private

    # Interrogates the list of installed gems and installs Bundler if it is
    # not found.
    def ensure_bundler_installed
      return if `gem list bundler`.include? 'bundler'

      args = %w{gem install --no-rdoc --no-ri bundler}
      args << '--pre' if @pre

      execute_command :rubygems, args
    end

    # Executes Bundler's install command, placing all of the installed gems
    # into the <tt>build/bundler</tt> directory.
    def install_gems
      execute_command :bundler, %w{bundle install --path build/bundler}
    end

  end

end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
bozo-scripts-0.3.1 lib/bozo/dependency_resolvers/bundler.rb
bozo-scripts-0.3.0 lib/bozo/dependency_resolvers/bundler.rb
bozo-scripts-0.2.4 lib/bozo/dependency_resolvers/bundler.rb
bozo-scripts-0.2.3 lib/bozo/dependency_resolvers/bundler.rb
bozo-scripts-0.2.2 lib/bozo/dependency_resolvers/bundler.rb
bozo-scripts-0.2.1 lib/bozo/dependency_resolvers/bundler.rb
bozo-scripts-0.2.0 lib/bozo/dependency_resolvers/bundler.rb
bozo-scripts-0.1.10 lib/bozo/dependency_resolvers/bundler.rb
bozo-scripts-0.1.9 lib/bozo/dependency_resolvers/bundler.rb
bozo-scripts-0.1.8 lib/bozo/dependency_resolvers/bundler.rb
bozo-scripts-0.1.7 lib/bozo/dependency_resolvers/bundler.rb