Class: Historian::CommitMessage

Inherits:
Object
  • Object
show all
Defined in:
lib/historian/commit_message.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(line) ⇒ CommitMessage

Returns a new instance of CommitMessage.



6
7
8
9
10
11
12
13
14
# File 'lib/historian/commit_message.rb', line 6

def initialize(line)
  if line =~ /^([!bmM])(#?):(.*[0-9a-zA-Z].*)$/
    @token = $1
    @suppressed = true if $2 == "#"
    @line = $3
  else
    @line = line
  end
end

Instance Attribute Details

#lineObject (readonly)

Returns the value of attribute line.



4
5
6
# File 'lib/historian/commit_message.rb', line 4

def line
  @line
end

#suppressedObject (readonly)

Returns the value of attribute suppressed.



4
5
6
# File 'lib/historian/commit_message.rb', line 4

def suppressed
  @suppressed
end

#tokenObject (readonly)

Returns the value of attribute token.



4
5
6
# File 'lib/historian/commit_message.rb', line 4

def token
  @token
end

Class Method Details

.parse_line(line) ⇒ Object



37
38
39
# File 'lib/historian/commit_message.rb', line 37

def self.parse_line(line)
  new line
end

Instance Method Details

#significanceObject



16
17
18
19
20
21
22
23
# File 'lib/historian/commit_message.rb', line 16

def significance
  case token
  when "b"; :patch
  when "m"; :minor
  when "M"; :major
  when "!"; :release
  end
end

#suppressed?Boolean

Returns:

  • (Boolean)


25
26
27
# File 'lib/historian/commit_message.rb', line 25

def suppressed?
  @suppressed == true
end

#to_message_sObject



33
34
35
# File 'lib/historian/commit_message.rb', line 33

def to_message_s
  line.gsub /^\W*/, '' if significance
end

#to_sObject



29
30
31
# File 'lib/historian/commit_message.rb', line 29

def to_s
  line
end