Module: Anvil::Helpers

Included in:
Builder, Manifest
Defined in:
lib/anvil/helpers.rb

Instance Method Summary collapse

Instance Method Details

#anvil_metadata_dir(root) ⇒ Object



14
15
16
17
18
# File 'lib/anvil/helpers.rb', line 14

def (root)
  dir = File.join(root, ".anvil")
  FileUtils.mkdir_p(dir)
  dir
end

#json_decode(str) ⇒ Object



10
11
12
# File 'lib/anvil/helpers.rb', line 10

def json_decode(str)
  JSON.load(str)
end

#json_encode(obj) ⇒ Object



6
7
8
# File 'lib/anvil/helpers.rb', line 6

def json_encode(obj)
  JSON.dump(obj)
end

#read_anvil_metadata(root, name) ⇒ Object



20
21
22
# File 'lib/anvil/helpers.rb', line 20

def (root, name)
  File.open(File.join((root), name)).read.chomp rescue nil
end

#write_anvil_metadata(root, name, data) ⇒ Object



24
25
26
27
28
# File 'lib/anvil/helpers.rb', line 24

def (root, name, data)
  File.open(File.join((root), name), "w") do |file|
    file.puts data
  end
end