rturk 2.10.3 → 2.11.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,64 @@
1
+ <Overview>
2
+ <Title>Game 01523, "X" to play</Title>
3
+ <Text>
4
+ You are helping to decide the next move in a game of Tic-Tac-Toe. The board looks like this:
5
+ </Text>
6
+ <Binary>
7
+ <MimeType>
8
+ <Type>image</Type>
9
+ <SubType>gif</SubType>
10
+ </MimeType>
11
+ <DataURL>http://tictactoe.amazon.com/game/01523/board.gif</DataURL>
12
+ <AltText>The game board, with "X" to move.</AltText>
13
+ </Binary>
14
+ <Text>
15
+ Player "X" has the next move.
16
+ </Text>
17
+ </Overview>
18
+ <Question>
19
+ <QuestionIdentifier>nextmove</QuestionIdentifier>
20
+ <DisplayName>The Next Move</DisplayName>
21
+ <IsRequired>true</IsRequired>
22
+ <QuestionContent>
23
+ <Text>
24
+ What are the coordinates of the best move for player "X" in this game?
25
+ </Text>
26
+ </QuestionContent>
27
+ <AnswerSpecification>
28
+ <FreeTextAnswer>
29
+ <Constraints>
30
+ <Length minLength="2" maxLength="2" />
31
+ </Constraints>
32
+ <DefaultText>C1</DefaultText>
33
+ </FreeTextAnswer>
34
+ </AnswerSpecification>
35
+ </Question>
36
+ <Question>
37
+ <QuestionIdentifier>likelytowin</QuestionIdentifier>
38
+ <DisplayName>The Next Move</DisplayName>
39
+ <IsRequired>true</IsRequired>
40
+ <QuestionContent>
41
+ <Text>
42
+ How likely is it that player "X" will win this game?
43
+ </Text>
44
+ </QuestionContent>
45
+ <AnswerSpecification>
46
+ <SelectionAnswer>
47
+ <StyleSuggestion>radiobutton</StyleSuggestion>
48
+ <Selections>
49
+ <Selection>
50
+ <SelectionIdentifier>notlikely</SelectionIdentifier>
51
+ <Text>Not likely</Text>
52
+ </Selection>
53
+ <Selection>
54
+ <SelectionIdentifier>unsure</SelectionIdentifier>
55
+ <Text>It could go either way</Text>
56
+ </Selection>
57
+ <Selection>
58
+ <SelectionIdentifier>likely</SelectionIdentifier>
59
+ <Text>Likely</Text>
60
+ </Selection>
61
+ </Selections>
62
+ </SelectionAnswer>
63
+ </AnswerSpecification>
64
+ </Question>
@@ -12,20 +12,37 @@ describe "using mechanical turk with RTurk" do
12
12
 
13
13
  it "should let me build and send a hit" do
14
14
  hit = RTurk::CreateHIT.new(:title => "Look at some pictures from 4Chan") do |hit|
15
- hit.assignments = 5
15
+ hit.max_assignments = 5
16
16
  hit.description = 'blah'
17
17
  hit.question("http://mpercival.com", :frame_height => 600)
18
18
  hit.reward = 0.05
19
19
  hit.qualifications.add :approval_rate, {:gt => 80}
20
20
  end
21
- hit.assignments.should eql(5)
21
+ hit.max_assignments.should eql(5)
22
+ response = hit.request
23
+ response.hit_id.should_not be_nil
24
+ end
25
+
26
+ it "should fail if I don't provide required params" do
27
+ lambda do
28
+ hit = RTurk::CreateHIT.new(:title => "Look at some pictures from 4Chan")
29
+ hit.request
30
+ end.should raise_error "Parameters: 'description, reward, question'" # Rspec is being too clever here
31
+ end
32
+
33
+ it "should let me build and send a hit with mostly default values" do
34
+ hit = RTurk::CreateHIT.new(:title => "Look at some pictures from 4Chan") do |hit|
35
+ hit.description = 'blah'
36
+ hit.question("http://mpercival.com", :frame_height => 600)
37
+ hit.reward = 0.05
38
+ end
22
39
  response = hit.request
23
40
  response.hit_id.should_not be_nil
24
41
  end
25
42
 
26
43
  it "should let me create a hit" do
27
44
  response = RTurk::CreateHIT(:title => "Look at some pictures from 4Chan") do |hit|
28
- hit.assignments = 5
45
+ hit.max_assignments = 5
29
46
  hit.description = 'blah'
30
47
  hit.question("http://mpercival.com", :test => 'b')
31
48
  hit.reward = 0.05
@@ -37,7 +54,7 @@ describe "using mechanical turk with RTurk" do
37
54
  it "should let me create a hit with just option arguments" do
38
55
  hit = RTurk::CreateHIT.new(:title => "Look at some pictures from 4Chan",
39
56
  :description => "Pics from the b-tards",
40
- :assignments => 5,
57
+ :max_assignments => 5,
41
58
  :reward => nil,
42
59
  :question => 'http://mpercival.com?picture=1',
43
60
  :qualifications => [
@@ -45,14 +62,14 @@ describe "using mechanical turk with RTurk" do
45
62
  [:adult, true]
46
63
  ]
47
64
  )
48
- hit.assignments.should eql(5)
65
+ hit.max_assignments.should eql(5)
49
66
  hit.qualifications.qualifications.size.should eql(2)
50
67
  lambda{hit.request}.should raise_error RTurk::MissingParameters
51
68
  end
52
69
 
53
70
  it "should rerturn a CreateHITResponse after the request" do
54
71
  response = RTurk::CreateHIT(:title => "Look at some pictures from 4Chan") do |hit|
55
- hit.assignments = 5
72
+ hit.max_assignments = 5
56
73
  hit.description = "foo"
57
74
  hit.question("http://mpercival.com", :test => 'b')
58
75
  hit.reward = 0.05
@@ -63,4 +80,14 @@ describe "using mechanical turk with RTurk" do
63
80
  response.type_id.should == 'NYVZTQ1QVKJZXCYZCZVZ'
64
81
  end
65
82
 
83
+ it "should let me build and send a hit with an internal question" do
84
+ hit = RTurk::CreateHIT.new(:title => "Who is your favorite Beatle?") do |hit|
85
+ hit.description = 'blah'
86
+ hit.reward = 0.05
87
+ hit.question_form ExampleQuestionForm.new
88
+ end
89
+ response = hit.request
90
+ response.hit_id.should_not be_nil
91
+ end
92
+
66
93
  end
@@ -13,6 +13,14 @@ describe RTurk::Requester do
13
13
  RTurk::Requester.request(:Operation => 'GetHIT', 'HITId' => 'test')
14
14
  end
15
15
 
16
+ it "should use UTC and ISO8601 format for the timestamp" do
17
+ now = Time.now
18
+ utc = now.utc
19
+ Time.should_receive(:now).and_return(now) # freeze time for a moment
20
+ RestClient.should_receive(:post).with(/amazonaws/, /Timestamp=#{CGI.escape(utc.iso8601)}/)
21
+ RTurk::Requester.request(:Operation => 'GetHIT', 'HITId' => 'test')
22
+ end
23
+
16
24
  it "should build a correct querystring with one value per key" do
17
25
  params = {
18
26
  :Operation => 'GetHIT',
data/spec/spec_helper.rb CHANGED
@@ -1,6 +1,7 @@
1
1
  SPEC_ROOT = File.expand_path(File.dirname(__FILE__)) unless defined? SPEC_ROOT
2
2
  $: << SPEC_ROOT
3
- $: << File.join(File.dirname(__FILE__), '..', 'lib')
3
+ $: << File.join(SPEC_ROOT, '..', 'lib')
4
+
4
5
  require 'rubygems'
5
6
  require 'spec'
6
7
  require 'yaml'
@@ -35,3 +36,5 @@ end
35
36
  Spec::Runner.configure do |config|
36
37
 
37
38
  end
39
+
40
+ require 'example_question_form'
metadata CHANGED
@@ -1,15 +1,9 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: rturk
3
- version: !ruby/object:Gem::Version
4
- hash: 33
5
- prerelease:
6
- segments:
7
- - 2
8
- - 10
9
- - 3
10
- version: 2.10.3
3
+ version: !ruby/object:Gem::Version
4
+ version: 2.11.0
11
5
  platform: ruby
12
- authors:
6
+ authors:
13
7
  - Mark Percival
14
8
  - Zach Hale
15
9
  - David Balatero
@@ -17,112 +11,117 @@ authors:
17
11
  autorequire:
18
12
  bindir: bin
19
13
  cert_chain: []
20
-
21
- date: 2013-08-19 00:00:00 +00:00
22
- default_executable:
23
- dependencies:
24
- - !ruby/object:Gem::Dependency
14
+ date: 2013-08-19 00:00:00.000000000 Z
15
+ dependencies:
16
+ - !ruby/object:Gem::Dependency
25
17
  name: rest-client
26
- prerelease: false
27
- requirement: &id001 !ruby/object:Gem::Requirement
28
- none: false
29
- requirements:
30
- - - "="
31
- - !ruby/object:Gem::Version
32
- hash: 1
33
- segments:
34
- - 1
35
- - 6
36
- - 7
37
- version: 1.6.7
18
+ requirement: !ruby/object:Gem::Requirement
19
+ requirements:
20
+ - - '>='
21
+ - !ruby/object:Gem::Version
22
+ version: '0'
38
23
  type: :runtime
39
- version_requirements: *id001
40
- - !ruby/object:Gem::Dependency
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
30
+ - !ruby/object:Gem::Dependency
41
31
  name: nokogiri
32
+ requirement: !ruby/object:Gem::Requirement
33
+ requirements:
34
+ - - '>='
35
+ - !ruby/object:Gem::Version
36
+ version: '0'
37
+ type: :runtime
42
38
  prerelease: false
43
- requirement: &id002 !ruby/object:Gem::Requirement
44
- none: false
45
- requirements:
46
- - - "="
47
- - !ruby/object:Gem::Version
48
- hash: 23
49
- segments:
50
- - 1
51
- - 5
52
- - 10
53
- version: 1.5.10
39
+ version_requirements: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - '>='
42
+ - !ruby/object:Gem::Version
43
+ version: '0'
44
+ - !ruby/object:Gem::Dependency
45
+ name: erector
46
+ requirement: !ruby/object:Gem::Requirement
47
+ requirements:
48
+ - - '>='
49
+ - !ruby/object:Gem::Version
50
+ version: '0'
54
51
  type: :runtime
55
- version_requirements: *id002
56
- - !ruby/object:Gem::Dependency
57
- name: rspec
58
52
  prerelease: false
59
- requirement: &id003 !ruby/object:Gem::Requirement
60
- none: false
61
- requirements:
53
+ version_requirements: !ruby/object:Gem::Requirement
54
+ requirements:
55
+ - - '>='
56
+ - !ruby/object:Gem::Version
57
+ version: '0'
58
+ - !ruby/object:Gem::Dependency
59
+ name: rspec
60
+ requirement: !ruby/object:Gem::Requirement
61
+ requirements:
62
62
  - - ~>
63
- - !ruby/object:Gem::Version
64
- hash: 25
65
- segments:
66
- - 1
67
- - 3
68
- - 1
63
+ - !ruby/object:Gem::Version
69
64
  version: 1.3.1
70
65
  type: :development
71
- version_requirements: *id003
72
- - !ruby/object:Gem::Dependency
73
- name: rake
74
66
  prerelease: false
75
- requirement: &id004 !ruby/object:Gem::Requirement
76
- none: false
77
- requirements:
78
- - - ">="
79
- - !ruby/object:Gem::Version
80
- hash: 3
81
- segments:
82
- - 0
83
- version: "0"
67
+ version_requirements: !ruby/object:Gem::Requirement
68
+ requirements:
69
+ - - ~>
70
+ - !ruby/object:Gem::Version
71
+ version: 1.3.1
72
+ - !ruby/object:Gem::Dependency
73
+ name: rake
74
+ requirement: !ruby/object:Gem::Requirement
75
+ requirements:
76
+ - - '>='
77
+ - !ruby/object:Gem::Version
78
+ version: '0'
84
79
  type: :development
85
- version_requirements: *id004
86
- - !ruby/object:Gem::Dependency
87
- name: rdoc
88
80
  prerelease: false
89
- requirement: &id005 !ruby/object:Gem::Requirement
90
- none: false
91
- requirements:
92
- - - ">="
93
- - !ruby/object:Gem::Version
94
- hash: 3
95
- segments:
96
- - 0
97
- version: "0"
81
+ version_requirements: !ruby/object:Gem::Requirement
82
+ requirements:
83
+ - - '>='
84
+ - !ruby/object:Gem::Version
85
+ version: '0'
86
+ - !ruby/object:Gem::Dependency
87
+ name: rdoc
88
+ requirement: !ruby/object:Gem::Requirement
89
+ requirements:
90
+ - - '>='
91
+ - !ruby/object:Gem::Version
92
+ version: '0'
98
93
  type: :development
99
- version_requirements: *id005
100
- - !ruby/object:Gem::Dependency
101
- name: webmock
102
94
  prerelease: false
103
- requirement: &id006 !ruby/object:Gem::Requirement
104
- none: false
105
- requirements:
106
- - - ">="
107
- - !ruby/object:Gem::Version
108
- hash: 3
109
- segments:
110
- - 0
111
- version: "0"
95
+ version_requirements: !ruby/object:Gem::Requirement
96
+ requirements:
97
+ - - '>='
98
+ - !ruby/object:Gem::Version
99
+ version: '0'
100
+ - !ruby/object:Gem::Dependency
101
+ name: webmock
102
+ requirement: !ruby/object:Gem::Requirement
103
+ requirements:
104
+ - - '>='
105
+ - !ruby/object:Gem::Version
106
+ version: '0'
112
107
  type: :development
113
- version_requirements: *id006
108
+ prerelease: false
109
+ version_requirements: !ruby/object:Gem::Requirement
110
+ requirements:
111
+ - - '>='
112
+ - !ruby/object:Gem::Version
113
+ version: '0'
114
114
  description:
115
115
  email: mk@mdp.im
116
116
  executables: []
117
-
118
117
  extensions: []
119
-
120
- extra_rdoc_files:
118
+ extra_rdoc_files:
121
119
  - LICENSE
122
120
  - README.markdown
123
- files:
121
+ files:
124
122
  - .gitignore
125
123
  - .gitmodules
124
+ - .rspec
126
125
  - .travis.yml
127
126
  - .yardoc
128
127
  - CHANGELOG.markdown
@@ -228,10 +227,12 @@ files:
228
227
  - lib/rturk/adapters/assignment.rb
229
228
  - lib/rturk/adapters/hit.rb
230
229
  - lib/rturk/adapters/worker.rb
230
+ - lib/rturk/builders/answer_key_builder.rb
231
+ - lib/rturk/builders/external_question_builder.rb
231
232
  - lib/rturk/builders/notification_builder.rb
232
233
  - lib/rturk/builders/qualification_builder.rb
233
234
  - lib/rturk/builders/qualifications_builder.rb
234
- - lib/rturk/builders/question_builder.rb
235
+ - lib/rturk/builders/question_form_builder.rb
235
236
  - lib/rturk/errors.rb
236
237
  - lib/rturk/logger.rb
237
238
  - lib/rturk/macros.rb
@@ -299,10 +300,14 @@ files:
299
300
  - rturk.gemspec
300
301
  - spec/adapters/assignment_spec.rb
301
302
  - spec/adapters/hit_spec.rb
303
+ - spec/builders/answer_key_builder_spec.rb
304
+ - spec/builders/external_question_spec.rb
302
305
  - spec/builders/notification_builder_spec.rb
303
306
  - spec/builders/qualification_spec.rb
304
307
  - spec/builders/qualifications_spec.rb
305
- - spec/builders/question_spec.rb
308
+ - spec/builders/question_form_builder_spec.rb
309
+ - spec/example_question_form.rb
310
+ - spec/example_question_form.xml
306
311
  - spec/fake_responses/approve_assignment.xml
307
312
  - spec/fake_responses/approve_rejected_assignment.xml
308
313
  - spec/fake_responses/assign_qualification.xml
@@ -384,39 +389,27 @@ files:
384
389
  - spec/spec_helper.rb
385
390
  - spec/tmp
386
391
  - spec/xml_parse_spec.rb
387
- has_rdoc: true
388
392
  homepage: http://github.com/mdp/rturk
389
393
  licenses: []
390
-
394
+ metadata: {}
391
395
  post_install_message:
392
396
  rdoc_options: []
393
-
394
- require_paths:
397
+ require_paths:
395
398
  - lib
396
- required_ruby_version: !ruby/object:Gem::Requirement
397
- none: false
398
- requirements:
399
- - - ">="
400
- - !ruby/object:Gem::Version
401
- hash: 3
402
- segments:
403
- - 0
404
- version: "0"
405
- required_rubygems_version: !ruby/object:Gem::Requirement
406
- none: false
407
- requirements:
408
- - - ">="
409
- - !ruby/object:Gem::Version
410
- hash: 3
411
- segments:
412
- - 0
413
- version: "0"
399
+ required_ruby_version: !ruby/object:Gem::Requirement
400
+ requirements:
401
+ - - '>='
402
+ - !ruby/object:Gem::Version
403
+ version: '0'
404
+ required_rubygems_version: !ruby/object:Gem::Requirement
405
+ requirements:
406
+ - - '>='
407
+ - !ruby/object:Gem::Version
408
+ version: '0'
414
409
  requirements: []
415
-
416
410
  rubyforge_project: pulley
417
- rubygems_version: 1.6.2
411
+ rubygems_version: 2.0.2
418
412
  signing_key:
419
- specification_version: 3
413
+ specification_version: 4
420
414
  summary: Mechanical Turk API Wrapper
421
415
  test_files: []
422
-