Class: HookGenerator
- Inherits:
-
Object
- Object
- HookGenerator
- Defined in:
- lib/skynet/hook_generator.rb
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#output ⇒ Object
readonly
Returns the value of attribute output.
-
#server ⇒ Object
readonly
Returns the value of attribute server.
Instance Method Summary collapse
- #generate ⇒ Object
-
#initialize(config, server, output) ⇒ HookGenerator
constructor
A new instance of HookGenerator.
Constructor Details
#initialize(config, server, output) ⇒ HookGenerator
Returns a new instance of HookGenerator.
8 9 10 11 12 |
# File 'lib/skynet/hook_generator.rb', line 8 def initialize(config, server, output) @config = config @server = server @output = output end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
6 7 8 |
# File 'lib/skynet/hook_generator.rb', line 6 def config @config end |
#output ⇒ Object (readonly)
Returns the value of attribute output.
6 7 8 |
# File 'lib/skynet/hook_generator.rb', line 6 def output @output end |
#server ⇒ Object (readonly)
Returns the value of attribute server.
6 7 8 |
# File 'lib/skynet/hook_generator.rb', line 6 def server @server end |
Instance Method Details
#generate ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/skynet/hook_generator.rb', line 14 def generate File.open(output, 'w') do |file| payload = { repository: { url: config[:url] }, before: '$oldrev', after: '$newrev', ref: '$refname' } file.write <<-EOS.strip_heredoc read oldrev newrev refname curl -d "payload=#{payload.to_json.gsub('"', '\"')}" #{server} EOS end end |