cloudfactory 0.5 → 0.5.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,7 @@
1
+ ## 0.5.1 (2012-02-22)
2
+ * Bug fixed for problem in options with block DSL
3
+ * Default Worker Pool changed to mTurk
4
+
1
5
  ## 0.5 (2012-02-16)
2
6
  * All updates from 0.4x
3
7
  * worker pool added, by default it is cloudfactory
@@ -45,6 +45,7 @@ module CF
45
45
  resp = self.class.post("/lines/#{CF.account_name}/#{@line.title.downcase}/gold_standards.json", {:file => file_upload,:template => options[:template]})
46
46
  @line.gold_standards = self
47
47
  end
48
+ #self.errors = resp['error']['message'] if resp["code"] != 200
48
49
  else
49
50
  request =
50
51
  {
@@ -28,10 +28,10 @@ module CF
28
28
 
29
29
  # input_formats contained within line object
30
30
  attr_accessor :input_formats
31
-
31
+
32
32
  # Contains Error Messages
33
33
  attr_accessor :errors
34
-
34
+
35
35
  # output_formats of the final output for a line
36
36
  attr_accessor :output_formats
37
37
 
@@ -46,7 +46,7 @@ module CF
46
46
  @title = title
47
47
  @department_name = department_name
48
48
  @public = options[:public].nil? ? true : options[:public]
49
- @worker_pool = options[:worker_pool].nil? ? "cloudfactory" : options[:worker_pool]
49
+ @worker_pool = options[:worker_pool].nil? ? "mturk" : options[:worker_pool]
50
50
  @description = options[:description]
51
51
  resp = self.class.post("/lines/#{CF.account_name}.json", {:line => {:title => title, :department_name => department_name, :public => @public,:worker_pool => @worker_pool, :description => @description}})
52
52
  self.errors = resp['error']['message'] if resp['code'] != 200
@@ -74,9 +74,9 @@ module CF
74
74
  @auto_judge = stations.auto_judge
75
75
  @acceptance_ratio = stations.acceptance_ratio
76
76
  if @batch_size.nil?
77
- request_tournament =
77
+ request_tournament =
78
78
  {
79
- :body =>
79
+ :body =>
80
80
  {
81
81
  :api_key => CF.api_key,
82
82
  :station => {:type => type, :jury_worker => @jury_worker, :auto_judge => @auto_judge, :input_formats => @station_input_formats}
@@ -84,18 +84,18 @@ module CF
84
84
  }
85
85
  else
86
86
  if @acceptance_ratio.nil?
87
- request_tournament =
87
+ request_tournament =
88
88
  {
89
- :body =>
89
+ :body =>
90
90
  {
91
91
  :api_key => CF.api_key,
92
92
  :station => {:type => type, :jury_worker => @jury_worker, :auto_judge => @auto_judge, :input_formats => @station_input_formats, :batch_size => @batch_size}
93
93
  }
94
94
  }
95
95
  else
96
- request_tournament =
96
+ request_tournament =
97
97
  {
98
- :body =>
98
+ :body =>
99
99
  {
100
100
  :api_key => CF.api_key,
101
101
  :station => {:type => type, :jury_worker => @jury_worker, :auto_judge => @auto_judge, :input_formats => @station_input_formats, :batch_size => @batch_size, :acceptance_ratio => @acceptance_ratio}
@@ -106,18 +106,18 @@ module CF
106
106
  resp = HTTParty.post("#{CF.api_url}#{CF.api_version}/lines/#{CF.account_name}/#{self.title.downcase}/stations.json",request_tournament)
107
107
  else
108
108
  if @batch_size.nil?
109
- request_general =
109
+ request_general =
110
110
  {
111
- :body =>
111
+ :body =>
112
112
  {
113
113
  :api_key => CF.api_key,
114
114
  :station => {:type => type, :input_formats => @station_input_formats}
115
115
  }
116
116
  }
117
117
  else
118
- request_general =
118
+ request_general =
119
119
  {
120
- :body =>
120
+ :body =>
121
121
  {
122
122
  :api_key => CF.api_key,
123
123
  :station => {:type => type, :input_formats => @station_input_formats, :batch_size => @batch_size}
@@ -161,7 +161,7 @@ module CF
161
161
  # CF::Station.new({:line => self, :type => "Work"})
162
162
  # end
163
163
  def self.create(title, department_name, options={}, &block)
164
- line = Line.new(title,department_name,options={})
164
+ line = Line.new(title,department_name,options)
165
165
  @public = options[:public]
166
166
  @worker_pool = options[:worker_pool]
167
167
  @description = options[:description]
@@ -200,9 +200,9 @@ module CF
200
200
  else
201
201
  @input_formats
202
202
  end
203
-
203
+
204
204
  end
205
-
205
+
206
206
  def input_formats=(input_formats_value) # :nodoc:
207
207
  @input_formats << input_formats_value
208
208
  end
@@ -214,9 +214,9 @@ module CF
214
214
  def output_formats output_format = nil
215
215
  if output_format
216
216
  settings = output_format.settings
217
- request =
217
+ request =
218
218
  {
219
- :body =>
219
+ :body =>
220
220
  {
221
221
  :api_key => CF.api_key,
222
222
  :output_formats => settings
@@ -315,13 +315,13 @@ module CF
315
315
  end
316
316
  end
317
317
  if resp['code'] != 200
318
- @errors = resp['error']['message']
318
+ @errors = resp['error']['message']
319
319
  return nil
320
320
  else
321
321
  return resp
322
322
  end
323
323
  end
324
-
324
+
325
325
  # ==Returns all the lines of an account
326
326
  # ===Syntax for all method is
327
327
  # CF::Line.all
@@ -346,7 +346,7 @@ module CF
346
346
  # send_resp = {"lines" => new_resp, "total_pages" => resp.total_pages, "total_lines" => resp.total_lines}
347
347
  return resp
348
348
  end
349
-
349
+
350
350
  # ==Returns all the stations of a line
351
351
  # ===Usage Example:
352
352
  # CF::Line.get_stations
@@ -394,7 +394,7 @@ module CF
394
394
  self.errors = resp['error']['message'] if resp['code'] != 200
395
395
  return resp
396
396
  end
397
-
397
+
398
398
  # ==Deletes a line by passing it's title
399
399
  # ===Usage Example:
400
400
  # line = CF::Line.new("line_title", "Survey")
@@ -409,7 +409,7 @@ module CF
409
409
  @errors = resp['error']['message'] if resp['code'] != 200
410
410
  return resp
411
411
  end
412
-
412
+
413
413
  # ==Return all the associated elements of a line
414
414
  # ===Usage Example:
415
415
  # line = CF::Line.inspect("line_title")
@@ -425,7 +425,7 @@ module CF
425
425
  # # send_resp.delete("input_formats")
426
426
  # # send_resp.merge!("input_formats" => @line_input_formats)
427
427
  # # @stations = []
428
- #
428
+ #
429
429
  # # resp.stations.each do |s|
430
430
  # # @station_input_formats = []
431
431
  # # s.input_formats.each do |i|
@@ -444,7 +444,7 @@ module CF
444
444
  # # @temp_station.merge!("input_formats" => @station_input_formats)
445
445
  # # @stations << @temp_station
446
446
  # # end
447
- # #
447
+ # #
448
448
  # # send_resp.delete("stations")
449
449
  # # send_resp.merge!("stations" => @stations)
450
450
  # send_resp
@@ -1,3 +1,3 @@
1
1
  module CF # :nodoc: all
2
- VERSION = "0.5"
2
+ VERSION = "0.5.1"
3
3
  end
@@ -10,7 +10,7 @@ describe CF::Line do
10
10
  sleep 1
11
11
  line = CF::Line.new(title, "Digitization", {:public => false, :description => "this is description"})
12
12
  line.title.should eq(title)
13
- line.worker_pool.should eql("cloudfactory")
13
+ line.worker_pool.should eql("mturk")
14
14
  line.department_name.should eq("Digitization")
15
15
  end
16
16
 
@@ -18,9 +18,9 @@ describe CF::Line do
18
18
  WebMock.allow_net_connect!
19
19
  title = "line_title#{Time.new.strftime('%Y%b%d-%H%M%S')}".downcase
20
20
  sleep 1
21
- line = CF::Line.new(title, "Digitization", {:public => false,:worker_pool => "mturk", :description => "this is description"})
21
+ line = CF::Line.new(title, "Digitization", {:public => false,:worker_pool => "cloudfactory", :description => "this is description"})
22
22
  line.title.should eq(title)
23
- line.worker_pool.should eql("mturk")
23
+ line.worker_pool.should eql("cloudfactory")
24
24
  line.department_name.should eq("Digitization")
25
25
  end
26
26
 
@@ -80,7 +80,7 @@ describe CF::Line do
80
80
  line.title.should eq(title)
81
81
  line.department_name.should eq("Digitization")
82
82
  line.public.should eql(true)
83
- line.worker_pool.should eql("cloudfactory")
83
+ line.worker_pool.should eql("mturk")
84
84
  line.description.should eq("this is description")
85
85
  end
86
86
 
@@ -88,11 +88,11 @@ describe CF::Line do
88
88
  WebMock.allow_net_connect!
89
89
  title = "line_title#{Time.new.strftime('%Y%b%d-%H%M%S')}".downcase
90
90
  sleep 1
91
- line = CF::Line.new(title, "Digitization", {:public => true,:worker_pool => "mturk", :description => "this is description"})
91
+ line = CF::Line.new(title, "Digitization", {:public => true,:worker_pool => "cloudfactory", :description => "this is description"})
92
92
  line.title.should eq(title)
93
93
  line.department_name.should eq("Digitization")
94
94
  line.public.should eql(true)
95
- line.worker_pool.should eql("mturk")
95
+ line.worker_pool.should eql("cloudfactory")
96
96
  line.description.should eq("this is description")
97
97
  end
98
98
 
@@ -133,6 +133,25 @@ describe CF::Line do
133
133
  line.stations.first.form.form_fields.first.field_type.should eq("short_answer")
134
134
  line.stations.first.form.form_fields.first.required.should eq(true)
135
135
  end
136
+
137
+ it "create with a new station with worker_pool specified" do
138
+ WebMock.allow_net_connect!
139
+ title = "line_title#{Time.new.strftime('%Y%b%d-%H%M%S')}".downcase
140
+ sleep 1
141
+ line = CF::Line.create(title, "Digitization", :worker_pool => "mturk") do |l|
142
+ CF::InputFormat.new({:line => l, :name => "image_url", :required => true, :valid_type => "url"})
143
+ CF::Station.create({:line => l, :type => "work"}) do |station|
144
+ CF::HumanWorker.new({:line => l, :station => station, :number => 1, :reward => 20})
145
+ CF::TaskForm.create({:station => station, :title => "Enter text from a business card image", :instruction => "Describe"}) do |i|
146
+ CF::FormField.new({:form => i, :label => "First Name", :field_type => "short_answer", :required => "true"})
147
+ CF::FormField.new({:form => i, :label => "Middle Name", :field_type => "short_answer"})
148
+ CF::FormField.new({:form => i, :label => "Last Name", :field_type => "short_answer", :required => "true"})
149
+ end
150
+ end
151
+ end
152
+ line.title.should eq(title)
153
+ line.worker_pool.should eq("mturk")
154
+ end
136
155
  end
137
156
 
138
157
  context "listing lines" do
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: cloudfactory
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: "0.5"
5
+ version: 0.5.1
6
6
  platform: ruby
7
7
  authors:
8
8
  - CloudFactory.com
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2012-02-16 00:00:00 Z
13
+ date: 2012-02-22 00:00:00 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: i18n