turkee_rails4 2.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (71) hide show
  1. checksums.yaml +7 -0
  2. data/.document +5 -0
  3. data/.gitignore +27 -0
  4. data/.travis.yml +8 -0
  5. data/Gemfile +14 -0
  6. data/Gemfile.lock +121 -0
  7. data/Guardfile +12 -0
  8. data/LICENSE +20 -0
  9. data/README.rdoc +205 -0
  10. data/Rakefile +50 -0
  11. data/VERSION +1 -0
  12. data/lib/generators/turkee/templates/add_completed_tasks.rb.erb +17 -0
  13. data/lib/generators/turkee/templates/add_expired.rb.erb +15 -0
  14. data/lib/generators/turkee/templates/add_hit_duration.rb.erb +15 -0
  15. data/lib/generators/turkee/templates/add_imported_assignment_details.rb.erb +33 -0
  16. data/lib/generators/turkee/templates/create_turkee_study.rb.erb +18 -0
  17. data/lib/generators/turkee/templates/turkee.rb +8 -0
  18. data/lib/generators/turkee/templates/turkee_imported_assignments.rb.erb +16 -0
  19. data/lib/generators/turkee/templates/turkee_migration.rb.erb +25 -0
  20. data/lib/generators/turkee/turkee_generator.rb +51 -0
  21. data/lib/helpers/turkee_forms_helper.rb +69 -0
  22. data/lib/models/turkee_imported_assignment.rb +15 -0
  23. data/lib/models/turkee_study.rb +11 -0
  24. data/lib/models/turkee_task.rb +259 -0
  25. data/lib/tasks/turkee.rb +29 -0
  26. data/lib/turkee.rb +8 -0
  27. data/spec/dummy/Rakefile +7 -0
  28. data/spec/dummy/app/assets/javascripts/application.js +5 -0
  29. data/spec/dummy/app/assets/stylesheets/application.css +7 -0
  30. data/spec/dummy/app/controllers/application_controller.rb +3 -0
  31. data/spec/dummy/app/controllers/surveys_controller.rb +7 -0
  32. data/spec/dummy/app/helpers/application_helper.rb +2 -0
  33. data/spec/dummy/app/mailers/.gitkeep +0 -0
  34. data/spec/dummy/app/models/.gitkeep +0 -0
  35. data/spec/dummy/app/models/survey.rb +3 -0
  36. data/spec/dummy/app/views/layouts/application.html.erb +19 -0
  37. data/spec/dummy/config/application.rb +41 -0
  38. data/spec/dummy/config/boot.rb +10 -0
  39. data/spec/dummy/config/database.yml +25 -0
  40. data/spec/dummy/config/environment.rb +5 -0
  41. data/spec/dummy/config/environments/development.rb +26 -0
  42. data/spec/dummy/config/environments/production.rb +54 -0
  43. data/spec/dummy/config/environments/test.rb +38 -0
  44. data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
  45. data/spec/dummy/config/initializers/inflections.rb +10 -0
  46. data/spec/dummy/config/initializers/mime_types.rb +5 -0
  47. data/spec/dummy/config/initializers/secret_token.rb +7 -0
  48. data/spec/dummy/config/initializers/session_store.rb +8 -0
  49. data/spec/dummy/config/initializers/wrap_parameters.rb +12 -0
  50. data/spec/dummy/config/locales/en.yml +5 -0
  51. data/spec/dummy/config/routes.rb +61 -0
  52. data/spec/dummy/config.ru +4 -0
  53. data/spec/dummy/db/migrate/20110710143903_initial_tables.rb +23 -0
  54. data/spec/dummy/db/migrate/20120819164528_add_association_with_class_name.rb +12 -0
  55. data/spec/dummy/db/migrate/20130203095901_create_company.rb +14 -0
  56. data/spec/dummy/db/schema.rb +45 -0
  57. data/spec/dummy/public/404.html +26 -0
  58. data/spec/dummy/public/422.html +26 -0
  59. data/spec/dummy/public/500.html +26 -0
  60. data/spec/dummy/public/favicon.ico +0 -0
  61. data/spec/dummy/script/rails +6 -0
  62. data/spec/dummy/tmp/cache/.gitkeep +0 -0
  63. data/spec/factories/survey_factory.rb +7 -0
  64. data/spec/factories/turkee_task_factory.rb +21 -0
  65. data/spec/helpers/turkee_forms_helper_spec.rb +75 -0
  66. data/spec/models/turkee_study_spec.rb +19 -0
  67. data/spec/models/turkee_task_spec.rb +146 -0
  68. data/spec/spec.opts +1 -0
  69. data/spec/spec_helper.rb +89 -0
  70. data/turkee.gemspec +59 -0
  71. metadata +232 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: ce03796671683cc390e66bc19f2f8703b10c051d
4
+ data.tar.gz: e0af93f03975d1bb1b1f68dbce29ffb37a75b749
5
+ SHA512:
6
+ metadata.gz: 2351f036ba8ac21f4812071119da5b2e3241ba7a78c37116153da27a711a1df32e87faaed77599ef04b0fb5ea210347485d541ce90f341fd06768482116f4305
7
+ data.tar.gz: d6700bf4f27a04c70b1cc43a394950c90ba558c65b5bed4ba450256e406bac57aa9214144ccaae9a295ee5be9935a7a3b8d6ae2582f9cdc758ec9171de41faad
data/.document ADDED
@@ -0,0 +1,5 @@
1
+ README.rdoc
2
+ lib/**/*.rb
3
+ bin/*
4
+ features/**/*.feature
5
+ LICENSE
data/.gitignore ADDED
@@ -0,0 +1,27 @@
1
+ ## MAC OS
2
+ .DS_Store
3
+
4
+ *.gem
5
+ build.sh
6
+
7
+ ## TEXTMATE
8
+ *.tmproj
9
+ tmtags
10
+ *.log
11
+
12
+ ## EMACS
13
+ *~
14
+ \#*
15
+ .\#*
16
+
17
+ ## VIM
18
+ *.swp
19
+
20
+ ## PROJECT::GENERAL
21
+ coverage
22
+ rdoc
23
+ pkg
24
+
25
+ .idea
26
+
27
+ ## PROJECT::SPECIFIC
data/.travis.yml ADDED
@@ -0,0 +1,8 @@
1
+ env:
2
+ - "RAILS_VERSION=3.1.0"
3
+ - "RAILS_VERSION=3.2.0"
4
+ - "RAILS_VERSION=4.0.0"
5
+ - "RAILS_VERSION=master"
6
+ rvm:
7
+ - 1.9.3
8
+ - 2.0.0
data/Gemfile ADDED
@@ -0,0 +1,14 @@
1
+ source 'http://rubygems.org'
2
+
3
+ gemspec
4
+
5
+ rails_version = ENV["RAILS_VERSION"] || "default"
6
+
7
+ rails = case rails_version
8
+ when "master"
9
+ {github: "rails/rails"}
10
+ when "default"
11
+ "~> 4.0.0"
12
+ else
13
+ "~> #{rails_version}"
14
+ end
data/Gemfile.lock ADDED
@@ -0,0 +1,121 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ turkee (2.0.2)
5
+ lockfile
6
+ rails (>= 3.1.1)
7
+ rturk (>= 2.4.0)
8
+
9
+ GEM
10
+ remote: http://rubygems.org/
11
+ specs:
12
+ actionmailer (4.0.0)
13
+ actionpack (= 4.0.0)
14
+ mail (~> 2.5.3)
15
+ actionpack (4.0.0)
16
+ activesupport (= 4.0.0)
17
+ builder (~> 3.1.0)
18
+ erubis (~> 2.7.0)
19
+ rack (~> 1.5.2)
20
+ rack-test (~> 0.6.2)
21
+ activemodel (4.0.0)
22
+ activesupport (= 4.0.0)
23
+ builder (~> 3.1.0)
24
+ activerecord (4.0.0)
25
+ activemodel (= 4.0.0)
26
+ activerecord-deprecated_finders (~> 1.0.2)
27
+ activesupport (= 4.0.0)
28
+ arel (~> 4.0.0)
29
+ activerecord-deprecated_finders (1.0.3)
30
+ activesupport (4.0.0)
31
+ i18n (~> 0.6, >= 0.6.4)
32
+ minitest (~> 4.2)
33
+ multi_json (~> 1.3)
34
+ thread_safe (~> 0.1)
35
+ tzinfo (~> 0.3.37)
36
+ arel (4.0.0)
37
+ atomic (1.1.10)
38
+ builder (3.1.4)
39
+ diff-lcs (1.2.4)
40
+ erubis (2.7.0)
41
+ factory_girl (4.2.0)
42
+ activesupport (>= 3.0.0)
43
+ hike (1.2.3)
44
+ i18n (0.6.4)
45
+ lockfile (2.1.0)
46
+ mail (2.5.4)
47
+ mime-types (~> 1.16)
48
+ treetop (~> 1.4.8)
49
+ metaclass (0.0.1)
50
+ mime-types (1.23)
51
+ mini_portile (0.5.1)
52
+ minitest (4.7.5)
53
+ mocha (0.14.0)
54
+ metaclass (~> 0.0.1)
55
+ multi_json (1.7.7)
56
+ nokogiri (1.6.0)
57
+ mini_portile (~> 0.5.0)
58
+ polyglot (0.3.3)
59
+ rack (1.5.2)
60
+ rack-test (0.6.2)
61
+ rack (>= 1.0)
62
+ rails (4.0.0)
63
+ actionmailer (= 4.0.0)
64
+ actionpack (= 4.0.0)
65
+ activerecord (= 4.0.0)
66
+ activesupport (= 4.0.0)
67
+ bundler (>= 1.3.0, < 2.0)
68
+ railties (= 4.0.0)
69
+ sprockets-rails (~> 2.0.0)
70
+ railties (4.0.0)
71
+ actionpack (= 4.0.0)
72
+ activesupport (= 4.0.0)
73
+ rake (>= 0.8.7)
74
+ thor (>= 0.18.1, < 2.0)
75
+ rake (10.1.0)
76
+ rest-client (1.6.7)
77
+ mime-types (>= 1.16)
78
+ rspec-core (2.14.3)
79
+ rspec-expectations (2.14.0)
80
+ diff-lcs (>= 1.1.3, < 2.0)
81
+ rspec-mocks (2.14.1)
82
+ rspec-rails (2.14.0)
83
+ actionpack (>= 3.0)
84
+ activesupport (>= 3.0)
85
+ railties (>= 3.0)
86
+ rspec-core (~> 2.14.0)
87
+ rspec-expectations (~> 2.14.0)
88
+ rspec-mocks (~> 2.14.0)
89
+ rturk (2.10.2)
90
+ nokogiri (>= 1.4.1)
91
+ rest-client (>= 1.4.0)
92
+ spork (0.9.2)
93
+ sprockets (2.10.0)
94
+ hike (~> 1.2)
95
+ multi_json (~> 1.0)
96
+ rack (~> 1.0)
97
+ tilt (~> 1.1, != 1.3.0)
98
+ sprockets-rails (2.0.0)
99
+ actionpack (>= 3.0)
100
+ activesupport (>= 3.0)
101
+ sprockets (~> 2.8)
102
+ sqlite3 (1.3.7)
103
+ thor (0.18.1)
104
+ thread_safe (0.1.0)
105
+ atomic
106
+ tilt (1.4.1)
107
+ treetop (1.4.14)
108
+ polyglot
109
+ polyglot (>= 0.3.1)
110
+ tzinfo (0.3.37)
111
+
112
+ PLATFORMS
113
+ ruby
114
+
115
+ DEPENDENCIES
116
+ factory_girl (>= 1.3.2)
117
+ mocha
118
+ rspec-rails (~> 2.6)
119
+ spork
120
+ sqlite3
121
+ turkee!
data/Guardfile ADDED
@@ -0,0 +1,12 @@
1
+ guard 'spork', :rspec_env => { 'RAILS_ENV' => 'test' } do
2
+ watch('spec/spec_helper.rb')
3
+ end
4
+
5
+
6
+ guard 'rspec', :version => 2, :cli => "--drb" do
7
+ watch(%r{^spec/.+_spec\.rb$})
8
+
9
+ # lib/
10
+ watch(%r{^lib/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
11
+ end
12
+
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2010 Jim Jones
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.rdoc ADDED
@@ -0,0 +1,205 @@
1
+ == RAILS 4 SUPPORT
2
+ Rails 4 support is currently being tested. To try it out, just use Turkee's master branch. In your Gemfile, add the following :
3
+ gem 'turkee', :git => 'https://github.com/aantix/turkee.git', branch: 'master'
4
+
5
+ == WHAT TURKEE CAN DO
6
+
7
+ * Perform user feedback studies easily.
8
+ http://i.imgur.com/wIU40BAl.png
9
+
10
+ * Seamlessly convert your Rails forms for use on Mechanical Turk.
11
+ * Easily import the data posted by the Mechanical Turk workers back into your data models.
12
+
13
+ External forms are created using a simple form helper. HITs are created by issuing a rake command. Retrieving submitted response data and importing that data into your model(s) requires just one more rake command.
14
+
15
+
16
+ == INSTALL/UPGRADE
17
+
18
+ Add turkee to your Gemfile as a gem dependency, then do a 'bundle install':
19
+
20
+ gem 'turkee'
21
+
22
+
23
+ If you're upgrading Turkee (1.1.1 and prior) or installing for the first time, run:
24
+
25
+ rails g turkee --skip
26
+
27
+ (the skip flag will ensure that you don't overwrite prior Turkee initializers and migrations.)
28
+
29
+ This will copy the needed migrations and config/initializer into your application directory.
30
+
31
+ To access the Turkee rake tasks, add the following to your application's Rakefile:
32
+ require 'tasks/turkee'
33
+
34
+ If you haven't created a Mechanical Turk account, surf on over to {Amazon's Web Services}[http://aws.amazon.com/] and create an AWS account.
35
+
36
+ Once you have your account created, you can access your AWS access key and secret access key from {here.}[https://aws-portal.amazon.com/gp/aws/developer/account/index.html?action=access-key]
37
+
38
+
39
+ == CONFIGURATION
40
+
41
+ Inside the config/initializers directory, you'll see the file turkee.rb. Edit the file with your Amazon credentials.
42
+
43
+ AWSACCESSKEYID = 'XXXXXXXXXXXXXXXXXX'
44
+ AWSSECRETACCESSKEY = 'YYYYYYYYYYYYYYYYYYYYYYYYYYYY'
45
+
46
+ RTurk::logger.level = Logger::DEBUG
47
+ RTurk.setup(AWSACCESSKEYID, AWSSECRETACCESSKEY, :sandbox => (Rails.env == 'production' ? false : true))
48
+
49
+ Run the migrations :
50
+
51
+ rake db:migrate
52
+
53
+ == MIXED CONTENT WARNINGS
54
+
55
+ Mechanical Turk will open your forms in an iFrame from a secure URL (ssl).
56
+ If you test locally with localhost, you're going to need to be running SSL so that you don't
57
+ receive a mixed content warning within Chrome and a blank screen.
58
+ Thin allows for local SSL.
59
+
60
+ # Gemfile
61
+ gem 'thin', :group => :development
62
+
63
+ Then you can start the server by calling :
64
+
65
+ thin start --ssl
66
+
67
+
68
+ == BASIC FORMS
69
+
70
+ 1) You should disable form controls if the Turker hasn't accepted the HIT. You can determine this from your controller:
71
+ class SurveysController < ApplicationController
72
+
73
+ def new
74
+ @disabled = Turkee::TurkeeFormHelper::disable_form_fields?(params)
75
+
76
+ # If you wanted to find the associated turkee_task, you could do a find by hitId
77
+ # Not necessary in a simple example.
78
+ # @turkee_task = Turkee::TurkeeTask.find_by_hit_id(params[:hitId]).id rescue nil
79
+
80
+ ...
81
+ @survey = Survey.new
82
+ end
83
+
84
+ 2) Change your forms to use the form helper.
85
+
86
+ <%= turkee_form_for(@survey, params) do |f| %>
87
+ <p><%= f.text_area :value, :disabled => @disabled %></p>
88
+ <p><%= f.submit 'Create', :disabled => @disabled %></p>
89
+ <% end %>
90
+
91
+ Using the turkee_form_for helper will post the form to the Mechanical Turk sandbox if you're in development/test mode, otherwise it will be posted to Mechanical Turk production/live site.
92
+
93
+
94
+ 3) Run the following rake task to post to Mechanical Turk :
95
+ # Host URL of your application
96
+ # Title of your HIT
97
+ # Description of your HIT
98
+ # Model name of your task form (the New action should be implemented)
99
+ # Number of assignments for HIT
100
+ # The reward for a successful completion
101
+ # The lifetime of the HIT in days (e.g. 5 days)
102
+
103
+ rake turkee:post_hit[<Host>, <Title>, <Description>, <Model>, <Number of Assignments>, <Reward>, <Lifetime>]
104
+
105
+ e.g. :
106
+ rake turkee:post_hit["https://www.yourapp.com","Please complete our survey","Tell us your favorite color.","Survey",100,0.05,5,1]
107
+ ** Do not put spaces before or after commas for the rake task parameters
108
+
109
+ This will insert a row for the requested HIT into the turkee_tasks table. The turkee_tasks entry stores (along with the other properties) the HIT URL (e.g. http://workersandbox.mturk.com/mturk/preview?groupId=1HGHJJGHQSJB7WMWJ33YS8WM169XNIL ) and HIT ID (e.g. 1J1EXO8SUQ3URTTUYGHJ7EKUT11 ). These values are returned from Mechanical Turk when the HIT request is posted.
110
+
111
+ When a Turk worker views your HIT, the HIT will display your form within an iFrame. With the above example, Mechanical Turk will open an iFrame for the HIT assignment displaying the form http://www.yourapp.com/surveys/new
112
+
113
+ == USER FEEDBACK STUDIES
114
+
115
+ 1) Add the following method call to your app/views/layouts/application.html.haml file :
116
+
117
+ <%= turkee_study %>
118
+
119
+ 2) Call the create_study rake task :
120
+
121
+ rake turkee:create_study[<Application Page URL>, <HIT Title>, <HIT Description>, <Number of Assignments>, <Reward>, <Lifetime of HIT>]
122
+
123
+ # 30 Assignments at a quarter each requesting feedback on my site
124
+ RAILS_ENV=production rake turkee:create_study['https://yoursite.com/page-to-be-test',"Can you help me test my website?","Give feedback below on what you didn't like about my site. Click submit below when you're finished.", 30,0.25, 20]
125
+
126
+ 3) The Turker will see a feedback form overlayed over your website. Within this textarea, they can provide feedback.
127
+
128
+ Screenshot:
129
+
130
+ http://i.imgur.com/wIU40BA.png
131
+
132
+ == RETRIEVING RESULTS
133
+
134
+ 1) Run the rake task that retrieves the values from Mechanical Turk and stores the user entered values into your model.
135
+ rake turkee:get_all_results
136
+
137
+ Rerun this task periodically to retrieve newly entered form values. You can setup this task as a cronjob to automate this.
138
+
139
+ crontab -e
140
+
141
+ # E.g. run every five minutes
142
+ */5 * * * * cd /var/www/your/turk/application && rake turkee:get_all_results
143
+
144
+ Or you can directly call :
145
+
146
+ Turkee::TurkeeTask.process_hits
147
+
148
+
149
+ == DATA RETRIEVAL; THE INS AND OUTS
150
+
151
+ 1) When a response is retrieved from Mechanical Turk, Turkee attempts to create a data row for the model specified using the corresponding retrieved data. If the row cannot be created (input failed model validations), the assignment is rejected.
152
+ As for Mechanical Turk approval, if the row is created and you haven't specified your own custom approve? method for the model, the assignment will automatically be approved. If you'd like to add your own custom approval method, add the approve? instance method to your model. E.g. :
153
+ class Survey < ActiveRecord::Base
154
+ def approve?
155
+ (!response.blank? && !comment.blank?)
156
+ end
157
+ end
158
+
159
+ 2) When all specified assignments for a HIT have been completed, Turkee will attempt to call the optional hit_complete class method for the model. This can be used for any cleanup logic. E.g. :
160
+ class Survey < ActiveRecord::Base
161
+ def self.hit_complete(turkee_task)
162
+ #do something
163
+ end
164
+ end
165
+
166
+ 3) If all of specified assignments for a HIT have not been completed by the end of the HITs lifetime, Turkee will attempt to call the optional hit_expired class method for the model. This can be used for any cleanup logic. E.g. :
167
+ class Survey < ActiveRecord::Base
168
+ def self.hit_expired(turkee_task)
169
+ #do something
170
+ end
171
+ end
172
+
173
+
174
+ == Advanced Usage
175
+
176
+ 1) You can use the params hash to pass object IDs to your forms. E.g. if you wanted to setup a form of questions about a given URL (let's call the model UrlSurvey), your code would look something like :
177
+
178
+ URL.all do |url|
179
+ Turkee::TurkeeTask.create_hit(host, "Enter the address displayed for the given url.",
180
+ hit_description, UrlSurvey, num_assignments, reward,
181
+ lifetime, duration, {}, {:url_id => url.id}, {})
182
+ end
183
+
184
+ Then when displaying your form, you can find the URL object via the params[:url_id] value.
185
+
186
+ 2) You can pass in qualifications to allow only certain Turkers to work on your HIT.
187
+
188
+ E.g. qualifications = {:approval_rate => {:gt => 70}, :country => {:eql => 'US'}}
189
+
190
+ Turkee::TurkeeTask.create_hit(host, hit_title, hit_description, UrlSurvey, num_assignments, reward, lifetime, duration, qualifications, {}, {})
191
+
192
+ * The rake task does not support the passing of qualifications.
193
+
194
+ 3) Turkee assumes that the form url will be the new action for the class passed to create_hit. If you have a more complex form url which would be the case for nested resources, you can use the :form_url
195
+ option to designate a form url different from the default.
196
+
197
+ form_url = Rails.application.routes.url_helpers.send("new_user_survey_path",@my_survey)
198
+
199
+ Turkee::TurkeeTask.create_hit(host, hit_title, hit_description, :Survey, num_assignments, reward,
200
+ lifetime, duration, {}, {}, {:form_url => form_url})
201
+
202
+
203
+ == Copyright
204
+
205
+ Copyright (c) 2010 - 2012 Jim Jones. See LICENSE for details.
data/Rakefile ADDED
@@ -0,0 +1,50 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+ require 'bundler'
4
+ require 'rspec/core/rake_task'
5
+ Bundler::GemHelper.install_tasks
6
+
7
+ $:.push File.expand_path("../lib", __FILE__)
8
+
9
+ desc "Run specs"
10
+ RSpec::Core::RakeTask.new(:spec)
11
+
12
+ desc 'Default: run specs.'
13
+ task :default => :spec
14
+
15
+ begin
16
+ INSTALL_MESSAGE = %q{
17
+ ========================================================================
18
+ Turkee Installation Complete.
19
+ ------------------------------------------------------------------------
20
+ If you're upgrading Turkee (1.1.1 and prior) or installing for the first time, run:
21
+
22
+ rails g turkee --skip
23
+
24
+ For full instructions on gem usage, visit:
25
+ http://github.com/aantix/turkee#readme
26
+
27
+ ** If you like the Turkee gem, please click the "watch" button on the
28
+ Github project page. You'll make me smile and feel appreciated. :)
29
+ http://github.com/aantix/turkee
30
+
31
+ ========================================================================
32
+ }
33
+
34
+ Gem::Specification.new do |gem|
35
+ gem.name = "turkee"
36
+ gem.summary = "Turkee makes dealing with Amazon's Mechnical Turk a breeze."
37
+ gem.description = "Turkee will help you to create your Rails forms, post the HITs, and retrieve the user entered values from Mechanical Turk."
38
+ gem.email = "jjones@aantix.com"
39
+ gem.homepage = "http://github.com/aantix/turkee"
40
+ gem.authors = ["Jim Jones"]
41
+ gem.add_dependency(%q<rails>, [">= 3.1.1"])
42
+ gem.add_dependency(%q<rturk>, [">= 2.4.0"])
43
+ gem.add_dependency(%q<lockfile>, [">= 1.4.3"])
44
+
45
+ gem.post_install_message = INSTALL_MESSAGE
46
+ gem.require_path = 'lib'
47
+ gem.files = %w(MIT-LICENSE README.textile Gemfile Rakefile init.rb) + Dir.glob("{lib,spec}/**/*")
48
+
49
+ end
50
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 2.0.0
@@ -0,0 +1,17 @@
1
+ class AddCompletedTasks< ActiveRecord::Migration
2
+
3
+ def self.up
4
+ unless column_exists? :turkee_tasks, :completed_assignments
5
+ add_column :turkee_tasks, :completed_assignments, :integer, :default => 0
6
+ end
7
+
8
+ unless column_exists? :turkee_tasks, :hit_num_assignments
9
+ add_column :turkee_tasks, :hit_num_assignments, :integer
10
+ end
11
+
12
+ end
13
+
14
+ def self.down
15
+ end
16
+ end
17
+
@@ -0,0 +1,15 @@
1
+ class AddExpired < ActiveRecord::Migration
2
+
3
+ def self.up
4
+ unless column_exists? :turkee_tasks, :expired
5
+ add_column :turkee_tasks, :expired, :integer
6
+ end
7
+ end
8
+
9
+ def self.down
10
+ if column_exists? :turkee_tasks, :expired
11
+ remove_column :turkee_tasks, :expired
12
+ end
13
+ end
14
+ end
15
+
@@ -0,0 +1,15 @@
1
+ class AddHitDuration < ActiveRecord::Migration
2
+
3
+ def self.up
4
+ unless column_exists? :turkee_tasks, :hit_duration
5
+ add_column :turkee_tasks, :hit_duration, :integer
6
+ end
7
+ end
8
+
9
+ def self.down
10
+ if column_exists? :turkee_tasks, :hit_duration
11
+ remove_column :turkee_tasks, :hit_duration
12
+ end
13
+ end
14
+ end
15
+
@@ -0,0 +1,33 @@
1
+ class AddImportedAssignmentDetails < ActiveRecord::Migration
2
+
3
+ def self.up
4
+ unless column_exists? :turkee_imported_assignments, :turkee_task_id
5
+ add_column :turkee_imported_assignments, :turkee_task_id, :integer
6
+ add_index :turkee_imported_assignments, :turkee_task_id, :unique => false
7
+ end
8
+
9
+ unless column_exists? :turkee_imported_assignments, :worker_id
10
+ add_column :turkee_imported_assignments, :worker_id, :string
11
+ end
12
+
13
+ unless column_exists? :turkee_imported_assignments, :result_id
14
+ add_column :turkee_imported_assignments, :result_id, :integer
15
+ end
16
+ end
17
+
18
+ def self.down
19
+ if column_exists? :turkee_imported_assignments, :turkee_task_id
20
+ remove_column :turkee_imported_assignments, :turkee_task_id
21
+ remove_index :turkee_imported_assignments, :turkee_task_id
22
+ end
23
+
24
+ if column_exists? :turkee_imported_assignments, :worker_id
25
+ remove_column :turkee_imported_assignments, :worker_id
26
+ end
27
+
28
+ if column_exists? :turkee_imported_assignments, :result_id
29
+ remove_column :turkee_imported_assignments, :result_id
30
+ end
31
+ end
32
+ end
33
+
@@ -0,0 +1,18 @@
1
+ class CreateTurkeeStudy < ActiveRecord::Migration
2
+
3
+ def self.up
4
+ create_table "turkee_studies" do |t|
5
+ t.integer "turkee_task_id"
6
+ t.text "feedback"
7
+ t.string "gold_response"
8
+ t.timestamps
9
+ end
10
+
11
+ add_index :turkee_studies, :turkee_task_id
12
+ end
13
+
14
+ def self.down
15
+ drop_table :turkee_studies
16
+ end
17
+
18
+ end
@@ -0,0 +1,8 @@
1
+ # Go to this page https://aws-portal.amazon.com/gp/aws/developer/account/index.html?action=access-key
2
+ # to retrieve your AWS/Mechanical Turk access keys.
3
+
4
+ AWSACCESSKEYID = 'XXXXXXXXXXXXXXXXXX'
5
+ AWSSECRETACCESSKEY = 'YYYYYYYYYYYYYYYYYYYYYYYYYYYY'
6
+
7
+ RTurk::logger.level = Logger::DEBUG
8
+ RTurk.setup(AWSACCESSKEYID, AWSSECRETACCESSKEY, :sandbox => (Rails.env == 'production' ? false : true))
@@ -0,0 +1,16 @@
1
+ class CreateTurkeeImportedAssignments < ActiveRecord::Migration
2
+
3
+ def self.up
4
+ create_table "turkee_imported_assignments" do |t|
5
+ t.string "assignment_id"
6
+ t.timestamps
7
+ end
8
+
9
+ add_index :turkee_imported_assignments, :assignment_id, :unique => true
10
+ end
11
+
12
+ def self.down
13
+ drop_table :turkee_imported_assignments
14
+ end
15
+
16
+ end
@@ -0,0 +1,25 @@
1
+ class CreateTurkeeTasks < ActiveRecord::Migration
2
+
3
+ def self.up
4
+ create_table "turkee_tasks" do |t|
5
+ t.string "hit_url"
6
+ t.boolean "sandbox"
7
+ t.string "task_type"
8
+ t.text "hit_title"
9
+ t.text "hit_description"
10
+ t.string "hit_id"
11
+ t.decimal "hit_reward", :precision => 10, :scale => 2
12
+ t.integer "hit_num_assignments"
13
+ t.integer "hit_lifetime"
14
+ t.string "form_url"
15
+ t.integer "completed_assignments", :default => 0
16
+ t.boolean "complete"
17
+ t.timestamps
18
+ end
19
+ end
20
+
21
+ def self.down
22
+ drop_table :turkee_tasks
23
+ end
24
+
25
+ end