Class: MilkTea::PackageManifestEditor
- Inherits:
-
Object
- Object
- MilkTea::PackageManifestEditor
- Defined in:
- lib/milk_tea/packages/manifest_editor.rb
Instance Attribute Summary collapse
-
#manifest_path ⇒ Object
readonly
Returns the value of attribute manifest_path.
Instance Method Summary collapse
- #add_dependency(name, raw_spec) ⇒ Object
-
#initialize(path) ⇒ PackageManifestEditor
constructor
A new instance of PackageManifestEditor.
- #remove_dependency(name) ⇒ Object
Constructor Details
#initialize(path) ⇒ PackageManifestEditor
Returns a new instance of PackageManifestEditor.
11 12 13 14 15 16 |
# File 'lib/milk_tea/packages/manifest_editor.rb', line 11 def initialize(path) manifest = PackageManifest.load(path) @manifest_path = manifest.manifest_path rescue PackageManifestError => e raise PackageManifestEditorError, e. end |
Instance Attribute Details
#manifest_path ⇒ Object (readonly)
Returns the value of attribute manifest_path.
9 10 11 |
# File 'lib/milk_tea/packages/manifest_editor.rb', line 9 def manifest_path @manifest_path end |
Instance Method Details
#add_dependency(name, raw_spec) ⇒ Object
18 19 20 21 22 23 |
# File 'lib/milk_tea/packages/manifest_editor.rb', line 18 def add_dependency(name, raw_spec) config = parse_manifest dependencies = normalize_dependencies(config) dependencies[name] = raw_spec write_dependencies(dependencies) end |
#remove_dependency(name) ⇒ Object
25 26 27 28 29 30 31 32 |
# File 'lib/milk_tea/packages/manifest_editor.rb', line 25 def remove_dependency(name) config = parse_manifest dependencies = normalize_dependencies(config) raise PackageManifestEditorError, "dependency #{name} not found in #{@manifest_path}" unless dependencies.key?(name) dependencies.delete(name) write_dependencies(dependencies) end |