rturk 2.8.0 → 2.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,3 +1,12 @@
1
+ 2.8.0
2
+ ----
3
+ * Adding support for operation SearchQualificationTypes [hampei]
4
+ * Bumped to API version 2012-03-25
5
+ 2.7.0
6
+ ----
7
+ * Adding support for operation SearchQualificationTypes [denniskuczynski]
8
+ * Added ServiceUnavailable error type for detecting/handling HTTP
9
+ Service Unavailable errors [denniskuczynski]
1
10
  2.6.0
2
11
  -----
3
12
  * Adding IntegerValue attribute to AssignQualification from Ross
@@ -16,6 +16,10 @@ module RTurk
16
16
  RTurk::ApproveAssignment(:assignment_id => self.id, :feedback => feedback)
17
17
  end
18
18
 
19
+ def approve_rejected!(feedback = nil)
20
+ RTurk::ApproveRejectedAssignment(:assignment_id => self.id, :feedback => feedback)
21
+ end
22
+
19
23
  def reject!(reason)
20
24
  RTurk::RejectAssignment(:assignment_id => self.id, :feedback => reason)
21
25
  end
@@ -10,7 +10,7 @@ module RTurk
10
10
  :lte => 'LessThanOrEqualTo', :eql => 'EqualTo', :not => 'NotEqualTo', :exists => 'Exists'}
11
11
 
12
12
  TYPES = {:approval_rate => '000000000000000000L0', :submission_rate => '00000000000000000000',
13
- :abandoned_rate => '0000000000000000007', :return_rate => '000000000000000000E0',
13
+ :abandoned_rate => '00000000000000000070', :return_rate => '000000000000000000E0',
14
14
  :rejection_rate => '000000000000000000S0', :hits_approved => '00000000000000000040',
15
15
  :adult => '00000000000000000060', :country => '00000000000000000071'}
16
16
 
@@ -20,9 +20,9 @@ module RTurk
20
20
  # needs at the minimum
21
21
  # type_id, :comparator => :value
22
22
  # or
23
- # type_id, true
23
+ # type_id, :exists => true
24
24
  # or
25
- # type_id, :exists
25
+ # type_id, true
26
26
  #
27
27
  def initialize(type, opts)
28
28
  # If the value is a string, we can assume it's the country since,
@@ -39,7 +39,7 @@ module RTurk
39
39
  elsif opts == true || opts == false
40
40
  qualifier[:IntegerValue] = opts == true ? 1 : 0
41
41
  qualifier[:Comparator] = COMPARATORS[:eql]
42
- end
42
+ end
43
43
  qualifier
44
44
  end
45
45
 
@@ -68,7 +68,7 @@ module RTurk
68
68
  if v.to_s.match(/[A-Z]./)
69
69
  qualifier[:Country] = v
70
70
  else
71
- qualifier[:IntegerValue] = v
71
+ qualifier[:IntegerValue] = v unless k == :exists
72
72
  end
73
73
  end
74
74
  end
@@ -0,0 +1,16 @@
1
+ module RTurk
2
+ class ApproveRejectedAssignment < Operation
3
+
4
+ attr_accessor :assignment_id, :feedback
5
+ require_params :assignment_id
6
+
7
+ def to_params
8
+ {'AssignmentId' => self.assignment_id,
9
+ 'RequesterFeedback' => self.feedback}
10
+ end
11
+ end
12
+
13
+ def self.ApproveRejectedAssignment(*args)
14
+ RTurk::ApproveRejectedAssignment.create(*args)
15
+ end
16
+ end
@@ -48,11 +48,12 @@ module RTurk
48
48
  :expires_at, :assignments_duration, :reward_amount, :max_assignments,
49
49
  :auto_approval_delay, :description, :reward, :lifetime, :annotation,
50
50
  :similar_hits_count, :assignments_pending_count, :assignments_available_count,
51
- :assignments_completed_count
51
+ :assignments_completed_count, :question_external_url, :qualification_requirement_comparator,
52
+ :qualification_requirement_value
52
53
 
53
54
  def initialize(response)
54
55
  @raw_xml = response.body
55
- @xml = Nokogiri::XML(@raw_xml)
56
+ @xml = Nokogiri::XML(CGI.unescapeHTML(@raw_xml))
56
57
  raise_errors
57
58
  map_content(@xml.xpath('//HIT'),
58
59
  :hit_id => 'HITId',
@@ -74,7 +75,10 @@ module RTurk
74
75
  :similar_hits_count => 'NumberOfSimilarHITs',
75
76
  :assignments_pending_count => 'NumberOfAssignmentsPending',
76
77
  :assignments_available_count => 'NumberOfAssignmentsAvailable',
77
- :assignments_completed_count => 'NumberOfAssignmentsCompleted'
78
+ :assignments_completed_count => 'NumberOfAssignmentsCompleted',
79
+ :question_external_url => 'Question/*/*[1]',
80
+ :qualification_requirement_comparator => 'QualificationRequirement/Comparator',
81
+ :qualification_requirement_value => 'QualificationRequirement/IntegerValue'
78
82
  )
79
83
 
80
84
  @keywords = @keywords.split(', ') if @keywords
@@ -1,3 +1,3 @@
1
1
  module RTurk
2
- VERSION = "2.8.0"
2
+ VERSION = "2.9.0"
3
3
  end
@@ -4,10 +4,19 @@ describe RTurk::Assignment do
4
4
  describe "#bonus_payments" do
5
5
  it "should call GetBonusPayments with the assignment_id" do
6
6
  result = mock('result', :payments => [1, 2, 3])
7
- hit = RTurk::Assignment.new(123456)
7
+ assignment = RTurk::Assignment.new(123456)
8
8
  RTurk.should_receive(:GetBonusPayments).
9
9
  with(:assignment_id => 123456).and_return(result)
10
- hit.bonus_payments.should == result.payments
10
+ assignment.bonus_payments.should == result.payments
11
+ end
12
+ end
13
+
14
+ describe "#approve_rejected!" do
15
+ it "should call ApproveRejectedAssignment with assignment_id and optional feedback" do
16
+ RTurk.should_receive(:ApproveRejectedAssignment).
17
+ with(:assignment_id => 123456, :feedback => "abcde")
18
+ assignment = RTurk::Assignment.new(123456)
19
+ assignment.approve_rejected!("abcde")
11
20
  end
12
21
  end
13
22
  end
@@ -2,7 +2,7 @@ require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper'))
2
2
 
3
3
 
4
4
  describe RTurk::Qualifications do
5
-
5
+
6
6
  # Possible values coming back
7
7
  # {"QualificationTypeId","Comparator", "IntegerValue", "LocaleValue.Country","RequiredToPreview"}
8
8
 
@@ -21,21 +21,27 @@ describe RTurk::Qualifications do
21
21
  @qualification.to_params.should eql({"QualificationTypeId" => '000000000000000000L0',"Comparator" => 'GreaterThan',
22
22
  "IntegerValue" => 90, "RequiredToPreview" => 'false'})
23
23
  end
24
-
24
+
25
25
  it "should build a qualification for boolean qualification" do
26
26
  @qualification = RTurk::Qualification.new('00000000000000000060', true)
27
27
  @qualification.to_params.should eql({"QualificationTypeId" => '00000000000000000060',"Comparator" => 'EqualTo',
28
28
  "IntegerValue" => 1, "RequiredToPreview" => "true"})
29
29
  end
30
-
30
+
31
31
  it "should build a qualification for country qualification" do
32
32
  @qualification = RTurk::Qualification.new('00000000000000000071', :eql => 'PH')
33
33
  @qualification.to_params.should eql({"QualificationTypeId" => '00000000000000000071',"Comparator" => 'EqualTo',
34
34
  "LocaleValue.Country" => 'PH', "RequiredToPreview" => "true"})
35
35
  end
36
-
36
+
37
+ it "should build a qualification for existence qualification" do
38
+ @qualification = RTurk::Qualification.new('00000000000000000071', :exists => true)
39
+ @qualification.to_params.should eql({"QualificationTypeId" => '00000000000000000071',"Comparator" => 'Exists',
40
+ "RequiredToPreview" => "true"})
41
+ end
42
+
37
43
  context 'passing in symbols representing a TypeID' do
38
-
44
+
39
45
  it "should build a qualification for Approval rate" do
40
46
  @qualification = RTurk::Qualification.new(:approval_rate, :gt => 90)
41
47
  @qualification.to_params.should eql({"QualificationTypeId" => '000000000000000000L0',"Comparator" => 'GreaterThan',
@@ -53,7 +59,7 @@ describe RTurk::Qualifications do
53
59
  @qualification.to_params.should eql({"QualificationTypeId" => '00000000000000000071',"Comparator" => 'EqualTo',
54
60
  "LocaleValue.Country" => 'PH', "RequiredToPreview" => "true"})
55
61
  end
56
-
62
+
57
63
  end
58
64
 
59
65
  end
@@ -0,0 +1,6 @@
1
+ <ApproveRejectedAssignmentResult>
2
+ <Request>
3
+ <IsValid>True</IsValid>
4
+ </Request>
5
+ </ApproveRejectedAssignmentResult>
6
+
@@ -0,0 +1,28 @@
1
+ require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper'))
2
+
3
+ describe RTurk::ApproveRejectedAssignment 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('approve_rejected_assignment', :operation => 'ApproveRejectedAssignment')
9
+ end
10
+
11
+ it "should ensure required params" do
12
+ lambda{RTurk::ApproveRejectedAssignment()}.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' => 'ApproveRejectedAssignment'))
18
+ RTurk::ApproveRejectedAssignment(:assignment_id => "123456789") rescue RTurk::InvalidRequest
19
+ end
20
+
21
+ it "should parse and return the result" do
22
+ RTurk::ApproveRejectedAssignment(:assignment_id => "123456789").elements.should eql(
23
+ {"ApproveRejectedAssignmentResult"=>{"Request"=>{"IsValid"=>"True"}}}
24
+ )
25
+ end
26
+
27
+ end
28
+
@@ -11,6 +11,9 @@ describe RTurk::GetHIT do
11
11
  response.type_id.should eql('YGKZ2W5X6YFZ08ZRXXZZ')
12
12
  response.auto_approval_delay.should eql(3600)
13
13
  response.status.should eql('Reviewable')
14
+ response.question_external_url.should eql("http://s3.amazonaws.com/mpercival.com/newtweet.html?id=foo")
15
+ response.qualification_requirement_comparator.should eql("GreaterThan")
16
+ response.qualification_requirement_value.should eql(90)
14
17
  end
15
18
 
16
19
  it "should not specify the ResponseGroup by default" do
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.8.0
4
+ version: 2.9.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -202,6 +202,7 @@ files:
202
202
  - lib/rturk/macros.rb
203
203
  - lib/rturk/operation.rb
204
204
  - lib/rturk/operations/approve_assignment.rb
205
+ - lib/rturk/operations/approve_rejected_assignment.rb
205
206
  - lib/rturk/operations/assign_qualification.rb
206
207
  - lib/rturk/operations/block_worker.rb
207
208
  - lib/rturk/operations/create_hit.rb
@@ -268,6 +269,7 @@ files:
268
269
  - spec/builders/qualifications_spec.rb
269
270
  - spec/builders/question_spec.rb
270
271
  - spec/fake_responses/approve_assignment.xml
272
+ - spec/fake_responses/approve_rejected_assignment.xml
271
273
  - spec/fake_responses/assign_qualification.xml
272
274
  - spec/fake_responses/block_worker.xml
273
275
  - spec/fake_responses/create_hit.xml
@@ -302,6 +304,7 @@ files:
302
304
  - spec/fake_responses/update_qualification_type.xml
303
305
  - spec/mturk.sample.yml
304
306
  - spec/operations/approve_assignment_spec.rb
307
+ - spec/operations/approve_rejected_assignment_spec.rb
305
308
  - spec/operations/assign_qualification_spec.rb
306
309
  - spec/operations/block_worker_spec.rb
307
310
  - spec/operations/create_hit_spec.rb