Class: LoadRunner::Client
- Inherits:
-
Object
- Object
- LoadRunner::Client
- Includes:
- HTTParty
- Defined in:
- lib/load_runner/client.rb
Overview
Send simulated GitHub events to any webhook server
Instance Attribute Summary collapse
-
#base_url ⇒ Object
Returns the value of attribute base_url.
-
#encoding ⇒ Object
Returns the value of attribute encoding.
-
#payload ⇒ Object
Returns the value of attribute payload.
-
#secret_token ⇒ Object
Returns the value of attribute secret_token.
Instance Method Summary collapse
-
#initialize(opts = {}) ⇒ Client
constructor
A new instance of Client.
-
#send_event(event = :push, opts = {}) ⇒ Object
Send a simulated event using a shorthand syntax.
-
#send_payload(event, payload) ⇒ Object
Send a simulated event.
Constructor Details
#initialize(opts = {}) ⇒ Client
Returns a new instance of Client.
11 12 13 14 15 16 |
# File 'lib/load_runner/client.rb', line 11 def initialize(opts={}) @secret_token = opts[:secret_token] @base_url = opts[:base_url] || 'localhost:3000/payload' @encoding = opts[:encoding] || :json self.class.base_uri base_url end |
Instance Attribute Details
#base_url ⇒ Object
Returns the value of attribute base_url.
9 10 11 |
# File 'lib/load_runner/client.rb', line 9 def base_url @base_url end |
#encoding ⇒ Object
Returns the value of attribute encoding.
9 10 11 |
# File 'lib/load_runner/client.rb', line 9 def encoding @encoding end |
#payload ⇒ Object
Returns the value of attribute payload.
9 10 11 |
# File 'lib/load_runner/client.rb', line 9 def payload @payload end |
#secret_token ⇒ Object
Returns the value of attribute secret_token.
9 10 11 |
# File 'lib/load_runner/client.rb', line 9 def secret_token @secret_token end |
Instance Method Details
#send_event(event = :push, opts = {}) ⇒ Object
Send a simulated event using a shorthand syntax. opts can contain any of these:
-
repo: repository name -
ref: ref ID (for exampleref/heads/branchname) -
branch: branch name -
tag: tag name
24 25 26 27 |
# File 'lib/load_runner/client.rb', line 24 def send_event(event=:push, opts={}) payload = build_payload opts send_payload event, payload end |
#send_payload(event, payload) ⇒ Object
Send a simulated event. Payload can be a hash or a JSON string.
30 31 32 33 34 |
# File 'lib/load_runner/client.rb', line 30 def send_payload(event, payload) @payload = payload.is_a?(String) ? payload : payload.to_json @payload = URI.encode_www_form(payload: @payload) if encoding == :form self.class.post "", body: @payload, headers: headers(event) end |