Class: Frontman::Builder::Mapping

Inherits:
Object
  • Object
show all
Extended by:
T::Sig
Defined in:
lib/frontman/builder/mapping.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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_pathObject (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

#allObject



27
28
29
# File 'lib/frontman/builder/mapping.rb', line 27

def all
  @mapping
end

#delete_fileObject



49
50
51
# File 'lib/frontman/builder/mapping.rb', line 49

def delete_file
  FileUtils.rm_f(output_path)
end

#save_fileObject



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