chronatog-client 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/chronatog/client.rb +37 -2
- data/lib/chronatog/client/version.rb +1 -1
- metadata +3 -3
data/lib/chronatog/client.rb
CHANGED
@@ -4,13 +4,48 @@ module Chronatog
|
|
4
4
|
module Client
|
5
5
|
|
6
6
|
def self.setup!(service_url, auth_username, auth_password)
|
7
|
-
|
7
|
+
if service_url == "in-memory"
|
8
|
+
@connection = Fake.new
|
9
|
+
else
|
10
|
+
@connection = Connection.new(service_url, auth_username, auth_password)
|
11
|
+
end
|
8
12
|
end
|
9
13
|
|
10
14
|
def self.connection
|
11
15
|
@connection or raise "connection not setup! yet"
|
12
16
|
end
|
13
17
|
|
18
|
+
class Fake
|
19
|
+
def create_job(callback_url, schedule)
|
20
|
+
job_url = "/jobs/#{Object.new.object_id}"
|
21
|
+
created = {'callback_url' => callback_url, 'schedule' => schedule, 'url' => job_url }
|
22
|
+
jobs[job_url] = created
|
23
|
+
JSON::parse(created.to_json)
|
24
|
+
end
|
25
|
+
|
26
|
+
def destroy_job(job_url)
|
27
|
+
jobs.delete(job_url)
|
28
|
+
end
|
29
|
+
|
30
|
+
def list_jobs
|
31
|
+
JSON::parse(jobs.values.to_json)
|
32
|
+
end
|
33
|
+
|
34
|
+
def get_job(job_url)
|
35
|
+
JSON::parse(jobs[job_url].to_json)
|
36
|
+
end
|
37
|
+
|
38
|
+
private
|
39
|
+
|
40
|
+
def jobs
|
41
|
+
self.class.jobs
|
42
|
+
end
|
43
|
+
def self.jobs
|
44
|
+
@jobs ||= {}
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
48
|
+
|
14
49
|
class Connection
|
15
50
|
def initialize(service_url, auth_username, auth_password)
|
16
51
|
@service_url = service_url
|
@@ -64,7 +99,7 @@ module Chronatog
|
|
64
99
|
|
65
100
|
def client
|
66
101
|
#need to set vars in scope here because Rack::Client.new instance_evals
|
67
|
-
bak =
|
102
|
+
bak = backend
|
68
103
|
creds = @creds
|
69
104
|
@client ||= Rack::Client.new do
|
70
105
|
use BasicAuth, creds
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: chronatog-client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 23
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
-
|
8
|
+
- 2
|
9
9
|
- 0
|
10
|
-
version: 0.
|
10
|
+
version: 0.2.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Jacob Burkhart & Josh Lane & Others
|