Class: Jackal::Github::Formatter::CodeFetcher
- Inherits:
-
Formatter
- Object
- Formatter
- Jackal::Github::Formatter::CodeFetcher
- Defined in:
- lib/jackal-github/formatter/code_fetcher.rb
Constant Summary collapse
- SOURCE =
Format payloads from source
'*'- DESTINATION =
Formats for destination
'code_fetcher'
Instance Method Summary collapse
-
#format(payload) ⇒ Smash
Format the payload to provide code fetcher information.
-
#set_reference_information(event, payload) ⇒ Smash
Set repository reference information into payload if available.
Instance Method Details
#format(payload) ⇒ Smash
Format the payload to provide code fetcher information
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/jackal-github/formatter/code_fetcher.rb', line 18 def format(payload) if(payload.get(:data, :github)) payload.set(:data, :code_fetcher, :info, :source, 'github') payload.set(:data, :code_fetcher, :info, :owner, payload.get(:data, :github, :repository, :owner, :login)) payload.set(:data, :code_fetcher, :info, :name, payload.get(:data, :github, :repository, :name)) payload.set(:data, :code_fetcher, :info, :private, payload.get(:data, :github, :repository, :private)) payload.set(:data, :code_fetcher, :info, :url, payload.get(:data, :github, :repository, :clone_url)) set_reference_information(payload.get(:data, :github, :event).to_s, payload) payload end end |
#set_reference_information(event, payload) ⇒ Smash
Set repository reference information into payload if available
40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/jackal-github/formatter/code_fetcher.rb', line 40 def set_reference_information(event, payload) if(event.empty?) event = 'push' end method_name = "#{event}_reference" if(self.respond_to?(method_name, true)) ref, sha = send(method_name, payload) payload.set(:data, :code_fetcher, :info, :reference, ref) payload.set(:data, :code_fetcher, :info, :commit_sha, sha) end payload end |