Top Level Namespace
Defined Under Namespace
Modules: Chake
Instance Method Summary collapse
- #encrypted_for(node) ⇒ Object
- #if_files_changed(node, group_name, files) ⇒ Object
- #write_json_file(file, data) ⇒ Object
Instance Method Details
#encrypted_for(node) ⇒ Object
76 77 78 79 80 81 |
# File 'lib/chake.rb', line 76 def encrypted_for(node) Dir.glob("**/files/{default,host-#{node}}/*.{asc,gpg}").inject({}) do |hash, key| hash[key] = key.sub(/\.(asc|gpg)$/, '') hash end end |
#if_files_changed(node, group_name, files) ⇒ Object
83 84 85 86 87 88 89 90 91 92 93 94 95 |
# File 'lib/chake.rb', line 83 def if_files_changed(node, group_name, files) if files.empty? return end hash = IO.popen(['sha1sum', *files]).read hash_file = File.join('.tmp', node + '.' + group_name + '.sha1sum') if !File.exists?(hash_file) || File.read(hash_file) != hash yield end File.open(hash_file, 'w') do |f| f.write(hash) end end |
#write_json_file(file, data) ⇒ Object
98 99 100 101 102 103 |
# File 'lib/chake.rb', line 98 def write_json_file(file, data) File.open(file, 'w') do |f| f.write(JSON.dump(data)) f.write("\n") end end |