Class: GithubOrganizationMemberList::OrganizationViewer
- Inherits:
-
Object
- Object
- GithubOrganizationMemberList::OrganizationViewer
- Defined in:
- lib/github_organization_member_list.rb
Instance Attribute Summary collapse
-
#organization ⇒ Object
readonly
Returns the value of attribute organization.
Instance Method Summary collapse
- #fetch! ⇒ Object
- #fetch_members! ⇒ Object
- #fetch_team! ⇒ Object
-
#initialize(organization:, token:) ⇒ OrganizationViewer
constructor
A new instance of OrganizationViewer.
- #member_template ⇒ Object
- #report_member_with_teams_and_repositories ⇒ Object
Constructor Details
#initialize(organization:, token:) ⇒ OrganizationViewer
Returns a new instance of OrganizationViewer.
34 35 36 37 |
# File 'lib/github_organization_member_list.rb', line 34 def initialize(organization: , token: ) @organization = organization @client = Octokit::Client.new(access_token: token) end |
Instance Attribute Details
#organization ⇒ Object (readonly)
Returns the value of attribute organization.
33 34 35 |
# File 'lib/github_organization_member_list.rb', line 33 def organization @organization end |
Instance Method Details
#fetch! ⇒ Object
52 53 54 55 |
# File 'lib/github_organization_member_list.rb', line 52 def fetch! fetch_members! fetch_team! end |
#fetch_members! ⇒ Object
57 58 59 |
# File 'lib/github_organization_member_list.rb', line 57 def fetch_members! @members = client.organization_members(@organization) end |
#fetch_team! ⇒ Object
61 62 63 64 65 66 67 68 69 |
# File 'lib/github_organization_member_list.rb', line 61 def fetch_team! @team = client.organization_teams(@organization).map do |team| GithubOrganizationMemberList::Team.new( team, members: @client.team_members(team[:id]), repositories: @client.team_repositories(team[:id]) ) end end |
#member_template ⇒ Object
46 47 48 49 50 |
# File 'lib/github_organization_member_list.rb', line 46 def member_template @member_template ||= ERB.new("<%= login %>|<%= joined_teams.map(&:name).join(',') %>|<%= joined_teams.flat_map(&:repository_names).uniq.join(',') %>\n EOS\nend\n", nil, '-') |
#report_member_with_teams_and_repositories ⇒ Object
39 40 41 42 43 44 |
# File 'lib/github_organization_member_list.rb', line 39 def report_member_with_teams_and_repositories @members.map do |member| joined_teams = @team.find_all {|t| t.member?(member[:id]) } member_template.result_with_hash(login: member[:login], joined_teams: joined_teams) end end |