Class: Metior::ActorCollection
- Inherits:
-
Collection
- Object
- Collection
- Metior::ActorCollection
- Defined in:
- lib/metior/collections/actor_collection.rb
Overview
This class implements a collection of actors and provides functionality specific to actors.
Instance Method Summary collapse
-
#authored_commits(actor_id = nil) ⇒ CommitCollection
(also: #commits)
Returns the commits authored by all or a specific actor in this collection.
-
#committed_commits(actor_id = nil) ⇒ CommitCollection
Returns the commits committed by all or a specific actor in this collection.
-
#load_commits(commit_type, actor_id = nil) ⇒ CommitCollection
private
Loads the commits authored or committed by all actors in this collection or a specific actor.
-
#most_significant(count = 3) ⇒ ActorCollection
Returns up to the given number of actors in this collection with the biggest impact on the repository, i.e.
-
#top(count = 3) ⇒ ActorCollection
Returns up to the given number of actors in this collection with the most commits.
Methods inherited from Collection
#<<, #each, #initialize, #last, #merge!
Constructor Details
This class inherits a constructor from Metior::Collection
Instance Method Details
#authored_commits(actor_id = nil) ⇒ CommitCollection Also known as: commits
Returns the commits authored by all or a specific actor in this collection
25 26 27 |
# File 'lib/metior/collections/actor_collection.rb', line 25 def (actor_id = nil) load_commits :authored_commits, actor_id end |
#committed_commits(actor_id = nil) ⇒ CommitCollection
Returns the commits committed by all or a specific actor in this collection
37 38 39 |
# File 'lib/metior/collections/actor_collection.rb', line 37 def committed_commits(actor_id = nil) load_commits :committed_commits, actor_id end |
#load_commits(commit_type, actor_id = nil) ⇒ CommitCollection (private)
Loads the commits authored or committed by all actors in this collection or a specific actor
85 86 87 88 89 90 91 92 93 |
# File 'lib/metior/collections/actor_collection.rb', line 85 def load_commits(commit_type, actor_id = nil) commits = CommitCollection.new if actor_id.nil? each { |actor| commits.merge! actor.send(commit_type) } elsif key? actor_id commits = self[actor_id].send commit_type end commits end |
#most_significant(count = 3) ⇒ ActorCollection
Returns up to the given number of actors in this collection with the biggest impact on the repository, i.e. changing the most code
47 48 49 50 51 52 53 54 55 56 |
# File 'lib/metior/collections/actor_collection.rb', line 47 def most_significant(count = 3) first.support! :line_stats = ActorCollection.new sort_by { || -.modifications }.each do || << break if .size == count end end |
#top(count = 3) ⇒ ActorCollection
Returns up to the given number of actors in this collection with the most commits
65 66 67 68 69 70 71 72 |
# File 'lib/metior/collections/actor_collection.rb', line 65 def top(count = 3) = ActorCollection.new sort_by { || -..size }.each do || << break if .size == count end end |