From 6200acce71bcd82751699c3a89edf0259507465a Mon Sep 17 00:00:00 2001 From: Denis Knauf Date: Fri, 18 Jan 2013 23:47:03 +0100 Subject: [PATCH] metadata: set_timestamps_in_metadata for files without parse, too --- bin/ace | 3 ++- lib/ace.rb | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/bin/ace b/bin/ace index 9b84756..9dc2018 100755 --- a/bin/ace +++ b/bin/ace @@ -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 diff --git a/lib/ace.rb b/lib/ace.rb index da0bf65..f1e9f0b 100644 --- a/lib/ace.rb +++ b/lib/ace.rb @@ -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)