Sha256: bc99c026d90306a9a32cacb9e77c683d25a192646fd24493508332f915d5ee7a

Contents?: true

Size: 1.64 KB

Versions: 16

Compression:

Stored size: 1.64 KB

Contents

module Shipit
  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
        # Heroku apps often specify a ruby version.
        if /darwin/ =~ RUBY_PLATFORM
          # OSX is nitpicky about the -i.
          %q(sed -i '' '/^ruby\s/d' Gemfile)
        else
          %q(sed -i '/^ruby\s/d' Gemfile)
        end
      end

      def frozen_flag
        return unless gemfile_lock_exists?
        return if config('dependencies', 'bundler', 'frozen') == false
        '--frozen'
      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
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
shipit-engine-0.8.9 app/models/shipit/deploy_spec/bundler_discovery.rb
shipit-engine-0.8.8 app/models/shipit/deploy_spec/bundler_discovery.rb
shipit-engine-0.8.7 app/models/shipit/deploy_spec/bundler_discovery.rb
shipit-engine-0.8.6 app/models/shipit/deploy_spec/bundler_discovery.rb
shipit-engine-0.8.5 app/models/shipit/deploy_spec/bundler_discovery.rb
shipit-engine-0.8.4 app/models/shipit/deploy_spec/bundler_discovery.rb
shipit-engine-0.8.3 app/models/shipit/deploy_spec/bundler_discovery.rb
shipit-engine-0.8.2 app/models/shipit/deploy_spec/bundler_discovery.rb
shipit-engine-0.8.1 app/models/shipit/deploy_spec/bundler_discovery.rb
shipit-engine-0.8.0 app/models/shipit/deploy_spec/bundler_discovery.rb
shipit-engine-0.7.0 app/models/shipit/deploy_spec/bundler_discovery.rb
shipit-engine-0.6.4 app/models/shipit/deploy_spec/bundler_discovery.rb
shipit-engine-0.6.3 app/models/shipit/deploy_spec/bundler_discovery.rb
shipit-engine-0.6.2 app/models/shipit/deploy_spec/bundler_discovery.rb
shipit-engine-0.6.1 app/models/shipit/deploy_spec/bundler_discovery.rb
shipit-engine-0.6.0 app/models/shipit/deploy_spec/bundler_discovery.rb