cloudfactory 0.3.1 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -51,11 +51,9 @@ module CF
51
51
  if station
52
52
  request = options[:settings].merge(:type => @type)
53
53
  resp = self.class.post("/lines/#{CF.account_name}/#{station.line_title.downcase}/stations/#{station.index}/workers.json", :worker => request)
54
- if resp.code != 200
55
- self.errors = resp.error.message
56
- end
57
- self.number = resp.number
58
- self.reward = resp.reward
54
+ self.errors = resp['error']['message'] if resp['code'] != 200
55
+ self.number = resp['number']
56
+ self.reward = resp['reward']
59
57
  self.station = station
60
58
  station.worker = self
61
59
  end
data/lib/cf/run.rb CHANGED
@@ -48,9 +48,7 @@ module CF
48
48
  else
49
49
  resp = self.class.post("/lines/#{CF.account_name}/#{@line_title.downcase}/runs.json", {:data => {:run => {:title => @title}}, @param_for_input => @param_data})
50
50
  end
51
- if resp.code != 200
52
- self.errors = resp.error.message
53
- end
51
+ self.errors = resp['error']['message'] if resp['code'] != 200
54
52
  else
55
53
  @input = input
56
54
  @param_data = input
@@ -109,7 +107,7 @@ module CF
109
107
  if File.exist?(file.to_s)
110
108
  file_upload = File.new(file, 'rb')
111
109
  resp = post("/runs/#{CF.account_name}/#{run_title.downcase}/units.json", {:file => file_upload})
112
- @errors = resp.error.message if resp.code != 200
110
+ @errors = resp['error']['message'] if resp['code'] != 200
113
111
  return resp.to_hash
114
112
  end
115
113
  end
@@ -119,14 +117,8 @@ module CF
119
117
  # run_object.final_output
120
118
  def final_output
121
119
  resp = self.class.get("/runs/#{CF.account_name}/#{self.title.downcase}/output.json")
122
- self.errors = resp.error.message if resp.code != 200
123
- output = []
124
- if resp['output'].class == Array
125
- resp['output'].each do |o|
126
- output << o.to_hash
127
- end
128
- end
129
- return output
120
+ self.errors = resp['error']['message'] if resp['code'] != 200
121
+ return resp['output']
130
122
  end
131
123
 
132
124
  # ==Returns Final Output of production Run
@@ -134,14 +126,8 @@ module CF
134
126
  # CF::Run.final_output("run_title")
135
127
  def self.final_output(title)
136
128
  resp = get("/runs/#{CF.account_name}/#{title.downcase}/output.json")
137
- @errors = resp.error.message if resp.code != 200
138
- output = []
139
- if resp['output'].class == Array
140
- resp['output'].each do |o|
141
- output << o.to_hash
142
- end
143
- end
144
- return output
129
+ @errors = resp['error']['message'] if resp['code'] != 200
130
+ return resp['output']
145
131
  end
146
132
 
147
133
  # ==Returns Output of production Run for any specific Station and for given Run Title
@@ -152,14 +138,8 @@ module CF
152
138
  station_no = options[:station]
153
139
  title = options[:title]
154
140
  resp = get("/runs/#{CF.account_name}/#{title.downcase}/output/#{station_no}.json")
155
- @errors = resp.error.message if resp.code != 200
156
- output = []
157
- if resp['output'].class == Array
158
- resp['output'].each do |o|
159
- output << o.to_hash
160
- end
161
- end
162
- return output
141
+ @errors = resp['error']['message'] if resp['code'] != 200
142
+ return resp['output']
163
143
  end
164
144
 
165
145
  # ==Returns Output of Run object for any specific Station
@@ -169,14 +149,8 @@ module CF
169
149
  def output(options={})
170
150
  station_no = options[:station]
171
151
  resp = self.class.get("/runs/#{CF.account_name}/#{self.title.downcase}/output/#{station_no}.json")
172
- self.errors = resp.error.message if resp.code != 200
173
- output = []
174
- if resp['output'].class == Array
175
- resp['output'].each do |o|
176
- output << o.to_hash
177
- end
178
- end
179
- return output
152
+ self.errors = resp['error']['message'] if resp['code'] != 200
153
+ return resp['output']
180
154
  end
181
155
 
182
156
  # ==Searches Run for the given "run_title"
@@ -184,11 +158,11 @@ module CF
184
158
  # CF::Run.find("run_title")
185
159
  def self.find(title)
186
160
  resp = get("/runs/#{CF.account_name}/#{title.downcase}.json")
187
- if resp.code != 200
188
- @errors = resp.error.message
189
- resp.error = resp.error.message
190
- resp.merge!(:errors => "#{resp.error}")
191
- resp.delete(:error)
161
+ if resp['code'] != 200
162
+ @errors = resp['error']['message']
163
+ resp['error'] = resp['error']['message']
164
+ resp.merge!('errors' => "#{resp['error']}")
165
+ resp.delete('error')
192
166
  end
193
167
  return resp
194
168
  end
@@ -238,22 +212,11 @@ module CF
238
212
  end
239
213
  end
240
214
 
241
- if resp.code != 200
242
- send_resp = {"error" => resp.error.message}
243
- return send_resp
244
- end
245
-
246
- new_resp = []
247
- if resp.code == 200
248
- if resp.runs
249
- if resp.runs.count > 0
250
- resp.runs.each do |r|
251
- new_resp << r.to_hash
252
- end
253
- end
254
- end
255
- send_resp = {"runs" => new_resp, "total_pages" => resp.total_pages, "total_runs" => resp.total_runs}
215
+ if resp['code'] != 200
216
+ send_resp = {"error" => resp['error']['message']}
256
217
  return send_resp
218
+ else
219
+ return resp
257
220
  end
258
221
  end
259
222
 
@@ -262,7 +225,7 @@ module CF
262
225
  # resume_run = CF::Run.resume("run_title")
263
226
  def self.resume(run_title)
264
227
  resp = post("/runs/#{CF.account_name}/#{run_title}/resume.json")
265
- @errors = resp.error.message if resp.code != 200
228
+ @errors = resp['error']['message'] if resp['code'] != 200
266
229
  return resp
267
230
  end
268
231
 
@@ -271,7 +234,7 @@ module CF
271
234
  # delete_run = CF::Run.destroy("run_title")
272
235
  def self.destroy(run_title)
273
236
  resp = delete("/runs/#{CF.account_name}/#{run_title}.json")
274
- @errors = resp.error.message if resp.code != 200
237
+ @errors = resp['error']['message'] if resp['code'] != 200
275
238
  return resp
276
239
  end
277
240
  end
data/lib/cf/station.rb CHANGED
@@ -219,11 +219,9 @@ module CF
219
219
  worker = CF::RobotWorker.new({})
220
220
  worker.settings = @settings
221
221
  worker.type = @type
222
- worker.number = resp.number
223
- worker.reward = resp.reward
224
- if resp.code != 200
225
- worker.errors = resp.error.message
226
- end
222
+ worker.number = resp['number']
223
+ worker.reward = resp['reward']
224
+ worker.errors = resp['error']['message'] if resp['code'] != 200
227
225
  @worker_instance = worker
228
226
  end
229
227
  end
@@ -273,9 +271,7 @@ module CF
273
271
  @resp.to_hash.each_pair do |k,v|
274
272
  form.send("#{k}=",v) if form.respond_to?(k)
275
273
  end
276
- if @resp.code != 200
277
- form.errors = @resp.error.message
278
- end
274
+ form.errors = @resp['error']['message'] if @resp['code'] != 200
279
275
  form.station = self
280
276
  @form_instance = form
281
277
  end
@@ -291,7 +287,7 @@ module CF
291
287
  # returns the station object
292
288
  def get
293
289
  resp = self.class.get("/lines/#{CF.account_name}/#{self.line_title.downcase}/stations/#{self.index}.json")
294
- self.errors = resp.error.message if resp.code != 200
290
+ self.errors = resp['error']['message'] if resp['code'] != 200
295
291
  return resp
296
292
  end
297
293
 
@@ -300,7 +296,7 @@ module CF
300
296
  # @got_form = line.stations[0].get_form
301
297
  def get_form
302
298
  resp = self.class.get("/lines/#{CF.account_name}/#{self.line_title.downcase}/stations/#{self.index}/form.json")
303
- self.errors = resp.error.message if resp.code != 200
299
+ self.errors = resp['error']['message'] if resp['code'] != 200
304
300
  return resp
305
301
  end
306
302
 
data/lib/cf/task_form.rb CHANGED
@@ -34,9 +34,7 @@ module CF
34
34
  resp.to_hash.each_pair do |k,v|
35
35
  self.send("#{k}=",v) if self.respond_to?(k)
36
36
  end
37
- if resp.code != 200
38
- self.errors = resp.error.message
39
- end
37
+ self.errors = resp['error']['message'] if resp['code'] != 200
40
38
  @station.form = self
41
39
  end
42
40
  end
data/lib/cf/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module CF # :nodoc: all
2
- VERSION = "0.3.1"
2
+ VERSION = "0.4.0"
3
3
  end
data/spec/account_spec.rb CHANGED
@@ -2,10 +2,8 @@ require 'spec_helper'
2
2
 
3
3
  describe CF::Account do
4
4
  it "should get the account info" do
5
- # WebMock.allow_net_connect!
6
- VCR.use_cassette "account/info", :record => :new_episodes do
7
- account_info = CF::Account.info
8
- account_info.name.should eql("manish")
9
- end
5
+ WebMock.allow_net_connect!
6
+ account_info = CF::Account.info
7
+ account_info['name'].should eql("4r9t")
10
8
  end
11
9
  end
data/spec/badge_spec.rb CHANGED
@@ -4,84 +4,84 @@ module CF
4
4
  describe CF::HumanWorker do
5
5
  context "create badge" do
6
6
  it "should create multiple badge for worker" do
7
- # WebMock.allow_net_connect!
8
- VCR.use_cassette "human_worker/block/create-multiple-badge", :record => :new_episodes do
9
- badge =
7
+ WebMock.allow_net_connect!
8
+ badge =
9
+ {
10
+ :title => 'Football Fanatic',
11
+ :description => "This qualification allows you to perform work at stations which have this badge.",
12
+ :max_badges => 3,
13
+ :test =>
10
14
  {
11
- :title => 'Football Fanatic',
12
- :description => "This qualification allows you to perform work at stations which have this badge.",
13
- :max_badges => 3,
14
- :test =>
15
- {
16
- :input => {:name => "Lionel Andres Messi", :country => "Argentina"},
17
- :expected_output =>
18
- [{:birthplace => "Rosario, Santa Fe, Argentina",:match_options => {:tolerance => 10, :ignore_case => true }},{:position => "CF",:match_options => {:tolerance => 1 }},{:"current-club" => "Barcelona",:match_options => {:tolerance => 1, :ignore_case => false }}]
19
- }
15
+ :input => {:name => "Lionel Andres Messi", :country => "Argentina"},
16
+ :expected_output =>
17
+ [{:birthplace => "Rosario, Santa Fe, Argentina",:match_options => {:tolerance => 10, :ignore_case => true }},{:position => "CF",:match_options => {:tolerance => 1 }},{:"current-club" => "Barcelona",:match_options => {:tolerance => 1, :ignore_case => false }}]
20
18
  }
21
- badge_1 =
19
+ }
20
+ badge_1 =
21
+ {
22
+ :title => 'Football Fanatic',
23
+ :description => "This qualification allows you to perform work at stations which have this badge.",
24
+ :max_badges => 3,
25
+ :test =>
22
26
  {
23
- :title => 'Football Fanatic',
24
- :description => "This qualification allows you to perform work at stations which have this badge.",
25
- :max_badges => 3,
26
- :test =>
27
- {
28
- :input => {:name => "Cristiano Ronaldo", :country => "Portugal"},
29
- :expected_output =>
30
- [{:birthplace => "Rosario, Santa Fe, Portugal",:match_options => {:tolerance => 10, :ignore_case => true }},{:position => "CF",:match_options => {:tolerance => 1 }},{:"current-club" => "Real Madrid",:match_options => {:tolerance => 1, :ignore_case => false }}]
31
- }
27
+ :input => {:name => "Cristiano Ronaldo", :country => "Portugal"},
28
+ :expected_output =>
29
+ [{:birthplace => "Rosario, Santa Fe, Portugal",:match_options => {:tolerance => 10, :ignore_case => true }},{:position => "CF",:match_options => {:tolerance => 1 }},{:"current-club" => "Real Madrid",:match_options => {:tolerance => 1, :ignore_case => false }}]
32
30
  }
33
- line = CF::Line.create("badge_in_worker", "Digitization") do |l|
34
- CF::InputFormat.new({:line => l, :name => "image_url", :required => true, :valid_type => "url"})
35
- CF::Station.create({:line =>l, :type => "work"}) do |s|
36
- CF::HumanWorker.new({:station => s, :number => 1, :reward => 20, :skill_badge => badge})
37
- end
31
+ }
32
+ title = "line_title#{Time.new.strftime('%Y%b%d-%H%M%S')}".downcase
33
+ sleep 1
34
+ line = CF::Line.create(title, "Digitization") do |l|
35
+ CF::InputFormat.new({:line => l, :name => "image_url", :required => true, :valid_type => "url"})
36
+ CF::Station.create({:line =>l, :type => "work"}) do |s|
37
+ CF::HumanWorker.new({:station => s, :number => 1, :reward => 20, :skill_badge => badge})
38
38
  end
39
- line.stations.first.worker.badge = badge_1
40
- line.stations.first.type.should eql("WorkStation")
41
- line.stations.first.worker.number.should eql(1)
42
- line.stations.first.worker.reward.should eql(20)
43
- line.stations.first.worker.skill_badges.first.should eql([{"title"=>"Football Fanatic", "description"=>"This qualification allows you to perform work at stations which have this badge.", "score"=>nil, "quality_rating"=>nil, "max_badges"=>3, "skill_test"=>{"score_after"=>"submit", "manual_scoring"=>false, "display_answers"=>false, "edit_answers"=>true, "retries"=>0, "pass_percentage"=>100, "test_units"=>[{"input"=>{"name"=>"Lionel Andres Messi", "country"=>"Argentina"}, "expected_output"=>[{"birthplace"=>"Rosario, Santa Fe, Argentina", "match_options"=>{"tolerance"=>"1", "ignore_case"=>"false"}, "position"=>"CF", "current-club"=>"Barcelona"}], "match_options"=>{"tolerance"=>0, "ignore_case"=>false}}]}}])
44
- line.stations.first.worker.skill_badges.last.should eql([{"title"=>"Football Fanatic", "description"=>"This qualification allows you to perform work at stations which have this badge.", "score"=>nil, "quality_rating"=>nil, "max_badges"=>3, "skill_test"=>{"score_after"=>"submit", "manual_scoring"=>false, "display_answers"=>false, "edit_answers"=>true, "retries"=>0, "pass_percentage"=>100, "test_units"=>[{"input"=>{"name"=>"Cristiano Ronaldo", "country"=>"Portugal"}, "expected_output"=>[{"birthplace"=>"Rosario, Santa Fe, Portugal", "match_options"=>{"tolerance"=>"1", "ignore_case"=>"false"}, "position"=>"CF", "current-club"=>"Real Madrid"}], "match_options"=>{"tolerance"=>0, "ignore_case"=>false}}]}}])
45
- line.stations.first.worker.stat_badge.should eql({"approval_rating"=>80, "assignment_duration"=>3600, "abandonment_rate"=>30, "country"=>nil})
46
39
  end
40
+ line.stations.first.worker.badge = badge_1
41
+ line.stations.first.type.should eql("WorkStation")
42
+ line.stations.first.worker.number.should eql(1)
43
+ line.stations.first.worker.reward.should eql(20)
44
+ line.stations.first.worker.skill_badges.first.should eql([{"title"=>"Football Fanatic", "description"=>"This qualification allows you to perform work at stations which have this badge.", "score"=>nil, "quality_rating"=>nil, "max_badges"=>3, "skill_test"=>{"score_after"=>"submit", "manual_scoring"=>false, "display_answers"=>false, "edit_answers"=>true, "retries"=>0, "pass_percentage"=>100, "test_units"=>[{"input"=>{"name"=>"Lionel Andres Messi", "country"=>"Argentina"}, "expected_output"=>[{"birthplace"=>"Rosario, Santa Fe, Argentina", "match_options"=>{"tolerance"=>"1", "ignore_case"=>"false"}, "position"=>"CF", "current-club"=>"Barcelona"}], "match_options"=>{"tolerance"=>0, "ignore_case"=>false}}]}}])
45
+ line.stations.first.worker.skill_badges.last.should eql([{"title"=>"Football Fanatic", "description"=>"This qualification allows you to perform work at stations which have this badge.", "score"=>nil, "quality_rating"=>nil, "max_badges"=>3, "skill_test"=>{"score_after"=>"submit", "manual_scoring"=>false, "display_answers"=>false, "edit_answers"=>true, "retries"=>0, "pass_percentage"=>100, "test_units"=>[{"input"=>{"name"=>"Cristiano Ronaldo", "country"=>"Portugal"}, "expected_output"=>[{"birthplace"=>"Rosario, Santa Fe, Portugal", "match_options"=>{"tolerance"=>"1", "ignore_case"=>"false"}, "position"=>"CF", "current-club"=>"Real Madrid"}], "match_options"=>{"tolerance"=>0, "ignore_case"=>false}}]}}])
46
+ line.stations.first.worker.stat_badge.should eql({"approval_rating"=>80, "assignment_duration"=>3600, "abandonment_rate"=>30, "country"=>nil})
47
47
  end
48
-
48
+
49
49
  it "should create stat badge for worker in block DSL way" do
50
- # WebMock.allow_net_connect!
51
- VCR.use_cassette "human_worker/block/create-stat-badge", :record => :new_episodes do
52
- stat_badge = {:approval_rating => 40, :assignment_duration => 1800}
53
- line = CF::Line.create("stat_badge_in_worker", "Digitization") do |l|
54
- CF::InputFormat.new({:line => l, :name => "image_url", :required => true, :valid_type => "url"})
55
- CF::Station.create({:line =>l, :type => "work"}) do |s|
56
- CF::HumanWorker.new({:station => s, :number => 1, :reward => 20, :stat_badge => stat_badge})
57
- end
50
+ WebMock.allow_net_connect!
51
+ stat_badge = {:approval_rating => 40, :assignment_duration => 1800}
52
+ title = "line_title#{Time.new.strftime('%Y%b%d-%H%M%S')}".downcase
53
+ sleep 1
54
+ line = CF::Line.create(title, "Digitization") do |l|
55
+ CF::InputFormat.new({:line => l, :name => "image_url", :required => true, :valid_type => "url"})
56
+ CF::Station.create({:line =>l, :type => "work"}) do |s|
57
+ CF::HumanWorker.new({:station => s, :number => 1, :reward => 20, :stat_badge => stat_badge})
58
58
  end
59
- line.stations.first.type.should eql("WorkStation")
60
- line.stations.first.worker.number.should eql(1)
61
- line.stations.first.worker.reward.should eql(20)
62
- line.stations.first.worker.stat_badge.should eql({"approval_rating"=>40, "assignment_duration"=>1800, "abandonment_rate"=>30, "country"=>nil})
63
59
  end
60
+ line.stations.first.type.should eql("WorkStation")
61
+ line.stations.first.worker.number.should eql(1)
62
+ line.stations.first.worker.reward.should eql(20)
63
+ line.stations.first.worker.stat_badge.should eql({"approval_rating"=>40, "assignment_duration"=>1800, "abandonment_rate"=>30, "country"=>nil})
64
64
  end
65
-
65
+
66
66
  it "should create stat badge for worker in plain ruby way" do
67
- # WebMock.allow_net_connect!
68
- VCR.use_cassette "human_worker/plain-ruby/create-stat-badge", :record => :new_episodes do
69
- stat_badge = {:approval_rating => 40, :assignment_duration => 1800}
70
- line = CF::Line.new("stat_badge_in_worker_1", "Digitization")
71
- input_format = CF::InputFormat.new({:name => "image_url", :required => true, :valid_type => "url"})
72
- line.input_formats input_format
67
+ WebMock.allow_net_connect!
68
+ stat_badge = {:approval_rating => 40, :assignment_duration => 1800}
69
+ title = "line_title#{Time.new.strftime('%Y%b%d-%H%M%S')}".downcase
70
+ sleep 1
71
+ line = CF::Line.new(title, "Digitization")
72
+ input_format = CF::InputFormat.new({:name => "image_url", :required => true, :valid_type => "url"})
73
+ line.input_formats input_format
73
74
 
74
- station = CF::Station.new({:type => "work"})
75
- line.stations station
75
+ station = CF::Station.new({:type => "work"})
76
+ line.stations station
76
77
 
77
- worker = CF::HumanWorker.new({:number => 1, :reward => 20, :stat_badge => stat_badge})
78
- line.stations.first.worker = worker
79
-
80
- line.stations.first.type.should eql("WorkStation")
81
- line.stations.first.worker.number.should eql(1)
82
- line.stations.first.worker.reward.should eql(20)
83
- line.stations.first.worker.stat_badge.should eql({"approval_rating"=>40, "assignment_duration"=>1800, "abandonment_rate"=>30, "country"=>nil})
84
- end
78
+ worker = CF::HumanWorker.new({:number => 1, :reward => 20, :stat_badge => stat_badge})
79
+ line.stations.first.worker = worker
80
+
81
+ line.stations.first.type.should eql("WorkStation")
82
+ line.stations.first.worker.number.should eql(1)
83
+ line.stations.first.worker.reward.should eql(20)
84
+ line.stations.first.worker.stat_badge.should eql({"approval_rating"=>40, "assignment_duration"=>1800, "abandonment_rate"=>30, "country"=>nil})
85
85
  end
86
86
  end
87
87
  end
@@ -5,51 +5,51 @@ module CF
5
5
  describe CF::RobotWorker do
6
6
  context "create a concept tagging robot worker" do
7
7
  it "should create concept tagging robot worker for first station in Block DSL way" do
8
- # WebMock.allow_net_connect!
9
- VCR.use_cassette "robot_worker/concept_tagging_robot/block/create-worker-single-station", :record => :new_episodes do
10
- line = CF::Line.create("concept_tagging_robot","Digitization") do |l|
11
- CF::InputFormat.new({:line => l, :name => "url", :valid_type => "url", :required => "true"})
12
- CF::Station.create({:line => l, :type => "work"}) do |s|
13
- CF::RobotWorker.create({:station => s, :type => "concept_tagging_robot", :settings => {:url => ["{{url}}"]}})
14
- end
8
+ WebMock.allow_net_connect!
9
+ title = "line_title#{Time.new.strftime('%Y%b%d-%H%M%S')}".downcase
10
+ sleep 1
11
+ line = CF::Line.create(title,"Digitization") do |l|
12
+ CF::InputFormat.new({:line => l, :name => "url", :valid_type => "url", :required => "true"})
13
+ CF::Station.create({:line => l, :type => "work"}) do |s|
14
+ CF::RobotWorker.create({:station => s, :type => "concept_tagging_robot", :settings => {:url => ["{{url}}"]}})
15
15
  end
16
- run = CF::Run.create(line, "concept_tagging_robot_run", [{"url"=>"www.mosexindex.com"}])
17
- # sleep 20 # require delay for final_output's processing
18
- output = run.final_output
19
- output.first['concept_tagging_of_url'].should eql(["Canada", "English language"])
20
- output.first['concept_tagging_relevance_of_url'].should eql([89.5153, 79.0912])
21
- line.stations.first.worker.class.should eql(CF::RobotWorker)
22
- line.stations.first.worker.reward.should eql(0.5)
23
- line.stations.first.worker.number.should eql(1)
24
- line.stations.first.worker.settings.should eql({:url => ["{{url}}"]})
25
- line.stations.first.worker.type.should eql("ConceptTaggingRobot")
26
16
  end
17
+ run = CF::Run.create(line, "run-#{title}", [{"url"=>"www.mosexindex.com"}])
18
+ sleep 20 # require delay for final_output's processing
19
+ output = run.final_output
20
+ output.first['concept_tagging_of_url'].should eql(["Canada", "English language"])
21
+ output.first['concept_tagging_relevance_of_url'].should eql([89.5153, 79.0912])
22
+ line.stations.first.worker.class.should eql(CF::RobotWorker)
23
+ line.stations.first.worker.reward.should eql(0.5)
24
+ line.stations.first.worker.number.should eql(1)
25
+ line.stations.first.worker.settings.should eql({:url => ["{{url}}"]})
26
+ line.stations.first.worker.type.should eql("ConceptTaggingRobot")
27
27
  end
28
28
 
29
29
  it "should create content_scraping_robot worker for first station in a plain ruby way" do
30
- # WebMock.allow_net_connect!
31
- VCR.use_cassette "robot_worker/concept_tagging_robot/plain-ruby/create-worker-in-first-station", :record => :new_episodes do
32
- line = CF::Line.new("concept_tagging_robot_1","Digitization")
33
- input_format = CF::InputFormat.new({:name => "url", :required => true, :valid_type => "url"})
34
- line.input_formats input_format
30
+ WebMock.allow_net_connect!
31
+ title = "line_title#{Time.new.strftime('%Y%b%d-%H%M%S')}".downcase
32
+ sleep 1
33
+ line = CF::Line.new(title,"Digitization")
34
+ input_format = CF::InputFormat.new({:name => "url", :required => true, :valid_type => "url"})
35
+ line.input_formats input_format
35
36
 
36
- station = CF::Station.new({:type => "work"})
37
- line.stations station
37
+ station = CF::Station.new({:type => "work"})
38
+ line.stations station
38
39
 
39
- worker = CF::RobotWorker.create({:type => "concept_tagging_robot", :settings => {:url => ["{{url}}"]}})
40
- line.stations.first.worker = worker
40
+ worker = CF::RobotWorker.create({:type => "concept_tagging_robot", :settings => {:url => ["{{url}}"]}})
41
+ line.stations.first.worker = worker
41
42
 
42
- run = CF::Run.create(line, "concept_tagging_robot_run_1", [{"url"=>"www.mosexindex.com"}])
43
- # sleep 20 # require delay for final_output's processing
44
- output = run.final_output
45
- output.first['concept_tagging_of_url'].should eql(["Canada", "English language"])
46
- output.first['concept_tagging_relevance_of_url'].should eql([89.5153, 79.0912])
47
- line.stations.first.worker.class.should eql(CF::RobotWorker)
48
- line.stations.first.worker.reward.should eql(0.5)
49
- line.stations.first.worker.number.should eql(1)
50
- line.stations.first.worker.settings.should eql({:url => ["{{url}}"]})
51
- line.stations.first.worker.type.should eql("ConceptTaggingRobot")
52
- end
43
+ run = CF::Run.create(line, "run-#{title}", [{"url"=>"www.mosexindex.com"}])
44
+ sleep 20 # require delay for final_output's processing
45
+ output = run.final_output
46
+ output.first['concept_tagging_of_url'].should eql(["Canada", "English language"])
47
+ output.first['concept_tagging_relevance_of_url'].should eql([89.5153, 79.0912])
48
+ line.stations.first.worker.class.should eql(CF::RobotWorker)
49
+ line.stations.first.worker.reward.should eql(0.5)
50
+ line.stations.first.worker.number.should eql(1)
51
+ line.stations.first.worker.settings.should eql({:url => ["{{url}}"]})
52
+ line.stations.first.worker.type.should eql("ConceptTaggingRobot")
53
53
  end
54
54
  end
55
55
  end