rturk 2.3.5 → 2.3.6
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.markdown +1 -0
- data/Gemfile +3 -1
- data/README.markdown +20 -13
- data/VERSION +1 -1
- data/lib/rturk/operations/grant_qualification.rb +19 -0
- data/lib/rturk/operations/reject_qualification_request.rb +19 -0
- data/spec/fake_responses/grant_qualification.xml +5 -0
- data/spec/fake_responses/reject_qualification_request.xml +5 -0
- data/spec/operations/grant_qualification_spec.rb +27 -0
- data/spec/operations/reject_qualification_request_spec.rb +28 -0
- metadata +47 -61
data/CHANGELOG.markdown
CHANGED
data/Gemfile
CHANGED
data/README.markdown
CHANGED
@@ -11,7 +11,7 @@ If your integrating RTurk with a Rails app, do yourself a favor and check out [T
|
|
11
11
|
## Installation
|
12
12
|
|
13
13
|
gem install rturk
|
14
|
-
|
14
|
+
|
15
15
|
## Use
|
16
16
|
|
17
17
|
Let's say you have a form at "http://myapp.com/turkers/add_tags" where Turkers can add some tags to items in your catalogue.
|
@@ -29,9 +29,9 @@ Let's say you have a form at "http://myapp.com/turkers/add_tags" where Turkers c
|
|
29
29
|
hit.reward = 0.05
|
30
30
|
hit.qualifications.add :approval_rate, { :gt => 80 }
|
31
31
|
end
|
32
|
-
|
32
|
+
|
33
33
|
p hit.url #=> 'https://workersandbox.mturk.com:443/mturk/preview?groupId=Q29J3XZQ1ASZH5YNKZDZ'
|
34
|
-
|
34
|
+
|
35
35
|
### Reviewing and Approving hits HIT's
|
36
36
|
|
37
37
|
hits = RTurk::Hit.all_reviewable
|
@@ -40,7 +40,7 @@ Let's say you have a form at "http://myapp.com/turkers/add_tags" where Turkers c
|
|
40
40
|
|
41
41
|
unless hits.empty?
|
42
42
|
puts "Reviewing all assignments"
|
43
|
-
|
43
|
+
|
44
44
|
hits.each do |hit|
|
45
45
|
hit.assignments.each do |assignment|
|
46
46
|
puts assignment.answers['tags']
|
@@ -48,7 +48,7 @@ Let's say you have a form at "http://myapp.com/turkers/add_tags" where Turkers c
|
|
48
48
|
end
|
49
49
|
end
|
50
50
|
end
|
51
|
-
|
51
|
+
|
52
52
|
### Wiping all your hits out
|
53
53
|
|
54
54
|
hits = RTurk::Hit.all_reviewable
|
@@ -57,7 +57,7 @@ Let's say you have a form at "http://myapp.com/turkers/add_tags" where Turkers c
|
|
57
57
|
|
58
58
|
unless hits.empty?
|
59
59
|
puts "Approving all assignments and disposing of each hit!"
|
60
|
-
|
60
|
+
|
61
61
|
hits.each do |hit|
|
62
62
|
hit.expire!
|
63
63
|
hit.assignments.each do |assignment|
|
@@ -66,13 +66,13 @@ Let's say you have a form at "http://myapp.com/turkers/add_tags" where Turkers c
|
|
66
66
|
hit.dispose!
|
67
67
|
end
|
68
68
|
end
|
69
|
-
|
70
|
-
|
69
|
+
|
70
|
+
|
71
71
|
### Logging
|
72
72
|
Want to see what's going on - enable logging.
|
73
73
|
|
74
74
|
RTurk::logger.level = Logger::DEBUG
|
75
|
-
|
75
|
+
|
76
76
|
## Nitty Gritty
|
77
77
|
|
78
78
|
Here's a quick peak at what happens on the Mechanical Turk side.
|
@@ -82,11 +82,11 @@ A worker takes a look at your hit. The page will contain an iframe with your que
|
|
82
82
|
Amazon will append the AssignmentID parameter to the URL for your own information. In preview mode this will look like
|
83
83
|
|
84
84
|
http://myapp.com/turkers/add_tags?item_id=1234&AssignmentId=ASSIGNMENT_ID_NOT_AVAILABLE
|
85
|
-
|
85
|
+
|
86
86
|
If the Turker accepts the HIT, the page will reload and the iframe URL will resemble
|
87
87
|
|
88
88
|
http://myapp.com/turkers/add_tags?item_id=1234&AssignmentId=1234567890123456789ABC
|
89
|
-
|
89
|
+
|
90
90
|
The form in your page MUST CONTAIN the AssignmentID in a hidden input element. You could do this on the server side with a rails app, or on the client side with javascript(check the examples)
|
91
91
|
|
92
92
|
Anything submitted in this form will be sent to Amazon and saved for your review later.
|
@@ -95,5 +95,12 @@ Anything submitted in this form will be sent to Amazon and saved for your review
|
|
95
95
|
|
96
96
|
Take a look at the [Amazon MTurk developer docs](http://docs.amazonwebservices.com/AWSMechTurk/latest/AWSMechanicalTurkRequester/) for more information. They have a complete list of API operations, all of which can be called with this library.
|
97
97
|
|
98
|
-
|
99
|
-
|
98
|
+
## Contributors
|
99
|
+
|
100
|
+
[Zach Hale](http://github.com/zachhale)
|
101
|
+
[David Balatero](http://github.com/dbalatero)
|
102
|
+
[Rob Hanlon](http://github.com/ohwillie)
|
103
|
+
[Haris Amin](http://github.com/hamin)
|
104
|
+
[Tyler](http://github.com/tkieft)
|
105
|
+
[David Dai](http://github.com/newtonsapple)
|
106
|
+
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.3.
|
1
|
+
2.3.6
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# Operation grants a Worker's request for a Qualification.
|
2
|
+
|
3
|
+
module RTurk
|
4
|
+
class GrantQualification < Operation
|
5
|
+
|
6
|
+
attr_accessor :qualification_request_id, :integer_value
|
7
|
+
require_params :qualification_request_id
|
8
|
+
|
9
|
+
def to_params
|
10
|
+
{'QualificationRequestId' => self.qualification_request_id,
|
11
|
+
'IntegerValue' => self.integer_value}
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.GrantQualification(*args)
|
16
|
+
RTurk::GrantQualification.create(*args)
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# Operation rejects a user's request for a Qualification
|
2
|
+
|
3
|
+
module RTurk
|
4
|
+
class RejectQualificationRequest < Operation
|
5
|
+
|
6
|
+
attr_accessor :qualification_request_id, :reason
|
7
|
+
require_params :qualification_request_id
|
8
|
+
|
9
|
+
def to_params
|
10
|
+
{'QualificationRequestId' => self.qualification_request_id,
|
11
|
+
'Reason' => self.reason}
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.RejectQualificationRequest(*args)
|
16
|
+
RTurk::RejectQualificationRequest.create(*args)
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper'))
|
2
|
+
|
3
|
+
describe RTurk::GrantQualification do
|
4
|
+
|
5
|
+
before(:all) do
|
6
|
+
aws = YAML.load(File.open(File.join(SPEC_ROOT, 'mturk.yml')))
|
7
|
+
RTurk.setup(aws['AWSAccessKeyId'], aws['AWSAccessKey'], :sandbox => true)
|
8
|
+
faker('grant_qualification', :operation => 'GrantQualification')
|
9
|
+
end
|
10
|
+
|
11
|
+
it "should ensure required params" do
|
12
|
+
lambda{RTurk::GrantQualification()}.should raise_error RTurk::MissingParameters
|
13
|
+
end
|
14
|
+
|
15
|
+
it "should successfully request the operation" do
|
16
|
+
RTurk::Requester.should_receive(:request).once.with(
|
17
|
+
hash_including('Operation' => 'GrantQualification'))
|
18
|
+
RTurk::GrantQualification(:qualification_request_id => "789RVWYBAZW00EXAMPLE951RVWYBAZW00EXAMPLE") rescue RTurk::InvalidRequest
|
19
|
+
end
|
20
|
+
|
21
|
+
it "should parse and return the result" do
|
22
|
+
RTurk::GrantQualification(:qualification_request_id => "789RVWYBAZW00EXAMPLE951RVWYBAZW00EXAMPLE").elements.should eql(
|
23
|
+
{"GrantQualificationResult"=>{"Request"=>{"IsValid"=>"True"}}}
|
24
|
+
)
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper'))
|
2
|
+
|
3
|
+
describe RTurk::RejectQualificationRequest do
|
4
|
+
|
5
|
+
before(:all) do
|
6
|
+
aws = YAML.load(File.open(File.join(SPEC_ROOT, 'mturk.yml')))
|
7
|
+
RTurk.setup(aws['AWSAccessKeyId'], aws['AWSAccessKey'], :sandbox => true)
|
8
|
+
faker('reject_qualification_request', :operation => 'RejectQualificationRequest')
|
9
|
+
end
|
10
|
+
|
11
|
+
it "should ensure required params" do
|
12
|
+
lambda{RTurk::RejectQualificationRequest()}.should raise_error RTurk::MissingParameters
|
13
|
+
end
|
14
|
+
|
15
|
+
it "should successfully request the operation" do
|
16
|
+
RTurk::Requester.should_receive(:request).once.with(
|
17
|
+
hash_including('Operation' => 'RejectQualificationRequest'))
|
18
|
+
RTurk::RejectQualificationRequest(:qualification_request_id => "123456789", :reason => "Your work is terrible!") rescue RTurk::InvalidRequest
|
19
|
+
end
|
20
|
+
|
21
|
+
it "should parse and return the result" do
|
22
|
+
RTurk::RejectQualificationRequest(:qualification_request_id => "123456789", :reason => "Your work is terrible!").should be_a_kind_of RTurk::Response
|
23
|
+
RTurk::RejectQualificationRequest(:qualification_request_id => "789RVWYBAZW00EXAMPLE951RVWYBAZW00EXAMPLE").elements.should eql(
|
24
|
+
{"RejectQualificationRequestResult"=>{"Request"=>{"IsValid"=>"True"}}}
|
25
|
+
)
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
metadata
CHANGED
@@ -1,13 +1,8 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rturk
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
|
6
|
-
segments:
|
7
|
-
- 2
|
8
|
-
- 3
|
9
|
-
- 5
|
10
|
-
version: 2.3.5
|
4
|
+
prerelease:
|
5
|
+
version: 2.3.6
|
11
6
|
platform: ruby
|
12
7
|
authors:
|
13
8
|
- Mark Percival
|
@@ -18,97 +13,86 @@ autorequire:
|
|
18
13
|
bindir: bin
|
19
14
|
cert_chain: []
|
20
15
|
|
21
|
-
date: 2011-03-
|
16
|
+
date: 2011-03-31 00:00:00 +00:00
|
22
17
|
default_executable:
|
23
18
|
dependencies:
|
24
19
|
- !ruby/object:Gem::Dependency
|
25
|
-
|
26
|
-
|
27
|
-
version_requirements: &id001 !ruby/object:Gem::Requirement
|
20
|
+
name: nokogiri
|
21
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
28
22
|
none: false
|
29
23
|
requirements:
|
30
24
|
- - ">="
|
31
25
|
- !ruby/object:Gem::Version
|
32
|
-
hash: 3
|
33
|
-
segments:
|
34
|
-
- 0
|
35
26
|
version: "0"
|
36
|
-
name: nokogiri
|
37
|
-
requirement: *id001
|
38
|
-
- !ruby/object:Gem::Dependency
|
39
27
|
type: :runtime
|
40
28
|
prerelease: false
|
41
|
-
version_requirements:
|
29
|
+
version_requirements: *id001
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: jeweler
|
32
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
42
33
|
none: false
|
43
34
|
requirements:
|
44
35
|
- - ">="
|
45
36
|
- !ruby/object:Gem::Version
|
46
|
-
hash: 3
|
47
|
-
segments:
|
48
|
-
- 0
|
49
37
|
version: "0"
|
50
|
-
name: fakeweb
|
51
|
-
requirement: *id002
|
52
|
-
- !ruby/object:Gem::Dependency
|
53
38
|
type: :runtime
|
54
39
|
prerelease: false
|
55
|
-
version_requirements:
|
40
|
+
version_requirements: *id002
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: fakeweb
|
43
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
56
44
|
none: false
|
57
45
|
requirements:
|
58
46
|
- - ">="
|
59
47
|
- !ruby/object:Gem::Version
|
60
|
-
hash: 3
|
61
|
-
segments:
|
62
|
-
- 0
|
63
48
|
version: "0"
|
64
|
-
name: rest-client
|
65
|
-
requirement: *id003
|
66
|
-
- !ruby/object:Gem::Dependency
|
67
49
|
type: :runtime
|
68
50
|
prerelease: false
|
69
|
-
version_requirements:
|
51
|
+
version_requirements: *id003
|
52
|
+
- !ruby/object:Gem::Dependency
|
53
|
+
name: rest-client
|
54
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
70
55
|
none: false
|
71
56
|
requirements:
|
72
57
|
- - ">="
|
73
58
|
- !ruby/object:Gem::Version
|
74
|
-
hash: 3
|
75
|
-
segments:
|
76
|
-
- 0
|
77
59
|
version: "0"
|
78
|
-
|
79
|
-
|
60
|
+
type: :runtime
|
61
|
+
prerelease: false
|
62
|
+
version_requirements: *id004
|
80
63
|
- !ruby/object:Gem::Dependency
|
64
|
+
name: rspec
|
65
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
66
|
+
none: false
|
67
|
+
requirements:
|
68
|
+
- - ~>
|
69
|
+
- !ruby/object:Gem::Version
|
70
|
+
version: 1.3.1
|
81
71
|
type: :runtime
|
82
72
|
prerelease: false
|
83
|
-
version_requirements:
|
73
|
+
version_requirements: *id005
|
74
|
+
- !ruby/object:Gem::Dependency
|
75
|
+
name: rest-client
|
76
|
+
requirement: &id006 !ruby/object:Gem::Requirement
|
84
77
|
none: false
|
85
78
|
requirements:
|
86
79
|
- - ">="
|
87
80
|
- !ruby/object:Gem::Version
|
88
|
-
hash: 7
|
89
|
-
segments:
|
90
|
-
- 1
|
91
|
-
- 4
|
92
|
-
- 0
|
93
81
|
version: 1.4.0
|
94
|
-
name: rest-client
|
95
|
-
requirement: *id005
|
96
|
-
- !ruby/object:Gem::Dependency
|
97
82
|
type: :runtime
|
98
83
|
prerelease: false
|
99
|
-
version_requirements:
|
84
|
+
version_requirements: *id006
|
85
|
+
- !ruby/object:Gem::Dependency
|
86
|
+
name: nokogiri
|
87
|
+
requirement: &id007 !ruby/object:Gem::Requirement
|
100
88
|
none: false
|
101
89
|
requirements:
|
102
90
|
- - ">="
|
103
91
|
- !ruby/object:Gem::Version
|
104
|
-
hash: 5
|
105
|
-
segments:
|
106
|
-
- 1
|
107
|
-
- 4
|
108
|
-
- 1
|
109
92
|
version: 1.4.1
|
110
|
-
|
111
|
-
|
93
|
+
type: :runtime
|
94
|
+
prerelease: false
|
95
|
+
version_requirements: *id007
|
112
96
|
description:
|
113
97
|
email: mark@mpercival.com
|
114
98
|
executables: []
|
@@ -251,9 +235,11 @@ files:
|
|
251
235
|
- lib/rturk/operations/get_qualifications_for_qualification_type.rb
|
252
236
|
- lib/rturk/operations/get_reviewable_hits.rb
|
253
237
|
- lib/rturk/operations/grant_bonus.rb
|
238
|
+
- lib/rturk/operations/grant_qualification.rb
|
254
239
|
- lib/rturk/operations/notify_workers.rb
|
255
240
|
- lib/rturk/operations/register_hit_type.rb
|
256
241
|
- lib/rturk/operations/reject_assignment.rb
|
242
|
+
- lib/rturk/operations/reject_qualification_request.rb
|
257
243
|
- lib/rturk/operations/revoke_qualification.rb
|
258
244
|
- lib/rturk/operations/search_hits.rb
|
259
245
|
- lib/rturk/operations/send_test_event_notification.rb
|
@@ -309,10 +295,12 @@ files:
|
|
309
295
|
- spec/fake_responses/get_qualifications_for_qualification_type.xml
|
310
296
|
- spec/fake_responses/get_reviewable_hits.xml
|
311
297
|
- spec/fake_responses/grant_bonus.xml
|
298
|
+
- spec/fake_responses/grant_qualification.xml
|
312
299
|
- spec/fake_responses/invalid_credentials.xml
|
313
300
|
- spec/fake_responses/notify_workers.xml
|
314
301
|
- spec/fake_responses/register_hit_type.xml
|
315
302
|
- spec/fake_responses/reject_assignment.xml
|
303
|
+
- spec/fake_responses/reject_qualification_request.xml
|
316
304
|
- spec/fake_responses/revoke_qualification.xml
|
317
305
|
- spec/fake_responses/search_hits.xml
|
318
306
|
- spec/fake_responses/unblock_worker.xml
|
@@ -337,9 +325,11 @@ files:
|
|
337
325
|
- spec/operations/get_qualifications_for_qualification_type_spec.rb
|
338
326
|
- spec/operations/get_reviewable_hits_spec.rb
|
339
327
|
- spec/operations/grant_bonus_spec.rb
|
328
|
+
- spec/operations/grant_qualification_spec.rb
|
340
329
|
- spec/operations/notify_workers_spec.rb
|
341
330
|
- spec/operations/register_hit_type_spec.rb
|
342
331
|
- spec/operations/reject_assignment_spec.rb
|
332
|
+
- spec/operations/reject_qualification_request_spec.rb
|
343
333
|
- spec/operations/revoke_qualification_spec.rb
|
344
334
|
- spec/operations/send_test_event_notification_spec.rb
|
345
335
|
- spec/operations/set_hit_type_notification_spec.rb
|
@@ -367,23 +357,17 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
367
357
|
requirements:
|
368
358
|
- - ">="
|
369
359
|
- !ruby/object:Gem::Version
|
370
|
-
hash: 3
|
371
|
-
segments:
|
372
|
-
- 0
|
373
360
|
version: "0"
|
374
361
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
375
362
|
none: false
|
376
363
|
requirements:
|
377
364
|
- - ">="
|
378
365
|
- !ruby/object:Gem::Version
|
379
|
-
hash: 3
|
380
|
-
segments:
|
381
|
-
- 0
|
382
366
|
version: "0"
|
383
367
|
requirements: []
|
384
368
|
|
385
369
|
rubyforge_project:
|
386
|
-
rubygems_version: 1.
|
370
|
+
rubygems_version: 1.6.2
|
387
371
|
signing_key:
|
388
372
|
specification_version: 3
|
389
373
|
summary: Mechanical Turk API Wrapper
|
@@ -416,9 +400,11 @@ test_files:
|
|
416
400
|
- spec/operations/get_qualifications_for_qualification_type_spec.rb
|
417
401
|
- spec/operations/get_reviewable_hits_spec.rb
|
418
402
|
- spec/operations/grant_bonus_spec.rb
|
403
|
+
- spec/operations/grant_qualification_spec.rb
|
419
404
|
- spec/operations/notify_workers_spec.rb
|
420
405
|
- spec/operations/register_hit_type_spec.rb
|
421
406
|
- spec/operations/reject_assignment_spec.rb
|
407
|
+
- spec/operations/reject_qualification_request_spec.rb
|
422
408
|
- spec/operations/revoke_qualification_spec.rb
|
423
409
|
- spec/operations/send_test_event_notification_spec.rb
|
424
410
|
- spec/operations/set_hit_type_notification_spec.rb
|