module Dbcommit
Constants
- CURSES
- IMPERATIVE
- PUNCTUATION
- VERSION
Private Class Methods
check_capitalized_first_word(message)
click to toggle source
# File lib/dbcommit.rb, line 28 def self.check_capitalized_first_word(message) if message[0] != message[0].upcase print "* Always begin your commit message with a capital letter of.".red, "\n" end end
check_conjunctions_in_message(message)
click to toggle source
# File lib/dbcommit.rb, line 41 def self.check_conjunctions_in_message(message) message.split.each do |word| if word.downcase == "and" print '* Never use "and" in your commit message simply make a separate commit."'.red, "\n" end end end
check_cursing_in_message(message)
click to toggle source
# File lib/dbcommit.rb, line 56 def self.check_cursing_in_message(message) message.split.each do |word| if CURSES.include?(word.downcase) print "* Your should never swear in your commit messages!".red, "\n" end end end
check_if_message_ends_with_period(message)
click to toggle source
# File lib/dbcommit.rb, line 49 def self.check_if_message_ends_with_period(message) if PUNCTUATION.include?(message[-1]) print "* First line of commit message should never include ending punctuation.".red, "\n" print "* You ended your message with a #{message[-1]}".red, "\n" end end
check_length_of_message(message)
click to toggle source
# File lib/dbcommit.rb, line 15 def self.check_length_of_message(message) case message.length when 0..10 print "* Commit message size: Too short: #{message.length} characters.".yellow, "\n" when 11..51 print "* Commit message size: Perfect: #{message.length} characters.".green, "\n" when 51..100 print "* Commit message size: Too long: #{message.length} characters.".red, "\n" else print "* Commit message size: Gingantic: #{message.length} characters.".red, "\n" end end
check_number_of_changes(changes)
click to toggle source
# File lib/dbcommit.rb, line 81 def self.check_number_of_changes(changes) case changes when 1..11 print "* Number of changes: Perfect: #{changes} change(s)".green, "\n" when 12..30 print "* Number of changes: Okay: #{changes} change(s)".yellow, "\n" when 31..60 print "* Number of changes: Too many: #{changes} change(s)".orange, "\n" else print "* Number of changes: Way too many: #{changes} change(s)".red, "\n" end end
check_number_of_files(files)
click to toggle source
# File lib/dbcommit.rb, line 64 def self.check_number_of_files(files) case files when 1 print "* Number of files changed: Perfect: #{files} file(s)".green, "\n" when 2 print "* Number of files changed: Good: #{files} file(s)".blue, "\n" when 3 print "* Number of files changed: Okay: #{files} file(s)".yellow, "\n" when 4 print "* Number of files changed: Marginal: #{files} file(s)".orange, "\n" when 5 print "* Number of files changed: Bad: #{files} file(s)".red, "\n" else print "* Number of files changed: Terrble: #{files} file(s)".red, "\n" end end
check_tense_of_message(message)
click to toggle source
# File lib/dbcommit.rb, line 34 def self.check_tense_of_message(message) if !IMPERATIVE.include?(message.split[0].downcase) print "* Commit message was not written in the correct gramatical mood: #{message.split[0]}".red, "\n" print '* Your commit messages should be in the "Imperative" mood.'.blue, "\n" end end