Module: Houdini
- Defined in:
- lib/houdini.rb,
lib/houdini/task.rb,
lib/houdini/model.rb,
lib/houdini/engine.rb,
lib/houdini/version.rb,
lib/houdini/task_manager.rb,
lib/houdini/postback_processor.rb
Defined Under Namespace
Modules: Model, PostbackProcessor, TaskManager
Classes: Engine, PostbacksController, Task
Constant Summary
collapse
- RequestError =
Class.new(NameError)
- HostError =
Class.new(NameError)
- HOST =
'v1.houdiniapi.com'
- VERSION =
"0.3.4"
Class Method Summary
collapse
Class Method Details
.request(params) ⇒ Object
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
# File 'lib/houdini.rb', line 39
def self.request(params)
raise HostError, "Houdini.app_url should specify http:// or https://" unless app_url.match(/^https?\:\/\//)
url = File.join("https://", HOST, "tasks.json")
uri = URI.parse(url)
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
response, body = http.post(uri.path, params.to_json)
if response.code != "200"
raise RequestError, "The request to houdini failed with code #{response.code}: #{body}"
end
end
|
.setup(environment, options) ⇒ Object
15
16
17
18
19
20
|
# File 'lib/houdini.rb', line 15
def self.setup(environment, options)
self.environment = environment.to_s
self.api_key = options[:api_key]
self.app_url = options[:app_host] || options[:app_url]
self.app_uri = URI.parse(self.app_url)
end
|
.submit!(blueprint, class_name, object_id, input_params) ⇒ Object
27
28
29
30
31
32
33
34
35
36
37
|
# File 'lib/houdini.rb', line 27
def self.submit!(blueprint, class_name, object_id, input_params)
unless environment.to_s == 'test'
request(
:environment => environment,
:api_key => api_key,
:blueprint => blueprint,
:input => input_params,
:postback_url => "#{app_uri.scheme}://#{app_uri.host}:#{app_uri.port}/houdini/#{CGI.escape(class_name)}/#{object_id}/postbacks"
)
end
end
|