rturk 2.3.2 → 2.3.3
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/lib/rturk/adapters/hit.rb +4 -2
- data/lib/rturk/operations/get_hit.rb +17 -5
- data/lib/rturk/parsers/responses/get_hit_response.rb +8 -6
- data/lib/rturk/requester.rb +4 -0
- data/rturk.gemspec +2 -2
- data/spec/adapters/hit_spec.rb +13 -0
- data/spec/operations/get_hit_spec.rb +14 -1
- data/spec/requester_spec.rb +12 -1
- metadata +4 -4
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.3.
|
1
|
+
2.3.3
|
data/lib/rturk/adapters/hit.rb
CHANGED
@@ -55,8 +55,9 @@ module RTurk
|
|
55
55
|
|
56
56
|
attr_accessor :id, :source
|
57
57
|
|
58
|
-
def initialize(id, source = nil)
|
58
|
+
def initialize(id, source = nil, options={})
|
59
59
|
@id, @source = id, source
|
60
|
+
@include_assignment_summary = options[:include_assignment_summary]
|
60
61
|
end
|
61
62
|
|
62
63
|
# memoing
|
@@ -68,7 +69,8 @@ module RTurk
|
|
68
69
|
end
|
69
70
|
|
70
71
|
def details
|
71
|
-
@details ||= RTurk::GetHIT(:hit_id => self.id
|
72
|
+
@details ||= RTurk::GetHIT(:hit_id => self.id,
|
73
|
+
:include_assignment_summary => !!@include_assignment_summary)
|
72
74
|
end
|
73
75
|
|
74
76
|
def extend!(options = {})
|
@@ -2,17 +2,29 @@ module RTurk
|
|
2
2
|
class GetHIT < Operation
|
3
3
|
|
4
4
|
require_params :hit_id
|
5
|
-
attr_accessor :hit_id
|
6
|
-
|
5
|
+
attr_accessor :hit_id, :include_assignment_summary
|
6
|
+
|
7
7
|
def parse(xml)
|
8
8
|
RTurk::GetHITResponse.new(xml)
|
9
9
|
end
|
10
|
-
|
10
|
+
|
11
11
|
def to_params
|
12
|
-
{"HITId" => self.hit_id}
|
12
|
+
params = {"HITId" => self.hit_id}
|
13
|
+
|
14
|
+
if @include_assignment_summary
|
15
|
+
params["ResponseGroup"] = {
|
16
|
+
0 => "HITDetail", # default
|
17
|
+
1 => "HITQuestion", # default
|
18
|
+
2 => "Minimal", # default
|
19
|
+
3 => "HITAssignmentSummary" # added
|
20
|
+
}
|
21
|
+
end
|
22
|
+
|
23
|
+
params
|
13
24
|
end
|
14
|
-
|
25
|
+
|
15
26
|
end
|
27
|
+
|
16
28
|
def self.GetHIT(*args, &blk)
|
17
29
|
RTurk::GetHIT.create(*args, &blk)
|
18
30
|
end
|
@@ -44,9 +44,11 @@
|
|
44
44
|
|
45
45
|
module RTurk
|
46
46
|
class GetHITResponse < Response
|
47
|
-
attr_reader :hit_id, :type_id, :status, :review_status, :title, :created_at,
|
48
|
-
:assignments_duration, :reward_amount, :max_assignments,
|
49
|
-
:
|
47
|
+
attr_reader :hit_id, :type_id, :keywords, :status, :review_status, :title, :created_at,
|
48
|
+
:expires_at, :assignments_duration, :reward_amount, :max_assignments,
|
49
|
+
:auto_approval_delay, :description, :reward, :lifetime, :annotation,
|
50
|
+
:similar_hits_count, :assignments_pending_count, :assignments_available_count,
|
51
|
+
:assignments_completed_count
|
50
52
|
|
51
53
|
def initialize(response)
|
52
54
|
@raw_xml = response.body
|
@@ -70,9 +72,9 @@ module RTurk
|
|
70
72
|
:lifetime => 'LifetimeInSeconds',
|
71
73
|
:annotation => 'RequesterAnnotation',
|
72
74
|
:similar_hits_count => 'NumberOfSimilarHITs',
|
73
|
-
:assignments_pending_count => '
|
74
|
-
:assignments_available_count => '
|
75
|
-
:assignments_completed_count => '
|
75
|
+
:assignments_pending_count => 'NumberOfAssignmentsPending',
|
76
|
+
:assignments_available_count => 'NumberOfAssignmentsAvailable',
|
77
|
+
:assignments_completed_count => 'NumberOfAssignmentsCompleted'
|
76
78
|
)
|
77
79
|
|
78
80
|
@keywords = @keywords.split(', ') if @keywords
|
data/lib/rturk/requester.rb
CHANGED
@@ -34,6 +34,10 @@ module RTurk
|
|
34
34
|
value.each do |multi_value|
|
35
35
|
pairs << [CGI.escape(key.to_s), CGI.escape(multi_value.to_s)].join('=')
|
36
36
|
end
|
37
|
+
elsif value.is_a?(Hash)
|
38
|
+
value.each do |multi_key, multi_value|
|
39
|
+
pairs << [CGI.escape("#{key}.#{multi_key}"), CGI.escape(multi_value.to_s)].join('=')
|
40
|
+
end
|
37
41
|
else
|
38
42
|
pairs << [CGI.escape(key.to_s), CGI.escape(value.to_s)].join('=')
|
39
43
|
end
|
data/rturk.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{rturk}
|
8
|
-
s.version = "2.3.
|
8
|
+
s.version = "2.3.3"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Mark Percival"]
|
12
|
-
s.date = %q{2010-11-
|
12
|
+
s.date = %q{2010-11-17}
|
13
13
|
s.email = %q{mark@mpercival.com}
|
14
14
|
s.extra_rdoc_files = [
|
15
15
|
"LICENSE",
|
data/spec/adapters/hit_spec.rb
CHANGED
@@ -72,4 +72,17 @@ describe "HIT adapter" do
|
|
72
72
|
hits.first.completed_assignments.should eql(1)
|
73
73
|
end
|
74
74
|
|
75
|
+
it "should get normal details without specifying" do
|
76
|
+
hit = RTurk::Hit.new(12345)
|
77
|
+
RTurk.should_receive(:GetHIT).with(:hit_id => 12345,
|
78
|
+
:include_assignment_summary => false)
|
79
|
+
hit.details
|
80
|
+
end
|
81
|
+
|
82
|
+
it "should include assignment summary attributes in details if specified in initialize" do
|
83
|
+
hit = RTurk::Hit.new(12345, nil, :include_assignment_summary => true)
|
84
|
+
RTurk.should_receive(:GetHIT).with(:hit_id => 12345,
|
85
|
+
:include_assignment_summary => true)
|
86
|
+
hit.details
|
87
|
+
end
|
75
88
|
end
|
@@ -1,6 +1,5 @@
|
|
1
1
|
require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper'))
|
2
2
|
|
3
|
-
|
4
3
|
describe RTurk::GetHIT do
|
5
4
|
|
6
5
|
before(:all) do
|
@@ -14,5 +13,19 @@ describe RTurk::GetHIT do
|
|
14
13
|
response.status.should eql('Reviewable')
|
15
14
|
end
|
16
15
|
|
16
|
+
it "should not specify the ResponseGroup by default" do
|
17
|
+
request = RTurk::GetHIT.new(:hit_id => '1234abcd')
|
18
|
+
request.to_params["ResponseGroup"].should be_nil
|
19
|
+
end
|
20
|
+
|
21
|
+
it "should include the assignment summary in the response group if specified" do
|
22
|
+
request = RTurk::GetHIT.new(:hit_id => '1234abcd', :include_assignment_summary => true)
|
23
|
+
request.to_params["ResponseGroup"].should == {
|
24
|
+
0 => "HITDetail", # default
|
25
|
+
1 => "HITQuestion", # default
|
26
|
+
2 => "Minimal", # default
|
27
|
+
3 => "HITAssignmentSummary" # added
|
28
|
+
}
|
29
|
+
end
|
17
30
|
|
18
31
|
end
|
data/spec/requester_spec.rb
CHANGED
@@ -24,7 +24,7 @@ describe RTurk::Requester do
|
|
24
24
|
RTurk::Requester.request(params)
|
25
25
|
end
|
26
26
|
|
27
|
-
it "
|
27
|
+
it "should build a correct querystring with two values per key" do
|
28
28
|
params = {
|
29
29
|
:Operation => 'GetHIT',
|
30
30
|
'Param1' => 'test1',
|
@@ -34,4 +34,15 @@ describe RTurk::Requester do
|
|
34
34
|
/(?=.*Operation=GetHIT)(?=.*Param1=test1)(?=.*Param2=test2a)(?=.*Param2=test2b)/)
|
35
35
|
RTurk::Requester.request(params)
|
36
36
|
end
|
37
|
+
|
38
|
+
it "should build a correct querystring with a hash of values" do
|
39
|
+
params = {
|
40
|
+
:Operation => 'GetHIT',
|
41
|
+
'Param1' => 'test1',
|
42
|
+
'Param2' => {0 => 'test2a', 1 => 'test2b'}
|
43
|
+
}
|
44
|
+
RestClient.should_receive(:get).with(
|
45
|
+
/(?=.*Operation=GetHIT)(?=.*Param1=test1)(?=.*Param2.0=test2a)(?=.*Param2.1=test2b)/)
|
46
|
+
RTurk::Requester.request(params)
|
47
|
+
end
|
37
48
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rturk
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 5
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 2
|
8
8
|
- 3
|
9
|
-
-
|
10
|
-
version: 2.3.
|
9
|
+
- 3
|
10
|
+
version: 2.3.3
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Mark Percival
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-11-
|
18
|
+
date: 2010-11-17 00:00:00 -08:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|