class Fingerprint::Record
Attributes
keys[R]
metadata[R]
mode[R]
path[R]
Public Class Methods
new(mode, path, metadata = {})
click to toggle source
# File lib/fingerprint/record.rb, line 36 def initialize(mode, path, metadata = {}) @mode = mode @path = path @metadata = metadata @keys = metadata.keys.grep(/^key\./) end
Public Instance Methods
[](key)
click to toggle source
# File lib/fingerprint/record.rb, line 49 def [](key) @metadata[key] end
diff(other)
click to toggle source
# File lib/fingerprint/record.rb, line 53 def diff(other) changes = [] all_keys = Set.new all_keys += @metadata.keys + other.metadata.keys # all_keys -= @keys + other.keys all_keys.each do |key| changes << key if @metadata[key].to_s != other.metadata[key].to_s end return changes end
options()
click to toggle source
# File lib/fingerprint/record.rb, line 67 def options options = {} options[:extended] = true if @metadata['options.extended'] == 'true' options[:checksums] = @metadata['options.checksums'].split(/[\s,]+/) if @metadata['options.checksums'] return options end
write(output)
click to toggle source
# File lib/fingerprint/record.rb, line 76 def write(output) output.puts "#{MODES[@mode]} #{@path}" return if @mode == :excluded @metadata.keys.sort.each do |key| output.puts "\t#{key} #{@metadata[key]}" end end