aboutsummaryrefslogtreecommitdiffstats
path: root/lib/bundler.rb
diff options
context:
space:
mode:
authorzofrex <zofrex@gmail.com>2012-11-11 16:58:04 +0000
committerzofrex <zofrex@gmail.com>2012-11-11 16:58:04 +0000
commit23b0ac3d0ec3628ef09972e40707e27f46ff3238 (patch)
treec08fdb977e764a2ef0655edf1ae2b5abbeda17f6 /lib/bundler.rb
parent4ab32202aeb6b5c67fe19bc404421119fa2f73ae (diff)
parent15fe70b01b20a508acfd42d1ef7386593a1d23a2 (diff)
downloadbundler-23b0ac3d0ec3628ef09972e40707e27f46ff3238.tar.gz
Merge remote-tracking branch 'upstream/master' into issue-2000
Diffstat (limited to 'lib/bundler.rb')
-rw-r--r--lib/bundler.rb42
1 files changed, 25 insertions, 17 deletions
diff --git a/lib/bundler.rb b/lib/bundler.rb
index 7497e03d..6091a6e0 100644
--- a/lib/bundler.rb
+++ b/lib/bundler.rb
@@ -24,6 +24,7 @@ module Bundler
autoload :Graph, 'bundler/graph'
autoload :Index, 'bundler/index'
autoload :Installer, 'bundler/installer'
+ autoload :Injector, 'bundler/injector'
autoload :LazySpecification, 'bundler/lazy_specification'
autoload :LockfileParser, 'bundler/lockfile_parser'
autoload :MatchPlatform, 'bundler/match_platform'
@@ -261,7 +262,7 @@ module Bundler
def which(executable)
if File.executable?(executable)
executable
- else
+ elsif ENV['PATH']
path = ENV['PATH'].split(File::PATH_SEPARATOR).find do |p|
File.executable?(File.join(p, executable))
end
@@ -291,24 +292,16 @@ module Bundler
# Eval the gemspec from its parent directory
Dir.chdir(path.dirname.to_s) do
contents = File.read(path.basename.to_s)
- begin
- Gem::Specification.from_yaml(contents)
- # Raises ArgumentError if the file is not valid YAML
- rescue ArgumentError, SyntaxError, Gem::EndOfYAMLException, Gem::Exception
+ if contents =~ /\A---/ # try YAML
begin
- eval(contents, TOPLEVEL_BINDING, path.expand_path.to_s)
- rescue LoadError, SyntaxError => e
- original_line = e.backtrace.find { |line| line.include?(path.to_s) }
- msg = "There was a #{e.class} while evaluating #{path.basename}: \n#{e.message}"
- msg << " from\n #{original_line}" if original_line
- msg << "\n"
-
- if e.is_a?(LoadError) && RUBY_VERSION >= "1.9"
- msg << "\nDoes it try to require a relative path? That's been removed in Ruby 1.9."
- end
-
- raise GemspecError, msg
+ Gem::Specification.from_yaml(contents)
+ # Raises ArgumentError if the file is not valid YAML (on syck)
+ # Psych raises a Psych::SyntaxError
+ rescue ArgumentError, YamlSyntaxError, Gem::EndOfYAMLException, Gem::Exception
+ eval_gemspec(path, contents)
end
+ else
+ eval_gemspec(path, contents)
end
end
end
@@ -319,6 +312,21 @@ module Bundler
private
+ def eval_gemspec(path, contents)
+ eval(contents, TOPLEVEL_BINDING, path.expand_path.to_s)
+ rescue LoadError, SyntaxError => e
+ original_line = e.backtrace.find { |line| line.include?(path.to_s) }
+ msg = "There was a #{e.class} while evaluating #{path.basename}: \n#{e.message}"
+ msg << " from\n #{original_line}" if original_line
+ msg << "\n"
+
+ if e.is_a?(LoadError) && RUBY_VERSION >= "1.9"
+ msg << "\nDoes it try to require a relative path? That's been removed in Ruby 1.9."
+ end
+
+ raise GemspecError, msg
+ end
+
def configure_gem_home_and_path
blank_home = ENV['GEM_HOME'].nil? || ENV['GEM_HOME'].empty?