Sha256: 78b43e1b22279a254118e113fb1425bf865b7715603d9c96ed0c9163e7a37c1b

Contents?: true

Size: 1.3 KB

Versions: 1

Compression:

Stored size: 1.3 KB

Contents

class DeploySpec
  module BundlerDiscovery
    DEFAULT_BUNDLER_WITHOUT = %w(default production development test staging benchmark debug)

    def discover_dependencies_steps
      discover_bundler || super
    end

    def discover_bundler
      bundle_install if bundler?
    end

    def bundle_exec(command)
      return command unless bundler?
      "bundle exec #{command}"
    end

    def bundle_install
      bundle = %(bundle check --path=#{bundle_path} || bundle install #{frozen_flag} --path=#{bundle_path} --retry=2)
      bundle += " --without=#{bundler_without.join(':')}" unless bundler_without.empty?
      [remove_ruby_version_from_gemfile, bundle]
    end

    def remove_ruby_version_from_gemfile
      %q(sed -i '/^ruby\s/d' Gemfile) # Heroku apps often specify a ruby version.
    end

    def frozen_flag
      '--frozen' if gemfile_lock_exists?
    end

    def bundler_without
      config('dependencies', 'bundler', 'without') || (gem? ? [] : DEFAULT_BUNDLER_WITHOUT)
    end

    def bundler?
      file('Gemfile').exist?
    end

    def gemfile_lock_exists?
      file('Gemfile.lock').exist?
    end

    def coerce_task_definition(config)
      return super unless bundler?
      config['steps'] ||= []
      config['steps'] = config['steps'].map(&method(:bundle_exec))
      config
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
shipit-engine-0.0.1.pre app/models/deploy_spec/bundler_discovery.rb