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
90 91 92 93 94 95 96 |
# File 'lib/chake.rb', line 90 def encrypted_for(node) encrypted_files = Dir.glob("**/files/{default,host-#{node}}/*.{asc,gpg}") + Dir.glob("**/files/*.{asc,gpg}") encrypted_files.inject({}) do |hash, key| hash[key] = key.sub(/\.(asc|gpg)$/, '') hash end end |
#if_files_changed(node, group_name, files) ⇒ Object
98 99 100 101 102 103 104 105 106 107 108 109 110 111 |
# File 'lib/chake.rb', line 98 def if_files_changed(node, group_name, files) if files.empty? return end hash = IO.popen(['sha1sum', *files]).read hash_file = File.join($chake_tmpdir, node + '.' + group_name + '.sha1sum') if !File.exists?(hash_file) || File.read(hash_file) != hash yield end FileUtils.mkdir_p(File.dirname(hash_file)) File.open(hash_file, 'w') do |f| f.write(hash) end end |
#write_json_file(file, data) ⇒ Object
114 115 116 117 118 119 |
# File 'lib/chake.rb', line 114 def write_json_file(file, data) File.open(file, 'w') do |f| f.write(JSON.pretty_generate(data)) f.write("\n") end end |