Class: WhatsupGithub::RowCollector

Inherits:
Object
  • Object
show all
Defined in:
lib/whatsup_github/row_collector.rb

Overview

Creates Row objects for the future table

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args = {}) ⇒ RowCollector

Returns a new instance of RowCollector.



12
13
14
15
# File 'lib/whatsup_github/row_collector.rb', line 12

def initialize(args = {})
  @repos = config.repos
  @since = args[:since]
end

Instance Attribute Details

#reposObject (readonly)

Returns the value of attribute repos.



10
11
12
# File 'lib/whatsup_github/row_collector.rb', line 10

def repos
  @repos
end

#sinceObject (readonly)

Returns the value of attribute since.



10
11
12
# File 'lib/whatsup_github/row_collector.rb', line 10

def since
  @since
end

Instance Method Details

#collect_rowsObject



17
18
19
20
21
22
23
# 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) ⇒ Object



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# 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.),
      merger: pull.merged_by.,
      merge_commit_sha: pull.merge_commit_sha,
      author: pull.user.,
      author_url: pull.user.html_url,
      pr_url: pull.html_url
    )
  end
end

#reverse(collection) ⇒ Object



53
54
55
# File 'lib/whatsup_github/row_collector.rb', line 53

def reverse(collection)
  collection.reverse
end

#sort_by_dateObject



47
48
49
50
51
# 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