Class: TxghServer::Webhooks::Github::PushAttributes

Inherits:
TxghServer::Webhooks::Git::PushAttributes show all
Defined in:
lib/txgh-server/webhooks/github/push_attributes.rb

Constant Summary

Constants inherited from TxghServer::Webhooks::Git::PushAttributes

TxghServer::Webhooks::Git::PushAttributes::ATTRIBUTES

Class Method Summary collapse

Methods inherited from TxghServer::Webhooks::Git::PushAttributes

after, before, event, #files, from_webhook_payload, #initialize, ref, #to_h

Constructor Details

This class inherits a constructor from TxghServer::Webhooks::Git::PushAttributes

Class Method Details

.added_files(payload) ⇒ Object



10
11
12
# File 'lib/txgh-server/webhooks/github/push_attributes.rb', line 10

def added_files(payload)
  extract_files(payload, 'added')
end

.author(payload) ⇒ Object



18
19
20
21
22
23
24
25
# File 'lib/txgh-server/webhooks/github/push_attributes.rb', line 18

def author(payload)
  if head_commit = payload.fetch('head_commit')
    head_commit.fetch('committer').fetch('name')
  else
    # fall back to pusher if no head commit
    payload.fetch('pusher').fetch('name')
  end
end

.extract_files(payload, state) ⇒ Object



27
28
29
# File 'lib/txgh-server/webhooks/github/push_attributes.rb', line 27

def extract_files(payload, state)
  payload.fetch('commits').flat_map { |c| c[state] }.uniq
end

.modified_files(payload) ⇒ Object



14
15
16
# File 'lib/txgh-server/webhooks/github/push_attributes.rb', line 14

def modified_files(payload)
  extract_files(payload, 'modified')
end

.repo_name(payload) ⇒ Object



6
7
8
# File 'lib/txgh-server/webhooks/github/push_attributes.rb', line 6

def repo_name(payload)
  payload.fetch('repository').fetch('full_name')
end