cloudfactory 0.4.5.2 → 0.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,7 @@
1
+ ## 0.5 (2012-02-16)
2
+ * All updates from 0.4x
3
+ * worker pool added, by default it is cloudfactory
4
+
1
5
  ## 0.4.5.2 (2012-02-14)
2
6
  * Template and Template file added for bulk goldstandards from csv
3
7
  * Line deletion with runs bug fixed
@@ -170,7 +170,7 @@ module Cf # :nodoc: all
170
170
  line_description = line_dump['description']
171
171
  line_department = line_dump['department']
172
172
  line_public = line_dump['public']
173
-
173
+ line_worker_pool = line_dump['worker_pool']
174
174
  line = CF::Line.info(line_title)
175
175
  if line['error'].blank? && options.force?
176
176
  rollback(line.title)
@@ -185,7 +185,7 @@ module Cf # :nodoc: all
185
185
  say("Line creation aborted!!", :yellow) and exit(1)
186
186
  end
187
187
  end
188
- line = CF::Line.new(line_title, line_department, {:description => line_description, :public => line_public})
188
+ line = CF::Line.new(line_title, line_department, {:description => line_description, :public => line_public, :worker_pool => line_worker_pool})
189
189
  say "Creating new assembly line: #{line.title}", :green
190
190
  say("Error: #{line.errors}", :red) and exit(1) if line.errors.present?
191
191
 
@@ -14,6 +14,10 @@ module CF
14
14
  # Public attribute is optional, by default it's true
15
15
  attr_accessor :public
16
16
 
17
+ # worker_pool attribute is optional, by default it's cloudfactory
18
+ attr_accessor :worker_pool
19
+
20
+
17
21
  # Description attribute describes about the line
18
22
  #
19
23
  # Description attribute is optional
@@ -42,8 +46,9 @@ module CF
42
46
  @title = title
43
47
  @department_name = department_name
44
48
  @public = options[:public].nil? ? true : options[:public]
49
+ @worker_pool = options[:worker_pool].nil? ? "cloudfactory" : options[:worker_pool]
45
50
  @description = options[:description]
46
- resp = self.class.post("/lines/#{CF.account_name}.json", {:line => {:title => title, :department_name => department_name, :public => @public, :description => @description}})
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}})
47
52
  self.errors = resp['error']['message'] if resp['code'] != 200
48
53
  return resp
49
54
  end
@@ -158,6 +163,7 @@ module CF
158
163
  def self.create(title, department_name, options={}, &block)
159
164
  line = Line.new(title,department_name,options={})
160
165
  @public = options[:public]
166
+ @worker_pool = options[:worker_pool]
161
167
  @description = options[:description]
162
168
  if block.arity >= 1
163
169
  block.call(line)
@@ -369,8 +375,9 @@ module CF
369
375
  @title = options[:title]
370
376
  @department_name = options[:department_name]
371
377
  @public = options[:public]
378
+ @worker_pool = options[:worker_pool]
372
379
  @description = options[:description]
373
- self.class.put("/lines/#{CF.account_name}/#{old_title.downcase}.json", :line => {:title => @title, :department_name => @department_name, :public => @public, :description => @description})
380
+ self.class.put("/lines/#{CF.account_name}/#{old_title.downcase}.json", :line => {:title => @title, :department_name => @department_name, :public => @public, :worker_pool => @worker_pool, :description => @description})
374
381
  end
375
382
 
376
383
  # ==Deletes a line
@@ -1,3 +1,3 @@
1
1
  module CF # :nodoc: all
2
- VERSION = "0.4.5.2"
2
+ VERSION = "0.5"
3
3
  end
@@ -44,9 +44,9 @@ describe CF::CustomTaskForm do
44
44
  line.title.should eql(title)
45
45
  line.department_name.should eql("Digitization")
46
46
  line.stations.first.type.should eql("WorkStation")
47
- CGI.unescape_html(line.stations.first.form.raw_html).should eql("<!DOCTYPE html>\n<html>\n<head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\"></head>\n<body>\n<p>\"-//W3C//DTD HTML 4.0 Transitional//EN\\\" \\\"http://www.w3.org/TR/REC-html40/loose.dtd\\\"&gt;\\n\\n</p>\n<meta http-equiv='\\\"Content-Type\\\"' content='\\\"text/html;' charset='UTF-8\\\"'>\n<div id=\"form-content\">\n <form>\n<div id=\"instructions\">\n <ul>\n<li>Look at the business card properly and fill in asked data.</li>\n <li>Make sure you enter everything found on business card.</li>\n <li>Work may be rejected if it is incomplete or mistakes are found.</li>\n </ul>\n</div>\n <div id=\"image-field-wrapper\">\n <div id=\"image-panel\">\n <img class=\"card-image\" src=\"%7B%7Bimage_url%7D%7D\">\n</div>\n <div id=\"field-panel\">\n Name<br><input class=\"input-field first_name\" type=\"text\" name=\"output[first_name]\"><input class=\"input-field middle_name\" type=\"text\" name=\"output[middle_name]\"><input class=\"input-field last_name\" type=\"text\" name=\"output[last_name]\"><br><br>Contact<br><input class=\"input-field email\" type=\"text\" name=\"output[email]\" placeholder=\"Email\"><input class=\"input-field phone\" type=\"text\" name=\"output[phone]\" placeholder=\"Phone\"><input class=\"input-field mobile\" type=\"text\" name=\"output[mobile]\" placeholder=\"Mobile\"><br>\n</div>\n </div>\n </form>\n</div>\n</body>\n</html>\n")
47
+ CGI.unescape_html(line.stations.first.form.raw_html).should eql("<!DOCTYPE html>\n<html>\n<head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\"></head>\n<body>\n<p>\"-//W3C//DTD HTML 4.0 Transitional//EN\\\" \\\"http://www.w3.org/TR/REC-html40/loose.dtd\\\"&gt;\\n\\n</p>\n<meta http-equiv='\\\"Content-Type\\\"' content='\\\"text/html;' charset='UTF-8\\\"'>\n<div id=\"form-content\">\n <form>\n<div id=\"instructions\">\n <ul>\n<li>Look at the business card properly and fill in asked data.</li>\n <li>Make sure you enter everything found on business card.</li>\n <li>Work may be rejected if it is incomplete or mistakes are found.</li>\n </ul>\n</div>\n <div id=\"image-field-wrapper\">\n <div id=\"image-panel\">\n <img class=\"card-image\" src=\"{{image_url}}\">\n</div>\n <div id=\"field-panel\">\n Name<br><input class=\"input-field first_name\" type=\"text\" name=\"output[first_name]\"><input class=\"input-field middle_name\" type=\"text\" name=\"output[middle_name]\"><input class=\"input-field last_name\" type=\"text\" name=\"output[last_name]\"><br><br>Contact<br><input class=\"input-field email\" type=\"text\" name=\"output[email]\" placeholder=\"Email\"><input class=\"input-field phone\" type=\"text\" name=\"output[phone]\" placeholder=\"Phone\"><input class=\"input-field mobile\" type=\"text\" name=\"output[mobile]\" placeholder=\"Mobile\"><br>\n</div>\n </div>\n </form>\n</div>\n</body>\n</html>\n")
48
48
  end
49
-
49
+
50
50
  it "in plain ruby way" do
51
51
  WebMock.allow_net_connect!
52
52
  html = '<!DOCTYPE html>
@@ -100,10 +100,10 @@ describe CF::CustomTaskForm do
100
100
  line.title.should eql(title)
101
101
  line.department_name.should eql("Digitization")
102
102
  line.stations.first.type.should eql("WorkStation")
103
- CGI.unescape_html(line.stations.first.form.raw_html).should eql("<!DOCTYPE html>\n<html>\n<head>\n<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">\n<meta http-equiv='\\\"Content-Type\\\"' content='\\\"text/html;' charset='UTF-8\\\"'>\n</head>\n<body>\n<div id=\"form-content\">\n <form>\n<div id=\"instructions\">\n <ul>\n<li>Look at the business card properly and fill in asked data.</li>\n <li>Make sure you enter everything found on business card.</li>\n <li>Work may be rejected if it is incomplete or mistakes are found.</li>\n </ul>\n</div>\n <div id=\"image-field-wrapper\">\n <div id=\"image-panel\">\n <img class=\"card-image\" src=\"%7B%7Bimage_url%7D%7D\">\n</div>\n <div id=\"field-panel\">\n Name<br><input class=\"input-field first_name\" type=\"text\" name=\"output[first_name]\"><input class=\"input-field middle_name\" type=\"text\" name=\"output[middle_name]\"><input class=\"input-field last_name\" type=\"text\" name=\"output[last_name]\"><br><br>Contact<br><input class=\"input-field email\" type=\"text\" name=\"output[email]\" placeholder=\"Email\"><input class=\"input-field phone\" type=\"text\" name=\"output[phone]\" placeholder=\"Phone\"><input class=\"input-field mobile\" type=\"text\" name=\"output[mobile]\" placeholder=\"Mobile\"><br>\n</div>\n </div>\n </form>\n</div>\n</body>\n</html>\n")
103
+ CGI.unescape_html(line.stations.first.form.raw_html).should eql("<!DOCTYPE html>\n<html>\n<head>\n<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">\n<meta http-equiv='\\\"Content-Type\\\"' content='\\\"text/html;' charset='UTF-8\\\"'>\n</head>\n<body>\n<div id=\"form-content\">\n <form>\n<div id=\"instructions\">\n <ul>\n<li>Look at the business card properly and fill in asked data.</li>\n <li>Make sure you enter everything found on business card.</li>\n <li>Work may be rejected if it is incomplete or mistakes are found.</li>\n </ul>\n</div>\n <div id=\"image-field-wrapper\">\n <div id=\"image-panel\">\n <img class=\"card-image\" src=\"{{image_url}}\">\n</div>\n <div id=\"field-panel\">\n Name<br><input class=\"input-field first_name\" type=\"text\" name=\"output[first_name]\"><input class=\"input-field middle_name\" type=\"text\" name=\"output[middle_name]\"><input class=\"input-field last_name\" type=\"text\" name=\"output[last_name]\"><br><br>Contact<br><input class=\"input-field email\" type=\"text\" name=\"output[email]\" placeholder=\"Email\"><input class=\"input-field phone\" type=\"text\" name=\"output[phone]\" placeholder=\"Phone\"><input class=\"input-field mobile\" type=\"text\" name=\"output[mobile]\" placeholder=\"Mobile\"><br>\n</div>\n </div>\n </form>\n</div>\n</body>\n</html>\n")
104
104
  end
105
105
  end
106
-
106
+
107
107
  context "create a Custom Task Form for Error Handling;" do
108
108
  it "creating with invalid Html content" do
109
109
  WebMock.allow_net_connect!
@@ -4,15 +4,34 @@ describe CF::Line do
4
4
  let(:input_format) { CF::InputFormat.new({:name => "image_url", :required => true, :valid_type => "url"}) }
5
5
 
6
6
  context "create a line" do
7
- it "the plain ruby way" do
7
+ it "the plain ruby way if worker pool is not specified" do
8
8
  WebMock.allow_net_connect!
9
9
  title = "line_title#{Time.new.strftime('%Y%b%d-%H%M%S')}".downcase
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")
14
+ line.department_name.should eq("Digitization")
15
+ end
16
+
17
+ it "the plain ruby way if worker pool is specified" do
18
+ WebMock.allow_net_connect!
19
+ title = "line_title#{Time.new.strftime('%Y%b%d-%H%M%S')}".downcase
20
+ sleep 1
21
+ line = CF::Line.new(title, "Digitization", {:public => false,:worker_pool => "mturk", :description => "this is description"})
22
+ line.title.should eq(title)
23
+ line.worker_pool.should eql("mturk")
13
24
  line.department_name.should eq("Digitization")
14
25
  end
15
26
 
27
+ it "the plain ruby way if worker pool specified is not valid" do
28
+ WebMock.allow_net_connect!
29
+ title = "line_title#{Time.new.strftime('%Y%b%d-%H%M%S')}".downcase
30
+ sleep 1
31
+ line = CF::Line.new(title, "Digitization", {:public => false,:worker_pool => "chandra", :description => "this is description"})
32
+ line.errors.should eql(" chandra is invalid worker_pool")
33
+ end
34
+
16
35
  it "using block with variable" do
17
36
  WebMock.allow_net_connect!
18
37
  title = "line_title#{Time.new.strftime('%Y%b%d-%H%M%S')}".downcase
@@ -61,8 +80,29 @@ describe CF::Line do
61
80
  line.title.should eq(title)
62
81
  line.department_name.should eq("Digitization")
63
82
  line.public.should eql(true)
83
+ line.worker_pool.should eql("cloudfactory")
64
84
  line.description.should eq("this is description")
65
85
  end
86
+
87
+ it "with worker_pool specified" do
88
+ WebMock.allow_net_connect!
89
+ title = "line_title#{Time.new.strftime('%Y%b%d-%H%M%S')}".downcase
90
+ sleep 1
91
+ line = CF::Line.new(title, "Digitization", {:public => true,:worker_pool => "mturk", :description => "this is description"})
92
+ line.title.should eq(title)
93
+ line.department_name.should eq("Digitization")
94
+ line.public.should eql(true)
95
+ line.worker_pool.should eql("mturk")
96
+ line.description.should eq("this is description")
97
+ end
98
+
99
+ it "with worker_pool specified is invalid" do
100
+ WebMock.allow_net_connect!
101
+ title = "line_title#{Time.new.strftime('%Y%b%d-%H%M%S')}".downcase
102
+ sleep 1
103
+ line = CF::Line.new(title, "Digitization", {:public => true, :description => "this is description",:worker_pool => "chandra"})
104
+ line.errors.should eql(" chandra is invalid worker_pool")
105
+ end
66
106
  end
67
107
 
68
108
  context "with 1 station" do
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: cloudfactory
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.4.5.2
5
+ version: "0.5"
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-14 00:00:00 Z
13
+ date: 2012-02-16 00:00:00 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: i18n