Class: CommitSnapshot
- Inherits:
-
Object
- Object
- CommitSnapshot
- Defined in:
- lib/growthspurt.rb
Constant Summary collapse
- ATTRIBUTES =
[:commit_ref, :author, :email, :date, :messages]
Instance Method Summary collapse
- #formatted_date ⇒ Object
- #formatted_for_changes_dot_xml_file {|v| ... } ⇒ Object
- #formatted_for_changes_file {|v| ... } ⇒ Object
-
#initialize(*args) ⇒ CommitSnapshot
constructor
A new instance of CommitSnapshot.
Constructor Details
#initialize(*args) ⇒ CommitSnapshot
Returns a new instance of CommitSnapshot.
331 332 333 334 335 336 337 338 339 340 341 342 343 344 |
# File 'lib/growthspurt.rb', line 331 def initialize(*args) if args[0].kind_of? Hash ATTRIBUTES.each do | sym | self.instance_variable_set "@#{sym}", args[0][sym] end if self. self. = (self..kind_of?(String) ? self..split(/[;\n]/) : self.).delete_if{|e| e.empty?} end self.date = Time.parse( self.date ) if self.date && !self.date.kind_of?(Time) else commit = args[0] initialize(:commit_ref => commit.id_abbrev, :author => commit..name, :email => commit..email, :date => commit.date, :messages => commit.) end end |
Instance Method Details
#formatted_date ⇒ Object
346 347 348 |
# File 'lib/growthspurt.rb', line 346 def formatted_date self.date.strftime('%Y-%m-%d') end |
#formatted_for_changes_dot_xml_file {|v| ... } ⇒ Object
359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 |
# File 'lib/growthspurt.rb', line 359 def formatted_for_changes_dot_xml_file # <action dev=.. due-to=.. due-to-email=.. issue=.. type=.. system=.. date=.. > template = " <action dev='%s' type='%s' date='%s'><![CDATA[%s: %s]]></action>\n" reference = self.commit_ref[0...7] v = self..collect { | | msg = .downcase action_type = if !!(msg =~ /bug|fix/) 'fix' elsif !!(msg =~ /update/) 'update' elsif !!(msg =~ /remove/) 'remove' else 'add' end template % [self., action_type, formatted_date, reference, ] }.join('') yield v if block_given? v end |
#formatted_for_changes_file {|v| ... } ⇒ Object
350 351 352 353 354 355 356 357 |
# File 'lib/growthspurt.rb', line 350 def formatted_for_changes_file separator = ('-' * self..length) + '---------------------------' = self..join("\n") .gsub!(/(.{1,80}|\S{81,})(?: +|$\n?)/, " \\1\n") v = "#{separator}\n %s on %s, %s\n#{separator}\n%s\n\n" % [self., formatted_date, self.commit_ref[0...7], ] yield v if block_given? v end |