cloudfactory 0.1.9 → 0.1.10
Sign up to get free protection for your applications and to get access to all the features.
- data/cf.gemspec +1 -0
- data/features/error_custom_task_form.feature +117 -0
- data/features/error_form_field.feature +58 -0
- data/features/error_task_form.feature +64 -0
- data/features/errors.feature +192 -0
- data/features/run.feature +136 -121
- data/features/support/cli_steps.rb +44 -0
- data/features/support/env.rb +2 -2
- data/lib/cf.rb +3 -4
- data/lib/cf/account.rb +12 -1
- data/lib/cf/cli.rb +2 -2
- data/lib/cf/cli/config.rb +2 -2
- data/lib/cf/cli/form.rb +5 -5
- data/lib/cf/cli/line.rb +40 -16
- data/lib/cf/cli/production.rb +50 -18
- data/lib/cf/cli/templates/sample-line/form.css +41 -17
- data/lib/cf/cli/templates/sample-line/form.html +27 -18
- data/lib/cf/cli/templates/sample-line/form.js +12 -3
- data/lib/cf/cli/templates/sample-line/line.yml.erb +42 -32
- data/lib/cf/client.rb +3 -3
- data/lib/cf/custom_task_form.rb +21 -91
- data/lib/cf/department.rb +1 -10
- data/lib/cf/final_output.rb +2 -16
- data/lib/cf/form_field.rb +11 -6
- data/lib/cf/human_worker.rb +93 -1
- data/lib/cf/input_format.rb +10 -62
- data/lib/cf/line.rb +46 -37
- data/lib/cf/robot_worker.rb +63 -2
- data/lib/cf/run.rb +37 -66
- data/lib/cf/station.rb +42 -104
- data/lib/cf/task_form.rb +17 -56
- data/lib/cf/version.rb +2 -2
- data/lib/generators/cf/form/form_generator.rb +3 -3
- data/lib/generators/cf/install/install_generator.rb +3 -3
- data/spec/custom_task_form_spec.rb +169 -1
- data/spec/generators/form_generator_spec.rb +2 -2
- data/spec/generators/install_generator_spec.rb +2 -2
- data/spec/run_spec.rb +3 -3
- data/spec/spec_helper.rb +1 -0
- data/spec/station_spec.rb +13 -1
- data/spec/task_form_spec.rb +38 -6
- metadata +63 -44
@@ -1,20 +1,29 @@
|
|
1
|
-
<
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
1
|
+
<body>
|
2
|
+
<div id="wrapper">
|
3
|
+
<div id="header">
|
4
|
+
Be a Match Maker
|
5
|
+
</div>
|
6
|
+
<div id="instructions">
|
7
|
+
<h2>Instructions:</h2>
|
8
|
+
<ul>
|
9
|
+
<li><a target="_blank" href="http://wink.com/people/l/{{location}}/s/single/g/{{gender}}/a/{{age}}">Click this link.</a></li>
|
10
|
+
<li>Then enter the url of hottest date found</li>
|
11
|
+
</ul>
|
12
|
+
</div>
|
9
13
|
|
10
|
-
<div id="station_2_form"
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
14
|
+
<div id="station_2_form">
|
15
|
+
<div id = "field-panel">
|
16
|
+
<p>
|
17
|
+
<form>
|
18
|
+
<label>Enter URL of hottest date found</label><br />
|
19
|
+
<input id="fb_url" type="text" name="output[url]" data-valid-type="general"/>
|
20
|
+
<input type="submit" value="submit" />
|
21
|
+
</form>
|
22
|
+
</p>
|
23
|
+
</div>
|
19
24
|
</div>
|
20
|
-
|
25
|
+
<div id="footer">
|
26
|
+
Copyright(c)
|
27
|
+
</div>
|
28
|
+
</div>
|
29
|
+
</body>
|
@@ -1,7 +1,16 @@
|
|
1
1
|
<script src="http://code.jquery.com/jquery-latest.js"></script>
|
2
2
|
|
3
3
|
<script type="text/javascript">
|
4
|
-
|
5
|
-
|
6
|
-
|
4
|
+
$(document).ready(function() {
|
5
|
+
var url = $("#instructions a").attr('href');
|
6
|
+
var splitted_url = url.split("/");
|
7
|
+
var gender = splitted_url[splitted_url.length - 3];
|
8
|
+
var new_gender = gender.toLowerCase() == "male" ? "female" : "male";
|
9
|
+
splitted_url[splitted_url.length - 3] = new_gender;
|
10
|
+
var age = splitted_url[splitted_url.length - 1];
|
11
|
+
age = decodeURI(age).split(" ")[0];
|
12
|
+
splitted_url[splitted_url.length - 1] = age;
|
13
|
+
var new_url = splitted_url.join("/");
|
14
|
+
$("#instructions a").attr('href',new_url);
|
15
|
+
});
|
7
16
|
</script>
|
@@ -1,78 +1,87 @@
|
|
1
1
|
# ☁ ☁ ☁ ☁ ☁ ☁ ☁ ☁ ☁ ☁ ☁ ☁ ☁ ☁ ☁ ☁ ☁ ☁ ☁ ☁ ☁ ☁ ☁ ☁ ☁ ☁ ☁ ☁ ☁ ☁ ☁ ☁ ☁ ☁ ☁ ☁ ☁ ☁ ☁ ☁
|
2
2
|
# Assembly Line: <%= title.underscore.dasherize %>
|
3
3
|
# ☁ ☁ ☁ ☁ ☁ ☁ ☁ ☁ ☁ ☁ ☁ ☁ ☁ ☁ ☁ ☁ ☁ ☁ ☁ ☁ ☁ ☁ ☁ ☁ ☁ ☁ ☁ ☁ ☁ ☁ ☁ ☁ ☁ ☁ ☁ ☁ ☁ ☁ ☁ ☁
|
4
|
-
|
5
|
-
# See
|
6
|
-
#
|
4
|
+
|
5
|
+
# See docs at http://cloudfactory.com/developers/
|
6
|
+
# See example lines at http://cloudfactory.com/developers/lines/
|
7
|
+
|
8
|
+
# Run `cf login` OR manually specify your API key below (See http://cloudfactory.com/developers/resources/account.html)
|
9
|
+
|
7
10
|
# api_key: fill_in_your_api_key #(optional)
|
8
11
|
|
9
12
|
title: <%= title.underscore.dasherize %>
|
10
13
|
description: A shiny new assembly line ready for you to customize. Right now it is finding people dates (uncomment and try for fun) but you should just replace everything below accordingly for your line.
|
11
14
|
|
12
|
-
# Department to build line in (See http://cloudfactory.com/developers/
|
15
|
+
# Department to build line in (See http://cloudfactory.com/developers/resources/department.html)
|
13
16
|
department: Web Research
|
14
17
|
|
15
|
-
# Line Input Formats (see http://cloudfactory.com/developers/
|
18
|
+
# Line Input Formats (see http://cloudfactory.com/developers/resources/input_format.html)
|
16
19
|
input_formats:
|
17
20
|
# - name: email
|
18
21
|
# required: true
|
19
|
-
# valid_type: email #
|
22
|
+
# valid_type: email # email, url, number, date, phone
|
20
23
|
# - name: location
|
21
24
|
# required: true
|
22
|
-
# valid_type:
|
25
|
+
# valid_type: text # email, url, number, date, phone
|
23
26
|
# - name: photo
|
24
27
|
# required: true
|
25
|
-
# valid_type: url #
|
26
|
-
#
|
27
|
-
# # Stations (see http://cloudfactory.com/developers/lines/yaml.html#stations)
|
28
|
+
# valid_type: url # email, url, number, date, phone
|
29
|
+
# # Stations (see http://cloudfactory.com/developers/resources/station.html)
|
28
30
|
stations:
|
29
31
|
# # Sample Station #1: WORKER looks at photo of person seeking a date and determines their gender and approximate age
|
30
32
|
# - station:
|
31
33
|
# station_index: 1
|
32
34
|
# station_type: work # work, improve, tournament
|
33
|
-
# # Worker (see http://cloudfactory.com/developers/
|
35
|
+
# # Worker (see http://cloudfactory.com/developers/resources/worker.html)
|
34
36
|
# worker:
|
35
37
|
# worker_type: human # "human" or name of robot (google_translate_robot, etc)
|
36
38
|
# num_workers: 1
|
37
|
-
# reward:
|
38
|
-
# # Task Form (see http://cloudfactory.com/developers/
|
39
|
+
# reward: 2
|
40
|
+
# # Task Form (see http://cloudfactory.com/developers/resources/task_form.html)
|
39
41
|
# task_form:
|
40
42
|
# form_title: Look at a photo to determine the person's gender and approximate age
|
41
43
|
# instruction: Click the photo link and then enter the person's gender and approximate age in the form below
|
42
44
|
# form_fields:
|
43
45
|
# - label: Gender
|
44
|
-
# field_type:
|
46
|
+
# field_type: radio_button # short_answer, long_answer, radio_button, check_box, select_box
|
45
47
|
# required: true
|
46
48
|
# option_values:
|
47
49
|
# - male
|
48
50
|
# - female
|
49
51
|
# - not sure
|
50
52
|
# - label: Age
|
51
|
-
# field_type:
|
53
|
+
# field_type: select_box # short_answer, long_answer, radio_button, check_box, select_box
|
52
54
|
# required: true
|
53
55
|
# option_values:
|
54
|
-
#
|
55
|
-
#
|
56
|
-
#
|
57
|
-
#
|
58
|
-
#
|
56
|
+
# - 13 to 18
|
57
|
+
# - 19 to 24
|
58
|
+
# - 25 to 29
|
59
|
+
# - 30 to 34
|
60
|
+
# - 35 to 39
|
61
|
+
# - 40 to 49
|
62
|
+
# - 50 to 59
|
63
|
+
# - 60 and up
|
64
|
+
#
|
59
65
|
#
|
60
66
|
# # Sample Station #2: TOURNAMENT to find the best local person on facebook that matches the right gender and age
|
61
67
|
# - station:
|
62
68
|
# station_index: 2
|
63
69
|
# station_type: tournament # work, improve, tournament
|
70
|
+
# input_formats:
|
71
|
+
# station_0:
|
72
|
+
# - name: location
|
73
|
+
# worker:
|
74
|
+
# worker_type: human # "human" or name of the robot (google_translate_robot, etc)
|
75
|
+
# num_workers: 2
|
76
|
+
# reward: 2
|
64
77
|
# jury_worker:
|
65
78
|
# max_judges: 8
|
66
|
-
# reward:
|
79
|
+
# reward: 2
|
67
80
|
# auto_judge:
|
68
81
|
# enabled: true
|
69
|
-
# worker:
|
70
|
-
# worker_type: human # "human" or name of robot (google_translate_robot, etc)
|
71
|
-
# num_workers: 3
|
72
|
-
# reward: 3
|
73
82
|
# custom_task_form:
|
74
|
-
# form_title:
|
75
|
-
# instruction:
|
83
|
+
# form_title: Clink a link and paste in url
|
84
|
+
# instruction: Look through search results and find the best date
|
76
85
|
# html: form.html
|
77
86
|
# css: form.css
|
78
87
|
# js: form.js
|
@@ -81,11 +90,12 @@ stations:
|
|
81
90
|
# - station:
|
82
91
|
# station_index: 3
|
83
92
|
# station_type: work # work, improve, tournament
|
84
|
-
#
|
93
|
+
# input_formats:
|
94
|
+
# station_0:
|
95
|
+
# - name: email
|
96
|
+
# # Worker (see http://cloudfactory.com/developers/resources/worker.html)
|
85
97
|
# worker:
|
86
98
|
# worker_type: mailer_robot
|
87
99
|
# settings:
|
88
|
-
# to: {{email}}
|
89
|
-
# template: '<html><body><h1>We have searched high and low to find a sweet date for you. Now the rest is up to you - head to their facebook page and request them as a friend: {{
|
90
|
-
# template_variables:
|
91
|
-
# fb_url: {{fb_url}}
|
100
|
+
# to: ["{{email}}"]
|
101
|
+
# template: '<html><body><h1>We have searched high and low to find a sweet date for you. Now the rest is up to you - head to their facebook page and request them as a friend: {{url}}</h1><p>Good luck!!!!</p></body></html>'
|
data/lib/cf/client.rb
CHANGED
data/lib/cf/custom_task_form.rb
CHANGED
@@ -20,13 +20,17 @@ module CF
|
|
20
20
|
# station attribute is required for association with custom_from object
|
21
21
|
attr_accessor :station
|
22
22
|
|
23
|
+
# Contains Error message if any
|
24
|
+
attr_accessor :errors
|
25
|
+
|
23
26
|
# ==Initializes a new CustomForm
|
24
|
-
#
|
27
|
+
# ===Usage custom_instruction.new(hash):
|
25
28
|
#
|
26
|
-
#
|
27
|
-
#
|
29
|
+
# html = 'html_content'
|
30
|
+
# css = 'css_content'
|
31
|
+
# javascript = 'javascript_content'
|
28
32
|
#
|
29
|
-
# instruction =
|
33
|
+
# instruction = CF::CustomTaskForm.new({:title => "Enter text from a business card image", :instruction => "Describe", :raw_html => html, :raw_css => css, :raw_javascript => javascript})
|
30
34
|
def initialize(options={})
|
31
35
|
@station = options[:station]
|
32
36
|
@title = options[:title]
|
@@ -35,102 +39,28 @@ module CF
|
|
35
39
|
@raw_css = options[:raw_css]
|
36
40
|
@raw_javascript = options[:raw_javascript]
|
37
41
|
if @station
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
custom_form.send("#{k}=",v) if custom_form.respond_to?(k)
|
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, :raw_css => @raw_css, :raw_javascript => @raw_javascript})
|
43
|
+
resp.to_hash.each_pair do |k,v|
|
44
|
+
self.send("#{k}=",v) if self.respond_to?(k)
|
45
|
+
end
|
46
|
+
if resp.code != 200
|
47
|
+
self.errors = resp.error.message
|
45
48
|
end
|
46
|
-
|
47
|
-
|
49
|
+
@station.form = self
|
50
|
+
return self
|
48
51
|
end
|
49
52
|
end
|
50
53
|
|
51
54
|
# ==Initializes a new CustomForm within block using Variable
|
52
|
-
#
|
53
|
-
# ===Creating CustomForm using block variable
|
54
|
-
# attrs = {:title => "Enter text from a business card image",
|
55
|
-
# :description => "Describe"}
|
56
|
-
#
|
57
|
-
# html_content = '<div>.........</div>'
|
58
|
-
#
|
59
|
-
# css_content = 'body {background:#fbfbfb;}
|
60
|
-
# #instructions{
|
61
|
-
# text-align:center;
|
62
|
-
# }.....'
|
55
|
+
# ===Usage custom_instruction.create(hash):
|
63
56
|
#
|
64
|
-
#
|
57
|
+
# html = 'html_content'
|
58
|
+
# css = 'css_content'
|
59
|
+
# javascript = 'javascript_content'
|
65
60
|
#
|
66
|
-
# instruction =
|
67
|
-
# i.html = html_content
|
68
|
-
# i.css = css_content
|
69
|
-
# i.javascript = javascript_content
|
70
|
-
# end
|
71
|
-
#
|
72
|
-
# ===OR without block variable
|
73
|
-
# instruction = CustomForm.create(instruction) do
|
74
|
-
# html html_content
|
75
|
-
# css css_content
|
76
|
-
# javascript javascript_content
|
77
|
-
# end
|
61
|
+
# instruction = CF::CustomTaskForm.create({:title => "Enter text from a business card image", :instruction => "Describe", :raw_html => html, :raw_css => css, :raw_javascript => javascript})
|
78
62
|
def self.create(form)
|
79
63
|
instruction = CustomTaskForm.new(form)
|
80
|
-
# if block.arity >= 1
|
81
|
-
# block.call(instruction)
|
82
|
-
# else
|
83
|
-
# instruction.instance_eval &block
|
84
|
-
# end
|
85
|
-
# instruction
|
86
|
-
end
|
87
|
-
|
88
|
-
# ==Usage of instruction.html:
|
89
|
-
# html_content = '<div>.........</div>'
|
90
|
-
#
|
91
|
-
# instruction.html = html_content
|
92
|
-
#
|
93
|
-
def html html_content = nil
|
94
|
-
if html_content
|
95
|
-
@html_content = html_content
|
96
|
-
else
|
97
|
-
@html_content
|
98
|
-
end
|
99
|
-
end
|
100
|
-
def html=(html_content) # :nodoc:
|
101
|
-
@html_content = html_content
|
102
|
-
end
|
103
|
-
|
104
|
-
# ==Usage of instruction.css:
|
105
|
-
# css_content = 'body {background:#fbfbfb;}
|
106
|
-
# #instructions{
|
107
|
-
# text-align:center;
|
108
|
-
# }.....'
|
109
|
-
#
|
110
|
-
# instruction.css = css_content
|
111
|
-
def css css_content = nil
|
112
|
-
if css_content
|
113
|
-
@css_content = css_content
|
114
|
-
else
|
115
|
-
@css_content
|
116
|
-
end
|
117
|
-
end
|
118
|
-
def css=(css_content) # :nodoc:
|
119
|
-
@css_content = css_content
|
120
|
-
end
|
121
|
-
# ==Usage of instruction.javascript:
|
122
|
-
# javascript_content = '<script>.........</script>'
|
123
|
-
#
|
124
|
-
# instruction.html = javascript_content
|
125
|
-
def javascript javascript_content = nil
|
126
|
-
if javascript_content
|
127
|
-
@javascript_content = javascript_content
|
128
|
-
else
|
129
|
-
@javascript_content
|
130
|
-
end
|
131
|
-
end
|
132
|
-
def javascript=(javascript_content) # :nodoc:
|
133
|
-
@javascript_content = javascript_content
|
134
64
|
end
|
135
65
|
end
|
136
66
|
end
|
data/lib/cf/department.rb
CHANGED
@@ -1,11 +1,8 @@
|
|
1
1
|
module CF
|
2
2
|
class Department
|
3
3
|
include Client
|
4
|
-
|
5
|
-
# Id of the specific Category
|
6
|
-
attr_accessor :department_name
|
7
4
|
|
8
|
-
#
|
5
|
+
# Department name
|
9
6
|
attr_accessor :name
|
10
7
|
|
11
8
|
# ==Returns all Department
|
@@ -14,11 +11,5 @@ module CF
|
|
14
11
|
def self.all
|
15
12
|
response = get("/departments.json")
|
16
13
|
end
|
17
|
-
|
18
|
-
# Returns all lines of a specific Department
|
19
|
-
def self.get_lines_of_department(department_name)
|
20
|
-
@department_name = department_name
|
21
|
-
get("/departments/#{@department_name}.json")
|
22
|
-
end
|
23
14
|
end
|
24
15
|
end
|
data/lib/cf/final_output.rb
CHANGED
@@ -1,20 +1,6 @@
|
|
1
|
-
module CF
|
2
|
-
class FinalOutput
|
1
|
+
module CF # :nodoc:
|
2
|
+
class FinalOutput # :nodoc:
|
3
3
|
include Client
|
4
4
|
attr_accessor :final_outputs, :unit_id, :final_output, :output
|
5
|
-
|
6
|
-
# def self.get_result(run_id)
|
7
|
-
# resp = get("/runs/#{run_id}/results.json")
|
8
|
-
#
|
9
|
-
# @final_output =[]
|
10
|
-
# resp.each do |r|
|
11
|
-
# result = self.new()
|
12
|
-
# r.to_hash.each_pair do |k,v|
|
13
|
-
# result.send("#{k}=",v) if result.respond_to?(k)
|
14
|
-
# end
|
15
|
-
# @results << result
|
16
|
-
# end
|
17
|
-
# return @results
|
18
|
-
# end
|
19
5
|
end
|
20
6
|
end
|
data/lib/cf/form_field.rb
CHANGED
@@ -3,10 +3,10 @@ module CF
|
|
3
3
|
require 'httparty'
|
4
4
|
include Client
|
5
5
|
|
6
|
-
# Label for "
|
6
|
+
# Label for "form" object, e.g. :label => "First Name"
|
7
7
|
attr_accessor :label
|
8
8
|
|
9
|
-
# field_type for "
|
9
|
+
# field_type for "form" object, e.g. :field_type => "SA"
|
10
10
|
attr_accessor :field_type
|
11
11
|
|
12
12
|
# required boolean either true or false, e.g. :required => "true" & if false then you don't need to mention
|
@@ -17,13 +17,18 @@ module CF
|
|
17
17
|
|
18
18
|
# station id attribute required for API Calls
|
19
19
|
attr_accessor :station_id
|
20
|
-
|
20
|
+
|
21
|
+
# Parameters for form fields
|
22
|
+
attr_accessor :form_field_params
|
23
|
+
|
24
|
+
# Contains error message
|
25
|
+
attr_accessor :errors
|
21
26
|
|
22
|
-
# ==Initializes a new "
|
23
|
-
#
|
27
|
+
# ==Initializes a new "form" object
|
28
|
+
# ===Usage of form.new(hash):
|
24
29
|
# line = CF::Line.create("Digitize", "Survey") do |l|
|
25
30
|
# CF::Station.create({:line => l, :type => "work"}) do |s|
|
26
|
-
# CF::
|
31
|
+
# CF::TaskForm.create({:station => s, :title => "Enter text from a business card image", :instruction => "Describe"}) do |i|
|
27
32
|
# CF::FormField.new({:form => i, :label => "First Name", :field_type => "SA", :required => "true"})
|
28
33
|
# end
|
29
34
|
# end
|
data/lib/cf/human_worker.rb
CHANGED
@@ -4,7 +4,69 @@ module CF
|
|
4
4
|
require 'httparty'
|
5
5
|
extend ActiveSupport::Concern
|
6
6
|
|
7
|
-
|
7
|
+
# ID of "Worker" object
|
8
|
+
attr_accessor :id
|
9
|
+
|
10
|
+
# Number of worker, e.g. :number => 3
|
11
|
+
attr_accessor :number
|
12
|
+
|
13
|
+
# Reward for worker, e.g. :reward => 10 (reward unit is in cents)
|
14
|
+
attr_accessor :reward
|
15
|
+
|
16
|
+
# Station attribute for "worker" object
|
17
|
+
attr_accessor :station
|
18
|
+
|
19
|
+
# Stat Badge for "worker" object, e.g. worker = CF::HumanWorker.new({:number => 2, :reward => 20, :stat_badge => {:approval_rating => 40, :assignment_duration => 1800, :abandonment_rate => 30}})
|
20
|
+
attr_accessor :stat_badge
|
21
|
+
|
22
|
+
# Skill Badge for "worker" object
|
23
|
+
# example:
|
24
|
+
# badge_settings =
|
25
|
+
# {
|
26
|
+
# :title => 'Football Fanatic',
|
27
|
+
# :description => "This qualification allows you to perform work at stations which have this badge.",
|
28
|
+
# :max_badges => 3,
|
29
|
+
# :test =>
|
30
|
+
# {
|
31
|
+
# :input => {:name => "Lionel Andres Messi", :country => "Argentina"},
|
32
|
+
# :expected_output =>
|
33
|
+
# [
|
34
|
+
# {:birthplace => "Rosario, Santa Fe, Argentina",:match_options => {:tolerance => 10, :ignore_case => true }},
|
35
|
+
# {:position => "CF",:match_options => {:tolerance => 1 }},
|
36
|
+
# {:"current-club" => "Barcelona",:match_options => {:tolerance => 1, :ignore_case => false }}
|
37
|
+
# ]
|
38
|
+
# }
|
39
|
+
# }
|
40
|
+
#
|
41
|
+
# worker = CF::HumanWorker.new({:number => 2, :reward => 20, :skill_badge => badge_settings})
|
42
|
+
attr_accessor :skill_badges
|
43
|
+
|
44
|
+
# Contains Error messages if any for "worker" object
|
45
|
+
attr_accessor :errors
|
46
|
+
|
47
|
+
# Badge setting for "worker" object
|
48
|
+
attr_accessor :badge
|
49
|
+
|
50
|
+
# ==Initializes a new "worker" object
|
51
|
+
# ==Usage of HumanWorker.new(hash):
|
52
|
+
#
|
53
|
+
# ==In Block DSL way
|
54
|
+
# line = CF::Line.create("human_worker", "Survey") do |l|
|
55
|
+
# CF::Station.create({:line => l, :type => "work"}) do |s|
|
56
|
+
# CF::HumanWorker.new({:station => s, :number => 1, :reward => 10})
|
57
|
+
# end
|
58
|
+
# end
|
59
|
+
#
|
60
|
+
# ==In Plain Ruby way
|
61
|
+
# line = CF::Line.new("human_worker", "Digitization")
|
62
|
+
# input_format = CF::InputFormat.new({:name => "image_url", :required => true, :valid_type => "url"})
|
63
|
+
# line.input_formats input_format
|
64
|
+
#
|
65
|
+
# station = CF::Station.new({:type => "work"})
|
66
|
+
# line.stations station
|
67
|
+
#
|
68
|
+
# worker = CF::HumanWorker.new({:number => 2, :reward => 20})
|
69
|
+
# line.stations.first.worker = worker
|
8
70
|
|
9
71
|
def initialize(options={})
|
10
72
|
@skill_badges = []
|
@@ -51,6 +113,36 @@ module CF
|
|
51
113
|
end
|
52
114
|
end
|
53
115
|
|
116
|
+
# ==Creation a new "worker" object with Badge
|
117
|
+
# ==Usage Example:
|
118
|
+
# ==In Plain Ruby way
|
119
|
+
# badge_settings =
|
120
|
+
# {
|
121
|
+
# :title => 'Football Fanatic',
|
122
|
+
# :description => "This qualification allows you to perform work at stations which have this badge.",
|
123
|
+
# :max_badges => 3,
|
124
|
+
# :test =>
|
125
|
+
# {
|
126
|
+
# :input => {:name => "Lionel Andres Messi", :country => "Argentina"},
|
127
|
+
# :expected_output =>
|
128
|
+
# [
|
129
|
+
# {:birthplace => "Rosario, Santa Fe, Argentina",:match_options => {:tolerance => 10, :ignore_case => true }},
|
130
|
+
# {:position => "CF",:match_options => {:tolerance => 1 }},
|
131
|
+
# {:"current-club" => "Barcelona",:match_options => {:tolerance => 1, :ignore_case => false }}
|
132
|
+
# ]
|
133
|
+
# }
|
134
|
+
# }
|
135
|
+
# line = CF::Line.new("human_worker", "Digitization")
|
136
|
+
# input_format = CF::InputFormat.new({:name => "image_url", :required => true, :valid_type => "url"})
|
137
|
+
# line.input_formats input_format
|
138
|
+
#
|
139
|
+
# station = CF::Station.new({:type => "work"})
|
140
|
+
# line.stations station
|
141
|
+
#
|
142
|
+
# worker = CF::HumanWorker.new({:number => 2, :reward => 20, :skill_badge => skill_badge})
|
143
|
+
# line.stations.first.worker = worker
|
144
|
+
#
|
145
|
+
# line.stations.first.worker.badge = badge_settings
|
54
146
|
def badge=(badge)
|
55
147
|
request =
|
56
148
|
{
|