Sha256: 9822b40bc0bae7e3d70abd94536305e06e89f1c59fa527dc065f1b764bfe74fb

Contents?: true

Size: 1.75 KB

Versions: 10

Compression:

Stored size: 1.75 KB

Contents

# frozen_string_literal: true
module Shipit
  class DeploySpec
    module BundlerDiscovery
      DEFAULT_BUNDLER_WITHOUT = %w(default production development test staging benchmark debug).freeze

      def discover_dependencies_steps
        discover_bundler || super
      end

      def discover_bundler
        bundle_install if bundler?
      end

      def bundle_exec(command)
        if bundler? && dependencies_steps.include?(remove_ruby_version_from_gemfile)
          "bundle exec #{command}"
        else
          command
        end
      end

      def discover_machine_env
        super.merge('BUNDLE_PATH' => bundle_path.to_s)
      end

      def bundle_install
        bundle = %(bundle install #{frozen_flag} --jobs 4 --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/i.match?(RUBY_PLATFORM)
          # OSX is nitpicky about the -i.
          %q(/usr/bin/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)
        config.merge('steps' => Array(config['steps']))
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
shipit-engine-0.39.0 app/models/shipit/deploy_spec/bundler_discovery.rb
shipit-engine-0.38.0 app/models/shipit/deploy_spec/bundler_discovery.rb
shipit-engine-0.37.0 app/models/shipit/deploy_spec/bundler_discovery.rb
shipit-engine-0.36.1 app/models/shipit/deploy_spec/bundler_discovery.rb
shipit-engine-0.36.0 app/models/shipit/deploy_spec/bundler_discovery.rb
shipit-engine-0.35.1 app/models/shipit/deploy_spec/bundler_discovery.rb
shipit-engine-0.35.0 app/models/shipit/deploy_spec/bundler_discovery.rb
shipit-engine-0.34.0 app/models/shipit/deploy_spec/bundler_discovery.rb
shipit-engine-0.33.0 app/models/shipit/deploy_spec/bundler_discovery.rb
shipit-engine-0.32.0 app/models/shipit/deploy_spec/bundler_discovery.rb