Class: GitHub::Payload::Formatter::Parser

Inherits:
Object
  • Object
show all
Defined in:
lib/github/payload/formatter.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(payload) ⇒ Parser

Returns a new instance of Parser.



4
5
6
# File 'lib/github/payload/formatter.rb', line 4

def initialize(payload)
  @payload = payload
end

Instance Attribute Details

#payloadObject

Returns the value of attribute payload.



3
4
5
# File 'lib/github/payload/formatter.rb', line 3

def payload
  @payload
end

Instance Method Details

#summarizerObject



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

def summarizer
  @summarizer ||=
    case payload['event']
    when 'push'
      PushEvent.new(payload)
    when 'create'
      CreateEvent.new(payload)
    when 'delete'
      DeleteEvent.new(payload)
    when 'public'
      PublicEvent.new(payload)
    when 'issues'
      IssuesEvent.new(payload)
    when 'pull_request'
      PullRequestEvent.new(payload)
    when 'issue_comment'
      IssueCommentEvent.new(payload)
    when 'pull_request_review_comment'
      warn 'unsupported payload type pull_request_review_comment'
    else
      puts payload['event']
    end
end

#summary_messageObject



8
9
10
# File 'lib/github/payload/formatter.rb', line 8

def summary_message
  summarizer.summary_message
end

#summary_urlObject



12
13
14
# File 'lib/github/payload/formatter.rb', line 12

def summary_url
  summarizer.summary_url
end