class WhatsupGithub::RowCollector
Creates Row
objects for the future table
Attributes
repos[R]
since[R]
Public Class Methods
new(args = {})
click to toggle source
# File lib/whatsup_github/row_collector.rb, line 12 def initialize(args = {}) @repos = config.repos @since = args[:since] end
Public Instance Methods
collect_rows()
click to toggle source
# File lib/whatsup_github/row_collector.rb, line 17 def collect_rows rows = [] repos.each do |repo| rows << collect_rows_for_a(repo) end rows.flatten end
collect_rows_for_a(repo)
click to toggle source
# File lib/whatsup_github/row_collector.rb, line 25 def collect_rows_for_a(repo) pulls(repo).map do |pull| Row.new( repo: repo, repo_url: pull.base.repo.html_url, private: pull.base.repo.private?, pr_number: pull.number, pr_title: pull.title, pr_body: pull.body, date: pull.merged_at, pr_labels: label_names(pull.labels), assignee: assignee(pull.assignees), membership: member?(pull.user.login), merger: pull.merged_by.login, merge_commit_sha: pull.merge_commit_sha, author: pull.user.login, author_url: pull.user.html_url, pr_url: pull.html_url ) end end
reverse(collection)
click to toggle source
# File lib/whatsup_github/row_collector.rb, line 53 def reverse(collection) collection.reverse end
sort_by_date()
click to toggle source
# File lib/whatsup_github/row_collector.rb, line 47 def sort_by_date collect_rows.sort_by do |c| Date.parse(c.date) end.reverse end
Private Instance Methods
assignee(assignees)
click to toggle source
# File lib/whatsup_github/row_collector.rb, line 59 def assignee(assignees) if assignees.empty? 'NOBODY' else assignees.map(&:login).join(', ') end end
client()
click to toggle source
# File lib/whatsup_github/row_collector.rb, line 96 def client Client.instance end
config()
click to toggle source
# File lib/whatsup_github/row_collector.rb, line 92 def config Config.instance end
label_names(labels)
click to toggle source
# File lib/whatsup_github/row_collector.rb, line 73 def label_names(labels) labels.map(&:name) end
load_members()
click to toggle source
# File lib/whatsup_github/row_collector.rb, line 81 def load_members return if @members @members = client.org_members(config.membership) end
member?(login)
click to toggle source
# File lib/whatsup_github/row_collector.rb, line 67 def member?(login) return nil unless config.membership member_logins.include? login end
member_logins()
click to toggle source
# File lib/whatsup_github/row_collector.rb, line 87 def member_logins load_members @members.map(&:login) end
pulls(repo)
click to toggle source
# File lib/whatsup_github/row_collector.rb, line 77 def pulls(repo) Pulls.new(repo: repo, since: since).data end