Class: Shai::InstallRegistry
- Inherits:
-
Object
- Object
- Shai::InstallRegistry
- Defined in:
- lib/shai/install_registry.rb
Instance Attribute Summary collapse
-
#file_path ⇒ Object
readonly
Returns the value of attribute file_path.
Instance Method Summary collapse
- #add(slug, path) ⇒ Object
- #all ⇒ Object
- #has?(slug) ⇒ Boolean
-
#initialize ⇒ InstallRegistry
constructor
A new instance of InstallRegistry.
- #path_for(slug) ⇒ Object
- #remove(slug) ⇒ Object
Constructor Details
#initialize ⇒ InstallRegistry
Returns a new instance of InstallRegistry.
9 10 11 12 |
# File 'lib/shai/install_registry.rb', line 9 def initialize @file_path = File.join(Shai.configuration.config_dir, "installations.yml") @data = load_data end |
Instance Attribute Details
#file_path ⇒ Object (readonly)
Returns the value of attribute file_path.
14 15 16 |
# File 'lib/shai/install_registry.rb', line 14 def file_path @file_path end |
Instance Method Details
#add(slug, path) ⇒ Object
16 17 18 19 20 21 22 |
# File 'lib/shai/install_registry.rb', line 16 def add(slug, path) @data["projects"][slug] = { "path" => File.(path), "installed_at" => Time.now.iso8601 } save! end |
#all ⇒ Object
34 35 36 |
# File 'lib/shai/install_registry.rb', line 34 def all @data["projects"].dup end |
#has?(slug) ⇒ Boolean
38 39 40 |
# File 'lib/shai/install_registry.rb', line 38 def has?(slug) @data["projects"].key?(slug) end |
#path_for(slug) ⇒ Object
30 31 32 |
# File 'lib/shai/install_registry.rb', line 30 def path_for(slug) @data.dig("projects", slug, "path") end |
#remove(slug) ⇒ Object
24 25 26 27 28 |
# File 'lib/shai/install_registry.rb', line 24 def remove(slug) removed = @data["projects"].delete(slug) save! if removed removed end |