Class: Vx::ServiceConnector::Github::Repos
- Inherits:
-
Object
- Object
- Vx::ServiceConnector::Github::Repos
- Defined in:
- lib/vx/service_connector/github/repos.rb
Instance Attribute Summary collapse
-
#session ⇒ Object
readonly
Returns the value of attribute session.
Instance Method Summary collapse
-
#initialize(session) ⇒ Repos
constructor
A new instance of Repos.
- #organization_repositories ⇒ Object
- #organizations ⇒ Object
- #repo_to_model(repo) ⇒ Object
- #to_a ⇒ Object
- #user_repositories ⇒ Object
Constructor Details
#initialize(session) ⇒ Repos
Returns a new instance of Repos.
7 8 9 |
# File 'lib/vx/service_connector/github/repos.rb', line 7 def initialize(session) @session = session end |
Instance Attribute Details
#session ⇒ Object (readonly)
Returns the value of attribute session.
5 6 7 |
# File 'lib/vx/service_connector/github/repos.rb', line 5 def session @session end |
Instance Method Details
#organization_repositories ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/vx/service_connector/github/repos.rb', line 19 def organization_repositories organizations.map do |org| Thread.new do session .organization_repositories(org) .select { |repo| repo. && repo..admin } .map { |repo| repo_to_model repo } end.tap do |th| th.abort_on_exception = true end end.map(&:value).flatten end |
#organizations ⇒ Object
15 16 17 |
# File 'lib/vx/service_connector/github/repos.rb', line 15 def organizations session.organizations.map(&:login) || [] end |
#repo_to_model(repo) ⇒ Object
38 39 40 41 42 43 44 45 46 47 |
# File 'lib/vx/service_connector/github/repos.rb', line 38 def repo_to_model(repo) Model::Repo.new( repo.id, repo.full_name, repo.private, repo.rels[:ssh].href, repo.rels[:html].href, repo.description ) end |
#to_a ⇒ Object
11 12 13 |
# File 'lib/vx/service_connector/github/repos.rb', line 11 def to_a @repos ||= (user_repositories + organization_repositories) end |
#user_repositories ⇒ Object
32 33 34 35 36 |
# File 'lib/vx/service_connector/github/repos.rb', line 32 def user_repositories session.repositories.map do |repo| repo_to_model repo end end |