class VCLog::Change
The Change
class models an entry in a change log.
Attributes
ANSI color to apply. Actually this can be a list of any support ansi gem terms, but usually it’s just the color term, such as ‘:red`.
Date/time of commit.
List of files changed in the commit.
Commit revision/reference id.
The descriptive label of this change, as assigned by hueristics.
The priority level of this change, as assigned by hueristics. This can be ‘nil`, as Heuristics
will always make sure a commit has an inteer level before going out to template.
Commit message.
Commit message.
Commit revision/reference id.
Commit revision/reference id.
Commit revision/reference id.
Commit revision/reference id.
Commit revision/reference id.
Commit revision/reference id.
Commit revision/reference id.
Commit revision/reference id.
Type of change, as assigned by hueristics.
Committer.
Public Class Methods
Setup new Change
instance.
# File lib/vclog/change.rb, line 43 def initialize(data={}) @type = :default @level = nil @label = nil @color = [] data.each do |k,v| __send__("#{k}=", v) if respond_to?("#{k}=") end end
Public Instance Methods
Compare changes by date.
# File lib/vclog/change.rb, line 127 def <=>(other) other.date <=> date end
Apply heuristic rules to change.
# File lib/vclog/change.rb, line 153 def apply_heuristics(heuristics) heuristics.apply(self) end
Set the ANSI color terms.
@param [Symbol,Array<Symbol>] code
An ANSI gem recognized term, or array of such.
# File lib/vclog/change.rb, line 87 def color=(code) @color = [code].flatten end
Set date attribute, converting vale given to an instance of Time.
# File lib/vclog/change.rb, line 64 def date=(date) @date = parse_date(date) end
Inspection string of change object.
# File lib/vclog/change.rb, line 134 def inspect "#<Change:#{object_id} #{date}>" end
Set the commit message.
# File lib/vclog/change.rb, line 71 def message=(msg) @message = msg lines = msg.lines.to_a @summary = lines.first.strip @details = lines[1..-1].join('').strip msg end
Parse point entries from commit message. Point entries are outlined changes via line that start with an asterisk.
# File lib/vclog/change.rb, line 161 def points @points ||= parse_points end
Convert to Hash.
# File lib/vclog/change.rb, line 141 def to_h { 'author' => self.author, 'date' => self.date, 'id' => self.id, 'message' => self.message, 'type' => self.type } end
Output message with optional adjustments.
# File lib/vclog/change.rb, line 168 def to_s(opts={}) if opts[:summary] summary else message.strip end end
# File lib/vclog/change.rb, line 92 def type=(type) @type = type.to_sym end
Private Instance Methods
Convert given date
into Time instance.
@param [String,Data,Time] date
A valid data/time string or object.
# File lib/vclog/change.rb, line 184 def parse_date(date) case date when Time date else Time.parse(date.to_s) end end
Split message into individual points.
@todo Improve the parsing of point messages.
# File lib/vclog/change.rb, line 198 def parse_points point_messages = message.split(/^\*/) point_messages.map do |msg| ChangePoint.new(self, msg) end end