typingpool 0.8.2 → 0.8.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -95,9 +95,11 @@ module Typingpool
95
95
  end
96
96
 
97
97
  def external_question_url=(noko_xml)
98
- if url = noko_xml.css('HIT Question eq|ExternalQuestion eq|ExternalURL', {'eq' => 'http://mechanicalturk.amazonaws.com/AWSMechanicalTurkDataSchemas/2006-07-14/ExternalQuestion.xsd'})[0].inner_text
99
- @external_question_url = url
100
- end
98
+ if node = noko_xml.css('HIT Question eq|ExternalQuestion eq|ExternalURL', {'eq' => 'http://mechanicalturk.amazonaws.com/AWSMechanicalTurkDataSchemas/2006-07-14/ExternalQuestion.xsd'})[0]
99
+ if url = node.inner_text
100
+ @external_question_url = url
101
+ end
102
+ end #if node =....
101
103
  end
102
104
  end #Full
103
105
  end #HIT
@@ -0,0 +1,49 @@
1
+ <?xml version="1.0"?>
2
+ <GetHITResponse>
3
+ <OperationRequest>
4
+ <RequestId>49341251-fcbd-45c3-ab98-8fbe2e4d8060</RequestId>
5
+ </OperationRequest>
6
+
7
+ <HIT>
8
+ <Request>
9
+ <IsValid>True</IsValid>
10
+ </Request>
11
+ <HITId>ZZRZPTY4ERDZWJ868JCZ</HITId>
12
+ <HITTypeId>NYVZTQ1QVKJZXCYZCZVZ</HITTypeId>
13
+ <CreationTime>2009-07-07T00:56:40Z</CreationTime>
14
+ <Title>Location</Title>
15
+ <Description>Select the image that best represents</Description>
16
+ <Question>
17
+ <QuestionForm xmlns="http://mechanicalturk.amazonaws.com/AWSMechanicalTurkDataSchemas/2005-10-01/QuestionForm.xsd">
18
+ <Question>
19
+ <QuestionIdentifier>Question100</QuestionIdentifier>
20
+ <DisplayName>My Question</DisplayName>
21
+ <IsRequired>true</IsRequired>
22
+ <QuestionContent>
23
+ <Binary>
24
+ <MimeType>
25
+ <Type>image</Type>
26
+ <SubType>gif</SubType>
27
+ </MimeType>
28
+ <DataURL>http://tictactoe.amazon.com/game/01523/board.gif</DataURL>
29
+ <AltText>The game board, with "X" to move.</AltText>
30
+ </Binary>
31
+ </QuestionContent>
32
+ <AnswerSpecification><FreeTextAnswer/></AnswerSpecification>
33
+ </Question>
34
+ </QuestionForm>
35
+ </Question>
36
+ <HITStatus>Assignable</HITStatus>
37
+ <MaxAssignments>1</MaxAssignments>
38
+ <Reward>
39
+ <Amount>5.00</Amount>
40
+ <CurrencyCode>USD</CurrencyCode>
41
+ <FormattedPrice>$5.00</FormattedPrice>
42
+ </Reward>
43
+ <AutoApprovalDelayInSeconds>2592000</AutoApprovalDelayInSeconds>
44
+ <Expiration>2009-07-14T00:56:40Z</Expiration>
45
+ <AssignmentDurationInSeconds>30</AssignmentDurationInSeconds>
46
+ <NumberOfSimilarHITs>1</NumberOfSimilarHITs>
47
+ <HITReviewStatus>NotReviewed</HITReviewStatus>
48
+ </HIT>
49
+ </GetHITResponse>
@@ -1,3 +1,3 @@
1
1
  module Typingpool
2
- VERSION = '0.8.2'
2
+ VERSION = '0.8.3'
3
3
  end #Typingpool
@@ -6,6 +6,8 @@ require 'typingpool'
6
6
  require 'typingpool/test'
7
7
  require 'uri'
8
8
  require 'cgi'
9
+ require 'rturk'
10
+ require 'ostruct'
9
11
 
10
12
  class TestAmazon < Typingpool::Test
11
13
 
@@ -34,7 +36,7 @@ class TestAmazon < Typingpool::Test
34
36
  end
35
37
 
36
38
  def test_amazon_hit_create
37
- with_dummy_hit_or_skip('test_amazon_hit_create') do |hit, config|
39
+ with_dummy_typingpool_hit_or_skip('test_amazon_hit_create') do |hit, config|
38
40
  assert_equal(hit.full.external_question_url, dummy_question.url)
39
41
  assert_equal(config.assign.deadline, hit.full.assignments_duration.to_i)
40
42
  assert(rturk_hit = hit.at_amazon)
@@ -48,7 +50,7 @@ class TestAmazon < Typingpool::Test
48
50
 
49
51
  #fails to test all_reviewable or all_approved - those require a VCR fixture (TODO)
50
52
  def test_amazon_hit_retrievers
51
- with_dummy_hit_or_skip('test_amazon_hit_retrievers') do |hit, config|
53
+ with_dummy_typingpool_hit_or_skip('test_amazon_hit_retrievers') do |hit, config|
52
54
  assert(result = Typingpool::Amazon::HIT.with_ids([hit.id]))
53
55
  assert_equal(1, result.count)
54
56
  assert_equal(hit.id, result.first.id)
@@ -65,7 +67,7 @@ class TestAmazon < Typingpool::Test
65
67
 
66
68
  #fails to properly test approved?, rejected?, submitted?, assignment - those require a VCR ficture (TODO)
67
69
  def test_amazon_hit_base
68
- with_dummy_hit_or_skip('test_amazon_hit_base') do |hit, config|
70
+ with_dummy_typingpool_hit_or_skip('test_amazon_hit_base') do |hit, config|
69
71
  assert_instance_of(Typingpool::Amazon::HIT, hit)
70
72
  assert_match(/\S/, hit.id)
71
73
  assert_match(/^http/i, hit.url)
@@ -84,7 +86,7 @@ class TestAmazon < Typingpool::Test
84
86
 
85
87
  #fails to test external_question* methods
86
88
  def test_amazon_hit_full
87
- with_dummy_hit_or_skip('test_amazon_hit_full') do |hit, config|
89
+ with_dummy_typingpool_hit_or_skip('test_amazon_hit_full') do |hit, config|
88
90
  assert(full = hit.full)
89
91
  assert_instance_of(Typingpool::Amazon::HIT::Full, full)
90
92
  [:id, :type_id].each{|attr| assert_match(/\S/, full.send(attr)) }
@@ -101,7 +103,7 @@ class TestAmazon < Typingpool::Test
101
103
  end
102
104
 
103
105
  def test_amazon_hit_full_fromsearchhits
104
- with_dummy_hit_or_skip('test_amazon_hit_full_fromsearchhits') do |hit, config|
106
+ with_dummy_typingpool_hit_or_skip('test_amazon_hit_full_fromsearchhits') do |hit, config|
105
107
  assert(full = hit.full)
106
108
  assert_instance_of(Typingpool::Amazon::HIT::Full, full)
107
109
  assert(hit2 = Typingpool::Amazon::HIT.all{|incoming_hit| incoming_hit.id == hit.id }.first)
@@ -113,6 +115,20 @@ class TestAmazon < Typingpool::Test
113
115
  end #with_dummy_hit_or_skip
114
116
  end
115
117
 
118
+ def test_handles_hits_without_external_question
119
+ assert(dummy_response_xml = File.read(File.join(fixtures_dir, 'gethitresponse.xml')))
120
+ dummy_http_response = OpenStruct.new
121
+ dummy_http_response.body = dummy_response_xml
122
+ assert(dummy_rturk_response = RTurk::GetHITResponse.new(dummy_http_response))
123
+ assert(rturk_hit = RTurk::Hit.new(dummy_rturk_response.hit_id, dummy_rturk_response))
124
+ assert(typingpool_full_hit = Typingpool::Amazon::HIT::Full.new(rturk_hit))
125
+ refute(typingpool_full_hit.external_question_url)
126
+ refute(typingpool_full_hit.external_question)
127
+ assert(typingpool_hit = Typingpool::Amazon::HIT.new(rturk_hit))
128
+ typingpool_hit.full(typingpool_full_hit)
129
+ refute(typingpool_hit.ours?)
130
+ end
131
+
116
132
  #Lacks test for HIT::Assignment - needs VCR fixture (TODO)
117
133
 
118
134
  def question_html
@@ -131,7 +147,8 @@ class TestAmazon < Typingpool::Test
131
147
  Typingpool::Amazon::HIT.create(dummy_question, config.assign)
132
148
  end
133
149
 
134
- def with_dummy_hit_or_skip(skipping_what)
150
+
151
+ def with_dummy_typingpool_hit_or_skip(skipping_what)
135
152
  config = self.config
136
153
  skip_if_no_amazon_credentials(skipping_what, config)
137
154
  config.assign.reward = '0.01'
metadata CHANGED
@@ -1,7 +1,8 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: typingpool
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.2
4
+ version: 0.8.3
5
+ prerelease:
5
6
  platform: ruby
6
7
  authors:
7
8
  - Ryan Tate
@@ -13,6 +14,7 @@ dependencies:
13
14
  - !ruby/object:Gem::Dependency
14
15
  name: rturk
15
16
  requirement: !ruby/object:Gem::Requirement
17
+ none: false
16
18
  requirements:
17
19
  - - ~>
18
20
  - !ruby/object:Gem::Version
@@ -20,6 +22,7 @@ dependencies:
20
22
  type: :runtime
21
23
  prerelease: false
22
24
  version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
23
26
  requirements:
24
27
  - - ~>
25
28
  - !ruby/object:Gem::Version
@@ -27,34 +30,39 @@ dependencies:
27
30
  - !ruby/object:Gem::Dependency
28
31
  name: highline
29
32
  requirement: !ruby/object:Gem::Requirement
33
+ none: false
30
34
  requirements:
31
- - - '>='
35
+ - - ! '>='
32
36
  - !ruby/object:Gem::Version
33
37
  version: '1.6'
34
38
  type: :runtime
35
39
  prerelease: false
36
40
  version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
37
42
  requirements:
38
- - - '>='
43
+ - - ! '>='
39
44
  - !ruby/object:Gem::Version
40
45
  version: '1.6'
41
46
  - !ruby/object:Gem::Dependency
42
47
  name: nokogiri
43
48
  requirement: !ruby/object:Gem::Requirement
49
+ none: false
44
50
  requirements:
45
- - - '>='
51
+ - - ! '>='
46
52
  - !ruby/object:Gem::Version
47
53
  version: '1.5'
48
54
  type: :runtime
49
55
  prerelease: false
50
56
  version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
51
58
  requirements:
52
- - - '>='
59
+ - - ! '>='
53
60
  - !ruby/object:Gem::Version
54
61
  version: '1.5'
55
62
  - !ruby/object:Gem::Dependency
56
63
  name: aws-sdk
57
64
  requirement: !ruby/object:Gem::Requirement
65
+ none: false
58
66
  requirements:
59
67
  - - ~>
60
68
  - !ruby/object:Gem::Version
@@ -62,6 +70,7 @@ dependencies:
62
70
  type: :runtime
63
71
  prerelease: false
64
72
  version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
65
74
  requirements:
66
75
  - - ~>
67
76
  - !ruby/object:Gem::Version
@@ -69,20 +78,23 @@ dependencies:
69
78
  - !ruby/object:Gem::Dependency
70
79
  name: net-sftp
71
80
  requirement: !ruby/object:Gem::Requirement
81
+ none: false
72
82
  requirements:
73
- - - '>='
83
+ - - ! '>='
74
84
  - !ruby/object:Gem::Version
75
85
  version: 2.0.5
76
86
  type: :runtime
77
87
  prerelease: false
78
88
  version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
79
90
  requirements:
80
- - - '>='
91
+ - - ! '>='
81
92
  - !ruby/object:Gem::Version
82
93
  version: 2.0.5
83
94
  - !ruby/object:Gem::Dependency
84
95
  name: minitest
85
96
  requirement: !ruby/object:Gem::Requirement
97
+ none: false
86
98
  requirements:
87
99
  - - ~>
88
100
  - !ruby/object:Gem::Version
@@ -90,6 +102,7 @@ dependencies:
90
102
  type: :development
91
103
  prerelease: false
92
104
  version_requirements: !ruby/object:Gem::Requirement
105
+ none: false
93
106
  requirements:
94
107
  - - ~>
95
108
  - !ruby/object:Gem::Version
@@ -97,29 +110,33 @@ dependencies:
97
110
  - !ruby/object:Gem::Dependency
98
111
  name: vcr
99
112
  requirement: !ruby/object:Gem::Requirement
113
+ none: false
100
114
  requirements:
101
- - - '>='
115
+ - - ! '>='
102
116
  - !ruby/object:Gem::Version
103
117
  version: '0'
104
118
  type: :development
105
119
  prerelease: false
106
120
  version_requirements: !ruby/object:Gem::Requirement
121
+ none: false
107
122
  requirements:
108
- - - '>='
123
+ - - ! '>='
109
124
  - !ruby/object:Gem::Version
110
125
  version: '0'
111
126
  - !ruby/object:Gem::Dependency
112
127
  name: webmock
113
128
  requirement: !ruby/object:Gem::Requirement
129
+ none: false
114
130
  requirements:
115
- - - '>='
131
+ - - ! '>='
116
132
  - !ruby/object:Gem::Version
117
133
  version: '0'
118
134
  type: :development
119
135
  prerelease: false
120
136
  version_requirements: !ruby/object:Gem::Requirement
137
+ none: false
121
138
  requirements:
122
- - - '>='
139
+ - - ! '>='
123
140
  - !ruby/object:Gem::Version
124
141
  version: '0'
125
142
  description: An app for transcribing audio using Mechanical Turk
@@ -207,6 +224,7 @@ files:
207
224
  - lib/typingpool/test/fixtures/audio/wma/VN620052.WMA
208
225
  - lib/typingpool/test/fixtures/config-1
209
226
  - lib/typingpool/test/fixtures/config-2
227
+ - lib/typingpool/test/fixtures/gethitresponse.xml
210
228
  - lib/typingpool/test/fixtures/not_yaml.txt
211
229
  - lib/typingpool/test/fixtures/template-2.html.erb
212
230
  - lib/typingpool/test/fixtures/template-3.html.erb
@@ -255,19 +273,20 @@ files:
255
273
  - typingpool.gemspec
256
274
  homepage: http://github.com/ryantate/typingpool
257
275
  licenses: []
258
- metadata: {}
259
276
  post_install_message:
260
277
  rdoc_options: []
261
278
  require_paths:
262
279
  - lib
263
280
  required_ruby_version: !ruby/object:Gem::Requirement
281
+ none: false
264
282
  requirements:
265
- - - '>='
283
+ - - ! '>='
266
284
  - !ruby/object:Gem::Version
267
285
  version: 1.9.2
268
286
  required_rubygems_version: !ruby/object:Gem::Requirement
287
+ none: false
269
288
  requirements:
270
- - - '>='
289
+ - - ! '>='
271
290
  - !ruby/object:Gem::Version
272
291
  version: '0'
273
292
  requirements:
@@ -275,9 +294,9 @@ requirements:
275
294
  - mp3splt
276
295
  - mp3wrap
277
296
  rubyforge_project:
278
- rubygems_version: 2.0.3
297
+ rubygems_version: 1.8.25
279
298
  signing_key:
280
- specification_version: 4
299
+ specification_version: 3
281
300
  summary: An app for transcribing audio using Mechanical Turk
282
301
  test_files:
283
302
  - test/test_unit_amazon.rb
checksums.yaml DELETED
@@ -1,7 +0,0 @@
1
- ---
2
- SHA1:
3
- metadata.gz: eb6abdc9b9f07ff9c24adaa0304a9aed90619e3b
4
- data.tar.gz: a6d2d4f6de6ea82bec54e8a026b899257979d2d8
5
- SHA512:
6
- metadata.gz: 75c33b151d88e38bfb12b37751c3a8a8deaa9de91ed40971927e5d095a56d905c1841f160148b9f4f55000921e860436b198dd07240c7ca850ebe64b20ab12cd
7
- data.tar.gz: c1593d3a0aeb1755723bf4d8f1289a8803b69d985f7675a1eeef74d568f8acabdffa37e754bbb6e275923889c07049e2ff53ed4a79174cab2d723aa17095164f