Class: GithubPayload

Inherits:
Payload show all
Defined in:
lib/robot_sweatshop/payload/github.rb

Overview

A parser for Github payload data

Instance Method Summary collapse

Methods inherited from Payload

hash_keys, #to_hash

Constructor Details

#initialize(payload) ⇒ GithubPayload

Returns a new instance of GithubPayload.



6
7
8
# File 'lib/robot_sweatshop/payload/github.rb', line 6

def initialize(payload)
  @payload = JSON.parse payload || {}
end

Instance Method Details

#authorObject



22
23
24
# File 'lib/robot_sweatshop/payload/github.rb', line 22

def author
  commit['author']
end

#branchObject



30
31
32
# File 'lib/robot_sweatshop/payload/github.rb', line 30

def branch
  @payload['ref'] || ''
end

#clone_urlObject



18
19
20
# File 'lib/robot_sweatshop/payload/github.rb', line 18

def clone_url
  repository['clone_url'] || ''
end

#commitObject



10
11
12
# File 'lib/robot_sweatshop/payload/github.rb', line 10

def commit
  @payload['head_commit'] || {}
end

#hashObject



26
27
28
# File 'lib/robot_sweatshop/payload/github.rb', line 26

def hash
  commit['id'] || {}
end

#messageObject



34
35
36
# File 'lib/robot_sweatshop/payload/github.rb', line 34

def message
  commit['message'] || ''
end

#repo_slugObject



38
39
40
# File 'lib/robot_sweatshop/payload/github.rb', line 38

def repo_slug
  repository['full_name'] || ''
end

#repositoryObject



14
15
16
# File 'lib/robot_sweatshop/payload/github.rb', line 14

def repository
  @payload['repository'] || {}
end

#source_urlObject



42
43
44
# File 'lib/robot_sweatshop/payload/github.rb', line 42

def source_url
  commit['url'] || ''
end