Class: Grog::GitLog
- Inherits:
-
Object
- Object
- Grog::GitLog
- Defined in:
- lib/grog/git_log.rb
Constant Summary collapse
- @@placeholders =
%w{H P an ai s}
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(options) ⇒ GitLog
constructor
A new instance of GitLog.
- #to_s ⇒ Object
Constructor Details
#initialize(options) ⇒ GitLog
Returns a new instance of GitLog.
8 9 10 11 |
# File 'lib/grog/git_log.rb', line 8 def initialize() = fetch_log end |
Class Method Details
.generate(options) ⇒ Object
19 20 21 |
# File 'lib/grog/git_log.rb', line 19 def self.generate() self.new().to_s end |
.generate_parsing_arguments ⇒ Object
13 14 15 16 17 |
# File 'lib/grog/git_log.rb', line 13 def self.generate_parsing_arguments = Grog::Options.parse(ARGV) generate(:number_of_commits_to_show => .number_of_commits_to_show, :show_datetimes => .show_datetimes) end |
Instance Method Details
#to_s ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/grog/git_log.rb', line 23 def to_s @log_lines.map do |line| values = Hash[*@@placeholders.zip(line.split('|||')).flatten] sha = GitLog.short_sha1(values['H']) date = GitLog.nice_date_format(values['ai']) subject = values['s'] = values['an'] branches = branches(values['H']) = (values['H']) line = Term::ANSIColor.yellow + sha + ' ' if [:show_datetimes] line += Term::ANSIColor.green + date + ' ' end line += Term::ANSIColor.reset + subject + ' ' + Term::ANSIColor.green + "(#{author})" + Term::ANSIColor.reset unless branches.empty? line += " B(" + Term::ANSIColor.red + branches.join(' ') + Term::ANSIColor.reset + ")" end unless .empty? line += " T(" + Term::ANSIColor.cyan + .join(' ') + Term::ANSIColor.reset + ")" end line + "\n" end.join end |