Class: Frontman::Builder::Mapping
- Inherits:
-
Object
- Object
- Frontman::Builder::Mapping
- Extended by:
- T::Sig
- Defined in:
- lib/frontman/builder/mapping.rb
Instance Attribute Summary collapse
-
#output_path ⇒ Object
readonly
Returns the value of attribute output_path.
Instance Method Summary collapse
- #add(status, path) ⇒ Object
- #add_from_build_file(build_file) ⇒ Object
- #all ⇒ Object
- #delete_file ⇒ Object
-
#initialize(output_path) ⇒ Mapping
constructor
A new instance of Mapping.
- #save_file ⇒ Object
Constructor Details
#initialize(output_path) ⇒ Mapping
Returns a new instance of Mapping.
16 17 18 19 20 21 22 23 24 |
# File 'lib/frontman/builder/mapping.rb', line 16 def initialize(output_path) @output_path = output_path @mapping = { updated: [], created: [], unchanged: [], deleted: [] } end |
Instance Attribute Details
#output_path ⇒ Object (readonly)
Returns the value of attribute output_path.
13 14 15 |
# File 'lib/frontman/builder/mapping.rb', line 13 def output_path @output_path end |
Instance Method Details
#add(status, path) ⇒ Object
37 38 39 |
# File 'lib/frontman/builder/mapping.rb', line 37 def add(status, path) @mapping[status.to_sym].push(path) end |
#add_from_build_file(build_file) ⇒ Object
32 33 34 |
# File 'lib/frontman/builder/mapping.rb', line 32 def add_from_build_file(build_file) add(build_file.status, build_file.path) end |
#all ⇒ Object
27 28 29 |
# File 'lib/frontman/builder/mapping.rb', line 27 def all @mapping end |
#delete_file ⇒ Object
49 50 51 |
# File 'lib/frontman/builder/mapping.rb', line 49 def delete_file FileUtils.rm_f(output_path) end |
#save_file ⇒ Object
42 43 44 45 46 |
# File 'lib/frontman/builder/mapping.rb', line 42 def save_file ::File.open(output_path, 'w') do |f| f.write(JSON.pretty_generate(@mapping)) end end |