cloudfactory 0.4.0 → 0.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGELOG.md +7 -2
- data/lib/cf/cli/line.rb +10 -13
- data/lib/cf/cli/line_yaml_validator.rb +6 -6
- data/lib/cf/cli/production.rb +9 -6
- data/lib/cf/cli/templates/sample-line/line.yml.erb +0 -2
- data/lib/cf/custom_task_form.rb +4 -16
- data/lib/cf/line.rb +6 -2
- data/lib/cf/run.rb +3 -1
- data/lib/cf/station.rb +1 -3
- data/lib/cf/version.rb +1 -1
- data/spec/custom_task_form_spec.rb +20 -103
- data/spec/image_processing_robot_spec.rb +4 -4
- data/spec/line_spec.rb +2 -4
- data/spec/run_spec.rb +2 -3
- metadata +48 -50
- data/lib/cf/cli/templates/sample-line/form.css +0 -50
- data/lib/cf/cli/templates/sample-line/form.js +0 -12
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,10 @@
|
|
1
|
+
## 0.4.1 (2011-10-20)
|
2
|
+
|
3
|
+
* removed directory for custom forms from CLI
|
4
|
+
* find methods in Line and Run classes now returns nil if not found
|
5
|
+
* custom task form modified
|
6
|
+
* removed the requirement for css and js files while doing production run
|
7
|
+
|
1
8
|
## 0.4.0 (2011-10-1)
|
2
9
|
|
3
10
|
* removed the hashie from the client response that was causing problem while debugging and the response was pretty messed up
|
@@ -9,8 +16,6 @@
|
|
9
16
|
|
10
17
|
## 0.3.0 (2011-09-21)
|
11
18
|
|
12
|
-
* removed the clouds due to utf-8 chars issue on some system while installing the gem
|
13
|
-
|
14
19
|
* removed the clouds due to utf-8 chars issue on some system while installing the gem
|
15
20
|
* cf production list now has --live flag to list the live production runs
|
16
21
|
|
data/lib/cf/cli/line.rb
CHANGED
@@ -14,10 +14,8 @@ module Cf # :nodoc: all
|
|
14
14
|
arr.pop
|
15
15
|
line_destination = arr.join("/")
|
16
16
|
template("sample-line/line.yml.erb", yaml_destination)
|
17
|
-
copy_file("sample-line/form.
|
18
|
-
copy_file("sample-line/
|
19
|
-
copy_file("sample-line/form.js", "#{line_destination}/station_2/form.js")
|
20
|
-
copy_file("sample-line/sample-line.csv", "#{line_destination}/input/#{title.underscore.dasherize}.csv")
|
17
|
+
copy_file("sample-line/form.html", "#{line_destination}/station2.html")
|
18
|
+
copy_file("sample-line/sample-line.csv", "#{line_destination}/input/#{title.underscore.dasherize}.csv")
|
21
19
|
FileUtils.mkdir("#{line_destination}/output")
|
22
20
|
end
|
23
21
|
end
|
@@ -31,7 +29,6 @@ module Cf # :nodoc: all
|
|
31
29
|
|
32
30
|
desc "line generate LINE-TITLE", "generates a line template at <line-title>/line.yml"
|
33
31
|
method_option :force, :type => :boolean, :default => false, :aliases => "-f", :desc => "force to overwrite the files if the line already exists, default is false"
|
34
|
-
# method_option :with_custom_form, :type => :boolean, :default => false, :aliases => "-wcf", :desc => "generate the template with custom task form and the sample files, default is true"
|
35
32
|
|
36
33
|
def generate(title=nil)
|
37
34
|
if title.present?
|
@@ -72,8 +69,12 @@ module Cf # :nodoc: all
|
|
72
69
|
end
|
73
70
|
|
74
71
|
resp_line = CF::Line.find(line_title)
|
75
|
-
|
76
|
-
|
72
|
+
if resp_line.nil?
|
73
|
+
say("Line does not exist entitled #{line_title} !!!", :red) and exit(1)
|
74
|
+
else
|
75
|
+
line = Hashie::Mash.new(resp_line)
|
76
|
+
end
|
77
|
+
if line.title == line_title && !resp_line.nil?
|
77
78
|
if options.force
|
78
79
|
CF::Line.destroy(line_title, :forced => true)
|
79
80
|
say("The line #{line_title} deleted forcefully!", :yellow)
|
@@ -289,12 +290,8 @@ module Cf # :nodoc: all
|
|
289
290
|
instruction = station_file['station']['custom_task_form']['instruction']
|
290
291
|
|
291
292
|
html_file = station_file['station']['custom_task_form']['html']
|
292
|
-
html = File.read("#{line_source}/
|
293
|
-
|
294
|
-
css = File.read("#{line_source}/station_#{station_file['station']['station_index']}/#{css_file}") if File.exist?("#{line_source}/station_#{s_index+1}/#{css_file}")
|
295
|
-
js_file = station_file['station']['custom_task_form']['js']
|
296
|
-
js = File.read("#{line_source}/station_#{station_file['station']['station_index']}/#{js_file}") if File.exist?("#{line_source}/station_#{s_index+1}/#{js_file}")
|
297
|
-
form = CF::CustomTaskForm.create({:station => s, :title => title, :instruction => instruction, :raw_html => html, :raw_css => css, :raw_javascript => js})
|
293
|
+
html = File.read("#{line_source}/station#{station_file['station']['station_index']}.html")
|
294
|
+
form = CF::CustomTaskForm.create({:station => s, :title => title, :instruction => instruction, :raw_html => html})
|
298
295
|
say_status "form", "CustomTaskForm '#{form.title}'"
|
299
296
|
display_error(line_title, "#{form.errors}") if form.errors.present?
|
300
297
|
end
|
@@ -140,12 +140,12 @@ module Cf
|
|
140
140
|
instruction = custom_task_form['instruction']
|
141
141
|
errors << "Form Instruction is missing in Block station #{i+1}!" if instruction.nil?
|
142
142
|
|
143
|
-
errors << "
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
143
|
+
errors << "station#{i+1} is missing in folder #{Dir.pwd}/station_#{i+1} !" if !File.exist?("station#{i+1}.html")
|
144
|
+
#
|
145
|
+
# if File.exist?("#{Dir.pwd}")
|
146
|
+
# station_source = "#{Dir.pwd}/station_#{i+1}"
|
147
|
+
# errors << "station#{i+1} is missing in folder #{Dir.pwd}/station_#{i+1} !" if !File.exist?("station#{i+1}.html")
|
148
|
+
# end
|
149
149
|
end
|
150
150
|
elsif task_form.class == Hash
|
151
151
|
form_title = task_form['form_title']
|
data/lib/cf/cli/production.rb
CHANGED
@@ -24,18 +24,21 @@ module Cf # :nodoc: all
|
|
24
24
|
|
25
25
|
if options[:line].present?
|
26
26
|
line = CF::Line.find(options[:line])
|
27
|
-
line
|
28
|
-
|
29
|
-
line_title = options[:line]
|
27
|
+
if line.nil?
|
28
|
+
say("Line named #{options[:line]} does not exist !!!", :red) and exit(1)
|
30
29
|
else
|
31
|
-
|
30
|
+
line = Hashie::Mash.new(line)
|
31
|
+
line_title = options[:line]
|
32
32
|
end
|
33
33
|
elsif File.exist?("#{yaml_source}")
|
34
34
|
line_yaml_dump = YAML::load(File.read(yaml_source).strip)
|
35
35
|
line_title = line_yaml_dump['title'].parameterize
|
36
36
|
line = CF::Line.find(line_title)
|
37
|
-
line
|
38
|
-
|
37
|
+
if line.nil?
|
38
|
+
say("Line named #{options[:line]} does not exist !!!", :red) and exit(1)
|
39
|
+
else
|
40
|
+
line = Hashie::Mash.new(line)
|
41
|
+
end
|
39
42
|
else
|
40
43
|
say("Looks like you're not in the Line directory or did not provide the line title to use the line", :red) and return
|
41
44
|
end
|
@@ -81,8 +81,6 @@ stations:
|
|
81
81
|
form_title: Clink a link and paste in url
|
82
82
|
instruction: Look through search results and find the best date
|
83
83
|
html: form.html
|
84
|
-
css: form.css
|
85
|
-
js: form.js
|
86
84
|
|
87
85
|
# Sample Station #3: ROBOT to email the person seeking a date with their recommended match!
|
88
86
|
- station:
|
data/lib/cf/custom_task_form.rb
CHANGED
@@ -11,12 +11,6 @@ module CF
|
|
11
11
|
# raw_html is an attribute to store the custom html contents
|
12
12
|
attr_accessor :raw_html
|
13
13
|
|
14
|
-
# raw_css is an attribute to store the custom css contents
|
15
|
-
attr_accessor :raw_css
|
16
|
-
|
17
|
-
# raw_javascript is an attribute to store the custom javascript contents
|
18
|
-
attr_accessor :raw_javascript
|
19
|
-
|
20
14
|
# station attribute is required for association with custom_from object
|
21
15
|
attr_accessor :station
|
22
16
|
|
@@ -27,19 +21,15 @@ module CF
|
|
27
21
|
# ===Usage custom_instruction.new(hash):
|
28
22
|
#
|
29
23
|
# html = 'html_content'
|
30
|
-
# css = 'css_content'
|
31
|
-
# javascript = 'javascript_content'
|
32
24
|
#
|
33
|
-
# instruction = CF::CustomTaskForm.new({:title => "Enter text from a business card image", :instruction => "Describe", :raw_html => html
|
25
|
+
# instruction = CF::CustomTaskForm.new({:title => "Enter text from a business card image", :instruction => "Describe", :raw_html => html})
|
34
26
|
def initialize(options={})
|
35
27
|
@station = options[:station]
|
36
28
|
@title = options[:title]
|
37
29
|
@instruction = options[:instruction]
|
38
30
|
@raw_html = options[:raw_html]
|
39
|
-
@raw_css = options[:raw_css]
|
40
|
-
@raw_javascript = options[:raw_javascript]
|
41
31
|
if @station
|
42
|
-
resp = self.class.post("/lines/#{CF.account_name}/#{@station.line_title.downcase}/stations/#{@station.index}/form.json", :form => {:title => @title, :instruction => @instruction, :_type => "CustomTaskForm", :raw_html => @raw_html
|
32
|
+
resp = self.class.post("/lines/#{CF.account_name}/#{@station.line_title.downcase}/stations/#{@station.index}/form.json", :form => {:title => @title, :instruction => @instruction, :_type => "CustomTaskForm", :raw_html => @raw_html})
|
43
33
|
resp.to_hash.each_pair do |k,v|
|
44
34
|
self.send("#{k}=",v) if self.respond_to?(k)
|
45
35
|
end
|
@@ -53,16 +43,14 @@ module CF
|
|
53
43
|
# ===Usage custom_instruction.create(hash):
|
54
44
|
#
|
55
45
|
# html = 'html_content'
|
56
|
-
# css = 'css_content'
|
57
|
-
# javascript = 'javascript_content'
|
58
46
|
#
|
59
|
-
# instruction = CF::CustomTaskForm.create({:title => "Enter text from a business card image", :instruction => "Describe", :raw_html => html
|
47
|
+
# instruction = CF::CustomTaskForm.create({:title => "Enter text from a business card image", :instruction => "Describe", :raw_html => html})
|
60
48
|
def self.create(form)
|
61
49
|
instruction = CustomTaskForm.new(form)
|
62
50
|
end
|
63
51
|
|
64
52
|
def to_s # :nodoc:
|
65
|
-
"{:title => #{self.title}, :instruction => #{self.instruction}, :raw_html => #{self.raw_html}, :
|
53
|
+
"{:title => #{self.title}, :instruction => #{self.instruction}, :raw_html => #{self.raw_html}, :errors => #{self.errors}}"
|
66
54
|
end
|
67
55
|
end
|
68
56
|
end
|
data/lib/cf/line.rb
CHANGED
@@ -258,8 +258,12 @@ module CF
|
|
258
258
|
resp = get("/lines/#{CF.account_name}/#{line.downcase}.json")
|
259
259
|
end
|
260
260
|
end
|
261
|
-
|
262
|
-
|
261
|
+
if resp['code'] != 200
|
262
|
+
@errors = resp['error']['message']
|
263
|
+
return nil
|
264
|
+
else
|
265
|
+
return resp
|
266
|
+
end
|
263
267
|
end
|
264
268
|
|
265
269
|
# ==Returns all the lines of an account
|
data/lib/cf/run.rb
CHANGED
@@ -163,8 +163,10 @@ module CF
|
|
163
163
|
resp['error'] = resp['error']['message']
|
164
164
|
resp.merge!('errors' => "#{resp['error']}")
|
165
165
|
resp.delete('error')
|
166
|
+
return nil
|
167
|
+
else
|
168
|
+
return resp
|
166
169
|
end
|
167
|
-
return resp
|
168
170
|
end
|
169
171
|
|
170
172
|
# ==Returns progress of the production run
|
data/lib/cf/station.rb
CHANGED
@@ -262,9 +262,7 @@ module CF
|
|
262
262
|
form = @form.class.new({})
|
263
263
|
if type == "CustomTaskForm"
|
264
264
|
@html = @form.raw_html
|
265
|
-
@
|
266
|
-
@javascript = @form.raw_javascript
|
267
|
-
@resp = CF::CustomTaskForm.post("/lines/#{CF.account_name}/#{self.line_title.downcase}/stations/#{self.index}/form.json", :form => {:title => @title, :instruction => @instruction, :_type => "CustomTaskForm", :raw_html => @html, :raw_css => @css, :raw_javascript => @javascript})
|
265
|
+
@resp = CF::CustomTaskForm.post("/lines/#{CF.account_name}/#{self.line_title.downcase}/stations/#{self.index}/form.json", :form => {:title => @title, :instruction => @instruction, :_type => "CustomTaskForm", :raw_html => @html})
|
268
266
|
else
|
269
267
|
@resp = CF::TaskForm.post("/lines/#{CF.account_name}/#{self.line_title.downcase}/stations/#{self.index}/form.json", :form => {:title => @title, :instruction => @instruction, :_type => type})
|
270
268
|
end
|
data/lib/cf/version.rb
CHANGED
@@ -4,8 +4,8 @@ describe CF::CustomTaskForm do
|
|
4
4
|
context "create a Custom Task Form" do
|
5
5
|
it "in block DSL way" do
|
6
6
|
WebMock.allow_net_connect!
|
7
|
-
html = '<div id="form-content">
|
8
|
-
<div id="instructions">
|
7
|
+
html = '<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\" \"http://www.w3.org/TR/REC-html40/loose.dtd\">\n<html>\n<head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\"></head><div id="form-content">
|
8
|
+
<body><form><div id="instructions">
|
9
9
|
<ul>
|
10
10
|
<li>Look at the business card properly and fill in asked data.</li>
|
11
11
|
<li>Make sure you enter everything found on business card.</li>
|
@@ -18,60 +18,18 @@ describe CF::CustomTaskForm do
|
|
18
18
|
</div>
|
19
19
|
<div id = "field-panel">
|
20
20
|
Name<br />
|
21
|
-
<input class="input-field first_name" type="text" name="
|
22
|
-
<input class="input-field middle_name" type="text" name="
|
23
|
-
<input class="input-field last_name" type="text" name="
|
21
|
+
<input class="input-field first_name" type="text" name="output[first_name]" />
|
22
|
+
<input class="input-field middle_name" type="text" name="output[middle_name]" />
|
23
|
+
<input class="input-field last_name" type="text" name="output[last_name]" /><br />
|
24
24
|
|
25
25
|
<br />Contact<br />
|
26
|
-
<input class="input-field email" type="text" name="
|
27
|
-
<input class="input-field phone" type="text" name="
|
28
|
-
<input class="input-field mobile" type="text" name="
|
26
|
+
<input class="input-field email" type="text" name="output[email]" placeholder="Email"/>
|
27
|
+
<input class="input-field phone" type="text" name="output[phone]" placeholder="Phone"/>
|
28
|
+
<input class="input-field mobile" type="text" name="output[mobile]" placeholder="Mobile"/><br />
|
29
29
|
|
30
30
|
</div>
|
31
31
|
</div>
|
32
|
-
</div>'
|
33
|
-
|
34
|
-
css = '<style>body {background:#fbfbfb;}
|
35
|
-
#instructions{
|
36
|
-
text-align:center;
|
37
|
-
}
|
38
|
-
|
39
|
-
#image-field-wrapper{
|
40
|
-
float-left;
|
41
|
-
min-width:1050px;
|
42
|
-
overflow:hidden;
|
43
|
-
}
|
44
|
-
|
45
|
-
#field-panel{
|
46
|
-
float:left;
|
47
|
-
padding: 10px 10px 0 10px;
|
48
|
-
min-width:512px;
|
49
|
-
overflow:hidden;
|
50
|
-
}
|
51
|
-
|
52
|
-
.input-field{
|
53
|
-
width:150px;
|
54
|
-
margin:4px;
|
55
|
-
}</style>'
|
56
|
-
|
57
|
-
javascript = '<script src="http://code.jquery.com/jquery-latest.js"></script>
|
58
|
-
<script type="text/javascript" src="http://www.bizcardarmy.com/javascripts/jquery.autocomplete-min.js"></script>
|
59
|
-
<script type="text/javascript">
|
60
|
-
$(document).ready(function(){
|
61
|
-
autocomplete_fields = ["first_name", "middle_name", "last_name", "company", "job_title", "city", "state", "zip"];
|
62
|
-
|
63
|
-
$.each(autocomplete_fields, function(index, value){
|
64
|
-
var inputField = "input." + value;
|
65
|
-
$(inputField).autocomplete({
|
66
|
-
serviceUrl: "http://www.bizcardarmy.com/cards/return_data_for_autocompletion.json",
|
67
|
-
maxHeight: 400,
|
68
|
-
width: 300,
|
69
|
-
zIndex: 9999,
|
70
|
-
params: { field: value }
|
71
|
-
});
|
72
|
-
});
|
73
|
-
});
|
74
|
-
</script>'
|
32
|
+
</div></form></body></html>'
|
75
33
|
|
76
34
|
title = "line_title#{Time.new.strftime('%Y%b%d-%H%M%S')}".downcase
|
77
35
|
sleep 1
|
@@ -80,21 +38,23 @@ describe CF::CustomTaskForm do
|
|
80
38
|
CF::InputFormat.new({:line => self, :name => "Contact", :required => true, :valid_type => "url"})
|
81
39
|
CF::Station.create({:line => self, :type => "work"}) do |s|
|
82
40
|
CF::HumanWorker.new({:station => s, :number => 1, :reward => 20})
|
83
|
-
CF::CustomTaskForm.create({:station => s, :title => "Enter text from a business card image", :instruction => "Describe", :raw_html => html
|
41
|
+
CF::CustomTaskForm.create({:station => s, :title => "Enter text from a business card image", :instruction => "Describe", :raw_html => html})
|
84
42
|
end
|
85
43
|
end
|
86
44
|
line.title.should eql(title)
|
87
45
|
line.department_name.should eql("Digitization")
|
88
46
|
line.stations.first.type.should eql("WorkStation")
|
89
|
-
CGI.unescape_html(line.stations.first.form.raw_html).should eql(html)
|
90
|
-
CGI.unescape_html(line.stations.first.form.raw_css).should eql(css)
|
91
|
-
CGI.unescape_html(line.stations.first.form.raw_javascript).should eql(javascript)
|
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\\\">\\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")
|
92
48
|
end
|
93
49
|
|
94
50
|
it "in plain ruby way" do
|
95
51
|
WebMock.allow_net_connect!
|
96
|
-
html =
|
97
|
-
|
52
|
+
html = '<!DOCTYPE html>
|
53
|
+
<html>
|
54
|
+
<head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\"></head>
|
55
|
+
<body>
|
56
|
+
<div id="form-content">
|
57
|
+
<form><div id="instructions">
|
98
58
|
<ul>
|
99
59
|
<li>Look at the business card properly and fill in asked data.</li>
|
100
60
|
<li>Make sure you enter everything found on business card.</li>
|
@@ -118,49 +78,8 @@ describe CF::CustomTaskForm do
|
|
118
78
|
|
119
79
|
</div>
|
120
80
|
</div>
|
121
|
-
</div></form>'
|
81
|
+
</div></form></body></html>'
|
122
82
|
|
123
|
-
css = '<style>body {background:#fbfbfb;}
|
124
|
-
#instructions{
|
125
|
-
text-align:center;
|
126
|
-
}
|
127
|
-
|
128
|
-
#image-field-wrapper{
|
129
|
-
float-left;
|
130
|
-
min-width:1050px;
|
131
|
-
overflow:hidden;
|
132
|
-
}
|
133
|
-
|
134
|
-
#field-panel{
|
135
|
-
float:left;
|
136
|
-
padding: 10px 10px 0 10px;
|
137
|
-
min-width:512px;
|
138
|
-
overflow:hidden;
|
139
|
-
}
|
140
|
-
|
141
|
-
.input-field{
|
142
|
-
width:150px;
|
143
|
-
margin:4px;
|
144
|
-
}</style>'
|
145
|
-
|
146
|
-
javascript = '<script src="http://code.jquery.com/jquery-latest.js"></script>
|
147
|
-
<script type="text/javascript" src="http://www.bizcardarmy.com/javascripts/jquery.autocomplete-min.js"></script>
|
148
|
-
<script type="text/javascript">
|
149
|
-
$(document).ready(function(){
|
150
|
-
autocomplete_fields = ["first_name", "middle_name", "last_name", "company", "job_title", "city", "state", "zip"];
|
151
|
-
|
152
|
-
$.each(autocomplete_fields, function(index, value){
|
153
|
-
var inputField = "input." + value;
|
154
|
-
$(inputField).autocomplete({
|
155
|
-
serviceUrl: "http://www.bizcardarmy.com/cards/return_data_for_autocompletion.json",
|
156
|
-
maxHeight: 400,
|
157
|
-
width: 300,
|
158
|
-
zIndex: 9999,
|
159
|
-
params: { field: value }
|
160
|
-
});
|
161
|
-
});
|
162
|
-
});
|
163
|
-
</script>'
|
164
83
|
title = "line_title#{Time.new.strftime('%Y%b%d-%H%M%S')}".downcase
|
165
84
|
sleep 1
|
166
85
|
line = CF::Line.new(title, "Digitization")
|
@@ -176,14 +95,12 @@ describe CF::CustomTaskForm do
|
|
176
95
|
worker = CF::HumanWorker.new({:number => 1, :reward => 20})
|
177
96
|
line.stations.first.worker = worker
|
178
97
|
|
179
|
-
form = CF::CustomTaskForm.new({:title => "Enter text from a business card image", :instruction => "Describe", :raw_html => html
|
98
|
+
form = CF::CustomTaskForm.new({:title => "Enter text from a business card image", :instruction => "Describe", :raw_html => html})
|
180
99
|
line.stations.first.form = form
|
181
100
|
line.title.should eql(title)
|
182
101
|
line.department_name.should eql("Digitization")
|
183
102
|
line.stations.first.type.should eql("WorkStation")
|
184
|
-
CGI.unescape_html(line.stations.first.form.raw_html).should eql(html)
|
185
|
-
CGI.unescape_html(line.stations.first.form.raw_css).should eql(css)
|
186
|
-
CGI.unescape_html(line.stations.first.form.raw_javascript).should eql(javascript)
|
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")
|
187
104
|
end
|
188
105
|
end
|
189
106
|
|
@@ -14,8 +14,8 @@ module CF
|
|
14
14
|
CF::RobotWorker.create({:station => s, :type => "image_processing_robot", :settings => {:image => ["{{url}}"], :sharpen => {:radius => "10"}}})
|
15
15
|
end
|
16
16
|
end
|
17
|
-
run = CF::Run.create(line, "
|
18
|
-
sleep
|
17
|
+
run = CF::Run.create(line, "run-#{title}", [{"url"=> "http://wwwdelivery.superstock.com/WI/223/1527/PreviewComp/SuperStock_1527R-020214.jpg"}])
|
18
|
+
sleep 20
|
19
19
|
output = run.final_output
|
20
20
|
converted_url = output.first['processed_image_of_url']
|
21
21
|
File.exist?("/Users/manish/apps/cloudfactory/public#{converted_url}").should eql(true)
|
@@ -40,8 +40,8 @@ module CF
|
|
40
40
|
worker = CF::RobotWorker.create({:type => "image_processing_robot", :settings => {:image => ["{{url}}"], :sharpen => {:radius => "10"}}})
|
41
41
|
line.stations.first.worker = worker
|
42
42
|
|
43
|
-
run = CF::Run.create(line, "
|
44
|
-
sleep
|
43
|
+
run = CF::Run.create(line, "run-#{title}", [{"url"=> "http://wwwdelivery.superstock.com/WI/223/1527/PreviewComp/SuperStock_1527R-020214.jpg"}])
|
44
|
+
sleep 20
|
45
45
|
output = run.final_output
|
46
46
|
converted_url = output.first['processed_image_of_url']
|
47
47
|
File.exist?("/Users/manish/apps/cloudfactory/public#{converted_url}").should eql(true)
|
data/spec/line_spec.rb
CHANGED
@@ -344,8 +344,7 @@ describe CF::Line do
|
|
344
344
|
forced_delete = CF::Line.destroy(title, :forced => true)
|
345
345
|
|
346
346
|
search_line = CF::Line.find(title)
|
347
|
-
search_line
|
348
|
-
search_line['error']['message'].should eql("Line not found for title: #{title} under your account")
|
347
|
+
search_line.should eql(nil)
|
349
348
|
end
|
350
349
|
end
|
351
350
|
|
@@ -490,8 +489,7 @@ describe CF::Line do
|
|
490
489
|
config.api_key = API_CONFIG['api_key']
|
491
490
|
end
|
492
491
|
got_line = CF::Line.find("hero/#{title}")
|
493
|
-
got_line
|
494
|
-
got_line['error']['message'].should eql("Line with title: #{title} under account hero is not public")
|
492
|
+
got_line.should eql(nil)
|
495
493
|
end
|
496
494
|
end
|
497
495
|
|
data/spec/run_spec.rb
CHANGED
@@ -167,7 +167,7 @@ module CF
|
|
167
167
|
end
|
168
168
|
end
|
169
169
|
run = CF::Run.create(line, "run-#{title}", [{"url"=> "http://www.sprout-technology.com"}])
|
170
|
-
sleep
|
170
|
+
sleep 20
|
171
171
|
output = run.final_output
|
172
172
|
output.first['keyword_relevance_of_url'].should eql([96.7417, 57.3763, 56.8721, 54.6844, 17.7066])
|
173
173
|
output.first['keywords_of_url'].should eql(["tech startup thing", "nights", "Nepal", "Canada", "U.S."])
|
@@ -284,8 +284,7 @@ module CF
|
|
284
284
|
end
|
285
285
|
run = CF::Run.create(line, "run-#{title}", [{"url"=> "http://media-robot.s3.amazonaws.com/media_robot/media/upload/8/ten.mov"}])
|
286
286
|
found_run = CF::Run.find("unused_title")
|
287
|
-
found_run
|
288
|
-
found_run['errors'].should eql("Run document not found using selector: {:title=>\"unused_title\"}")
|
287
|
+
found_run.should eql(nil)
|
289
288
|
end
|
290
289
|
end
|
291
290
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cloudfactory
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2011-10-
|
12
|
+
date: 2011-10-20 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: i18n
|
16
|
-
requirement: &
|
16
|
+
requirement: &2154693260 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *2154693260
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: activesupport
|
27
|
-
requirement: &
|
27
|
+
requirement: &2154691240 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ~>
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: '3.0'
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *2154691240
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: hashie
|
38
|
-
requirement: &
|
38
|
+
requirement: &2154690520 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ~>
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: '1.0'
|
44
44
|
type: :runtime
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *2154690520
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: rest-client
|
49
|
-
requirement: &
|
49
|
+
requirement: &2154689840 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ! '>='
|
@@ -54,10 +54,10 @@ dependencies:
|
|
54
54
|
version: '0'
|
55
55
|
type: :runtime
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *2154689840
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: json
|
60
|
-
requirement: &
|
60
|
+
requirement: &2154688400 !ruby/object:Gem::Requirement
|
61
61
|
none: false
|
62
62
|
requirements:
|
63
63
|
- - ! '>='
|
@@ -65,10 +65,10 @@ dependencies:
|
|
65
65
|
version: '0'
|
66
66
|
type: :runtime
|
67
67
|
prerelease: false
|
68
|
-
version_requirements: *
|
68
|
+
version_requirements: *2154688400
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: thor
|
71
|
-
requirement: &
|
71
|
+
requirement: &2154683820 !ruby/object:Gem::Requirement
|
72
72
|
none: false
|
73
73
|
requirements:
|
74
74
|
- - ~>
|
@@ -76,10 +76,10 @@ dependencies:
|
|
76
76
|
version: '0.14'
|
77
77
|
type: :runtime
|
78
78
|
prerelease: false
|
79
|
-
version_requirements: *
|
79
|
+
version_requirements: *2154683820
|
80
80
|
- !ruby/object:Gem::Dependency
|
81
81
|
name: highline
|
82
|
-
requirement: &
|
82
|
+
requirement: &2154682740 !ruby/object:Gem::Requirement
|
83
83
|
none: false
|
84
84
|
requirements:
|
85
85
|
- - ! '>='
|
@@ -87,10 +87,10 @@ dependencies:
|
|
87
87
|
version: '0'
|
88
88
|
type: :runtime
|
89
89
|
prerelease: false
|
90
|
-
version_requirements: *
|
90
|
+
version_requirements: *2154682740
|
91
91
|
- !ruby/object:Gem::Dependency
|
92
92
|
name: httparty
|
93
|
-
requirement: &
|
93
|
+
requirement: &2154680840 !ruby/object:Gem::Requirement
|
94
94
|
none: false
|
95
95
|
requirements:
|
96
96
|
- - ~>
|
@@ -98,10 +98,10 @@ dependencies:
|
|
98
98
|
version: '0.7'
|
99
99
|
type: :runtime
|
100
100
|
prerelease: false
|
101
|
-
version_requirements: *
|
101
|
+
version_requirements: *2154680840
|
102
102
|
- !ruby/object:Gem::Dependency
|
103
103
|
name: terminal-table
|
104
|
-
requirement: &
|
104
|
+
requirement: &2154677800 !ruby/object:Gem::Requirement
|
105
105
|
none: false
|
106
106
|
requirements:
|
107
107
|
- - ~>
|
@@ -109,10 +109,10 @@ dependencies:
|
|
109
109
|
version: '1.4'
|
110
110
|
type: :runtime
|
111
111
|
prerelease: false
|
112
|
-
version_requirements: *
|
112
|
+
version_requirements: *2154677800
|
113
113
|
- !ruby/object:Gem::Dependency
|
114
114
|
name: millisami-csv-hash
|
115
|
-
requirement: &
|
115
|
+
requirement: &2154672600 !ruby/object:Gem::Requirement
|
116
116
|
none: false
|
117
117
|
requirements:
|
118
118
|
- - ! '>='
|
@@ -120,10 +120,10 @@ dependencies:
|
|
120
120
|
version: '0'
|
121
121
|
type: :runtime
|
122
122
|
prerelease: false
|
123
|
-
version_requirements: *
|
123
|
+
version_requirements: *2154672600
|
124
124
|
- !ruby/object:Gem::Dependency
|
125
125
|
name: awesome_print
|
126
|
-
requirement: &
|
126
|
+
requirement: &2154670200 !ruby/object:Gem::Requirement
|
127
127
|
none: false
|
128
128
|
requirements:
|
129
129
|
- - ! '>='
|
@@ -131,10 +131,10 @@ dependencies:
|
|
131
131
|
version: '0'
|
132
132
|
type: :runtime
|
133
133
|
prerelease: false
|
134
|
-
version_requirements: *
|
134
|
+
version_requirements: *2154670200
|
135
135
|
- !ruby/object:Gem::Dependency
|
136
136
|
name: ruby-debug19
|
137
|
-
requirement: &
|
137
|
+
requirement: &2154667660 !ruby/object:Gem::Requirement
|
138
138
|
none: false
|
139
139
|
requirements:
|
140
140
|
- - ! '>='
|
@@ -142,10 +142,10 @@ dependencies:
|
|
142
142
|
version: '0'
|
143
143
|
type: :development
|
144
144
|
prerelease: false
|
145
|
-
version_requirements: *
|
145
|
+
version_requirements: *2154667660
|
146
146
|
- !ruby/object:Gem::Dependency
|
147
147
|
name: aruba
|
148
|
-
requirement: &
|
148
|
+
requirement: &2154666820 !ruby/object:Gem::Requirement
|
149
149
|
none: false
|
150
150
|
requirements:
|
151
151
|
- - ! '>='
|
@@ -153,10 +153,10 @@ dependencies:
|
|
153
153
|
version: '0'
|
154
154
|
type: :development
|
155
155
|
prerelease: false
|
156
|
-
version_requirements: *
|
156
|
+
version_requirements: *2154666820
|
157
157
|
- !ruby/object:Gem::Dependency
|
158
158
|
name: rails
|
159
|
-
requirement: &
|
159
|
+
requirement: &2154662400 !ruby/object:Gem::Requirement
|
160
160
|
none: false
|
161
161
|
requirements:
|
162
162
|
- - ~>
|
@@ -164,10 +164,10 @@ dependencies:
|
|
164
164
|
version: 3.0.3
|
165
165
|
type: :development
|
166
166
|
prerelease: false
|
167
|
-
version_requirements: *
|
167
|
+
version_requirements: *2154662400
|
168
168
|
- !ruby/object:Gem::Dependency
|
169
169
|
name: bundler
|
170
|
-
requirement: &
|
170
|
+
requirement: &2154640560 !ruby/object:Gem::Requirement
|
171
171
|
none: false
|
172
172
|
requirements:
|
173
173
|
- - ~>
|
@@ -175,10 +175,10 @@ dependencies:
|
|
175
175
|
version: 1.0.0
|
176
176
|
type: :development
|
177
177
|
prerelease: false
|
178
|
-
version_requirements: *
|
178
|
+
version_requirements: *2154640560
|
179
179
|
- !ruby/object:Gem::Dependency
|
180
180
|
name: generator_spec
|
181
|
-
requirement: &
|
181
|
+
requirement: &2154639100 !ruby/object:Gem::Requirement
|
182
182
|
none: false
|
183
183
|
requirements:
|
184
184
|
- - ~>
|
@@ -186,10 +186,10 @@ dependencies:
|
|
186
186
|
version: 0.8.3
|
187
187
|
type: :development
|
188
188
|
prerelease: false
|
189
|
-
version_requirements: *
|
189
|
+
version_requirements: *2154639100
|
190
190
|
- !ruby/object:Gem::Dependency
|
191
191
|
name: rspec-rails
|
192
|
-
requirement: &
|
192
|
+
requirement: &2154637140 !ruby/object:Gem::Requirement
|
193
193
|
none: false
|
194
194
|
requirements:
|
195
195
|
- - ! '>='
|
@@ -197,10 +197,10 @@ dependencies:
|
|
197
197
|
version: '0'
|
198
198
|
type: :development
|
199
199
|
prerelease: false
|
200
|
-
version_requirements: *
|
200
|
+
version_requirements: *2154637140
|
201
201
|
- !ruby/object:Gem::Dependency
|
202
202
|
name: cucumber
|
203
|
-
requirement: &
|
203
|
+
requirement: &2154635380 !ruby/object:Gem::Requirement
|
204
204
|
none: false
|
205
205
|
requirements:
|
206
206
|
- - ! '>='
|
@@ -208,10 +208,10 @@ dependencies:
|
|
208
208
|
version: '0'
|
209
209
|
type: :development
|
210
210
|
prerelease: false
|
211
|
-
version_requirements: *
|
211
|
+
version_requirements: *2154635380
|
212
212
|
- !ruby/object:Gem::Dependency
|
213
213
|
name: rdoc
|
214
|
-
requirement: &
|
214
|
+
requirement: &2154633760 !ruby/object:Gem::Requirement
|
215
215
|
none: false
|
216
216
|
requirements:
|
217
217
|
- - ~>
|
@@ -219,10 +219,10 @@ dependencies:
|
|
219
219
|
version: 3.5.3
|
220
220
|
type: :development
|
221
221
|
prerelease: false
|
222
|
-
version_requirements: *
|
222
|
+
version_requirements: *2154633760
|
223
223
|
- !ruby/object:Gem::Dependency
|
224
224
|
name: vcr
|
225
|
-
requirement: &
|
225
|
+
requirement: &2154632980 !ruby/object:Gem::Requirement
|
226
226
|
none: false
|
227
227
|
requirements:
|
228
228
|
- - ! '>='
|
@@ -230,10 +230,10 @@ dependencies:
|
|
230
230
|
version: '0'
|
231
231
|
type: :development
|
232
232
|
prerelease: false
|
233
|
-
version_requirements: *
|
233
|
+
version_requirements: *2154632980
|
234
234
|
- !ruby/object:Gem::Dependency
|
235
235
|
name: rake
|
236
|
-
requirement: &
|
236
|
+
requirement: &2154632160 !ruby/object:Gem::Requirement
|
237
237
|
none: false
|
238
238
|
requirements:
|
239
239
|
- - ! '>='
|
@@ -241,10 +241,10 @@ dependencies:
|
|
241
241
|
version: '0'
|
242
242
|
type: :development
|
243
243
|
prerelease: false
|
244
|
-
version_requirements: *
|
244
|
+
version_requirements: *2154632160
|
245
245
|
- !ruby/object:Gem::Dependency
|
246
246
|
name: webmock
|
247
|
-
requirement: &
|
247
|
+
requirement: &2154631420 !ruby/object:Gem::Requirement
|
248
248
|
none: false
|
249
249
|
requirements:
|
250
250
|
- - ! '>='
|
@@ -252,10 +252,10 @@ dependencies:
|
|
252
252
|
version: '0'
|
253
253
|
type: :development
|
254
254
|
prerelease: false
|
255
|
-
version_requirements: *
|
255
|
+
version_requirements: *2154631420
|
256
256
|
- !ruby/object:Gem::Dependency
|
257
257
|
name: timecop
|
258
|
-
requirement: &
|
258
|
+
requirement: &2154630500 !ruby/object:Gem::Requirement
|
259
259
|
none: false
|
260
260
|
requirements:
|
261
261
|
- - ! '>='
|
@@ -263,7 +263,7 @@ dependencies:
|
|
263
263
|
version: '0'
|
264
264
|
type: :development
|
265
265
|
prerelease: false
|
266
|
-
version_requirements: *
|
266
|
+
version_requirements: *2154630500
|
267
267
|
description: A Ruby wrapper and CLI for to interact with Cloudfactory.com REST API
|
268
268
|
email:
|
269
269
|
- info@cloudfactory.com
|
@@ -313,9 +313,7 @@ files:
|
|
313
313
|
- lib/cf/cli/templates/form_preview.html.erb
|
314
314
|
- lib/cf/cli/templates/html_file.html.erb
|
315
315
|
- lib/cf/cli/templates/js_file.js.erb
|
316
|
-
- lib/cf/cli/templates/sample-line/form.css
|
317
316
|
- lib/cf/cli/templates/sample-line/form.html
|
318
|
-
- lib/cf/cli/templates/sample-line/form.js
|
319
317
|
- lib/cf/cli/templates/sample-line/line.yml.erb
|
320
318
|
- lib/cf/cli/templates/sample-line/sample-line.csv
|
321
319
|
- lib/cf/client.rb
|
@@ -1,50 +0,0 @@
|
|
1
|
-
body {
|
2
|
-
margin: 0 auto;
|
3
|
-
padding: 0;
|
4
|
-
color: #000;
|
5
|
-
width: 960px;
|
6
|
-
background: #302D2F;
|
7
|
-
font-family: georgia;
|
8
|
-
}
|
9
|
-
#wrapper {
|
10
|
-
background: #FFF;
|
11
|
-
position: relative;
|
12
|
-
padding:0 10px;
|
13
|
-
}
|
14
|
-
#header {
|
15
|
-
border-bottom: solid 1px grey;
|
16
|
-
padding: 10px;
|
17
|
-
height: 50px;
|
18
|
-
text-align: center;
|
19
|
-
font-size: 36px;
|
20
|
-
font-weight: bold;
|
21
|
-
color: #666666;
|
22
|
-
}
|
23
|
-
|
24
|
-
ul{
|
25
|
-
list-style: decimal;
|
26
|
-
}
|
27
|
-
input[type=text] {
|
28
|
-
width:660px;
|
29
|
-
margin:4px;
|
30
|
-
font-size: 12px;
|
31
|
-
height:40px;
|
32
|
-
}
|
33
|
-
input[type=submit]{
|
34
|
-
width: 160px;
|
35
|
-
height: 40px;
|
36
|
-
border: solid 1px black;
|
37
|
-
}
|
38
|
-
|
39
|
-
#gender, #age, #location {
|
40
|
-
font-weight: bold;
|
41
|
-
color: #A9BED4;
|
42
|
-
}
|
43
|
-
a{
|
44
|
-
color: #007EB9;
|
45
|
-
}
|
46
|
-
#footer{
|
47
|
-
border-top: solid 1px grey;
|
48
|
-
padding: 10px;
|
49
|
-
text-align: center;
|
50
|
-
}
|
@@ -1,12 +0,0 @@
|
|
1
|
-
$(document).ready(function() {
|
2
|
-
var url = $("#instructions a").attr('href');
|
3
|
-
var splitted_url = url.split("/");
|
4
|
-
var gender = splitted_url[splitted_url.length - 3];
|
5
|
-
var new_gender = gender.toLowerCase() == "male" ? "female" : "male";
|
6
|
-
splitted_url[splitted_url.length - 3] = new_gender;
|
7
|
-
var age = splitted_url[splitted_url.length - 1];
|
8
|
-
age = decodeURI(age).split(" ")[0];
|
9
|
-
splitted_url[splitted_url.length - 1] = age;
|
10
|
-
var new_url = splitted_url.join("/");
|
11
|
-
$("#instructions a").attr('href',new_url);
|
12
|
-
});
|