From 73fc703f7cbb2e6dfd50897d26b37fe8e76064e3 Mon Sep 17 00:00:00 2001 From: drbrain Date: Sat, 30 Nov 2013 23:27:52 +0000 Subject: * lib/rubygems: Update to RubyGems master 66e5c39. Notable changes: Implement gem.deps.rb (Gemfile) .lock support Fixed `gem uninstall` for a relative directory in GEM_HOME. * test/rubygems: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43939 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- lib/rubygems/request_set/lockfile.rb | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) (limited to 'lib/rubygems/request_set/lockfile.rb') diff --git a/lib/rubygems/request_set/lockfile.rb b/lib/rubygems/request_set/lockfile.rb index 0073bfdcc5..d70b09f7a2 100644 --- a/lib/rubygems/request_set/lockfile.rb +++ b/lib/rubygems/request_set/lockfile.rb @@ -1,3 +1,8 @@ +## +# Parses a gem.deps.rb.lock file and constructs a LockSet containing the +# dependencies found inside. If the lock file is missing no LockSet is +# constructed. + class Gem::RequestSet::Lockfile ## @@ -100,7 +105,7 @@ class Gem::RequestSet::Lockfile out << nil end - def relative_path_from(dest, base) + def relative_path_from dest, base # :nodoc: dest = File.expand_path(dest) base = File.expand_path(base) @@ -263,6 +268,9 @@ class Gem::RequestSet::Lockfile get while not @tokens.empty? and peek.first == type end + ## + # The contents of the lock file. + def to_s @set.resolve @@ -293,6 +301,10 @@ class Gem::RequestSet::Lockfile [byte_offset - @line_pos, @line] end + ## + # Converts a lock file into an Array of tokens. If the lock file is missing + # an empty Array is returned. + def tokenize # :nodoc: @line = 0 @line_pos = 0 @@ -342,6 +354,8 @@ class Gem::RequestSet::Lockfile end end + @tokens + rescue Errno::ENOENT @tokens end @@ -352,5 +366,14 @@ class Gem::RequestSet::Lockfile @tokens.unshift @current_token end + ## + # Writes the lock file alongside the gem dependencies file + + def write + open "#{@gem_deps_file}.lock", 'w' do |io| + io.write to_s + end + end + end -- cgit v1.2.3