metadata: set_timestamps_in_metadata for files without parse, too

This commit is contained in:
Denis Knauf 2013-01-18 23:47:03 +01:00
parent 92b4cc5dc2
commit 6200acce71
2 changed files with 3 additions and 2 deletions

View file

@ -46,7 +46,8 @@ rules.rules.each do |klass, files|
item = klass.create(raw_item.metadata, raw_item.content, file)
else
puts "~ Read #{file} without parse"
item = klass.create(Hash.new, File.read(file), file)
raw_item = Ace::RawItem.new(file).tap(&:set_timestamps_in_metadata)
item = klass.create(raw_item.metadata, File.read(file), file)
end
end
end

View file

@ -23,6 +23,7 @@ module Ace
def initialize(path)
@path = path
@data = File.read(path)
self.metadata = Hash.new
end
def parse
@ -40,7 +41,6 @@ module Ace
set_timestamps_in_metadata
end
private
def set_timestamps_in_metadata
self.metadata[:created_at] ||= File.ctime(self.path)
self.metadata[:updated_at] ||= File.mtime(self.path)