Class: RakeCommit::CommitMessage
- Inherits:
-
Object
- Object
- RakeCommit::CommitMessage
- Defined in:
- lib/rake_commit/commit_message.rb
Defined Under Namespace
Modules: MessageType
Constant Summary collapse
- SUBJECT_MAX_LENGTH =
50
Instance Attribute Summary collapse
-
#author ⇒ Object
readonly
Returns the value of attribute author.
-
#feature ⇒ Object
readonly
Returns the value of attribute feature.
-
#message ⇒ Object
readonly
Returns the value of attribute message.
Instance Method Summary collapse
-
#initialize(prompt_exclusions = [], type = MessageType::MESSAGE) ⇒ CommitMessage
constructor
A new instance of CommitMessage.
- #joined_message(wrap = nil) ⇒ Object
- #joined_message_with_author(wrap = nil) ⇒ Object
Constructor Details
#initialize(prompt_exclusions = [], type = MessageType::MESSAGE) ⇒ CommitMessage
Returns a new instance of CommitMessage.
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/rake_commit/commit_message.rb', line 14 def initialize(prompt_exclusions = [], type = MessageType::MESSAGE) = RakeCommit::PromptLine.new("author", prompt_exclusions).prompt @feature = RakeCommit::PromptLine.new("feature", prompt_exclusions).prompt = case type when MessageType::MESSAGE RakeCommit::PromptLine.new("message", prompt_exclusions).prompt when MessageType::WHAT_AND_WHY what = RakeCommit::PromptLine.new("what", prompt_exclusions).prompt why = RakeCommit::PromptLine.new("why", prompt_exclusions).prompt subject_space_remaining = SUBJECT_MAX_LENGTH - @feature.length truncated_what = what[0...subject_space_remaining] subject = RakeCommit::PromptLine.new("subject", prompt_exclusions, truncated_what).prompt (subject, what, why) end end |
Instance Attribute Details
#author ⇒ Object (readonly)
Returns the value of attribute author.
12 13 14 |
# File 'lib/rake_commit/commit_message.rb', line 12 def end |
#feature ⇒ Object (readonly)
Returns the value of attribute feature.
12 13 14 |
# File 'lib/rake_commit/commit_message.rb', line 12 def feature @feature end |
#message ⇒ Object (readonly)
Returns the value of attribute message.
12 13 14 |
# File 'lib/rake_commit/commit_message.rb', line 12 def end |
Instance Method Details
#joined_message(wrap = nil) ⇒ Object
32 33 34 35 36 |
# File 'lib/rake_commit/commit_message.rb', line 32 def (wrap = nil) = [@feature, ].compact.join(' - ') = WordWrap.ww(, wrap) if wrap end |
#joined_message_with_author(wrap = nil) ⇒ Object
38 39 40 41 42 |
# File 'lib/rake_commit/commit_message.rb', line 38 def (wrap = nil) = [, @feature, ].compact.join(' - ') = WordWrap.ww(, wrap) if wrap end |