Class: Deveo::App::Metadata
- Inherits:
-
Object
- Object
- Deveo::App::Metadata
- Defined in:
- lib/deveo/app.rb
Instance Method Summary collapse
- #filename ⇒ Object
-
#initialize(app_path) ⇒ Metadata
constructor
A new instance of Metadata.
- #read ⇒ Object
- #write(data = {}) ⇒ Object
Constructor Details
#initialize(app_path) ⇒ Metadata
Returns a new instance of Metadata.
44 45 46 |
# File 'lib/deveo/app.rb', line 44 def initialize(app_path) @app_path = app_path end |
Instance Method Details
#filename ⇒ Object
48 49 50 |
# File 'lib/deveo/app.rb', line 48 def filename File.join(@app_path, "app.json") end |
#read ⇒ Object
52 53 54 |
# File 'lib/deveo/app.rb', line 52 def read JSON.parse(File.read(filename), symbolize_names: true) end |
#write(data = {}) ⇒ Object
56 57 58 59 60 61 |
# File 'lib/deveo/app.rb', line 56 def write(data = {}) data = read.merge(data) File.open(filename, "w") do |file| file.write(JSON.pretty_generate(data)) end end |