Class: Gitrob::Github::DataManager
- Inherits:
-
Object
- Object
- Gitrob::Github::DataManager
- Defined in:
- lib/gitrob/github/data_manager.rb
Instance Attribute Summary collapse
-
#client_manager ⇒ Object
readonly
Returns the value of attribute client_manager.
-
#owners ⇒ Object
readonly
Returns the value of attribute owners.
-
#repositories ⇒ Object
readonly
Returns the value of attribute repositories.
-
#unknown_logins ⇒ Object
readonly
Returns the value of attribute unknown_logins.
Instance Method Summary collapse
- #blobs_for_repository(repository) ⇒ Object
- #gather_owners(thread_pool) ⇒ Object
- #gather_repositories(thread_pool) ⇒ Object
-
#initialize(logins, client_manager) ⇒ DataManager
constructor
A new instance of DataManager.
- #repositories_for_owner(owner) ⇒ Object
Constructor Details
#initialize(logins, client_manager) ⇒ DataManager
Returns a new instance of DataManager.
9 10 11 12 13 14 15 16 17 |
# File 'lib/gitrob/github/data_manager.rb', line 9 def initialize(logins, client_manager) @logins = logins @client_manager = client_manager @unknown_logins = [] @owners = [] @repositories = [] @repositories_for_owners = {} @mutex = Mutex.new end |
Instance Attribute Details
#client_manager ⇒ Object (readonly)
Returns the value of attribute client_manager.
4 5 6 |
# File 'lib/gitrob/github/data_manager.rb', line 4 def client_manager @client_manager end |
#owners ⇒ Object (readonly)
Returns the value of attribute owners.
4 5 6 |
# File 'lib/gitrob/github/data_manager.rb', line 4 def owners @owners end |
#repositories ⇒ Object (readonly)
Returns the value of attribute repositories.
4 5 6 |
# File 'lib/gitrob/github/data_manager.rb', line 4 def repositories @repositories end |
#unknown_logins ⇒ Object (readonly)
Returns the value of attribute unknown_logins.
4 5 6 |
# File 'lib/gitrob/github/data_manager.rb', line 4 def unknown_logins @unknown_logins end |
Instance Method Details
#blobs_for_repository(repository) ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/gitrob/github/data_manager.rb', line 46 def blobs_for_repository(repository) get_blobs(repository) rescue ::Github::Error::Forbidden => e # Hidden GitHub feature? raise e unless e..include?("403 Repository access blocked") [] rescue ::Github::Error::NotFound [] rescue ::Github::Error::ServiceError => e raise e unless e..include?("409 Git Repository is empty") [] end |
#gather_owners(thread_pool) ⇒ Object
19 20 21 22 23 24 25 26 27 28 |
# File 'lib/gitrob/github/data_manager.rb', line 19 def gather_owners(thread_pool) @logins.each do |login| next unless owner = get_owner(login) @owners << owner @repositories_for_owners[owner["login"]] = [] next unless owner["type"] == "Organization" get_members(owner, thread_pool) if owner["type"] == "Organization" end @owners = @owners.uniq { |o| o["login"] } end |
#gather_repositories(thread_pool) ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/gitrob/github/data_manager.rb', line 30 def gather_repositories(thread_pool) owners.each do |owner| thread_pool.process do repositories = get_repositories(owner) with_mutex do save_repositories(owner, repositories) end yield owner, repositories if block_given? end end end |
#repositories_for_owner(owner) ⇒ Object
42 43 44 |
# File 'lib/gitrob/github/data_manager.rb', line 42 def repositories_for_owner(owner) @repositories_for_owners[owner["login"]] end |