Class: Ballantine::Author
- Inherits:
-
Object
- Object
- Ballantine::Author
- Includes:
- Printable
- Defined in:
- lib/ballantine/author.rb
Instance Attribute Summary collapse
-
#commits_hash ⇒ Object
readonly
Returns the value of attribute commits_hash.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(name:) ⇒ Author
constructor
A new instance of Author.
- #print_commits ⇒ Boolean
-
#slack_message ⇒ Hash
returns an array to use slack attachments field reference: api.slack.com/messaging/composing/layouts#building-attachments.
Methods included from Printable
Constructor Details
#initialize(name:) ⇒ Author
Returns a new instance of Author.
32 33 34 35 |
# File 'lib/ballantine/author.rb', line 32 def initialize(name:) @name = name @commits_hash = {} end |
Instance Attribute Details
#commits_hash ⇒ Object (readonly)
Returns the value of attribute commits_hash.
7 8 9 |
# File 'lib/ballantine/author.rb', line 7 def commits_hash @commits_hash end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
7 8 9 |
# File 'lib/ballantine/author.rb', line 7 def name @name end |
Class Method Details
.all ⇒ Array<Author>
Returns authors.
24 25 26 27 28 |
# File 'lib/ballantine/author.rb', line 24 def all return [] unless defined?(@_collections) @_collections.sort.map(&:last) # sort and take values end |
.find(name:) ⇒ Author, NilClass
12 13 14 15 |
# File 'lib/ballantine/author.rb', line 12 def find(name:) @_collections = {} unless defined?(@_collections) @_collections[name] end |
.find_or_create_by(name:) ⇒ Author
19 20 21 |
# File 'lib/ballantine/author.rb', line 19 def find_or_create_by(name:) find(name:) || @_collections[name] = new(name:) end |
Instance Method Details
#print_commits ⇒ Boolean
38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/ballantine/author.rb', line 38 def print_commits conf.print_log(binding) if conf.verbose puts "\n" + "@#{name}".green commits_hash.each do |repo_name, commits| count, word = retrieve_count_and_word(commits) puts " > #{repo_name.blue}: #{count} new #{word}" commits.each do |commit| puts_r " - #{commit.hash.yellow} #{commit.subject}", commit.url.gray end end true end |
#slack_message ⇒ Hash
returns an array to use slack attachments field reference: api.slack.com/messaging/composing/layouts#building-attachments
56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/ballantine/author.rb', line 56 def conf.print_log(binding) if conf.verbose = commits_hash.map do |repo_name, commits| count, word = retrieve_count_and_word(commits) "*#{repo_name}*: #{count} new #{word}\n" \ "#{commits.map(&:slack_message).join("\n")}" end.join("\n") { "text" => "- <@#{name}>\n#{}", "color" => "#00B86A", # green } end |