Module: GitPair::Helpers
Instance Method Summary collapse
- #abort(error_message, extra = "") ⇒ Object
- #author_name_from_abbreviation(abbrev) ⇒ Object
- #author_names ⇒ Object
- #current_author ⇒ Object
- #current_email ⇒ Object
- #display_string_for_config ⇒ Object
- #display_string_for_current_info ⇒ Object
- #email(*initials_list) ⇒ Object
- #email_template ⇒ Object
Instance Method Details
#abort(error_message, extra = "") ⇒ Object
101 102 103 |
# File 'lib/git-pair.rb', line 101 def abort(, extra = "") super "#{$red}#{$reverse} Error: #{} #{$reset}\n" + extra end |
#author_name_from_abbreviation(abbrev) ⇒ Object
84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 |
# File 'lib/git-pair.rb', line 84 def (abbrev) # initials .each do |name| return name if abbrev.downcase == name.split.map { |word| word[0].chr }.join.downcase end # start of a name .each do |name| return name if name.gsub(" ", "") =~ /^#{abbrev}/i end # includes the letters in order .detect do |name| name =~ /#{abbrev.split("").join(".*")}/i end end |
#author_names ⇒ Object
62 63 64 65 |
# File 'lib/git-pair.rb', line 62 def names = `git config --get-all git-pair.authors`.split("\n") names.uniq.sort_by { |name| name.split.last } end |
#current_author ⇒ Object
76 77 78 |
# File 'lib/git-pair.rb', line 76 def `git config --get user.name`.strip end |
#current_email ⇒ Object
80 81 82 |
# File 'lib/git-pair.rb', line 80 def current_email `git config --get user.email`.strip end |
#display_string_for_config ⇒ Object
52 53 54 55 |
# File 'lib/git-pair.rb', line 52 def display_string_for_config "#{$bold} Email template: #{$reset}" + email("[aa]", "[bb]") + "\n" + "#{$bold} Author list: #{$reset}" + .join("\n ") end |
#display_string_for_current_info ⇒ Object
57 58 59 60 |
# File 'lib/git-pair.rb', line 57 def display_string_for_current_info "#{$bold} Current author: #{$reset}" + + "\n" + "#{$bold} Current email: #{$reset}" + current_email + "\n " end |
#email(*initials_list) ⇒ Object
67 68 69 70 |
# File 'lib/git-pair.rb', line 67 def email(*initials_list) initials_string = initials_list.map { |initials| "+#{initials}" }.join email_template.sub("@", "#{initials_string}@") end |
#email_template ⇒ Object
72 73 74 |
# File 'lib/git-pair.rb', line 72 def email_template `git config --get git-pair.email`.strip end |