class GradesFirst::CommitMessageCommand
Implementation of a Thor command for creating a git commit message that already includes the information from the related PivotalTracker
story associated with the current branch.
Public Class Methods
description()
click to toggle source
Description of the gf commit-message Thor command that well be usewd in the commandline help.
# File lib/gradesfirst/commit_message_command.rb, line 12 def self.description 'Generate a git commit message in the standard format.' end
Public Instance Methods
execute()
click to toggle source
Performs the gf commit-message Thor command.
# File lib/gradesfirst/commit_message_command.rb, line 17 def execute @story = current_story end
response()
click to toggle source
Output response of the gf commit-message Thor command in the standard format.
# File lib/gradesfirst/commit_message_command.rb, line 23 def response if @story.nil? '' else message = [ "", "", constrain_line_length(@story['name'], 72), @story['url'] ] message.join("\n") + "\n" end end
Private Instance Methods
constrain_line_length(string, length)
click to toggle source
# File lib/gradesfirst/commit_message_command.rb, line 39 def constrain_line_length(string, length) line_break_characters = '(?:[ .!?,\-();:\[\]]|$)' lines = /.{,#{length.to_i}}#{line_break_characters}/ string. scan(lines). map { |line| line.strip }. select { |line| line.length > 0 }. join("\n") end