summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHomu <homu@barosl.com>2015-10-05 04:04:46 +0900
committerHomu <homu@barosl.com>2015-10-05 04:04:46 +0900
commit850ae9c5b07f2905eaf8ef14ff917ef2afee6714 (patch)
treebcddff433b4988f72044acb494e01934d1b03cdf
parent8deb9e78e1ef323878a9897b3c9e5fd08df553a2 (diff)
parentb73c775240e02606479d9110efa2c9ad1503c982 (diff)
downloadbundler-850ae9c5b07f2905eaf8ef14ff917ef2afee6714.tar.gz
Auto merge of #4017 - A5308Y:master, r=segiddins
Show ruby engine and version instead of a static string.
-rw-r--r--lib/bundler/installer.rb41
-rw-r--r--lib/bundler/installer/standalone.rb48
2 files changed, 50 insertions, 39 deletions
diff --git a/lib/bundler/installer.rb b/lib/bundler/installer.rb
index 923fbd1faf..1fd0b85dd9 100644
--- a/lib/bundler/installer.rb
+++ b/lib/bundler/installer.rb
@@ -2,6 +2,7 @@ require "erb"
require "rubygems/dependency_installer"
require "bundler/worker"
require "bundler/installer/parallel_installer"
+require "bundler/installer/standalone"
module Bundler
class Installer < Environment
@@ -68,7 +69,7 @@ module Bundler
install(options)
lock unless Bundler.settings[:frozen]
- generate_standalone(options[:standalone]) if options[:standalone]
+ Standalone.new(options[:standalone], @definition).generate if options[:standalone]
end
def install_gem_from_spec(spec, standalone = false, worker = 0, force = false)
@@ -209,44 +210,6 @@ module Bundler
end
end
- def generate_standalone(groups)
- standalone_path = Bundler.settings[:path]
- bundler_path = File.join(standalone_path, "bundler")
- SharedHelpers.filesystem_access(bundler_path) do |p|
- FileUtils.mkdir_p(p)
- end
-
- paths = []
-
- if groups.empty?
- specs = @definition.requested_specs
- else
- specs = @definition.specs_for groups.map(&:to_sym)
- end
-
- specs.each do |spec|
- next if spec.name == "bundler"
- next if spec.require_paths.nil? # builtin gems
-
- spec.require_paths.each do |path|
- full_path = Pathname.new(path).absolute? ? path : File.join(spec.full_gem_path, path)
- gem_path = Pathname.new(full_path).relative_path_from(Bundler.root.join(bundler_path))
- paths << gem_path.to_s.sub("#{Bundler.ruby_version.engine}/#{RbConfig::CONFIG["ruby_version"]}", '#{ruby_engine}/#{ruby_version}')
- end
- end
-
- File.open File.join(bundler_path, "setup.rb"), "w" do |file|
- file.puts "require 'rbconfig'"
- file.puts "# ruby 1.8.7 doesn't define RUBY_ENGINE"
- file.puts "ruby_engine = defined?(RUBY_ENGINE) ? RUBY_ENGINE : 'ruby'"
- file.puts "ruby_version = RbConfig::CONFIG[\"ruby_version\"]"
- file.puts "path = File.expand_path('..', __FILE__)"
- paths.each do |path|
- file.puts %{$:.unshift "\#{path}/#{path}"}
- end
- end
- end
-
def install_in_parallel(size, standalone, force = false)
ParallelInstaller.call(self, specs, size, standalone, force)
end
diff --git a/lib/bundler/installer/standalone.rb b/lib/bundler/installer/standalone.rb
new file mode 100644
index 0000000000..6776dd6200
--- /dev/null
+++ b/lib/bundler/installer/standalone.rb
@@ -0,0 +1,48 @@
+module Bundler
+ class Standalone
+ def initialize(groups, definition)
+ @specs = groups.empty? ? definition.requested_specs : definition.specs_for(groups.map(&:to_sym))
+ end
+
+ def generate
+ SharedHelpers.filesystem_access(bundler_path) do |p|
+ FileUtils.mkdir_p(p)
+ end
+ File.open File.join(bundler_path, "setup.rb"), "w" do |file|
+ file.puts "require 'rbconfig'"
+ file.puts "# ruby 1.8.7 doesn't define RUBY_ENGINE"
+ file.puts "ruby_engine = defined?(RUBY_ENGINE) ? RUBY_ENGINE : 'ruby'"
+ file.puts "ruby_version = RbConfig::CONFIG[\"ruby_version\"]"
+ file.puts "path = File.expand_path('..', __FILE__)"
+ paths.each do |path|
+ file.puts %{$:.unshift "\#{path}/#{path}"}
+ end
+ end
+ end
+
+ private
+
+ def paths
+ @specs.map do |spec|
+ next if spec.name == "bundler"
+ Array(spec.require_paths).map do |path|
+ gem_path(path, spec).sub(version_dir, '#{ruby_engine}/#{ruby_version}')
+ # This is a static string intentionally. It's interpolated at a later time.
+ end
+ end.flatten
+ end
+
+ def version_dir
+ "#{Bundler.ruby_version.engine}/#{RbConfig::CONFIG["ruby_version"]}"
+ end
+
+ def bundler_path
+ File.join(Bundler.settings[:path], "bundler")
+ end
+
+ def gem_path(path, spec)
+ full_path = Pathname.new(path).absolute? ? path : File.join(spec.full_gem_path, path)
+ Pathname.new(full_path).relative_path_from(Bundler.root.join(bundler_path)).to_s
+ end
+ end
+end