lib/rim/rim_info.rb in esr-rim-1.3.9 vs lib/rim/rim_info.rb in esr-rim-1.4.0

- old
+ new

@@ -34,10 +34,16 @@ AttrsDef.each do |d| attr_accessor d end + @@git_infos = { + :committer_date => "%ci" + } + + attr_accessor :infos + def self.exists?(dir) File.exist?(info_file(dir)) end def self.from_dir(dir) @@ -50,10 +56,14 @@ mi = self.new mi.from_s(content) mi end + def self.git_infos + @@git_infos + end + def dirty? @dirty end def from_s(content) @@ -79,10 +89,16 @@ end end AttrsDef.each do |a| send("#{a}=".to_sym, attrs[a]) end + @@git_infos.each_pair do |key, value| + if attrs.has_key?(key) + @infos ||= {} + @infos[key] = attrs[key] + end + end @dirty = checksum != calc_sha1(content) end def from_dir(dir) file = RimInfo.info_file(dir) @@ -108,13 +124,21 @@ f.write(content) end end def to_s - max_len = AttrsDef.collect{|a| a.size}.max - AttrsDef.collect { |a| + i = @infos || {} + max_len = (AttrsDef + i.keys).collect{|a| a.size}.max + s = AttrsDef.collect { |a| "#{a.to_s.ljust(max_len)}: #{send(a)}" }.join("\n") + if !i.empty? + s << "\n\n" + i.each_pair { |key, value| + s << "#{key.to_s.ljust(max_len)}: #{value.to_s}\n" + } + end + s end private def calc_sha1(content)