Class: TxghServer::Webhooks::Git::PushAttributes
- Inherits:
-
Object
- Object
- TxghServer::Webhooks::Git::PushAttributes
show all
- Defined in:
- lib/txgh-server/webhooks/git/push_attributes.rb
Constant Summary
collapse
- ATTRIBUTES =
[
:event, :repo_name, :ref, :before, :after,
:added_files, :modified_files, :author
]
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
Returns a new instance of PushAttributes.
62
63
64
65
66
67
68
|
# File 'lib/txgh-server/webhooks/git/push_attributes.rb', line 62
def initialize(options = {})
ATTRIBUTES.each do |attr|
instance_variable_set(
"@#{attr}", options.fetch(attr) { options.fetch(attr.to_s) }
)
end
end
|
Class Method Details
.added_files(payload) ⇒ Object
39
40
41
|
# File 'lib/txgh-server/webhooks/git/push_attributes.rb', line 39
def added_files(payload)
raise NotImplementedError
end
|
.after(payload) ⇒ Object
35
36
37
|
# File 'lib/txgh-server/webhooks/git/push_attributes.rb', line 35
def after(payload)
payload.fetch('after')
end
|
.author(payload) ⇒ Object
47
48
49
|
# File 'lib/txgh-server/webhooks/git/push_attributes.rb', line 47
def author(payload)
raise NotImplementedError
end
|
.before(payload) ⇒ Object
31
32
33
|
# File 'lib/txgh-server/webhooks/git/push_attributes.rb', line 31
def before(payload)
payload.fetch('before')
end
|
.event(payload) ⇒ Object
19
20
21
|
# File 'lib/txgh-server/webhooks/git/push_attributes.rb', line 19
def event(payload)
'push'
end
|
51
52
53
|
# File 'lib/txgh-server/webhooks/git/push_attributes.rb', line 51
def (payload, state)
raise NotImplementedError
end
|
.from_webhook_payload(payload) ⇒ Object
11
12
13
14
15
16
17
|
# File 'lib/txgh-server/webhooks/git/push_attributes.rb', line 11
def from_webhook_payload(payload)
new(
ATTRIBUTES.each_with_object({}) do |attr, ret|
ret[attr] = public_send(attr, payload)
end
)
end
|
.modified_files(payload) ⇒ Object
43
44
45
|
# File 'lib/txgh-server/webhooks/git/push_attributes.rb', line 43
def modified_files(payload)
(payload, 'modified')
end
|
.ref(payload) ⇒ Object
27
28
29
|
# File 'lib/txgh-server/webhooks/git/push_attributes.rb', line 27
def ref(payload)
payload.fetch('ref')
end
|
.repo_name(payload) ⇒ Object
23
24
25
|
# File 'lib/txgh-server/webhooks/git/push_attributes.rb', line 23
def repo_name(payload)
raise NotImplementedError
end
|
Instance Method Details
#files ⇒ Object
56
57
58
|
# File 'lib/txgh-server/webhooks/git/push_attributes.rb', line 56
def files
@files ||= added_files + modified_files
end
|
#to_h ⇒ Object
70
71
72
73
74
|
# File 'lib/txgh-server/webhooks/git/push_attributes.rb', line 70
def to_h
ATTRIBUTES.each_with_object({}) do |attr, ret|
ret[attr] = public_send(attr)
end
end
|