Class: Grundler::PackageJsonWriter
- Inherits:
-
Object
- Object
- Grundler::PackageJsonWriter
- Defined in:
- lib/grundler/package_json_writer.rb
Instance Method Summary collapse
- #add(packages) ⇒ Object
- #existing_packages ⇒ Object
-
#initialize(path) ⇒ PackageJsonWriter
constructor
A new instance of PackageJsonWriter.
- #remove(packages) ⇒ Object
Constructor Details
#initialize(path) ⇒ PackageJsonWriter
Returns a new instance of PackageJsonWriter.
5 6 7 |
# File 'lib/grundler/package_json_writer.rb', line 5 def initialize(path) @path = path end |
Instance Method Details
#add(packages) ⇒ Object
9 10 11 |
# File 'lib/grundler/package_json_writer.rb', line 9 def add(packages) write(existing_packages.merge(packages)) end |
#existing_packages ⇒ Object
19 20 21 |
# File 'lib/grundler/package_json_writer.rb', line 19 def existing_packages existing_content["dependencies"] end |
#remove(packages) ⇒ Object
13 14 15 16 17 |
# File 'lib/grundler/package_json_writer.rb', line 13 def remove(packages) write( existing_packages.delete_if { |k, _v| packages.include?(k) } ) end |