kempelen 1.0.4 → 1.0.6

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0019e4a7473ffb6cdc3f9690ead7c38798595428
4
- data.tar.gz: 11ba138ac706191202d17bf67501155165b8453f
3
+ metadata.gz: d2bdc0755db7490260e513d2822a15b02bbbd079
4
+ data.tar.gz: c3a7c293995763cbd61561e1b85b37bac6083eda
5
5
  SHA512:
6
- metadata.gz: b9ef9fe82a4f029127bc964cc8e4d20216f493ad2ae5f08fe3d09fb8a293ea54593035db3ab671265bcf47ad3d0fa4f9810273d6e882ff8e0804790dce8cd825
7
- data.tar.gz: d33a443095ee2de4501456bde4c44c69ea4e266443e25a99b8c081c7bf09ddfe3efc9b260967646f71170a87af2212a605156a38f19a3df93d631f6c10839dad
6
+ metadata.gz: c87d9d47d4c4022c629e05e4366fb58d405e15872b1d2117e8b6a3a0d996a27172e2a21daffd8a8e30aa0a584bbb42ac6a8bb9f38d4bf7451e0648aeb6629481
7
+ data.tar.gz: 72d675d6293cfe78fac9447cc27443d4d11b40eb7afe0dab1771147b299da09eb6dd20bc6bcb5b270a69c6e940e7a2b6437c7cbb884c49b369627099ecd78258
data/examples/get_hit.rb CHANGED
@@ -9,7 +9,8 @@ if ARGV.length < 3
9
9
  exit
10
10
  end
11
11
 
12
- @client = Kempelen::API::Client.new(ARGV[0], ARGV[1], :sandbox)
12
+ @client = Kempelen::API::Client.new(ARGV[0], ARGV[1], :production)
13
+ @client.debug_output = $stdout
13
14
  @operation = Kempelen::API::Operations::GetHit.new(@client, ARGV[2])
14
15
 
15
16
  get_hit_response = @operation.perform_operation
@@ -0,0 +1,16 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
4
+ require 'kempelen'
5
+ require 'httparty'
6
+
7
+ if ARGV.length < 3
8
+ puts "notify_workers.rb <ACCESS_KEY> <SECRET_KEY> <WORKER_ID> <SUBJECT> <MESSAGE>"
9
+ exit
10
+ end
11
+
12
+ @client = Kempelen::API::Client.new(ARGV[0], ARGV[1], :sandbox)
13
+ @operation = Kempelen::API::Operations::NotifyWorkers.new(@client, [ARGV[2]], "Test Message", "This is a test message")
14
+
15
+ result = @operation.perform_operation
16
+ puts result.inspect
data/kempelen.gemspec CHANGED
@@ -24,12 +24,10 @@ Gem::Specification.new do |spec|
24
24
  spec.add_dependency "httparty", "~> 0.13.6"
25
25
 
26
26
  spec.add_development_dependency "bundler", "~> 1.9"
27
- spec.add_development_dependency "rake", "~> 10.0"
27
+ spec.add_development_dependency "rake", "~> 11.1"
28
28
  spec.add_development_dependency "minitest", "~> 5.8.0"
29
29
  spec.add_development_dependency "minitest-reporters", "~> 1.1.6"
30
30
  spec.add_development_dependency "pry"
31
31
  spec.add_development_dependency "pry-byebug"
32
- spec.add_development_dependency "guard"
33
- spec.add_development_dependency "guard-minitest"
34
32
  spec.add_development_dependency "coveralls"
35
33
  end
data/lib/kempelen.rb CHANGED
@@ -29,6 +29,7 @@ require "kempelen/API/operations/reject_assignment"
29
29
  require "kempelen/API/operations/get_assignments_for_hit"
30
30
  require "kempelen/API/operations/set_hit_as_reviewing"
31
31
  require "kempelen/API/operations/register_hit_type"
32
+ require "kempelen/API/operations/notify_workers"
32
33
 
33
34
  module Kempelen
34
35
  # Your code goes here...
@@ -10,6 +10,9 @@ module Kempelen
10
10
  # Mechanical Turk environment to make API calls to - defaults to :production.
11
11
  attr_reader :environment
12
12
 
13
+ # HTTParty debug options
14
+ attr_accessor :debug_output
15
+
13
16
  # URLs for Mechanical Turk APIs, indexed by environment.
14
17
  SERVICE_URLS = {
15
18
  sandbox: 'https://mechanicalturk.sandbox.amazonaws.com'.freeze,
@@ -24,6 +27,7 @@ module Kempelen
24
27
  @secret_key = secret_key
25
28
 
26
29
  @environment = environment.to_sym
30
+ @debug_output = nil
27
31
 
28
32
  raise ArgumentError.new("Unknown environment".freeze) if SERVICE_URLS[@environment].nil?
29
33
  end
@@ -37,7 +41,7 @@ module Kempelen
37
41
  end
38
42
 
39
43
  def perform_request(query_string, response_object)
40
- response = HTTParty.get(query_string)
44
+ response = HTTParty.get(query_string, debug_output: @debug_output)
41
45
  response.parsed_response[response_object]
42
46
  end
43
47
  end
@@ -52,6 +52,9 @@ module Kempelen
52
52
  request_str += "&" unless request_str.empty?
53
53
  request_str += "#{aws_name}.#{idx + 1}.#{k}=#{CGI.escape(v.to_s)}"
54
54
  end
55
+ else
56
+ request_str += "&" unless request_str.empty?
57
+ request_str += "#{aws_name}.#{idx + 1}=#{CGI.escape(hash_value.to_s)}"
55
58
  end
56
59
  end
57
60
  end
@@ -28,10 +28,14 @@ module Kempelen
28
28
 
29
29
  @hit_type_id = hit_type_id
30
30
  @lifetime_in_seconds = lifetime_in_seconds.to_i
31
+ @layout_id = nil
32
+ @requester_annotation = nil
33
+ @unique_request_token = nil
31
34
  @layout_parameters = []
32
35
  @max_assignments = 1
33
36
  @response_object = AWS_RESPONSE_OBJECT
34
37
 
38
+ @auto_approval_delay = 2592000
35
39
  @reward_amount = 0.0
36
40
  @currency_code = "USD".freeze
37
41
 
@@ -0,0 +1,54 @@
1
+ module Kempelen
2
+ module API
3
+ module Operations
4
+ class NotifyWorkers < Base
5
+ attr_accessor :message
6
+ attr_accessor :subject
7
+ attr_accessor :worker_ids
8
+
9
+ AWS_OPERATION_NAME = "NotifyWorkers".freeze
10
+ AWS_RESPONSE_OBJECT = "NotifyWorkersResponse".freeze
11
+
12
+ SUBJECT_MAX_LENGTH = 200
13
+ MESSAGE_MAX_LENGTH = 4096
14
+ WORKER_IDS_MAX_LENGTH = 100
15
+
16
+ def initialize(client, worker_ids, subject, message)
17
+ super(client)
18
+
19
+ @operation_name = AWS_OPERATION_NAME
20
+ @subject = subject.strip
21
+ @message = message
22
+ @worker_ids = worker_ids
23
+ end
24
+
25
+ def valid_arguments?
26
+ @subject.length <= SUBJECT_MAX_LENGTH and
27
+ @subject.length > 0 and
28
+ @message.length <= MESSAGE_MAX_LENGTH and
29
+ @message.length > 0 and
30
+ @worker_ids.length <= WORKER_IDS_MAX_LENGTH and
31
+ @worker_ids.length > 0
32
+ end
33
+
34
+ def create_parameters
35
+ raise "Argument size restrictions violated" unless valid_arguments?
36
+
37
+ @parameters[:subject] = @subject
38
+ @parameters[:message_text] = @message
39
+ @parameters[:worker_ids] = @worker_ids
40
+
41
+ super
42
+ end
43
+
44
+ def perform_operation
45
+ create_request_string
46
+
47
+ super
48
+
49
+ Kempelen::API::Responses::EmptyResponse.new(@raw_response)
50
+ end
51
+ end
52
+ end
53
+ end
54
+ end
@@ -29,13 +29,16 @@ module Kempelen
29
29
  assignment_duration: "AssignmentDurationInSeconds".freeze,
30
30
  keywords: "Keywords".freeze,
31
31
  auto_approval_delay: "AutoApprovalDelayInSeconds".freeze,
32
- qualification_requirement: "QualificationRequirement".freeze
32
+ qualification_requirement: "QualificationRequirement".freeze,
33
+ subject: "Subject".freeze,
34
+ message_text: "MessageText".freeze
33
35
  }
34
36
 
35
37
  ARRAY_PARAMETERS = {
36
38
  qualification_requirements: "QualificationRequirement".freeze,
37
39
  layout_parameters: "HITLayoutParameter".freeze,
38
- reward_amount: "Reward".freeze
40
+ reward_amount: "Reward".freeze,
41
+ worker_ids: "WorkerId".freeze
39
42
  }
40
43
  end
41
44
  end
@@ -21,6 +21,7 @@ module Kempelen
21
21
  @description = description
22
22
  @reward = reward
23
23
  @assignment_duration = assignment_duration
24
+ @auto_approval_delay = 2592000
24
25
  @keywords = []
25
26
 
26
27
  yield self unless block == nil
@@ -1,3 +1,3 @@
1
1
  module Kempelen
2
- VERSION = "1.0.4"
2
+ VERSION = "1.0.6"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kempelen
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.4
4
+ version: 1.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brian Nelson
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-03-07 00:00:00.000000000 Z
11
+ date: 2016-10-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ruby-hmac
@@ -72,14 +72,14 @@ dependencies:
72
72
  requirements:
73
73
  - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: '10.0'
75
+ version: '11.1'
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
- version: '10.0'
82
+ version: '11.1'
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: minitest
85
85
  requirement: !ruby/object:Gem::Requirement
@@ -136,34 +136,6 @@ dependencies:
136
136
  - - ">="
137
137
  - !ruby/object:Gem::Version
138
138
  version: '0'
139
- - !ruby/object:Gem::Dependency
140
- name: guard
141
- requirement: !ruby/object:Gem::Requirement
142
- requirements:
143
- - - ">="
144
- - !ruby/object:Gem::Version
145
- version: '0'
146
- type: :development
147
- prerelease: false
148
- version_requirements: !ruby/object:Gem::Requirement
149
- requirements:
150
- - - ">="
151
- - !ruby/object:Gem::Version
152
- version: '0'
153
- - !ruby/object:Gem::Dependency
154
- name: guard-minitest
155
- requirement: !ruby/object:Gem::Requirement
156
- requirements:
157
- - - ">="
158
- - !ruby/object:Gem::Version
159
- version: '0'
160
- type: :development
161
- prerelease: false
162
- version_requirements: !ruby/object:Gem::Requirement
163
- requirements:
164
- - - ">="
165
- - !ruby/object:Gem::Version
166
- version: '0'
167
139
  - !ruby/object:Gem::Dependency
168
140
  name: coveralls
169
141
  requirement: !ruby/object:Gem::Requirement
@@ -202,6 +174,7 @@ files:
202
174
  - examples/get_assignments_for_hit.rb
203
175
  - examples/get_hit.rb
204
176
  - examples/get_reviewable_hits.rb
177
+ - examples/notify_workers.rb
205
178
  - examples/reject_assignment.rb
206
179
  - examples/set_hit_as_reviewing.rb
207
180
  - kempelen.gemspec
@@ -221,6 +194,7 @@ files:
221
194
  - lib/kempelen/API/operations/get_hit.rb
222
195
  - lib/kempelen/API/operations/get_reviewable_hits.rb
223
196
  - lib/kempelen/API/operations/hit_operation.rb
197
+ - lib/kempelen/API/operations/notify_workers.rb
224
198
  - lib/kempelen/API/operations/parameters.rb
225
199
  - lib/kempelen/API/operations/register_hit_type.rb
226
200
  - lib/kempelen/API/operations/reject_assignment.rb
@@ -253,7 +227,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
253
227
  version: '0'
254
228
  requirements: []
255
229
  rubyforge_project:
256
- rubygems_version: 2.5.1
230
+ rubygems_version: 2.4.5.1
257
231
  signing_key:
258
232
  specification_version: 4
259
233
  summary: Ruby integration with Amazon's Mechanical Turk