summaryrefslogtreecommitdiff
path: root/lib/rubygems/request_set
diff options
context:
space:
mode:
Diffstat (limited to 'lib/rubygems/request_set')
-rw-r--r--lib/rubygems/request_set/lockfile.rb25
1 files changed, 24 insertions, 1 deletions
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
@@ -343,6 +355,8 @@ class Gem::RequestSet::Lockfile
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