Class: Vx::ServiceConnector::Github::Repos
- Inherits:
-
Struct
- Object
- Struct
- Vx::ServiceConnector::Github::Repos
- Defined in:
- lib/vx/service_connector/github/repos.rb
Instance Attribute Summary collapse
-
#session ⇒ Object
Returns the value of attribute session.
Instance Method Summary collapse
- #filter_repos ⇒ Object
- #organization_repositories ⇒ Object
- #organizations ⇒ Object
- #repo_to_model(repo) ⇒ Object
- #to_a ⇒ Object
- #user_repositories ⇒ Object
Instance Attribute Details
#session ⇒ Object
Returns the value of attribute session
4 5 6 |
# File 'lib/vx/service_connector/github/repos.rb', line 4 def session @session end |
Instance Method Details
#filter_repos ⇒ Object
33 34 35 36 37 38 39 40 41 |
# File 'lib/vx/service_connector/github/repos.rb', line 33 def filter_repos ->(repos, repo) { if repo. && repo..admin repos << repo_to_model(repo) else repos end } end |
#organization_repositories ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/vx/service_connector/github/repos.rb', line 18 def organization_repositories organizations.map do |org| Thread.new do begin session.organization_repositories(org) .reduce([], &filter_repos) rescue Octokit::Unauthorized [] end end.tap do |th| th.abort_on_exception = true end end.flat_map(&:value) end |
#organizations ⇒ Object
10 11 12 13 14 15 16 |
# File 'lib/vx/service_connector/github/repos.rb', line 10 def organizations begin session.organizations.map(&:login) || [] rescue Octokit::Unauthorized [] end end |
#repo_to_model(repo) ⇒ Object
51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/vx/service_connector/github/repos.rb', line 51 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, repo.language ) end |
#to_a ⇒ Object
6 7 8 |
# File 'lib/vx/service_connector/github/repos.rb', line 6 def to_a @repos ||= (user_repositories + organization_repositories) end |
#user_repositories ⇒ Object
43 44 45 46 47 48 49 |
# File 'lib/vx/service_connector/github/repos.rb', line 43 def user_repositories begin session.repositories.reduce([], &filter_repos) rescue Octokit::Unauthorized [] end end |