class Object
Public Instance Methods
encrypted_for(node)
click to toggle source
# File lib/chake.rb, line 83 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) { || ... }
click to toggle source
# File lib/chake.rb, line 91 def if_files_changed(node, group_name, files) if files.empty? return end hash_io = IO.popen(['xargs', 'sha1sum'], 'w+') files.sort.each { |f| hash_io.puts(f) } hash_io.close_write current_hash = hash_io.read hash_file = File.join(Chake.tmpdir, node + '.' + group_name + '.sha1sum') hash_on_disk = nil if File.exists?(hash_file) hash_on_disk = File.read(hash_file) end if current_hash != hash_on_disk yield end FileUtils.mkdir_p(File.dirname(hash_file)) File.open(hash_file, 'w') do |f| f.write(current_hash) end end
write_json_file(file, data)
click to toggle source
# File lib/chake.rb, line 116 def write_json_file(file, data) File.chmod(0600, file) if File.exists?(file) File.open(file, 'w', 0600) do |f| f.write(JSON.pretty_generate(data)) f.write("\n") end end