Class: GitTracker::CommitMessage

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

Instance Method Summary collapse

Constructor Details

#initialize(file) ⇒ CommitMessage

Returns a new instance of CommitMessage.



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

def initialize(file)
  @file = file
  @message = File.read(@file)
end

Instance Method Details

#append(text) ⇒ Object



18
19
20
21
22
23
24
25
# File 'lib/git_tracker/commit_message.rb', line 18

def append(text)
  body, postscript = parse(@message)
  new_message = format_message(body, text, postscript)
  File.open(@file, 'w') do |f|
    f.write(new_message)
  end
  new_message
end

#keywordObject



13
14
15
16
# File 'lib/git_tracker/commit_message.rb', line 13

def keyword
  @message =~ /\[(fix|fixes|fixed|complete|completes|completed|finish|finishes|finished|deliver|delivers|delivered)\]/io
  $1
end

#mentions_story?(number) ⇒ Boolean

Returns:

  • (Boolean)


9
10
11
# File 'lib/git_tracker/commit_message.rb', line 9

def mentions_story?(number)
  @message =~ /^(?!#).*\[(\w+\s)?(#\d+\s)*##{number}(\s#\d+)*(\s\w+)?\]/io
end