lib/engineyard-serverside/dependency_manager/bundler.rb in engineyard-serverside-2.7.0.pre vs lib/engineyard-serverside/dependency_manager/bundler.rb in engineyard-serverside-2.7.8pre2
- old
+ new
@@ -2,23 +2,16 @@
module EY
module Serverside
class DependencyManager
class Bundler < Base
- DEFAULT_VERSION = "1.14.6"
+ DEFAULT_VERSION = "1.7.9"
- # Number of Bundler workers (--jobs)
- JOBS_NUMBER = 4
-
def self.default_version
DEFAULT_VERSION
end
- def self.jobs_number
- JOBS_NUMBER
- end
-
def detected?
gemfile?
end
def gemfile?
@@ -64,11 +57,11 @@
def uses_sqlite3?
lockfile && lockfile.uses_sqlite3?
end
def show_ey_config_instructions
- if lockfile && !lockfile.has_ey_config? && !config.ignore_ey_config_warning
+ if lockfile && !lockfile.has_ey_config?
shell.warning "Gemfile.lock does not contain ey_config. Add gem 'ey_config' to your Gemfile to access service configurations through EY::Config."
end
end
def rails_version
@@ -92,11 +85,11 @@
# their versions considered too
#
# the [,)] is to stop us from looking for e.g. 0.9.2, seeing
# 0.9.22, and mistakenly thinking 0.9.2 is there
has_gem_cmd = %{gem list bundler | grep "bundler " | egrep -q "#{egrep_escaped_version}[,)]"}
- install_cmd = %{gem install bundler -q -v "#{bundler_version}"}
+ install_cmd = %{gem install bundler -q --no-rdoc --no-ri -v "#{bundler_version}"}
sudo "#{clean_environment} && #{has_gem_cmd} || #{install_cmd}"
end
# GIT_SSH needs to be defined in the environment for customers with private bundler repos in their Gemfile.
# It seems redundant to declare the env var again, but I'm hesitant to remove it right now.
@@ -108,15 +101,10 @@
options = [
"--gemfile", "#{paths.gemfile}",
"--path", "#{paths.bundled_gems}",
"--binstubs", "#{paths.binstubs}",
]
-
- # Install gems in parallel (Bundler.1.5+ only)
- # @see EYPP-58
- options += ["--jobs", self.class.jobs_number] if check_version(bundler_version, ">= 1.5")
-
options += ["--deployment"] if lockfile
options += config.extra_bundle_install_options
options
end
@@ -130,13 +118,14 @@
if config.clean?
shell.substatus "Clean bundle forced (--clean)"
run clean_bundle
else
+ check_ruby = "#{config.ruby_version_command} | diff - #{paths.ruby_version} >/dev/null 2>&1"
check_system = "#{config.system_version_command} | diff - #{paths.system_version} >/dev/null 2>&1"
shell.substatus "Checking for system version changes"
- run "#{check_system} || #{clean_bundle}"
+ run "#{check_ruby} && #{check_system} || #{clean_bundle}"
end
end
def bundler_version
@bundler_version ||= lockfile && lockfile.bundler_version || self.class.default_version
@@ -149,28 +138,13 @@
if lockfile_path.exist?
@lockfile = Lockfile.new(lockfile_path.read, self.class.default_version)
end
end
- ##
- # Checks that given version is satisfies give requirement.
- #
- # @param [String] version
- # @param [String] requirement
- # @return [true, false]
- #
- def check_version(version, requirement)
- Gem::Requirement.new( requirement ).satisfied_by? Gem::Version.new( version )
- end
-
class Lockfile
attr_reader :bundler_version
- METADATA = 'METADATA'.freeze
- BUNDLED = 'BUNDLED WITH'.freeze
- DEPENDENCIES = 'DEPENDENCIES'.freeze
-
def initialize(lockfile_contents, default = EY::Serverside::DependencyManager::Bundler.default_version)
@contents = lockfile_contents
@default = default
@default_gem_version = Gem::Version.new(@default)
parse
@@ -204,12 +178,13 @@
def uses_sqlite3?
!any_database_adapter? && @contents.index(/^\s+sqlite3\s\([^\)]+\)$/)
end
def parse
- @bundler_version = parse_from_metadata || parse_from_bundled_with || parse_from_dependencies
- raise("Malformed or pre bundler-1.0.0 Gemfile.lock: #{@contents[0,50]}...") unless @bundler_version
+ parse_from_metadata ||
+ parse_from_dependencies ||
+ raise("Malformed or pre bundler-1.0.0 Gemfile.lock: #{@contents[0,50]}...")
end
def slice_section(header)
if start = @contents.index(/^#{header}/)
finish = @contents.index(/(^\S|\Z)/, start + header.length)
@@ -218,31 +193,28 @@
""
end
end
def parse_from_metadata
- section = slice_section(METADATA)
- return if section.empty?
+ section = slice_section('METADATA')
+ if section.empty?
+ return nil
+ end
+
result = section.scan(/^\s*version:\s*(.*)$/).first
- result ? result.first : @default
+ @bundler_version = result ? result.first : @default
end
- def parse_from_bundled_with
- section = slice_section(BUNDLED)
- return if section.empty?
-
- result = section.scan(/^#{BUNDLED}\s*(.*)$/).first
- result ? result.first : @default
- end
-
def dependencies_section
- @dependencies_section ||= slice_section(DEPENDENCIES)
+ @dependencies_section ||= slice_section('DEPENDENCIES')
end
def parse_from_dependencies
section = dependencies_section
- return if section.empty?
+ if section.empty?
+ return nil
+ end
result = scan_gem('bundler', section)
bundler_version = result ? result.last : nil
version_qualifier = result ? result.first : nil
@bundler_version = fetch_version(version_qualifier, bundler_version)