Class: Ballantine::Author
- Inherits:
-
Object
- Object
- Ballantine::Author
- Defined in:
- lib/ballantine/author.rb
Instance Attribute Summary collapse
-
#commits ⇒ Object
Returns the value of attribute commits.
-
#name ⇒ Object
Returns the value of attribute name.
Class Method Summary collapse
-
.all ⇒ Array<Author>
Authors.
-
.find_or_create_by(name) ⇒ Author
Author.
Instance Method Summary collapse
-
#initialize(name) ⇒ Author
constructor
A new instance of Author.
-
#print_commits ⇒ NilClass
Nil.
-
#serialize_commits ⇒ Hash
returns an array to use slack attachments field reference: api.slack.com/messaging/composing/layouts#building-attachments.
Constructor Details
#initialize(name) ⇒ Author
Returns a new instance of Author.
24 25 26 27 |
# File 'lib/ballantine/author.rb', line 24 def initialize(name) @name = name @commits = {} end |
Instance Attribute Details
#commits ⇒ Object
Returns the value of attribute commits.
5 6 7 |
# File 'lib/ballantine/author.rb', line 5 def commits @commits end |
#name ⇒ Object
Returns the value of attribute name.
5 6 7 |
# File 'lib/ballantine/author.rb', line 5 def name @name end |
Class Method Details
.all ⇒ Array<Author>
Returns authors.
17 18 19 20 |
# File 'lib/ballantine/author.rb', line 17 def all return [] unless defined?(@@_collections) @@_collections.sort.map(&:last) # sort and take values end |
.find_or_create_by(name) ⇒ Author
Returns author.
10 11 12 13 14 |
# File 'lib/ballantine/author.rb', line 10 def find_or_create_by(name) @@_collections = {} unless defined?(@@_collections) return @@_collections[name] unless @@_collections[name].nil? @@_collections[name] = new(name) end |
Instance Method Details
#print_commits ⇒ NilClass
Returns nil.
30 31 32 33 34 35 36 37 38 |
# File 'lib/ballantine/author.rb', line 30 def print_commits puts "\n" + "@#{name}".green @commits.each do |repo, lists| count, word = retrieve_count_and_word(lists) puts " > #{repo.blue}: #{count} new #{word}\n" puts lists end nil end |
#serialize_commits ⇒ Hash
returns an array to use slack attachments field reference: api.slack.com/messaging/composing/layouts#building-attachments
43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/ballantine/author.rb', line 43 def serialize_commits = @commits.map do |repo, lists| count, word = retrieve_count_and_word(lists) "*#{repo}*: #{count} new #{word}\n#{lists.join("\n")}" end.join("\n") results = { 'text' => "- <@#{name}>\n#{}", 'color' => '#00B86A', # green } end |