lib/epuber/lockfile.rb in epuber-0.5.1 vs lib/epuber/lockfile.rb in epuber-0.5.2
- old
+ new
@@ -11,10 +11,12 @@
#
def initialize(data = {})
@internal_data = data
end
+ # Load existing lockfile from given path, or create new one. You can define default attributes in block.
+ #
# @return [self]
#
def self.from_file(file_path)
if File.exists?(file_path)
hash = YAML.safe_load(File.read(file_path))
@@ -27,9 +29,10 @@
hash['epuber_version'] = hash.delete('version')
end
inst = self.new(hash)
inst.defined_from_file = file_path
+ yield inst if hash.empty? && block_given?
inst
end
# @return nil
#