cloudfactory 0.3.1 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +5 -0
- data/lib/cf/account.rb +3 -6
- data/lib/cf/cli.rb +8 -12
- data/lib/cf/cli/line.rb +13 -13
- data/lib/cf/cli/production.rb +18 -14
- data/lib/cf/client.rb +2 -12
- data/lib/cf/custom_task_form.rb +1 -3
- data/lib/cf/input_format.rb +1 -3
- data/lib/cf/line.rb +63 -66
- data/lib/cf/robot_worker.rb +3 -5
- data/lib/cf/run.rb +21 -58
- data/lib/cf/station.rb +6 -10
- data/lib/cf/task_form.rb +1 -3
- data/lib/cf/version.rb +1 -1
- data/spec/account_spec.rb +3 -5
- data/spec/badge_spec.rb +64 -64
- data/spec/concept_tagging_robot_spec.rb +37 -37
- data/spec/config_spec.rb +0 -1
- data/spec/content_scraping_robot_spec.rb +38 -38
- data/spec/custom_task_form_spec.rb +106 -105
- data/spec/department_spec.rb +5 -6
- data/spec/entity_extraction_robot_spec.rb +39 -39
- data/spec/form_field_spec.rb +148 -148
- data/spec/google_translate_robot_spec.rb +40 -40
- data/spec/human_worker_spec.rb +87 -87
- data/spec/image_processing_robot_spec.rb +37 -37
- data/spec/input_format_spec.rb +97 -97
- data/spec/keyword_matching_and_text_extraction_robot_spec.rb +56 -56
- data/spec/line_spec.rb +442 -416
- data/spec/mailer_robot_spec.rb +39 -39
- data/spec/media_converter_robot_spec.rb +40 -46
- data/spec/media_splitting_robot_spec.rb +41 -41
- data/spec/robot_worker_spec.rb +8 -8
- data/spec/run_spec.rb +424 -432
- data/spec/sentiment_robot_spec.rb +37 -37
- data/spec/station_spec.rb +209 -207
- data/spec/task_form_spec.rb +79 -79
- data/spec/term_extraction_robot_spec.rb +37 -37
- metadata +48 -48
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,8 @@
|
|
1
|
+
## 0.4.0 (2011-10-1)
|
2
|
+
|
3
|
+
* removed the hashie from the client response that was causing problem while debugging and the response was pretty messed up
|
4
|
+
* cli code changed as well to adapt with the hashie removal
|
5
|
+
|
1
6
|
## 0.3.1 (2011-09-22)
|
2
7
|
|
3
8
|
* added --live option while adding units to existing production run
|
data/lib/cf/account.rb
CHANGED
@@ -12,10 +12,7 @@ module CF
|
|
12
12
|
# CF::Account.info
|
13
13
|
def info
|
14
14
|
resp = get('/account.json')
|
15
|
-
|
16
|
-
if resp.code != 200
|
17
|
-
self.errors = resp.error.message
|
18
|
-
end
|
15
|
+
self.errors = resp['error']['message'] if resp['code'] != 200
|
19
16
|
return resp
|
20
17
|
end
|
21
18
|
|
@@ -32,8 +29,8 @@ module CF
|
|
32
29
|
# CF::Account.login("sprout@sprout-technology.com", "password")
|
33
30
|
def login(email, passwd)
|
34
31
|
resp = post('/account_login.json', :user => {:email => email, :password => passwd})
|
35
|
-
self.errors = resp
|
36
|
-
resp
|
32
|
+
self.errors = resp['error']['message'] if resp['code'] != 200
|
33
|
+
return resp
|
37
34
|
end
|
38
35
|
end
|
39
36
|
end
|
data/lib/cf/cli.rb
CHANGED
@@ -45,11 +45,11 @@ module Cf # :nodoc: all
|
|
45
45
|
set_target_uri(false)
|
46
46
|
resp = CF::Account.login(email, passwd)
|
47
47
|
|
48
|
-
if resp
|
49
|
-
File.open(config_file, 'w') {|f| f.write("#Don't change this file unless you know what you're doing\n" + { :target_url => CF.api_url, :api_version => CF.api_version, :api_key => resp
|
48
|
+
if resp['error'].blank? and resp['api_key'].present?
|
49
|
+
File.open(config_file, 'w') {|f| f.write("#Don't change this file unless you know what you're doing\n" + { :target_url => CF.api_url, :api_version => CF.api_version, :api_key => resp['api_key'], :account_name => resp['account_name'], :email => email.strip }.to_yaml) }
|
50
50
|
say("\nNow you're logged in.\nTo get started, run cf help\n", :green)
|
51
51
|
else
|
52
|
-
say("\n#{resp
|
52
|
+
say("\n#{resp['error']['message']}\nTry again with valid one.\n", :red)
|
53
53
|
end
|
54
54
|
end
|
55
55
|
|
@@ -113,7 +113,7 @@ module Cf # :nodoc: all
|
|
113
113
|
set_api_key(yaml_source)
|
114
114
|
CF.account_name = CF::Account.info.name
|
115
115
|
run = CF::Run.find(run_title)
|
116
|
-
if run
|
116
|
+
if run['errors'].blank?
|
117
117
|
say("Fetching output for run: #{run_title}", :green)
|
118
118
|
|
119
119
|
if options[:station_index].present?
|
@@ -123,13 +123,9 @@ module Cf # :nodoc: all
|
|
123
123
|
# Ouput for the whole production run
|
124
124
|
output = CF::Run.final_output(run_title)
|
125
125
|
end
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
end
|
130
|
-
if !res_array.empty?
|
131
|
-
res_array.each
|
132
|
-
csv_str = CSVHash(res_array,res_array.first.keys)
|
126
|
+
if !output.empty?
|
127
|
+
output.each
|
128
|
+
csv_str = CSVHash(output,output.first.keys)
|
133
129
|
csv_str = csv_str.gsub("\"\"", '"')
|
134
130
|
FileUtils.mkdir("#{line_source}/output") unless Dir.exist?("#{line_source}/output") if RUBY_VERSION > "1.9"
|
135
131
|
FileUtils.mkdir("#{line_source}/output") unless File.directory?("#{line_source}/output") if RUBY_VERSION < "1.9"
|
@@ -140,7 +136,7 @@ module Cf # :nodoc: all
|
|
140
136
|
say("Run not completed yet", :red)
|
141
137
|
end
|
142
138
|
else
|
143
|
-
say("Error: #{run
|
139
|
+
say("Error: #{run['errors'].inspect}", :red)
|
144
140
|
end
|
145
141
|
|
146
142
|
else
|
data/lib/cf/cli/line.rb
CHANGED
@@ -61,13 +61,13 @@ module Cf # :nodoc: all
|
|
61
61
|
say("The line.yml file does not exist in this directory", :red) and exit(1) unless File.exist?(yaml_source)
|
62
62
|
set_target_uri(false)
|
63
63
|
set_api_key(yaml_source)
|
64
|
-
CF.account_name = CF::Account.info
|
64
|
+
CF.account_name = CF::Account.info['name']
|
65
65
|
line_dump = YAML::load(File.read(yaml_source).strip)
|
66
66
|
line_title = line_dump['title'].parameterize
|
67
67
|
else
|
68
68
|
set_target_uri(false)
|
69
69
|
set_api_key
|
70
|
-
CF.account_name = CF::Account.info
|
70
|
+
CF.account_name = CF::Account.info['name']
|
71
71
|
line_title = options['line'].parameterize
|
72
72
|
end
|
73
73
|
|
@@ -92,7 +92,7 @@ module Cf # :nodoc: all
|
|
92
92
|
say("\n")
|
93
93
|
if delete_forcefully
|
94
94
|
resp = CF::Line.destroy(line_title, :forced => true)
|
95
|
-
if resp
|
95
|
+
if resp['code'] != 200
|
96
96
|
say("Error: #{resp.error.message}\n", :red)
|
97
97
|
else
|
98
98
|
say("The line #{line_title} deleted successfully!\n", :yellow)
|
@@ -114,8 +114,8 @@ module Cf # :nodoc: all
|
|
114
114
|
# method to call with line title to delete the line if validation fails during the creation of line
|
115
115
|
def rollback(line_title)
|
116
116
|
deleted_resp = CF::Line.destroy(line_title)
|
117
|
-
if !deleted_resp
|
118
|
-
if deleted_resp
|
117
|
+
if !deleted_resp['error'].nil?
|
118
|
+
if deleted_resp['error']['message'] == "Cannot delete line. You have production runs using this line. Pass force option to enforce deletion."
|
119
119
|
say("!!! Warning !!!\nThe following are the existing production runs based on this line.", :yellow)
|
120
120
|
existing_runs = Cf::Production.new([],{'line' => line_title, 'all' => true})
|
121
121
|
existing_runs.list
|
@@ -125,7 +125,7 @@ module Cf # :nodoc: all
|
|
125
125
|
say("\n")
|
126
126
|
if delete_forcefully
|
127
127
|
resp = CF::Line.destroy(line_title, :forced => true)
|
128
|
-
if resp
|
128
|
+
if resp['code'] != 200
|
129
129
|
say("Error: #{resp.error.message}\n", :red)
|
130
130
|
end
|
131
131
|
else
|
@@ -163,7 +163,7 @@ module Cf # :nodoc: all
|
|
163
163
|
set_target_uri(false)
|
164
164
|
set_api_key(yaml_source)
|
165
165
|
|
166
|
-
CF.account_name = CF::Account.info
|
166
|
+
CF.account_name = CF::Account.info['name']
|
167
167
|
|
168
168
|
line_dump = YAML::load(File.read(yaml_source).strip)
|
169
169
|
line_title = line_dump['title'].parameterize
|
@@ -172,14 +172,14 @@ module Cf # :nodoc: all
|
|
172
172
|
line_public = line_dump['public']
|
173
173
|
|
174
174
|
line = CF::Line.info(line_title)
|
175
|
-
if line
|
175
|
+
if line['error'].blank? && options.force?
|
176
176
|
rollback(line.title)
|
177
|
-
elsif line
|
177
|
+
elsif line['error'].blank?
|
178
178
|
say("This line already exist.", :yellow)
|
179
179
|
override = agree("Do you want to override? [y/n] ")
|
180
180
|
if override
|
181
181
|
say("Deleting the line forcefuly..", :yellow)
|
182
|
-
rollback(line
|
182
|
+
rollback(line['title'])
|
183
183
|
else
|
184
184
|
say("Line creation aborted!!", :yellow) and exit(1)
|
185
185
|
end
|
@@ -324,7 +324,7 @@ module Cf # :nodoc: all
|
|
324
324
|
|
325
325
|
set_target_uri(false)
|
326
326
|
set_api_key(yaml_source)
|
327
|
-
CF.account_name = CF::Account.info
|
327
|
+
CF.account_name = CF::Account.info['name']
|
328
328
|
|
329
329
|
if options.all
|
330
330
|
resp_lines = CF::Line.all(:page => 'all')
|
@@ -375,14 +375,14 @@ module Cf # :nodoc: all
|
|
375
375
|
say("The line.yml file does not exist in this directory", :red) and exit(1) unless File.exist?(yaml_source)
|
376
376
|
set_target_uri(false)
|
377
377
|
set_api_key(yaml_source)
|
378
|
-
CF.account_name = CF::Account.info
|
378
|
+
CF.account_name = CF::Account.info['name']
|
379
379
|
|
380
380
|
line_dump = YAML::load(File.read(yaml_source).strip)
|
381
381
|
line_title = line_dump['title'].parameterize
|
382
382
|
else
|
383
383
|
set_target_uri(false)
|
384
384
|
set_api_key
|
385
|
-
CF.account_name = CF::Account.info
|
385
|
+
CF.account_name = CF::Account.info['name']
|
386
386
|
line_title = options['line'].parameterize
|
387
387
|
end
|
388
388
|
|
data/lib/cf/cli/production.rb
CHANGED
@@ -20,7 +20,7 @@ module Cf # :nodoc: all
|
|
20
20
|
|
21
21
|
set_target_uri(options[:live])
|
22
22
|
set_api_key
|
23
|
-
CF.account_name = CF::Account.info
|
23
|
+
CF.account_name = CF::Account.info['name']
|
24
24
|
|
25
25
|
if options[:line].present?
|
26
26
|
line = CF::Line.find(options[:line])
|
@@ -116,7 +116,7 @@ module Cf # :nodoc: all
|
|
116
116
|
def list
|
117
117
|
set_target_uri(options[:live])
|
118
118
|
set_api_key
|
119
|
-
CF.account_name = CF::Account.info
|
119
|
+
CF.account_name = CF::Account.info['name']
|
120
120
|
param = {}
|
121
121
|
current_page = 1
|
122
122
|
|
@@ -181,15 +181,15 @@ module Cf # :nodoc: all
|
|
181
181
|
def resume
|
182
182
|
set_target_uri(false)
|
183
183
|
set_api_key
|
184
|
-
CF.account_name = CF::Account.info
|
184
|
+
CF.account_name = CF::Account.info['name']
|
185
185
|
result = CF::Run.resume(options['run_title'].parameterize)
|
186
186
|
|
187
|
-
if result
|
188
|
-
say("Error: #{result
|
187
|
+
if result['error'].present?
|
188
|
+
say("Error: #{result['error']['message']}", :red) and exit(1)
|
189
189
|
end
|
190
190
|
|
191
191
|
# if result.status == "resumed"
|
192
|
-
say("Run with title \"#{result
|
192
|
+
say("Run with title \"#{result['title']}\" is resumed!", :green)
|
193
193
|
# end
|
194
194
|
end
|
195
195
|
|
@@ -200,7 +200,7 @@ module Cf # :nodoc: all
|
|
200
200
|
def add_units
|
201
201
|
set_target_uri(options[:live])
|
202
202
|
set_api_key
|
203
|
-
CF.account_name = CF::Account.info
|
203
|
+
CF.account_name = CF::Account.info['name']
|
204
204
|
run_title = options[:run_title].parameterize
|
205
205
|
input_data = options[:input_data].presence
|
206
206
|
|
@@ -213,10 +213,14 @@ module Cf # :nodoc: all
|
|
213
213
|
input_data_file = "#{Dir.pwd}/#{input_data}"
|
214
214
|
end
|
215
215
|
units = CF::Run.add_units({:run_title => run_title, :file => input_data_file})
|
216
|
-
if units
|
217
|
-
say("Error:
|
216
|
+
if units.nil?
|
217
|
+
say("Error: Invalid File!", :red) and exit(1)
|
218
|
+
else
|
219
|
+
if units['error'].present?
|
220
|
+
say("Error: #{units['error']['message']}", :red) and exit(1)
|
221
|
+
end
|
222
|
+
say("\"#{units['successfull']}\"!", :green)
|
218
223
|
end
|
219
|
-
say("\"#{units['successfull']}\"!", :green)
|
220
224
|
end
|
221
225
|
|
222
226
|
desc "production delete", "Deletes created Production Run"
|
@@ -224,14 +228,14 @@ module Cf # :nodoc: all
|
|
224
228
|
def delete
|
225
229
|
set_target_uri(false)
|
226
230
|
set_api_key
|
227
|
-
CF.account_name = CF::Account.info
|
231
|
+
CF.account_name = CF::Account.info['name']
|
228
232
|
run_title = options[:run_title].parameterize
|
229
233
|
|
230
234
|
deleted_run = CF::Run.destroy(run_title)
|
231
|
-
if deleted_run
|
232
|
-
say("Error: #{deleted_run
|
235
|
+
if deleted_run['error'].present?
|
236
|
+
say("Error: #{deleted_run['error']['message']}", :red) and exit(1)
|
233
237
|
end
|
234
|
-
say("Run Deleted Successfully entitled: \"#{deleted_run
|
238
|
+
say("Run Deleted Successfully entitled: \"#{deleted_run['title']}\"!", :green)
|
235
239
|
end
|
236
240
|
end
|
237
241
|
end
|
data/lib/cf/client.rb
CHANGED
@@ -37,27 +37,17 @@ module CF # :nodoc: all
|
|
37
37
|
end
|
38
38
|
|
39
39
|
def handle_response(response)
|
40
|
-
# FIX: raise the exception along with the response error message
|
41
|
-
# Ref: http://www.simonecarletti.com/blog/2009/12/inside-ruby-on-rails-rescuable-and-rescue_from/
|
42
|
-
# case response.code
|
43
|
-
# when 401; raise Unauthorized.new
|
44
|
-
# when 403; raise RateLimitExceeded.new
|
45
|
-
# when 404; raise ::CF::NotFound.new(response)
|
46
|
-
# when 400...500; raise ClientError.new
|
47
|
-
# when 500...600; raise ServerError.new(response.code)
|
48
|
-
# else; response
|
49
|
-
# end
|
50
40
|
unless response.length == 2
|
51
41
|
parsed_response = JSON.load(response)
|
52
42
|
if parsed_response.is_a?(Array)
|
53
|
-
parsed_response
|
43
|
+
return parsed_response
|
54
44
|
else
|
55
45
|
parsed_resp = parsed_response.merge("code" => response.code)
|
56
46
|
new_response = parsed_resp.inject({ }) do |x, (k,v)|
|
57
47
|
x[k.sub(/\A_/, '')] = v
|
58
48
|
x
|
59
49
|
end
|
60
|
-
|
50
|
+
return new_response
|
61
51
|
end
|
62
52
|
else
|
63
53
|
JSON.load(response)
|
data/lib/cf/custom_task_form.rb
CHANGED
@@ -43,9 +43,7 @@ module CF
|
|
43
43
|
resp.to_hash.each_pair do |k,v|
|
44
44
|
self.send("#{k}=",v) if self.respond_to?(k)
|
45
45
|
end
|
46
|
-
if resp
|
47
|
-
self.errors = resp.error.message
|
48
|
-
end
|
46
|
+
self.errors = resp['error']['message'] if resp['code'] != 200
|
49
47
|
@station.form = self
|
50
48
|
return self
|
51
49
|
end
|
data/lib/cf/input_format.rb
CHANGED
@@ -49,9 +49,7 @@ module CF
|
|
49
49
|
@resp.to_hash.each_pair do |k,v|
|
50
50
|
self.send("#{k}=",v) if self.respond_to?(k)
|
51
51
|
end
|
52
|
-
if @resp
|
53
|
-
self.errors = @resp.error.message
|
54
|
-
end
|
52
|
+
self.errors = @resp['error']['message'] if @resp['code'] != 200
|
55
53
|
@line_title = line_title
|
56
54
|
if !@station.nil? && @station.except.nil? && @station.extra.nil?
|
57
55
|
@station.input_formats = self
|
data/lib/cf/line.rb
CHANGED
@@ -43,9 +43,8 @@ module CF
|
|
43
43
|
@public = options[:public].nil? ? true : options[:public]
|
44
44
|
@description = options[:description]
|
45
45
|
resp = self.class.post("/lines/#{CF.account_name}.json", {:line => {:title => title, :department_name => department_name, :public => @public, :description => @description}})
|
46
|
-
if resp
|
47
|
-
|
48
|
-
end
|
46
|
+
self.errors = resp['error']['message'] if resp['code'] != 200
|
47
|
+
return resp
|
49
48
|
end
|
50
49
|
|
51
50
|
# ==Adds station in a line
|
@@ -128,9 +127,7 @@ module CF
|
|
128
127
|
station.batch_size = @batch_size
|
129
128
|
station.line = self
|
130
129
|
station.line_title = self.title
|
131
|
-
if resp.response.code != "200"
|
132
|
-
station.errors = resp.parsed_response['error']['message']
|
133
|
-
end
|
130
|
+
station.errors = resp.parsed_response['error']['message'] if resp.response.code != "200"
|
134
131
|
@stations << station
|
135
132
|
end
|
136
133
|
else
|
@@ -191,9 +188,7 @@ module CF
|
|
191
188
|
@resp.each_pair do |k,v|
|
192
189
|
input_format.send("#{k}=",v) if input_format.respond_to?(k)
|
193
190
|
end
|
194
|
-
if @resp
|
195
|
-
input_format.errors = @resp.error.message
|
196
|
-
end
|
191
|
+
input_format.errors = @resp['error']['message'] if @resp['code'] != 200
|
197
192
|
@input_formats << input_format
|
198
193
|
else
|
199
194
|
@input_formats
|
@@ -242,7 +237,7 @@ module CF
|
|
242
237
|
else
|
243
238
|
resp = get("/lines/#{CF.account_name}/#{line.downcase}.json")
|
244
239
|
end
|
245
|
-
@errors = resp
|
240
|
+
@errors = resp['error']['message'] if resp['code'] != 200
|
246
241
|
return resp
|
247
242
|
end
|
248
243
|
|
@@ -263,8 +258,8 @@ module CF
|
|
263
258
|
resp = get("/lines/#{CF.account_name}/#{line.downcase}.json")
|
264
259
|
end
|
265
260
|
end
|
266
|
-
@errors = resp
|
267
|
-
return resp
|
261
|
+
@errors = resp['error']['message'] if resp['code'] != 200
|
262
|
+
return resp
|
268
263
|
end
|
269
264
|
|
270
265
|
# ==Returns all the lines of an account
|
@@ -279,17 +274,17 @@ module CF
|
|
279
274
|
else
|
280
275
|
resp = get("/lines/#{CF.account_name}.json")
|
281
276
|
end
|
282
|
-
@errors = resp
|
283
|
-
new_resp = []
|
284
|
-
if resp
|
285
|
-
if resp
|
286
|
-
resp
|
287
|
-
new_resp << l.to_hash
|
288
|
-
end
|
289
|
-
end
|
290
|
-
end
|
291
|
-
send_resp = {"lines" => new_resp, "total_pages" => resp.total_pages, "total_lines" => resp.total_lines}
|
292
|
-
return
|
277
|
+
@errors = resp['error']['message'] if resp['code'] != 200
|
278
|
+
# new_resp = []
|
279
|
+
# if resp['lines']
|
280
|
+
# if resp['lines'].count > 0
|
281
|
+
# resp['lines'].each do |l|
|
282
|
+
# new_resp << l.to_hash
|
283
|
+
# end
|
284
|
+
# end
|
285
|
+
# end
|
286
|
+
# send_resp = {"lines" => new_resp, "total_pages" => resp.total_pages, "total_lines" => resp.total_lines}
|
287
|
+
return resp
|
293
288
|
end
|
294
289
|
|
295
290
|
# ==Returns all the stations of a line
|
@@ -301,9 +296,13 @@ module CF
|
|
301
296
|
# ==Return all the public lines
|
302
297
|
# ===Usage Example:
|
303
298
|
# CF::Line.public_lines
|
304
|
-
def self.public_lines
|
305
|
-
|
306
|
-
|
299
|
+
def self.public_lines(options={})
|
300
|
+
if options[:page]=="all"
|
301
|
+
resp = get("/public_lines.json", :page => "all")
|
302
|
+
else
|
303
|
+
resp = get("/public_lines.json")
|
304
|
+
end
|
305
|
+
return resp['lines']
|
307
306
|
end
|
308
307
|
|
309
308
|
# ==Updates a line
|
@@ -331,9 +330,7 @@ module CF
|
|
331
330
|
else
|
332
331
|
resp = self.class.delete("/lines/#{CF.account_name}/#{self.title.downcase}.json")
|
333
332
|
end
|
334
|
-
if resp
|
335
|
-
self.errors = resp.errors.message
|
336
|
-
end
|
333
|
+
self.errors = resp['error']['message'] if resp['code'] != 200
|
337
334
|
return resp
|
338
335
|
end
|
339
336
|
|
@@ -348,7 +345,7 @@ module CF
|
|
348
345
|
else
|
349
346
|
resp = delete("/lines/#{CF.account_name}/#{title.downcase}.json")
|
350
347
|
end
|
351
|
-
@errors = resp
|
348
|
+
@errors = resp['error']['message'] if resp['code'] != 200
|
352
349
|
return resp
|
353
350
|
end
|
354
351
|
|
@@ -357,42 +354,42 @@ module CF
|
|
357
354
|
# line = CF::Line.inspect("line_title")
|
358
355
|
def self.inspect(line_title)
|
359
356
|
resp = get("/lines/#{CF.account_name}/#{line_title.downcase}/inspect.json")
|
360
|
-
@errors = resp
|
361
|
-
if resp
|
362
|
-
|
363
|
-
|
364
|
-
resp.input_formats.each do |l_i|
|
365
|
-
@line_input_formats << l_i.to_hash
|
366
|
-
end
|
367
|
-
send_resp.delete("input_formats")
|
368
|
-
send_resp.merge!("input_formats" => @line_input_formats)
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
|
376
|
-
|
377
|
-
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
|
390
|
-
|
391
|
-
|
392
|
-
|
393
|
-
else
|
394
|
-
|
395
|
-
end
|
357
|
+
@errors = resp['error']['message'] if resp['code'] != 200
|
358
|
+
# if resp['code'] == 200
|
359
|
+
# send_resp = resp.to_hash
|
360
|
+
# # @line_input_formats = []
|
361
|
+
# # resp.input_formats.each do |l_i|
|
362
|
+
# # @line_input_formats << l_i.to_hash
|
363
|
+
# # end
|
364
|
+
# # send_resp.delete("input_formats")
|
365
|
+
# # send_resp.merge!("input_formats" => @line_input_formats)
|
366
|
+
# # @stations = []
|
367
|
+
#
|
368
|
+
# # resp.stations.each do |s|
|
369
|
+
# # @station_input_formats = []
|
370
|
+
# # s.input_formats.each do |i|
|
371
|
+
# # @station_input_formats << i.to_hash
|
372
|
+
# # end
|
373
|
+
# # @station_form_fields = []
|
374
|
+
# # @temp_station = s.to_hash
|
375
|
+
# # if !s.form_fields.nil?
|
376
|
+
# # s.form_fields.each do |f|
|
377
|
+
# # @station_form_fields << f.to_hash
|
378
|
+
# # end
|
379
|
+
# # @temp_station.delete("form_fields")
|
380
|
+
# # @temp_station.merge!("form_fields" => @station_form_fields)
|
381
|
+
# # end
|
382
|
+
# # @temp_station.delete("input_formats")
|
383
|
+
# # @temp_station.merge!("input_formats" => @station_input_formats)
|
384
|
+
# # @stations << @temp_station
|
385
|
+
# # end
|
386
|
+
# #
|
387
|
+
# # send_resp.delete("stations")
|
388
|
+
# # send_resp.merge!("stations" => @stations)
|
389
|
+
# send_resp
|
390
|
+
# else
|
391
|
+
return resp
|
392
|
+
# end
|
396
393
|
end
|
397
394
|
end
|
398
395
|
end
|