class Seed::Manifest
Public Class Methods
new(configuration)
click to toggle source
# File lib/seed/manifest.rb, line 5 def initialize(configuration) @configuration = configuration @paths = [] end
Public Instance Methods
appends(paths = [])
click to toggle source
# File lib/seed/manifest.rb, line 10 def appends(paths = []) @paths << paths @paths.flatten! end
current()
click to toggle source
@return [Hash]
# File lib/seed/manifest.rb, line 28 def current @current ||= self.generate_manifest end
diff?()
click to toggle source
# File lib/seed/manifest.rb, line 15 def diff? self.current.hash != self.latest.hash end
generate_manifest()
click to toggle source
# File lib/seed/manifest.rb, line 45 def generate_manifest hash = {} @paths.each do |path| next unless File.exist?(path) content = File.read(path) hash[path] = Digest::SHA256.new.update(content).hexdigest end hash end
latest()
click to toggle source
@return [Hash]
# File lib/seed/manifest.rb, line 33 def latest @configuration.make_tmp_dir open(self.manifest_path, File::RDONLY | File::CREAT) do |io| JSON.load(io) rescue {} end end
manifest_path()
click to toggle source
# File lib/seed/manifest.rb, line 41 def manifest_path @configuration.base_path.join('seed_manifest.json') end
save()
click to toggle source
# File lib/seed/manifest.rb, line 19 def save @configuration.make_tmp_dir open(self.manifest_path, File::WRONLY | File::CREAT | File::TRUNC) do |io| JSON.dump(self.current, io) end end