factor 0.1.06 → 0.1.07
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/client/client.rb +8 -7
- metadata +2 -2
data/lib/client/client.rb
CHANGED
@@ -9,8 +9,9 @@ module Factor
|
|
9
9
|
module Client
|
10
10
|
class Client
|
11
11
|
attr_accessor :host
|
12
|
+
FACTOR_HOST = ENV["FACTOR_HOST"] || "factor.io"
|
12
13
|
|
13
|
-
def initialize(host=
|
14
|
+
def initialize(host=FACTOR_HOST)
|
14
15
|
@host=host
|
15
16
|
end
|
16
17
|
|
@@ -108,7 +109,7 @@ module Factor
|
|
108
109
|
|
109
110
|
# workflows
|
110
111
|
def add_workflow(key,definition)
|
111
|
-
rest_post("workflows",{:name=>key,:definition=>definition})
|
112
|
+
rest_post("workflows",{:workflow=>{:name=>key,:definition=>definition}})
|
112
113
|
end
|
113
114
|
|
114
115
|
def get_workflows()
|
@@ -124,7 +125,7 @@ module Factor
|
|
124
125
|
def add_channel(path,definition_file)
|
125
126
|
file=zip(File.expand_path(path))
|
126
127
|
definition = File.read(definition_file)
|
127
|
-
rest_post("channels",{:zip=>file,:definition=>definition})
|
128
|
+
rest_post("channels",{:zip=>file,:channel=>{:definition=>definition}})
|
128
129
|
end
|
129
130
|
|
130
131
|
def get_channels()
|
@@ -191,19 +192,19 @@ module Factor
|
|
191
192
|
|
192
193
|
param_string=params.map{|key,value| "#{key}=#{value}"}.join("&")
|
193
194
|
|
194
|
-
JSON.parse(RestClient.get("
|
195
|
+
JSON.parse(RestClient.get("http://#{@host}/#{path}.json?#{param_string}"))
|
195
196
|
end
|
196
197
|
|
197
198
|
def rest_put(path,params={})
|
198
199
|
params["auth_token"]=@token
|
199
200
|
|
200
|
-
JSON.parse(RestClient.put("
|
201
|
+
JSON.parse(RestClient.put("http://#{@host}/#{path}.json",params))
|
201
202
|
end
|
202
203
|
|
203
204
|
def rest_post(path,params={})
|
204
205
|
#params["auth_token"]=@token
|
205
206
|
|
206
|
-
JSON.parse(RestClient.post("
|
207
|
+
JSON.parse(RestClient.post("http://#{@host}/#{path}.json?auth_token=#{@token}",params))
|
207
208
|
end
|
208
209
|
|
209
210
|
def rest_delete(path,params={})
|
@@ -211,7 +212,7 @@ module Factor
|
|
211
212
|
|
212
213
|
param_string=params.map{|key,value| "#{key}=#{value}"}.join("&")
|
213
214
|
|
214
|
-
JSON.parse(RestClient.delete("
|
215
|
+
JSON.parse(RestClient.delete("http://#{@host}/#{path}.json?#{param_string}"))
|
215
216
|
end
|
216
217
|
|
217
218
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: factor
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.07
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-02-
|
12
|
+
date: 2013-02-17 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: thor
|