Class: VCLog::ChangePoint

Inherits:
Object
  • Object
show all
Defined in:
lib/vclog/change_point.rb

Overview

The Change class models an entry in a change log.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(change, message) ⇒ ChangePoint

Returns a new instance of ChangePoint.



24
25
26
27
28
29
30
# File 'lib/vclog/change_point.rb', line 24

def initialize(change, message)
  @change  = change
  @message = message.strip

  @label = nil
  @level = nil
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(s, *a, &b) ⇒ Object

Delegate missing methods to change.



41
42
43
44
45
46
47
48
# File 'lib/vclog/change_point.rb', line 41

def method_missing(s,*a,&b)
  if @change.respond_to?(s)
    @change.send(s,*a,&b)
  else
p caller
    super(s,*a,&b)
  end
end

Instance Attribute Details

#changeObject (readonly)

Change from which point is derived.



33
34
35
# File 'lib/vclog/change_point.rb', line 33

def change
  @change
end

#colorObject

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`.



21
22
23
# File 'lib/vclog/change_point.rb', line 21

def color
  @color
end

#labelObject

The descriptive label of this change, as assigned by hueristics.



16
17
18
# File 'lib/vclog/change_point.rb', line 16

def label
  @label
end

#levelObject

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.



13
14
15
# File 'lib/vclog/change_point.rb', line 13

def level
  @level
end

#messageObject Also known as: msg

The point’s message.



36
37
38
# File 'lib/vclog/change_point.rb', line 36

def message
  @message
end

#typeObject

Type of change, as assigned by hueristics.



8
9
10
# File 'lib/vclog/change_point.rb', line 8

def type
  @type
end

Instance Method Details

#apply_heuristics(heuristics) ⇒ Object

Apply heuristic rules to change.



56
57
58
# File 'lib/vclog/change_point.rb', line 56

def apply_heuristics(heuristics)
  heuristics.apply(self)
end

#pointsObject

Change points do not have sub-points.



51
52
53
# File 'lib/vclog/change_point.rb', line 51

def points
  []
end

#to_hObject



61
62
63
64
65
66
67
68
# File 'lib/vclog/change_point.rb', line 61

def to_h
  { 'author'   => change.author,
    'date'     => change.date,
    'id'       => change.id,
    'message'  => message,
    'type'     => type
  }
end

#to_sObject



71
72
73
# File 'lib/vclog/change_point.rb', line 71

def to_s(*)
  message
end