Module: Cleo
- Defined in:
- lib/cleo/cleo.rb,
lib/xml/result.rb,
lib/cleo/element.rb,
lib/cleo/service.rb,
lib/xml/connection.rb,
lib/cleo/base_server.rb,
lib/cleo/element_server.rb,
lib/cleo/connection_server.rb,
lib/generators/acts_as_cleo/install/templates/jobs/cleo_element_processor.rb,
lib/generators/acts_as_cleo/install/templates/jobs/cleo_connection_processor.rb
Defined Under Namespace
Modules: ConnectionProcessor, ElementProcessor, Xml
Classes: Base, ConnectionServer, Element, ElementServer, Service
Class Method Summary
collapse
Class Method Details
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
|
# File 'lib/cleo/cleo.rb', line 49
def self.configure(new_config)
parts = new_config[:url].split("/")
parts -= %w{rest elements connections}
parts += %w{rest}
Cleo::Service.base_url = parts.join('/') + '/'
Cleo::ElementServer.url = (parts + %w{elements}).join('/') + '/'
Cleo::ConnectionServer.url = (parts + %w{connections}).join('/') + '/'
if new_config.has_key?(:async)
Cleo::Service.async = new_config[:async]
elsif new_config.has_key?(:run_async)
Cleo::Service.async = new_config[:run_async]
else
Cleo::Service.async = false
end
Cleo::Service.auto_flush = new_config.has_key?(:auto_flush) ? new_config[:auto_flush] : true
Cleo::Service.queue = new_config.has_key?(:queue) ? new_config[:queue] : "cleo"
if new_config.has_key?(:auto_enable_queue) && new_config[:auto_enable_queue]
env = ENV['QUEUE'] || ''
ENV['QUEUE'] = (env.split(',') << Cleo::Service.queue).uniq.join(',')
end
end
|
.flush_connections ⇒ Object
35
36
37
38
39
40
|
# File 'lib/cleo/cleo.rb', line 35
def self.flush_connections
uri = URI.parse Cleo::Service.connection_server_url + "flush"
request = Net::HTTP::Post.new(uri.path)
response = Net::HTTP.new(uri.host, uri.port).start { |http| http.request request }
Cleo::Service.good_response_code?(response)
end
|
.flush_elements ⇒ Object
42
43
44
45
46
47
|
# File 'lib/cleo/cleo.rb', line 42
def self.flush_elements
uri = URI.parse Cleo::Service.element_server_url + "flush"
request = Net::HTTP::Post.new(uri.path)
response = Net::HTTP.new(uri.host, uri.port).start { |http| http.request request }
Cleo::Service.good_response_code?(response)
end
|
.get(uri) ⇒ Object
25
26
27
28
29
|
# File 'lib/cleo/cleo.rb', line 25
def self.get(uri)
response = net_http.request(Net::HTTP::Get.new(uri.request_uri))
return response if Cleo::Service.good_response_code?(response)
end
|
.load_configuration ⇒ Object
76
77
78
79
80
81
82
83
84
85
86
|
# File 'lib/cleo/cleo.rb', line 76
def self.load_configuration
cleo_file_path = File.join( Rails.root, 'config', 'cleo.yml' )
if File.exists?( cleo_file_path )
Cleo.configure(YAML::load_file( cleo_file_path )[Rails.env].symbolize_keys)
true
else
raise ArgumentError.new("No configuration file found. Check for cleo.yml")
false
end
end
|
.net_http ⇒ Object
20
21
22
23
|
# File 'lib/cleo/cleo.rb', line 20
def self.net_http
uri = URI.parse(Cleo::Service.url)
Net::HTTP.new(uri.host, uri.port)
end
|
.network_query(source_id, query) ⇒ Object
17
18
|
# File 'lib/cleo/cleo.rb', line 17
def self.network_query(source_id, query)
end
|