Class: VCLog::Change
Overview
The Change class models an entry in a change log.
Instance Attribute Summary collapse
-
#author ⇒ Object
(also: #who)
Committer.
-
#color ⇒ Object
ANSI color to apply.
-
#date ⇒ Object
Date/time of commit.
-
#details ⇒ Object
readonly
Returns the value of attribute details.
-
#files ⇒ Object
List of files changed in the commit.
-
#id ⇒ Object
(also: #rev, #revision, #ref, #reference)
Commit revision/reference id.
-
#label ⇒ Object
The descriptive label of this change, as assigned by hueristics.
-
#level ⇒ Object
The priority level of this change, as assigned by hueristics.
-
#message ⇒ Object
(also: #msg)
Commit message.
-
#summary ⇒ Object
readonly
Returns the value of attribute summary.
-
#type ⇒ Object
Type of change, as assigned by hueristics.
Instance Method Summary collapse
-
#<=>(other) ⇒ Object
Compare changes by date.
-
#apply_heuristics(heuristics) ⇒ Object
Apply heuristic rules to change.
-
#initialize(data = {}) ⇒ Change
constructor
Setup new Change instance.
-
#inspect ⇒ Object
Inspection string of change object.
-
#parse_date(date) ⇒ Object
private
Convert given
date
into Time instance. -
#parse_points ⇒ Object
private
Split message into individual points.
-
#points ⇒ Object
Parse point entries from commit message.
-
#to_h ⇒ Object
Convert to Hash.
-
#to_s(opts = {}) ⇒ Object
Output message with optional adjustments.
Constructor Details
#initialize(data = {}) ⇒ Change
Setup new Change instance.
43 44 45 46 47 48 49 50 51 52 |
# 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 |
Instance Attribute Details
#author ⇒ Object Also known as: who
Committer.
18 19 20 |
# File 'lib/vclog/change.rb', line 18 def @author end |
#color ⇒ Object
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`.
40 41 42 |
# File 'lib/vclog/change.rb', line 40 def color @color end |
#date ⇒ Object
Date/time of commit.
15 16 17 |
# File 'lib/vclog/change.rb', line 15 def date @date end |
#details ⇒ Object (readonly)
Returns the value of attribute details.
122 123 124 |
# File 'lib/vclog/change.rb', line 122 def details @details end |
#files ⇒ Object
List of files changed in the commit.
24 25 26 |
# File 'lib/vclog/change.rb', line 24 def files @files end |
#id ⇒ Object Also known as: rev, revision, ref, reference
Commit revision/reference id.
12 13 14 |
# File 'lib/vclog/change.rb', line 12 def id @id end |
#label ⇒ Object
The descriptive label of this change, as assigned by hueristics.
35 36 37 |
# File 'lib/vclog/change.rb', line 35 def label @label end |
#level ⇒ Object
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.
32 33 34 |
# File 'lib/vclog/change.rb', line 32 def level @level end |
#message ⇒ Object Also known as: msg
Commit message.
21 22 23 |
# File 'lib/vclog/change.rb', line 21 def @message end |
#summary ⇒ Object (readonly)
Returns the value of attribute summary.
120 121 122 |
# File 'lib/vclog/change.rb', line 120 def summary @summary end |
#type ⇒ Object
Type of change, as assigned by hueristics.
27 28 29 |
# File 'lib/vclog/change.rb', line 27 def type @type end |
Instance Method Details
#<=>(other) ⇒ Object
Compare changes by date.
127 128 129 |
# File 'lib/vclog/change.rb', line 127 def <=>(other) other.date <=> date end |
#apply_heuristics(heuristics) ⇒ Object
Apply heuristic rules to change.
153 154 155 |
# File 'lib/vclog/change.rb', line 153 def apply_heuristics(heuristics) heuristics.apply(self) end |
#inspect ⇒ Object
Inspection string of change object.
134 135 136 |
# File 'lib/vclog/change.rb', line 134 def inspect "#<Change:#{object_id} #{date}>" end |
#parse_date(date) ⇒ Object (private)
Convert given date
into Time instance.
184 185 186 187 188 189 190 191 |
# File 'lib/vclog/change.rb', line 184 def parse_date(date) case date when Time date else Time.parse(date.to_s) end end |
#parse_points ⇒ Object (private)
Improve the parsing of point messages.
Split message into individual points.
198 199 200 201 202 203 |
# File 'lib/vclog/change.rb', line 198 def parse_points = .split(/^\*/) .map do |msg| ChangePoint.new(self, msg) end end |
#points ⇒ Object
Parse point entries from commit message. Point entries are outlined changes via line that start with an asterisk.
161 162 163 |
# File 'lib/vclog/change.rb', line 161 def points @points ||= parse_points end |
#to_h ⇒ Object
Convert to Hash.
141 142 143 144 145 146 147 148 |
# File 'lib/vclog/change.rb', line 141 def to_h { 'author' => self., 'date' => self.date, 'id' => self.id, 'message' => self., 'type' => self.type } end |
#to_s(opts = {}) ⇒ Object
Output message with optional adjustments.
168 169 170 171 172 173 174 |
# File 'lib/vclog/change.rb', line 168 def to_s(opts={}) if opts[:summary] summary else .strip end end |