Class: Typingpool::Amazon
- Inherits:
-
Object
- Object
- Typingpool::Amazon
- Defined in:
- lib/typingpool/amazon.rb,
lib/typingpool/amazon/hit.rb,
lib/typingpool/amazon/hit/full.rb,
lib/typingpool/amazon/question.rb,
lib/typingpool/amazon/hit/assignment.rb,
lib/typingpool/amazon/hit/assignment/empty.rb,
lib/typingpool/amazon/hit/full/fromsearchhits.rb
Defined Under Namespace
Constant Summary collapse
- @@cache_file =
'~/.typingpool.cache'
Class Method Summary collapse
-
.cache ⇒ Object
Returns a PStore instance tied to the cache file specified in Amazon.setup (or the default).
-
.rturk_hit_full(id) ⇒ Object
Convenience wrapper that calls RTurk::Hit.new with :include_assignment_summary set to true.
-
.setup(args = {}) ⇒ Object
You must call Amazon.setup before using any subclass methods that rely on Amazon servers.
Class Method Details
.cache ⇒ Object
Returns a PStore instance tied to the cache file specified in Amazon.setup (or the default).
52 53 54 |
# File 'lib/typingpool/amazon.rb', line 52 def cache @@cache ||= PStore.new(File.(@@cache_file)) end |
.rturk_hit_full(id) ⇒ Object
Convenience wrapper that calls RTurk::Hit.new with :include_assignment_summary set to true. Takes a HIT id and returns an RTurk::Hit instance.
46 47 48 |
# File 'lib/typingpool/amazon.rb', line 46 def rturk_hit_full(id) RTurk::Hit.new(id, nil, :include_assignment_summary => true) end |
.setup(args = {}) ⇒ Object
You must call Amazon.setup before using any subclass methods that rely on Amazon servers.
Params
Takes params as a hash of named arguments. [:key] Your Amazon Web Services Access Key ID. Required param. If not passed, will be read from :config. [:secret] Your Amazon Web Services Secret Access Key. Required param. If not passed, will be read from :config. [:config] A Typingpool::Config instance. If not passed, will use the default Config.file (usually ~/.typingpool). Supplies the default values for :key and :secret and can override the default cache file location (usually ~/.typingpool.cache) via the 'cache' param. [:sandbox] Boolean specifying whether to perform all operations in the Amazon Mechanical Turk sandbox. Default is false.
Returns
Result of call to RTurk.setup with security credentials and sandbox param.
31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/typingpool/amazon.rb', line 31 def setup(args={}) args[:config] ||= Config.file args[:key] ||= args[:config].amazon.key args[:secret] ||= args[:config].amazon.secret args[:sandbox] = false if args[:sandbox].nil? if args[:config].cache @@cache = nil @@cache_file = args[:config].cache end RTurk.setup(args[:key], args[:secret], :sandbox => args[:sandbox]) end |