rturk 2.7.0 → 2.8.0
Sign up to get free protection for your applications and to get access to all the features.
- data/examples/create_hit.rb +1 -0
- data/lib/rturk.rb +1 -1
- data/lib/rturk/operations/get_assignment.rb +18 -0
- data/lib/rturk/parsers/responses/get_assignment_response.rb +12 -0
- data/lib/rturk/version.rb +1 -1
- data/spec/fake_responses/get_assignment.xml +64 -0
- data/spec/operations/get_assignment_spec.rb +35 -0
- metadata +5 -1
data/examples/create_hit.rb
CHANGED
data/lib/rturk.rb
CHANGED
@@ -0,0 +1,18 @@
|
|
1
|
+
module RTurk
|
2
|
+
class GetAssignment < Operation
|
3
|
+
require_params :assignment_id
|
4
|
+
attr_accessor :assignment_id
|
5
|
+
|
6
|
+
def parse(xml)
|
7
|
+
GetAssignmentResponse.new(xml)
|
8
|
+
end
|
9
|
+
|
10
|
+
def to_params
|
11
|
+
{'AssignmentId' => assignment_id}
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.GetAssignment(*args, &blk)
|
16
|
+
RTurk::GetAssignment.create(*args, &blk)
|
17
|
+
end
|
18
|
+
end
|
data/lib/rturk/version.rb
CHANGED
@@ -0,0 +1,64 @@
|
|
1
|
+
<?xml version="1.0"?>
|
2
|
+
<GetAssignmentResult>
|
3
|
+
<Request>
|
4
|
+
<IsValid>True</IsValid>
|
5
|
+
</Request>
|
6
|
+
<Assignment>
|
7
|
+
<AssignmentId>GYFTRHZ5J3DZREY48WNZE38ZR9RR1ZPMXGWE7WE0</AssignmentId>
|
8
|
+
<WorkerId>AD20WXZZP9XXK</WorkerId>
|
9
|
+
<HITId>GYFTRHZ5J3DZREY48WNZ</HITId>
|
10
|
+
<AssignmentStatus>Approved</AssignmentStatus>
|
11
|
+
<AutoApprovalTime>2012-08-12T19:21:54Z</AutoApprovalTime>
|
12
|
+
<AcceptTime>2012-07-13T19:21:40Z</AcceptTime>
|
13
|
+
<SubmitTime>2012-07-13T19:21:54Z</SubmitTime>
|
14
|
+
<ApprovalTime>2012-07-13T19:27:54Z</ApprovalTime>
|
15
|
+
<Answer>
|
16
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
17
|
+
<QuestionFormAnswers xmlns="http://mechanicalturk.amazonaws.com/AWSMechanicalTurkDataSchemas/2005-10-01/QuestionFormAnswers.xsd">
|
18
|
+
<Answer>
|
19
|
+
<QuestionIdentifier>Question100</QuestionIdentifier>
|
20
|
+
<FreeText>Move to X.</FreeText>
|
21
|
+
</Answer>
|
22
|
+
</QuestionFormAnswers>
|
23
|
+
</Answer>
|
24
|
+
</Assignment>
|
25
|
+
<HIT>
|
26
|
+
<HITId>GYFTRHZ5J3DZREY48WNZ</HITId>
|
27
|
+
<HITTypeId>NYVZTQ1QVKJZXCYZCZVZ</HITTypeId>
|
28
|
+
<CreationTime>2012-07-07T00:56:40Z</CreationTime>
|
29
|
+
<Title>Location</Title>
|
30
|
+
<Description>Answer this Question</Description>
|
31
|
+
<Question>
|
32
|
+
<QuestionForm xmlns="http://mechanicalturk.amazonaws.com/AWSMechanicalTurkDataSchemas/2005-10-01/QuestionForm.xsd">
|
33
|
+
<Question>
|
34
|
+
<QuestionIdentifier>Question100</QuestionIdentifier>
|
35
|
+
<DisplayName>My Question</DisplayName>
|
36
|
+
<IsRequired>true</IsRequired>
|
37
|
+
<QuestionContent>
|
38
|
+
<Binary>
|
39
|
+
<MimeType>
|
40
|
+
<Type>image</Type>
|
41
|
+
<SubType>gif</SubType>
|
42
|
+
</MimeType>
|
43
|
+
<DataURL>http://tictactoe.amazon.com/game/01523/board.gif</DataURL>
|
44
|
+
<AltText>The game board, with "X" to move.</AltText>
|
45
|
+
</Binary>
|
46
|
+
</QuestionContent>
|
47
|
+
<AnswerSpecification><FreeTextAnswer/></AnswerSpecification>
|
48
|
+
</Question>
|
49
|
+
</QuestionForm>
|
50
|
+
</Question>
|
51
|
+
<HITStatus>Assignable</HITStatus>
|
52
|
+
<MaxAssignments>1</MaxAssignments>
|
53
|
+
<Reward>
|
54
|
+
<Amount>5.00</Amount>
|
55
|
+
<CurrencyCode>USD</CurrencyCode>
|
56
|
+
<FormattedPrice>$5.00</FormattedPrice>
|
57
|
+
</Reward>
|
58
|
+
<AutoApprovalDelayInSeconds>2592000</AutoApprovalDelayInSeconds>
|
59
|
+
<Expiration>2012-07-14T00:56:40Z</Expiration>
|
60
|
+
<AssignmentDurationInSeconds>30</AssignmentDurationInSeconds>
|
61
|
+
<NumberOfSimilarHITs>1</NumberOfSimilarHITs>
|
62
|
+
<HITReviewStatus>NotReviewed</HITReviewStatus>
|
63
|
+
</HIT>
|
64
|
+
</GetAssignment>
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper'))
|
2
|
+
|
3
|
+
describe RTurk::GetAssignment do
|
4
|
+
before(:all) do
|
5
|
+
aws = YAML.load(File.open(File.join(SPEC_ROOT, 'mturk.yml')))
|
6
|
+
RTurk.setup(aws['AWSAccessKeyId'], aws['AWSAccessKey'], :sandbox => true)
|
7
|
+
end
|
8
|
+
|
9
|
+
it "should ensure required params" do
|
10
|
+
lambda{RTurk::GetAssignment()}.should raise_error RTurk::MissingParameters
|
11
|
+
end
|
12
|
+
|
13
|
+
it "should successfully request an assignment" do
|
14
|
+
RTurk::Requester.should_receive(:request).once.with(
|
15
|
+
hash_including('Operation' => 'GetAssignment'))
|
16
|
+
RTurk::GetAssignment(:assignment_id => "abcd") rescue RTurk::InvalidRequest
|
17
|
+
end
|
18
|
+
|
19
|
+
context "an HIT with one assignment" do
|
20
|
+
before(:all) do
|
21
|
+
WebMock.reset!
|
22
|
+
faker('get_assignment', :operation => 'GetAssignment')
|
23
|
+
end
|
24
|
+
|
25
|
+
it "should parse and return and answer" do
|
26
|
+
answers = RTurk::GetAssignment(:assignment_id => "abcd").assignment.answers
|
27
|
+
answers['Question100'].should eql("Move to X.")
|
28
|
+
end
|
29
|
+
|
30
|
+
it "should parse and return the hit" do
|
31
|
+
hit = RTurk::GetAssignment(:assignment_id => "abcd").hit
|
32
|
+
hit.title.should eql("Location")
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rturk
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.8.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -212,6 +212,7 @@ files:
|
|
212
212
|
- lib/rturk/operations/extend_hit.rb
|
213
213
|
- lib/rturk/operations/force_expire_hit.rb
|
214
214
|
- lib/rturk/operations/get_account_balance.rb
|
215
|
+
- lib/rturk/operations/get_assignment.rb
|
215
216
|
- lib/rturk/operations/get_assignments_for_hit.rb
|
216
217
|
- lib/rturk/operations/get_bonus_payments.rb
|
217
218
|
- lib/rturk/operations/get_hit.rb
|
@@ -244,6 +245,7 @@ files:
|
|
244
245
|
- lib/rturk/parsers/response.rb
|
245
246
|
- lib/rturk/parsers/responses/create_hit_response.rb
|
246
247
|
- lib/rturk/parsers/responses/get_account_balance_response.rb
|
248
|
+
- lib/rturk/parsers/responses/get_assignment_response.rb
|
247
249
|
- lib/rturk/parsers/responses/get_assignments_for_hit_response.rb
|
248
250
|
- lib/rturk/parsers/responses/get_bonus_payments_response.rb
|
249
251
|
- lib/rturk/parsers/responses/get_hit_response.rb
|
@@ -276,6 +278,7 @@ files:
|
|
276
278
|
- spec/fake_responses/extend_hit.xml
|
277
279
|
- spec/fake_responses/force_expire_hit.xml
|
278
280
|
- spec/fake_responses/get_account_balance.xml
|
281
|
+
- spec/fake_responses/get_assignment.xml
|
279
282
|
- spec/fake_responses/get_assignments.xml
|
280
283
|
- spec/fake_responses/get_assignments_multiple.xml
|
281
284
|
- spec/fake_responses/get_bonus_payments.xml
|
@@ -309,6 +312,7 @@ files:
|
|
309
312
|
- spec/operations/extend_hit_spec.rb
|
310
313
|
- spec/operations/force_expire_hit_spec.rb
|
311
314
|
- spec/operations/get_account_balance_spec.rb
|
315
|
+
- spec/operations/get_assignment_spec.rb
|
312
316
|
- spec/operations/get_assignments_spec.rb
|
313
317
|
- spec/operations/get_bonus_payments_spec.rb
|
314
318
|
- spec/operations/get_hit_spec.rb
|