Class: RBS::Collection::Config::Lockfile
Relationships & Source Files | |
Inherits: | Object |
Defined in: | lib/rbs/collection/config/lockfile.rb |
Class Method Summary
Instance Attribute Summary
- #gemfile_lock_path readonly
- #gems readonly
- #lockfile_dir readonly
- #lockfile_path readonly
- #path readonly
- #sources readonly
Instance Method Summary
Constructor Details
.new(lockfile_path:, path:, gemfile_lock_path:) ⇒ Lockfile
# File 'lib/rbs/collection/config/lockfile.rb', line 9
def initialize(lockfile_path:, path:, gemfile_lock_path:) @lockfile_path = lockfile_path @lockfile_dir = lockfile_path.parent @path = path @gemfile_lock_path = gemfile_lock_path @gems = {} end
Class Method Details
.from_lockfile(lockfile_path:, data:)
[ GitHub ]# File 'lib/rbs/collection/config/lockfile.rb', line 42
def self.from_lockfile(lockfile_path:, data:) path = Pathname(data["path"]) if p = data["gemfile_lock_path"] gemfile_lock_path = Pathname(p) end lockfile = Lockfile.new(lockfile_path: lockfile_path, path: path, gemfile_lock_path: gemfile_lock_path) if gems = data["gems"] gems.each do |gem| src = gem["source"] source = Sources.from_config_entry(src, base_directory: lockfile_path.dirname) lockfile.gems[gem["name"]] = { name: gem["name"], version: gem["version"], source: source } end end lockfile end
Instance Attribute Details
#gemfile_lock_path (readonly)
[ GitHub ]# File 'lib/rbs/collection/config/lockfile.rb', line 7
attr_reader :lockfile_path, :lockfile_dir, :path, :gemfile_lock_path, :sources, :gems
#gems (readonly)
[ GitHub ]# File 'lib/rbs/collection/config/lockfile.rb', line 7
attr_reader :lockfile_path, :lockfile_dir, :path, :gemfile_lock_path, :sources, :gems
#lockfile_dir (readonly)
[ GitHub ]# File 'lib/rbs/collection/config/lockfile.rb', line 7
attr_reader :lockfile_path, :lockfile_dir, :path, :gemfile_lock_path, :sources, :gems
#lockfile_path (readonly)
[ GitHub ]# File 'lib/rbs/collection/config/lockfile.rb', line 7
attr_reader :lockfile_path, :lockfile_dir, :path, :gemfile_lock_path, :sources, :gems
#path (readonly)
[ GitHub ]# File 'lib/rbs/collection/config/lockfile.rb', line 7
attr_reader :lockfile_path, :lockfile_dir, :path, :gemfile_lock_path, :sources, :gems
#sources (readonly)
[ GitHub ]# File 'lib/rbs/collection/config/lockfile.rb', line 7
attr_reader :lockfile_path, :lockfile_dir, :path, :gemfile_lock_path, :sources, :gems
Instance Method Details
#check_rbs_availability!
# File 'lib/rbs/collection/config/lockfile.rb', line 73
def check_rbs_availability! raise CollectionNotAvailable unless fullpath.exist? gems.each_value do |gem| source = gem[:source] case source when Sources::Git = fullpath.join(gem[:name], gem[:version], Sources::Git::METADATA_FILENAME) raise CollectionNotAvailable unless .exist? raise CollectionNotAvailable unless library_data(gem) == YAML.load( .read) when Sources::Local raise CollectionNotAvailable unless fullpath.join(gem[:name], gem[:version]).symlink? end end end
#fullpath
[ GitHub ]# File 'lib/rbs/collection/config/lockfile.rb', line 18
def fullpath lockfile_dir + path end
#gemfile_lock_fullpath
[ GitHub ]# File 'lib/rbs/collection/config/lockfile.rb', line 22
def gemfile_lock_fullpath if gemfile_lock_path lockfile_dir + gemfile_lock_path end end
#library_data(lib)
[ GitHub ]# File 'lib/rbs/collection/config/lockfile.rb', line 65
def library_data(lib) { "name" => lib[:name], "version" => lib[:version], "source" => lib[:source].to_lockfile } end
#to_lockfile
[ GitHub ]# File 'lib/rbs/collection/config/lockfile.rb', line 28
def to_lockfile # @type var data: lockfile_data data = { "path" => path.to_s, "gems" => gems.each_value.sort_by {|g| g[:name] }.map {|hash| library_data(hash) }, "gemfile_lock_path" => gemfile_lock_path.to_s } data.delete("gems") if gems.empty? data end