class GitCompound::Lock
Class that represents lock file
Constants
- FILENAME
Public Class Methods
exist?()
click to toggle source
# File lib/git_compound/lock.rb, line 9 def self.exist? File.exist?(FILENAME) end
new(file = FILENAME)
click to toggle source
# File lib/git_compound/lock.rb, line 13 def initialize(file = FILENAME) @file = file @locked = YAML.load(File.read(file)) if File.exist?(file) clean unless @locked.is_a? Hash end
Public Instance Methods
clean()
click to toggle source
# File lib/git_compound/lock.rb, line 19 def clean @locked = { manifest: '', components: [] } self end
components()
click to toggle source
# File lib/git_compound/lock.rb, line 36 def components @locked[:components].to_a.map do |locked| Component.new(locked[:name].to_sym) do sha locked[:sha] source locked[:source] destination locked[:destination] end end end
contents()
click to toggle source
# File lib/git_compound/lock.rb, line 46 def contents @locked end
find(component)
click to toggle source
# File lib/git_compound/lock.rb, line 50 def find(component) components.find do |locked_component| locked_component.path == component.path end end
lock_component(component)
click to toggle source
# File lib/git_compound/lock.rb, line 28 def lock_component(component) @locked[:components] << component.to_hash end
lock_manifest(manifest)
click to toggle source
# File lib/git_compound/lock.rb, line 24 def lock_manifest(manifest) @locked[:manifest] = manifest.md5sum end
manifest()
click to toggle source
# File lib/git_compound/lock.rb, line 32 def manifest @locked[:manifest] end
process(worker)
click to toggle source
# File lib/git_compound/lock.rb, line 56 def process(worker) components.each { |component| worker.visit_component(component) } end
write()
click to toggle source
# File lib/git_compound/lock.rb, line 60 def write File.open(@file, 'w') { |f| f.puts @locked.to_yaml } end