Class: Github::Nippou::Format

Inherits:
Object
  • Object
show all
Defined in:
lib/github/nippou/format.rb

Instance Method Summary collapse

Constructor Details

#initialize(client, thread_num, settings, debug) ⇒ Format

Returns a new instance of Format.

Parameters:

  • client (Octokit::Client)
  • thread_num (Integer)
  • settings (Settings)
  • debug (Boolean)


11
12
13
14
15
16
# File 'lib/github/nippou/format.rb', line 11

def initialize(client, thread_num, settings, debug)
  @client = client
  @thread_num = thread_num
  @settings = settings
  @debug = debug
end

Instance Method Details

#all(lines) ⇒ Object



39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/github/nippou/format.rb', line 39

def all(lines)
  result = ""
  prev_repo_name = nil
  current_repo_name = nil

  sort(lines).each do |line|
    current_repo_name = line[:repo_name]

    unless current_repo_name == prev_repo_name
      prev_repo_name = current_repo_name
      result << "\n#{format_subject(current_repo_name)}\n\n"
    end

    result << "#{format_line(line)}\n"
  end

  result
end

#line(user_event, i) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/github/nippou/format.rb', line 18

def line(user_event, i)
  STDERR.puts "#{i % @thread_num} : #{user_event.html_url}\n" if @debug
  issue = issue(user_event)

  line = {
    title: issue.title,
    repo_name: user_event.repo.name,
    url: user_event.html_url,
    user: issue.user.,
  }

  line[:status] =
    if issue.merged
      :merged
    elsif issue.state == 'closed'
      :closed
    end

  line
end