turkee 1.2.2 → 2.0.0

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.
Files changed (55) hide show
  1. data/.document +5 -0
  2. data/.gitignore +27 -0
  3. data/Gemfile.lock +124 -0
  4. data/Guardfile +12 -0
  5. data/README.rdoc +53 -21
  6. data/VERSION +1 -0
  7. data/lib/generators/turkee/templates/create_turkee_study.rb.erb +18 -0
  8. data/lib/generators/turkee/turkee_generator.rb +4 -0
  9. data/lib/helpers/turkee_forms_helper.rb +68 -0
  10. data/lib/models/turkee_imported_assignment.rb +15 -0
  11. data/lib/models/turkee_study.rb +11 -0
  12. data/lib/models/turkee_task.rb +257 -0
  13. data/lib/tasks/turkee.rb +13 -1
  14. data/lib/turkee.rb +4 -317
  15. data/spec/dummy/Rakefile +7 -0
  16. data/spec/dummy/app/assets/javascripts/application.js +5 -0
  17. data/spec/dummy/app/assets/stylesheets/application.css +7 -0
  18. data/spec/dummy/app/controllers/application_controller.rb +3 -0
  19. data/spec/dummy/app/helpers/application_helper.rb +2 -0
  20. data/spec/dummy/app/mailers/.gitkeep +0 -0
  21. data/spec/dummy/app/models/.gitkeep +0 -0
  22. data/spec/dummy/app/views/layouts/application.html.erb +19 -0
  23. data/spec/dummy/config.ru +4 -0
  24. data/spec/dummy/config/application.rb +41 -0
  25. data/spec/dummy/config/boot.rb +10 -0
  26. data/spec/dummy/config/database.yml +25 -0
  27. data/spec/dummy/config/environment.rb +5 -0
  28. data/spec/dummy/config/environments/development.rb +27 -0
  29. data/spec/dummy/config/environments/production.rb +54 -0
  30. data/spec/dummy/config/environments/test.rb +39 -0
  31. data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
  32. data/spec/dummy/config/initializers/inflections.rb +10 -0
  33. data/spec/dummy/config/initializers/mime_types.rb +5 -0
  34. data/spec/dummy/config/initializers/secret_token.rb +7 -0
  35. data/spec/dummy/config/initializers/session_store.rb +8 -0
  36. data/spec/dummy/config/initializers/wrap_parameters.rb +12 -0
  37. data/spec/dummy/config/locales/en.yml +5 -0
  38. data/spec/dummy/config/routes.rb +62 -0
  39. data/spec/dummy/db/migrate/20110710143903_initial_tables.rb +23 -0
  40. data/spec/dummy/db/migrate/20120819164528_add_association_with_class_name.rb +12 -0
  41. data/spec/dummy/db/migrate/20130203095901_create_company.rb +14 -0
  42. data/spec/dummy/db/schema.rb +45 -0
  43. data/spec/dummy/public/404.html +26 -0
  44. data/spec/dummy/public/422.html +26 -0
  45. data/spec/dummy/public/500.html +26 -0
  46. data/spec/dummy/public/favicon.ico +0 -0
  47. data/spec/dummy/script/rails +6 -0
  48. data/spec/dummy/tmp/cache/.gitkeep +0 -0
  49. data/spec/factories/turkee_task_factory.rb +21 -0
  50. data/spec/helpers/turkee_forms_helper_spec.rb +44 -0
  51. data/spec/models/turkee_study_spec.rb +19 -0
  52. data/spec/{turkee_spec.rb → models/turkee_task_spec.rb} +0 -0
  53. data/spec/spec_helper.rb +21 -6
  54. data/turkee.gemspec +59 -0
  55. metadata +69 -21
@@ -0,0 +1,14 @@
1
+ class CreateCompany < ActiveRecord::Migration
2
+ def self.up
3
+ create_table :companies do |t|
4
+ t.string :name
5
+ end
6
+
7
+ add_column :projects, :company_id, :integer
8
+ end
9
+
10
+ def self.down
11
+ remove_column :projects, :company_id
12
+ drop_table :companies
13
+ end
14
+ end
@@ -0,0 +1,45 @@
1
+ # encoding: UTF-8
2
+ # This file is auto-generated from the current state of the database. Instead
3
+ # of editing this file, please use the migrations feature of Active Record to
4
+ # incrementally modify your database, and then regenerate this schema definition.
5
+ #
6
+ # Note that this schema.rb definition is the authoritative source for your
7
+ # database schema. If you need to create the application database on another
8
+ # system, you should be using db:schema:load, not running all the migrations
9
+ # from scratch. The latter is a flawed and unsustainable approach (the more migrations
10
+ # you'll amass, the slower it'll run and the greater likelihood for issues).
11
+ #
12
+ # It's strongly recommended to check this file into your version control system.
13
+
14
+ ActiveRecord::Schema.define(:version => 20130203095901) do
15
+
16
+ create_table :turkee_tasks do |t|
17
+ t.string "hit_url"
18
+ t.boolean "sandbox"
19
+ t.string "task_type"
20
+ t.text "hit_title"
21
+ t.text "hit_description"
22
+ t.string "hit_id"
23
+ t.decimal "hit_reward", :precision => 10, :scale => 2
24
+ t.integer "hit_num_assignments"
25
+ t.integer "hit_lifetime"
26
+ t.string "form_url"
27
+ t.integer "completed_assignments", :default => 0
28
+ t.boolean "complete"
29
+ t.boolean "expired"
30
+ t.datetime "created_at", :null => false
31
+ t.datetime "updated_at", :null => false
32
+ t.integer "turkee_flow_id"
33
+ t.integer "hit_duration"
34
+ end
35
+
36
+ create_table :surveys do |t|
37
+ t.string :answer
38
+ end
39
+
40
+ create_table :turkee_studies do |t|
41
+ t.integer :turkee_task_id
42
+ t.string :feedback
43
+ end
44
+
45
+ end
@@ -0,0 +1,26 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>The page you were looking for doesn't exist (404)</title>
5
+ <style type="text/css">
6
+ body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
7
+ div.dialog {
8
+ width: 25em;
9
+ padding: 0 4em;
10
+ margin: 4em auto 0 auto;
11
+ border: 1px solid #ccc;
12
+ border-right-color: #999;
13
+ border-bottom-color: #999;
14
+ }
15
+ h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
16
+ </style>
17
+ </head>
18
+
19
+ <body>
20
+ <!-- This file lives in public/404.html -->
21
+ <div class="dialog">
22
+ <h1>The page you were looking for doesn't exist.</h1>
23
+ <p>You may have mistyped the address or the page may have moved.</p>
24
+ </div>
25
+ </body>
26
+ </html>
@@ -0,0 +1,26 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>The change you wanted was rejected (422)</title>
5
+ <style type="text/css">
6
+ body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
7
+ div.dialog {
8
+ width: 25em;
9
+ padding: 0 4em;
10
+ margin: 4em auto 0 auto;
11
+ border: 1px solid #ccc;
12
+ border-right-color: #999;
13
+ border-bottom-color: #999;
14
+ }
15
+ h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
16
+ </style>
17
+ </head>
18
+
19
+ <body>
20
+ <!-- This file lives in public/422.html -->
21
+ <div class="dialog">
22
+ <h1>The change you wanted was rejected.</h1>
23
+ <p>Maybe you tried to change something you didn't have access to.</p>
24
+ </div>
25
+ </body>
26
+ </html>
@@ -0,0 +1,26 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>We're sorry, but something went wrong (500)</title>
5
+ <style type="text/css">
6
+ body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
7
+ div.dialog {
8
+ width: 25em;
9
+ padding: 0 4em;
10
+ margin: 4em auto 0 auto;
11
+ border: 1px solid #ccc;
12
+ border-right-color: #999;
13
+ border-bottom-color: #999;
14
+ }
15
+ h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
16
+ </style>
17
+ </head>
18
+
19
+ <body>
20
+ <!-- This file lives in public/500.html -->
21
+ <div class="dialog">
22
+ <h1>We're sorry, but something went wrong.</h1>
23
+ <p>We've been notified about this issue and we'll take a look at it shortly.</p>
24
+ </div>
25
+ </body>
26
+ </html>
File without changes
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+ # This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
3
+
4
+ APP_PATH = File.expand_path('../../config/application', __FILE__)
5
+ require File.expand_path('../../config/boot', __FILE__)
6
+ require 'rails/commands'
File without changes
@@ -0,0 +1,21 @@
1
+ require 'turkee'
2
+ FactoryGirl.define do
3
+ factory :turkee_task, :class => Turkee::TurkeeTask do |s|
4
+ s.hit_url "http://workersandbox.mturk.com/mturk/preview?groupId=248SVGULF395SZ65OC6S6NYNJDXAO5"
5
+ s.sandbox true
6
+ s.task_type "TestTask"
7
+ s.hit_title "Test Title"
8
+ s.hit_description "Test Desc"
9
+ s.hit_id "123"
10
+ s.hit_reward 0.05
11
+ s.completed_assignments 0
12
+ s.hit_num_assignments 100
13
+ s.hit_lifetime 1
14
+ s.hit_duration 1
15
+ s.form_url "http://localhost/test_task/new"
16
+ s.complete false
17
+ s.expired false
18
+ s.created_at Time.now
19
+ s.updated_at Time.now
20
+ end
21
+ end
@@ -0,0 +1,44 @@
1
+ require 'spec_helper'
2
+
3
+ describe Turkee::TurkeeFormHelper, :type => :helper do
4
+ #include RSpec::Rails::HelperExampleGroup
5
+ describe "mturk_url" do
6
+ it "should return sandbox" do
7
+ RTurk.stub(:sandbox?).and_return true
8
+ mturk_url.should match /workersandbox.mturk.com/
9
+ end
10
+ it "should return production url" do
11
+ RTurk.stub(:sandbox?).and_return false
12
+ mturk_url.should match /www.mturk.com/
13
+ end
14
+ end
15
+
16
+ describe "turkee_study" do
17
+ before do
18
+ @task = Factory(:turkee_task)
19
+ RTurk.stub(:sandbox?).and_return true
20
+ end
21
+
22
+ it "includes the description" do
23
+ helper.stub(:params).and_return {}
24
+ study_form = turkee_study
25
+ study_form.should =~ /Test Desc/
26
+ study_form.should =~ /feedback/
27
+ study_form.should match /workersandbox.mturk.com/
28
+ end
29
+
30
+ it "saves the assignmentId to a cookie for later retrieval" do
31
+ helper.stub(:params).and_return({'assignmentId' => '123456'})
32
+
33
+ helper.turkee_study
34
+
35
+ helper.cookies['assignmentId'].should == '123456'
36
+
37
+ # Subsequent requests should still return form fields for assignmentId
38
+ helper.stub(:params).and_return({})
39
+ study_form = helper.turkee_study
40
+
41
+ study_form.should =~ /123456/
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,19 @@
1
+ require 'spec_helper'
2
+
3
+ describe Turkee::TurkeeStudy do
4
+
5
+ describe "approve?" do
6
+ before do
7
+ @study = Turkee::TurkeeStudy.new(:feedback => "I really loved the site. I will tell my mom about it.",
8
+ :gold_response => 'the')
9
+ end
10
+ it "approves the task" do
11
+ @study.approve?.should be_true
12
+ end
13
+
14
+ it "rejects the task" do
15
+ @study.gold_response = "loved"
16
+ @study.approve?.should be_false
17
+ end
18
+ end
19
+ end
File without changes
data/spec/spec_helper.rb CHANGED
@@ -1,15 +1,21 @@
1
- require 'rubygems'
2
- require "bundler/setup"
1
+ #require 'rubygems'
2
+ #require "bundler/setup"
3
+
4
+ require File.expand_path("../dummy/config/environment.rb", __FILE__)
3
5
 
4
6
  require 'factory_girl'
5
- require 'rspec'
6
7
  require 'spork'
7
- require 'rails'
8
+ require 'rails/all'
8
9
  require 'rturk'
9
10
  require 'lockfile'
10
- require 'active_record'
11
+ #require 'active_record'
12
+ #require 'active_support/dependencies/autoload'
13
+ #require 'action_view'
14
+ require 'rspec/rails'
15
+
11
16
 
12
- ActiveRecord::Base.establish_connection(:adapter => "sqlite3", :database => ":memory:")
17
+
18
+ #ActiveRecord::Base.establish_connection(:adapter => "sqlite3", :database => ":memory:")
13
19
  ActiveRecord::Schema.define(:version => 1) do
14
20
  create_table :turkee_tasks do |t|
15
21
  t.string "hit_url"
@@ -34,6 +40,13 @@ ActiveRecord::Schema.define(:version => 1) do
34
40
  create_table :surveys do |t|
35
41
  t.string :answer
36
42
  end
43
+
44
+ create_table :turkee_studies do |t|
45
+ t.integer :turkee_task_id
46
+ t.text :feedback
47
+ t.string :gold_response
48
+ end
49
+
37
50
  end
38
51
 
39
52
 
@@ -54,6 +67,8 @@ Spork.prefork do
54
67
  # config.mock_with :rr
55
68
  config.mock_with :rspec
56
69
 
70
+ config.include Turkee::TurkeeFormHelper
71
+
57
72
  #config.fixture_path = "#{::Rails.root}/spec/fixtures"
58
73
 
59
74
  # If you're not using ActiveRecord, or you'd prefer not to run each of your
data/turkee.gemspec ADDED
@@ -0,0 +1,59 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+
4
+ Gem::Specification.new do |s|
5
+ s.name = %q{turkee}
6
+ s.version = "2.0.0"
7
+
8
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
9
+ s.authors = [%q{Jim Jones}]
10
+ s.date = %q{2013-04-27}
11
+ s.description = %q{Turkee will help you to easily create usability studies, post HITs, and retrieve the user entered values from Mechanical Turk.}
12
+ s.email = %q{jjones@aantix.com}
13
+ s.extra_rdoc_files = [
14
+ "LICENSE",
15
+ "README.rdoc"
16
+ ]
17
+
18
+ s.files = `git ls-files`.split("\n")
19
+ s.test_files = `git ls-files -- {spec}/*`.split("\n")
20
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
21
+
22
+ s.homepage = %q{http://github.com/aantix/turkee}
23
+ s.post_install_message = %q{
24
+ ========================================================================
25
+ Turkee Installation Complete.
26
+ ------------------------------------------------------------------------
27
+
28
+ If you're upgrading, be sure to execute the following to receive the
29
+ latest migration changes.
30
+ rails g turkee --skip
31
+
32
+ (the skip flag will ensure that you don't overwrite prior
33
+ Turkee initializers and migrations)
34
+
35
+
36
+ For instructions on gem usage, visit:
37
+ http://github.com/aantix/turkee#readme
38
+
39
+ ========================================================================
40
+ -- Gobble, gobble.
41
+ }
42
+ s.require_paths = [%q{lib}]
43
+ s.rubygems_version = %q{1.8.1}
44
+ s.summary = %q{Turkee makes dealing with Amazon's Mechnical Turk a breeze.}
45
+
46
+ s.add_dependency(%q<lockfile>)
47
+ s.add_dependency(%q<rails>, [">= 3.1.1"])
48
+ s.add_dependency(%q<rturk>, [">= 2.4.0"])
49
+
50
+ s.add_development_dependency "mocha"
51
+ s.add_development_dependency "sqlite3"
52
+ s.add_development_dependency "spork"
53
+
54
+ # RSpec has to be in both test and development so that rake tasks and generators
55
+ # are available without having to explicitly switch the environment to 'test'
56
+ s.add_development_dependency 'factory_girl', '>= 1.3.2'
57
+ s.add_development_dependency "rspec-rails", "~> 2.6"
58
+ end
59
+
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: turkee
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.2
4
+ version: 2.0.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-01-09 00:00:00.000000000 Z
12
+ date: 2013-04-27 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: lockfile
@@ -124,23 +124,23 @@ dependencies:
124
124
  - !ruby/object:Gem::Version
125
125
  version: 1.3.2
126
126
  - !ruby/object:Gem::Dependency
127
- name: rspec
127
+ name: rspec-rails
128
128
  requirement: !ruby/object:Gem::Requirement
129
129
  none: false
130
130
  requirements:
131
- - - ! '>='
131
+ - - ~>
132
132
  - !ruby/object:Gem::Version
133
- version: 2.5.0
133
+ version: '2.6'
134
134
  type: :development
135
135
  prerelease: false
136
136
  version_requirements: !ruby/object:Gem::Requirement
137
137
  none: false
138
138
  requirements:
139
- - - ! '>='
139
+ - - ~>
140
140
  - !ruby/object:Gem::Version
141
- version: 2.5.0
142
- description: Turkee will help you to create your Rails forms, post the HITs, and retrieve
143
- the user entered values from Mechanical Turk.
141
+ version: '2.6'
142
+ description: Turkee will help you to easily create usability studies, post HITs, and
143
+ retrieve the user entered values from Mechanical Turk.
144
144
  email: jjones@aantix.com
145
145
  executables: []
146
146
  extensions: []
@@ -148,23 +148,71 @@ extra_rdoc_files:
148
148
  - LICENSE
149
149
  - README.rdoc
150
150
  files:
151
+ - .document
152
+ - .gitignore
151
153
  - Gemfile
154
+ - Gemfile.lock
155
+ - Guardfile
156
+ - LICENSE
157
+ - README.rdoc
152
158
  - Rakefile
159
+ - VERSION
160
+ - lib/generators/turkee/templates/add_completed_tasks.rb.erb
161
+ - lib/generators/turkee/templates/add_expired.rb.erb
162
+ - lib/generators/turkee/templates/add_hit_duration.rb.erb
163
+ - lib/generators/turkee/templates/add_imported_assignment_details.rb.erb
164
+ - lib/generators/turkee/templates/create_turkee_study.rb.erb
153
165
  - lib/generators/turkee/templates/turkee.rb
154
166
  - lib/generators/turkee/templates/turkee_imported_assignments.rb.erb
155
- - lib/generators/turkee/templates/add_completed_tasks.rb.erb
156
167
  - lib/generators/turkee/templates/turkee_migration.rb.erb
157
- - lib/generators/turkee/templates/add_imported_assignment_details.rb.erb
158
- - lib/generators/turkee/templates/add_hit_duration.rb.erb
159
- - lib/generators/turkee/templates/add_expired.rb.erb
160
168
  - lib/generators/turkee/turkee_generator.rb
169
+ - lib/helpers/turkee_forms_helper.rb
170
+ - lib/models/turkee_imported_assignment.rb
171
+ - lib/models/turkee_study.rb
172
+ - lib/models/turkee_task.rb
161
173
  - lib/tasks/turkee.rb
162
174
  - lib/turkee.rb
175
+ - spec/dummy/Rakefile
176
+ - spec/dummy/app/assets/javascripts/application.js
177
+ - spec/dummy/app/assets/stylesheets/application.css
178
+ - spec/dummy/app/controllers/application_controller.rb
179
+ - spec/dummy/app/helpers/application_helper.rb
180
+ - spec/dummy/app/mailers/.gitkeep
181
+ - spec/dummy/app/models/.gitkeep
182
+ - spec/dummy/app/views/layouts/application.html.erb
183
+ - spec/dummy/config.ru
184
+ - spec/dummy/config/application.rb
185
+ - spec/dummy/config/boot.rb
186
+ - spec/dummy/config/database.yml
187
+ - spec/dummy/config/environment.rb
188
+ - spec/dummy/config/environments/development.rb
189
+ - spec/dummy/config/environments/production.rb
190
+ - spec/dummy/config/environments/test.rb
191
+ - spec/dummy/config/initializers/backtrace_silencers.rb
192
+ - spec/dummy/config/initializers/inflections.rb
193
+ - spec/dummy/config/initializers/mime_types.rb
194
+ - spec/dummy/config/initializers/secret_token.rb
195
+ - spec/dummy/config/initializers/session_store.rb
196
+ - spec/dummy/config/initializers/wrap_parameters.rb
197
+ - spec/dummy/config/locales/en.yml
198
+ - spec/dummy/config/routes.rb
199
+ - spec/dummy/db/migrate/20110710143903_initial_tables.rb
200
+ - spec/dummy/db/migrate/20120819164528_add_association_with_class_name.rb
201
+ - spec/dummy/db/migrate/20130203095901_create_company.rb
202
+ - spec/dummy/db/schema.rb
203
+ - spec/dummy/public/404.html
204
+ - spec/dummy/public/422.html
205
+ - spec/dummy/public/500.html
206
+ - spec/dummy/public/favicon.ico
207
+ - spec/dummy/script/rails
208
+ - spec/dummy/tmp/cache/.gitkeep
209
+ - spec/factories/turkee_task_factory.rb
210
+ - spec/helpers/turkee_forms_helper_spec.rb
211
+ - spec/models/turkee_study_spec.rb
212
+ - spec/models/turkee_task_spec.rb
163
213
  - spec/spec.opts
164
214
  - spec/spec_helper.rb
165
- - spec/turkee_spec.rb
166
- - LICENSE
167
- - README.rdoc
215
+ - turkee.gemspec
168
216
  homepage: http://github.com/aantix/turkee
169
217
  licenses: []
170
218
  post_install_message: ! "\n ========================================================================\n
@@ -172,11 +220,8 @@ post_install_message: ! "\n ===================================================
172
220
  \ If you're upgrading, be sure to execute the following to receive the\n latest
173
221
  migration changes.\n rails g turkee --skip\n\n (the skip flag will ensure that
174
222
  you don't overwrite prior\n Turkee initializers and migrations)\n\n\n For instructions
175
- on gem usage, visit:\n http://github.com/aantix/turkee#readme\n\n ** If you
176
- like the Turkee gem, please click the \"watch\" button on the\n Github project
177
- page. You'll make me smile and feel appreciated. :)\n http://github.com/aantix/turkee\n\n
178
- \ ========================================================================\n --
179
- Gobble, gobble.\n "
223
+ on gem usage, visit:\n http://github.com/aantix/turkee#readme\n\n ========================================================================\n
224
+ \ -- Gobble, gobble.\n "
180
225
  rdoc_options: []
181
226
  require_paths:
182
227
  - lib
@@ -186,6 +231,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
186
231
  - - ! '>='
187
232
  - !ruby/object:Gem::Version
188
233
  version: '0'
234
+ segments:
235
+ - 0
236
+ hash: 2965433502609428037
189
237
  required_rubygems_version: !ruby/object:Gem::Requirement
190
238
  none: false
191
239
  requirements: