rturk 2.11.3 → 2.12.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a8340134a49fa75d173bc34485ff52da8421200e
4
- data.tar.gz: 928921b6345bda869c5f06825389d3979fefa71b
3
+ metadata.gz: 2a5d40c077e746e2315f00c8886519a0d8b59600
4
+ data.tar.gz: 3008275723e4f5afb357d0109f67330c74290592
5
5
  SHA512:
6
- metadata.gz: 0d13326f34a04614d0053e70721f9a63b7a4a5c8f9ed76ad59cade6648f3b75e9feb282907b9c2a014f92b020dfd1aa6a5b50ddfeecd2175ad1e6d08f240e9d5
7
- data.tar.gz: 91975acfb39692b1b39c334dc29b389eb588c8abb4ae12b1b4eeebc40f49b0551c10505a5b1bb674795908ceaa3e80a0824d120a1dc8c2ecd2369a8982401292
6
+ metadata.gz: 836fbf1a3465e727b7e18e69c10caee29811d1ad6837e277b5d1fa414d2c1718445e7cb28bb6e5e8058b555dd67fcd1bd48e6f3b9b797b30cbea0bad91a9ff04
7
+ data.tar.gz: 1eeaf3d566060f401da4b38bcbc8509837a9a38c047fa6d015cd1fad3f4f9a98c3788c73f2b5c9e7da42c1992f4e7e039c6cd5c4b15da6d9d3b885162c8bfd99
@@ -1,3 +1,9 @@
1
+ 2.12.0
2
+ ---
3
+ * Add UpdateQualificationsScore [#41] [eggie5]
4
+ * Add GetQualificationScore [#42] [c0r0nel]
5
+ * Add AnswerKey Builder [#42] [c0r0nel]
6
+
1
7
  2.11.3
2
8
  ---
3
9
  * Fix erroneous variable [#32] [george-xing]
@@ -1,11 +1,20 @@
1
+ require 'cgi'
2
+ require 'uri'
1
3
  require "erector/xml_widget"
2
4
 
3
- # see http://docs.amazonwebservices.com/AWSMechTurk/2008-08-02/AWSMturkAPI/index.html?ApiReference_CreateQualificationTypeOperation.html
4
- class RTurk::AnswerKey < Erector::XMLWidget
5
+ module RTurk
6
+ # see http://docs.amazonwebservices.com/AWSMechTurk/2008-08-02/AWSMturkAPI/index.html?ApiReference_CreateQualificationTypeOperation.html
7
+ class AnswerKey < Erector::XMLWidget
5
8
 
6
- XMLNS = "http://mechanicalturk.amazonaws.com/AWSMechanicalTurkDataSchemas/2005-10-01/AnswerKey.xsd"
9
+ XMLNS = "http://mechanicalturk.amazonaws.com/AWSMechanicalTurkDataSchemas/2005-10-01/AnswerKey.xsd"
7
10
 
8
- %w{
11
+ needs :xml => nil
12
+
13
+ def to_params
14
+ to_xml #create a new output string and call 'content' via Erector
15
+ end
16
+
17
+ %w{
9
18
  AnswerKey
10
19
  Question
11
20
  QuestionIdentifier
@@ -24,16 +33,26 @@ class RTurk::AnswerKey < Erector::XMLWidget
24
33
  InclusiveUpperBound
25
34
  QualificationValue
26
35
  OutOfRangeQualificationValue
27
- }.uniq.each do |element_name|
28
- tag element_name
29
- tag element_name, :snake_case
30
- end
36
+ }.uniq.each do |element_name|
37
+ tag element_name
38
+ tag element_name, :snake_case unless element_name =='Text'
39
+ end
31
40
 
32
- def content
33
- answer_key :xmlns => XMLNS do
34
- answer_key_content
41
+ tag "Text", "text_element" # very sticky since 'text' is a core Erector method
42
+
43
+ def content
44
+ if @xml and @xml.strip =~ /^<AnswerKey/
45
+ rawtext @xml
46
+ else
47
+ answer_key :xmlns => XMLNS do
48
+ answer_key_content
49
+ end
50
+ end
35
51
  end
36
- end
37
52
 
53
+ def answer_key_content
54
+ rawtext @xml # by default, use the parameter
55
+ end
56
+ end
38
57
  end
39
58
 
@@ -0,0 +1,20 @@
1
+ # Operation to get info about qualification score
2
+
3
+ module RTurk
4
+ class GetQualificationScore < Operation
5
+ attr_accessor :qualification_type_id, :subject_id
6
+ require_params :qualification_type_id, :subject_id
7
+
8
+ def parse(xml)
9
+ RTurk::GetQualificationScoreResponse.new(xml)
10
+ end
11
+
12
+ def to_params
13
+ {'QualificationTypeId' => qualification_type_id, 'SubjectId' => subject_id}
14
+ end
15
+ end
16
+
17
+ def self.GetQualificationScore(*args)
18
+ RTurk::GetQualificationScore.create(*args)
19
+ end
20
+ end
@@ -0,0 +1,26 @@
1
+ # Operation to update a qualification score
2
+ # http://docs.aws.amazon.com/AWSMechTurk/latest/AWSMturkAPI/ApiReference_UpdateQualificationScoreOperation.html
3
+
4
+ module RTurk
5
+ class UpdateQualificationScore < Operation
6
+ attr_accessor :qualification_type_id, :qualification_type_score, :subject_id, :integer_value
7
+ require_params :qualification_type_id, :subject_id, :integer_value
8
+
9
+ def parse(xml)
10
+ RTurk::GetQualificationScoreResponse.new(xml)
11
+ end
12
+
13
+ def to_params
14
+ params = {
15
+ 'QualificationTypeId' => qualification_type_id,
16
+ 'SubjectId' => subject_id,
17
+ 'IntegerValue'=> integer_value
18
+ }
19
+ end
20
+ end
21
+
22
+ def self.UpdateQualificationScore(*args)
23
+ RTurk::UpdateQualificationScore.create(*args)
24
+ end
25
+ end
26
+
@@ -0,0 +1,28 @@
1
+ # Parses the GetQualificationType Response
2
+ #
3
+ # <GetQualificationScoreResult>
4
+ # <Qualification>
5
+ # <QualificationTypeId>789RVWYBAZW00EXAMPLE</QualificationTypeId>
6
+ # <SubjectId>AZ3456EXAMPLE</SubjectId>
7
+ # <GrantTime>2005-01-31T23:59:59Z</GrantTime>
8
+ # <IntegerValue>95</IntegerValue>
9
+ # </Qualification>
10
+ # </GetQualificationScoreResult>
11
+
12
+ module RTurk
13
+ class GetQualificationScoreResponse < Response
14
+ attr_reader :qualification_type_id, :grant_time, :subject_id, :integer_value
15
+
16
+ def initialize(response)
17
+ @raw_xml = response.body
18
+ @xml = Nokogiri::XML(@raw_xml)
19
+ map_content(@xml.xpath('//Qualification'),
20
+ :qualification_type_id => 'QualificationTypeId',
21
+ :subject_id => 'SubjectId',
22
+ :grant_time => 'GrantTime',
23
+ :integer_value => 'IntegerValue'
24
+ )
25
+
26
+ end
27
+ end
28
+ end
@@ -16,7 +16,7 @@ module RTurk
16
16
  end
17
17
 
18
18
  def qualifications
19
- @qualifications ||= []
19
+ @qualifications = []
20
20
  @xml.xpath('//Qualification').each do |qualification_xml|
21
21
  @qualifications << QualificationParser.new(qualification_xml)
22
22
  end
@@ -0,0 +1,14 @@
1
+ # Parses the GetQualificationType Response
2
+
3
+ module RTurk
4
+ class UpdateQualificationScoreResponse < Response
5
+ attr_reader :is_valid
6
+
7
+ def initialize(response)
8
+ @raw_xml = response.body
9
+ @xml = Nokogiri::XML(@raw_xml)
10
+ raise_errors
11
+ map_content(@xml.xpath('//QualificationScore'), :is_valid => 'IsValid')
12
+ end
13
+ end
14
+ end
@@ -1,3 +1,3 @@
1
1
  module RTurk
2
- VERSION = "2.11.3"
2
+ VERSION = "2.12.0"
3
3
  end
@@ -0,0 +1,8 @@
1
+ <GetQualificationScoreResult>
2
+ <Qualification>
3
+ <QualificationTypeId>789RVWYBAZW00EXAMPLE</QualificationTypeId>
4
+ <SubjectId>AZ3456EXAMPLE</SubjectId>
5
+ <GrantTime>2005-01-31T23:59:59Z</GrantTime>
6
+ <IntegerValue>95</IntegerValue>
7
+ </Qualification>
8
+ </GetQualificationScoreResult>
@@ -0,0 +1,6 @@
1
+ <UpdateQualificationScoreResult>
2
+ <Request>
3
+ <IsValid>True</IsValid>
4
+ </Request>
5
+ </UpdateQualificationScoreResult>
6
+
@@ -0,0 +1,44 @@
1
+ require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper'))
2
+
3
+ describe RTurk::GetQualificationScore 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
+ faker('get_qualification_score', :operation => 'GetQualificationScore')
8
+ end
9
+
10
+ it "should ensure required params" do
11
+ lambda{RTurk::GetQualificationScore()}.should raise_error RTurk::MissingParameters
12
+ end
13
+
14
+ it "should successfully request the operation" do
15
+ RTurk::Requester.should_receive(:request).once.with(
16
+ hash_including('Operation' => 'GetQualificationScore'))
17
+ RTurk::GetQualificationScore(:qualification_type_id => '789RVWYBAZW00EXAMPLE',
18
+ :subject_id => "ABCDEF1234") rescue RTurk::InvalidRequest
19
+ end
20
+
21
+ it "should parse and return the result" do
22
+ RTurk::GetQualificationScore(:qualification_type_id => '789RVWYBAZW00EXAMPLE',
23
+ :subject_id => "ABCDEF1234").elements.should eql(
24
+ {"GetQualificationScoreResult"=>
25
+ {
26
+ "Qualification" =>{
27
+ "QualificationTypeId" => "789RVWYBAZW00EXAMPLE",
28
+ "SubjectId" => "AZ3456EXAMPLE",
29
+ "GrantTime" => "2005-01-31T23:59:59Z",
30
+ "IntegerValue"=>"95"
31
+ }
32
+ }
33
+ })
34
+ end
35
+
36
+ it "should pull out the attributes" do
37
+ results = RTurk::GetQualificationScore(:qualification_type_id => '789RVWYBAZW00EXAMPLE',
38
+ :subject_id => "AZ3456EXAMPLE")
39
+ results.qualification_type_id.should eql('789RVWYBAZW00EXAMPLE')
40
+ results.subject_id.should eql('AZ3456EXAMPLE')
41
+ results.integer_value.should eql(95)
42
+ end
43
+ end
44
+
@@ -0,0 +1,29 @@
1
+ require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper'))
2
+
3
+ describe RTurk::UpdateQualificationScore 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
+ faker('update_qualification_score', :operation => 'UpdateQualificationScore')
8
+ end
9
+
10
+ it "should ensure required params" do
11
+ lambda{RTurk::UpdateQualificationScore()}.should raise_error RTurk::MissingParameters
12
+ end
13
+
14
+ it "should successfully request the operation" do
15
+ RTurk::Requester.should_receive(:request).once.with(
16
+ hash_including('Operation' => 'UpdateQualificationScore'))
17
+ RTurk::UpdateQualificationScore(:qualification_type_id => '789RVWYBAZW00EXAMPLE',
18
+ :subject_id => "ABCDEF1234",
19
+ :integer_value => 80) rescue RTurk::InvalidRequest
20
+ end
21
+
22
+ it "should parse and return the result" do
23
+ RTurk::UpdateQualificationScore(:qualification_type_id => '789RVWYBAZW00EXAMPLE',
24
+ :subject_id => "ABCDEF1234",
25
+ :integer_value => 80).elements.should eql(
26
+ {"UpdateQualificationScoreResult"=>{"Request"=>{"IsValid"=>"True"}}})
27
+ end
28
+ end
29
+
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.11.3
4
+ version: 2.12.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mark Percival
@@ -254,6 +254,7 @@ files:
254
254
  - lib/rturk/operations/get_bonus_payments.rb
255
255
  - lib/rturk/operations/get_hit.rb
256
256
  - lib/rturk/operations/get_qualification_requests.rb
257
+ - lib/rturk/operations/get_qualification_score.rb
257
258
  - lib/rturk/operations/get_qualification_type.rb
258
259
  - lib/rturk/operations/get_qualifications_for_qualification_type.rb
259
260
  - lib/rturk/operations/get_reviewable_hits.rb
@@ -270,6 +271,7 @@ files:
270
271
  - lib/rturk/operations/set_hit_as_reviewing.rb
271
272
  - lib/rturk/operations/set_hit_type_notification.rb
272
273
  - lib/rturk/operations/unblock_worker.rb
274
+ - lib/rturk/operations/update_qualification_score.rb
273
275
  - lib/rturk/operations/update_qualification_type.rb
274
276
  - lib/rturk/parser.rb
275
277
  - lib/rturk/parsers/answer_parser.rb
@@ -287,12 +289,14 @@ files:
287
289
  - lib/rturk/parsers/responses/get_bonus_payments_response.rb
288
290
  - lib/rturk/parsers/responses/get_hit_response.rb
289
291
  - lib/rturk/parsers/responses/get_qualification_requests_response.rb
292
+ - lib/rturk/parsers/responses/get_qualification_score_response.rb
290
293
  - lib/rturk/parsers/responses/get_qualification_type_response.rb
291
294
  - lib/rturk/parsers/responses/get_qualifications_for_qualification_type_response.rb
292
295
  - lib/rturk/parsers/responses/get_reviewable_hits_response.rb
293
296
  - lib/rturk/parsers/responses/register_hit_type_response.rb
294
297
  - lib/rturk/parsers/responses/search_hits_response.rb
295
298
  - lib/rturk/parsers/responses/search_qualification_types_response.rb
299
+ - lib/rturk/parsers/responses/update_qualification_score_response.rb
296
300
  - lib/rturk/requester.rb
297
301
  - lib/rturk/utilities.rb
298
302
  - lib/rturk/version.rb
@@ -327,6 +331,7 @@ files:
327
331
  - spec/fake_responses/get_bonus_payments.xml
328
332
  - spec/fake_responses/get_hit.xml
329
333
  - spec/fake_responses/get_qualification_requests.xml
334
+ - spec/fake_responses/get_qualification_score.xml
330
335
  - spec/fake_responses/get_qualification_type.xml
331
336
  - spec/fake_responses/get_qualifications_for_qualification_type.xml
332
337
  - spec/fake_responses/get_rejected_assignments.xml
@@ -344,6 +349,7 @@ files:
344
349
  - spec/fake_responses/search_qualification_types.xml
345
350
  - spec/fake_responses/set_hit_as_reviewing.xml
346
351
  - spec/fake_responses/unblock_worker.xml
352
+ - spec/fake_responses/update_qualification_score.xml
347
353
  - spec/fake_responses/update_qualification_type.xml
348
354
  - spec/mturk.yml
349
355
  - spec/operations/approve_assignment_spec.rb
@@ -363,6 +369,7 @@ files:
363
369
  - spec/operations/get_bonus_payments_spec.rb
364
370
  - spec/operations/get_hit_spec.rb
365
371
  - spec/operations/get_qualification_requests_spec.rb
372
+ - spec/operations/get_qualification_score_spec.rb
366
373
  - spec/operations/get_qualification_type_spec.rb
367
374
  - spec/operations/get_qualifications_for_qualification_type_spec.rb
368
375
  - spec/operations/get_reviewable_hits_spec.rb
@@ -378,6 +385,7 @@ files:
378
385
  - spec/operations/set_hit_as_reviewing_spec.rb
379
386
  - spec/operations/set_hit_type_notification_spec.rb
380
387
  - spec/operations/unblock_worker_spec.rb
388
+ - spec/operations/update_qualification_score_spec.rb
381
389
  - spec/operations/update_qualification_type_spec.rb
382
390
  - spec/parsers/answer_parser_spec.rb
383
391
  - spec/parsers/hit_parser_spec.rb