Class: RubySkills::Lockfile
- Inherits:
-
Object
- Object
- RubySkills::Lockfile
- Defined in:
- lib/ruby_skills/lockfile.rb
Overview
Reads and writes the project Skills.lock file.
The lockfile records installed skill names, versions, and sources so later installs and removals stay consistent.
Instance Method Summary collapse
-
#add(name, version:, source:) ⇒ void
Record an installed skill in the lockfile.
-
#initialize(config: Config.new) ⇒ Lockfile
constructor
A new instance of Lockfile.
-
#remove(name) ⇒ void
Drop a skill from the lockfile.
-
#skills ⇒ Hash{String => Hash}
Installed skills stored in the lockfile.
Constructor Details
Instance Method Details
#add(name, version:, source:) ⇒ void
This method returns an undefined value.
Record an installed skill in the lockfile.
41 42 43 44 45 46 47 48 49 50 |
# File 'lib/ruby_skills/lockfile.rb', line 41 def add(name, version:, source:) data = load_data data["skills"][name] = { "version" => version, "source" => source } write(data) end |
#remove(name) ⇒ void
This method returns an undefined value.
Drop a skill from the lockfile.
56 57 58 59 60 61 62 |
# File 'lib/ruby_skills/lockfile.rb', line 56 def remove(name) data = load_data data["skills"].delete(name) write(data) end |
#skills ⇒ Hash{String => Hash}
Installed skills stored in the lockfile.
23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/ruby_skills/lockfile.rb', line 23 def skills return {} unless @config.lockfile_path.exist? data = YAML.safe_load_file( @config.lockfile_path, permitted_classes: [], aliases: true ) data.fetch("skills", {}) end |