Class: RubySkills::Manifest
- Inherits:
-
Object
- Object
- RubySkills::Manifest
- Defined in:
- lib/ruby_skills/manifest.rb
Overview
Defined Under Namespace
Classes: Skill
Instance Attribute Summary collapse
-
#skills ⇒ Array<Skill>
readonly
Skills declared in the Skillfile.
Instance Method Summary collapse
-
#initialize(path: default_skill_path) ⇒ Manifest
constructor
A new instance of Manifest.
-
#load! ⇒ Manifest
Read and evaluate the Skillfile, populating #skills.
-
#skill(name, github: nil, path: nil, version: nil) ⇒ void
Declare a skill in the Skillfile DSL.
Constructor Details
#initialize(path: default_skill_path) ⇒ Manifest
Returns a new instance of Manifest.
37 38 39 40 |
# File 'lib/ruby_skills/manifest.rb', line 37 def initialize(path: default_skill_path) @path = path @skills = [] end |
Instance Attribute Details
#skills ⇒ Array<Skill> (readonly)
Returns skills declared in the Skillfile.
34 35 36 |
# File 'lib/ruby_skills/manifest.rb', line 34 def skills @skills end |
Instance Method Details
#load! ⇒ Manifest
Read and evaluate the Skillfile, populating #skills.
46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/ruby_skills/manifest.rb', line 46 def load! unless @path.exist? raise RubySkills::Error, "Skillfile not found. Run `ruby-skills init` first." end instance_eval(@path.read, @path.to_s, 1) self rescue SyntaxError => e raise RubySkills::Error, "Invalid Skillfile: #{e.}" end |
#skill(name, github: nil, path: nil, version: nil) ⇒ void
This method returns an undefined value.
Declare a skill in the Skillfile DSL.
Exactly one source must be provided: github or path.
69 70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/ruby_skills/manifest.rb', line 69 def skill(name, github: nil, path: nil, version: nil) unless github || path raise RubySkills::Error, "#{name}: either github or path: must be provided" end @skills << Skill.new( name: name, github: github, path: path, version: version ) end |