Class: Gem::RequestSet::Lockfile
Relationships & Source Files | |
Namespace Children | |
Exceptions:
| |
Inherits: | Object |
Defined in: | lib/rubygems/request_set/lockfile.rb |
Overview
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 Method Summary
-
.new(request_set, gem_deps_file, dependencies = nil) ⇒ Lockfile
constructor
Creates a new
Lockfile
for the givenrequest_set
andgem_deps_file
location.
Instance Attribute Summary
-
#platforms
readonly
The platforms for this
Lockfile
.
Instance Method Summary
- #add_GIT(out)
-
#to_s
The contents of the lock file.
-
#write
Writes the lock file alongside the gem dependencies file.
Constructor Details
.new(request_set, gem_deps_file, dependencies = nil) ⇒ Lockfile
Creates a new Lockfile
for the given request_set
and gem_deps_file
location.
# File 'lib/rubygems/request_set/lockfile.rb', line 52
def initialize request_set, gem_deps_file, dependencies = nil @set = request_set @dependencies = dependencies @gem_deps_file = File. (gem_deps_file) @gem_deps_dir = File.dirname(@gem_deps_file) @gem_deps_file.untaint unless gem_deps_file.tainted? @current_token = nil @line = 0 @line_pos = 0 @platforms = [] @tokens = [] end
Instance Attribute Details
#platforms (readonly)
The platforms for this Lockfile
# File 'lib/rubygems/request_set/lockfile.rb', line 46
attr_reader :platforms
Instance Method Details
#add_GIT(out)
[ GitHub ]# File 'lib/rubygems/request_set/lockfile.rb', line 139
def add_GIT out return unless git_requests = @spec_groups.delete(Gem::Resolver::GitSpecification) by_repository_revision = git_requests.group_by do |request| source = request.spec.source [source.repository, source.rev_parse] end out << "GIT" by_repository_revision.each do |(repository, revision), requests| out << " remote: #{repository}" out << " revision: #{revision}" out << " specs:" requests.sort_by { |request| request.name }.each do |request| out << " #{request.name} (#{request.version})" dependencies = request.spec.dependencies.sort_by { |dep| dep.name } dependencies.each do |dep| out << " #{dep.name}#{dep.requirement.for_lockfile}" end end end out << nil end
#to_s
The contents of the lock file.
# File 'lib/rubygems/request_set/lockfile.rb', line 530
def to_s @set.resolve out = [] @requests = @set.sorted_requests @spec_groups = @requests.group_by do |request| request.spec.class end add_PATH out add_GIT out add_GEM out add_PLATFORMS out add_DEPENDENCIES out out.join "\n" end
#write
Writes the lock file alongside the gem dependencies file
# File 'lib/rubygems/request_set/lockfile.rb', line 641
def write content = to_s open "#{@gem_deps_file}.lock", 'w' do |io| io.write content end end