rturk 2.0.1 → 2.0.2
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.
- data/README.markdown +1 -1
- data/VERSION +1 -1
- data/lib/rturk.rb +1 -1
- data/lib/rturk/operation.rb +3 -2
- data/lib/rturk/operations/approve_assignment.rb +0 -1
- data/lib/rturk/operations/block_worker.rb +23 -0
- data/lib/rturk/operations/create_hit.rb +0 -2
- data/lib/rturk/operations/disable_hit.rb +0 -1
- data/lib/rturk/operations/dispose_hit.rb +0 -1
- data/lib/rturk/operations/force_expire_hit.rb +0 -1
- data/lib/rturk/operations/get_account_balance.rb +0 -2
- data/lib/rturk/operations/get_assignments_for_hit.rb +0 -1
- data/lib/rturk/operations/get_hit.rb +0 -1
- data/lib/rturk/operations/get_reviewable_hits.rb +0 -1
- data/lib/rturk/operations/grant_bonus.rb +0 -1
- data/lib/rturk/operations/reject_assignment.rb +0 -1
- data/lib/rturk/operations/unblock_worker.rb +23 -0
- data/lib/rturk/requester.rb +1 -1
- data/rturk.gemspec +10 -2
- data/spec/fake_responses/block_worker.xml +5 -0
- data/spec/fake_responses/unblock_worker.xml +5 -0
- data/spec/operations/block_worker_spec.rb +26 -0
- data/spec/operations/unblock_worker_spec.rb +26 -0
- metadata +10 -2
    
        data/README.markdown
    CHANGED
    
    
    
        data/VERSION
    CHANGED
    
    | @@ -1 +1 @@ | |
| 1 | 
            -
            2.0. | 
| 1 | 
            +
            2.0.2
         | 
    
        data/lib/rturk.rb
    CHANGED
    
    
    
        data/lib/rturk/operation.rb
    CHANGED
    
    | @@ -16,7 +16,7 @@ module RTurk | |
| 16 16 | 
             
                    @required_params.push(*args)
         | 
| 17 17 | 
             
                  end
         | 
| 18 18 |  | 
| 19 | 
            -
                  def  | 
| 19 | 
            +
                  def set_operation(op)
         | 
| 20 20 | 
             
                    default_params.merge!('Operation' => op)
         | 
| 21 21 | 
             
                  end
         | 
| 22 22 |  | 
| @@ -65,7 +65,8 @@ module RTurk | |
| 65 65 | 
             
                    validate
         | 
| 66 66 | 
             
                  end
         | 
| 67 67 | 
             
                  check_params
         | 
| 68 | 
            -
                  params = self. | 
| 68 | 
            +
                  params = {'Operation' => self.class.to_s.gsub('RTurk::', '')}
         | 
| 69 | 
            +
                  params = params.merge(self.default_params)
         | 
| 69 70 | 
             
                  params = to_params.merge(params)
         | 
| 70 71 | 
             
                  response = RTurk.Request(params)
         | 
| 71 72 | 
             
                  parse(response)
         | 
| @@ -0,0 +1,23 @@ | |
| 1 | 
            +
            # Operation to block a worker
         | 
| 2 | 
            +
            #
         | 
| 3 | 
            +
            # The worker does not see the reason you gave. It's for your records
         | 
| 4 | 
            +
            # only.
         | 
| 5 | 
            +
             | 
| 6 | 
            +
             | 
| 7 | 
            +
            module RTurk
         | 
| 8 | 
            +
              class BlockWorker < Operation
         | 
| 9 | 
            +
             | 
| 10 | 
            +
                attr_accessor :worker_id, :reason
         | 
| 11 | 
            +
                require_params :worker_id, :reason
         | 
| 12 | 
            +
                
         | 
| 13 | 
            +
                def to_params
         | 
| 14 | 
            +
                  {'WorkerId' => self.worker_id,
         | 
| 15 | 
            +
                    'Reason' => self.reason}
         | 
| 16 | 
            +
                end
         | 
| 17 | 
            +
                
         | 
| 18 | 
            +
              end
         | 
| 19 | 
            +
              def self.BlockWorker(*args)
         | 
| 20 | 
            +
                RTurk::BlockWorker.create(*args)
         | 
| 21 | 
            +
              end
         | 
| 22 | 
            +
             | 
| 23 | 
            +
            end
         | 
| @@ -0,0 +1,23 @@ | |
| 1 | 
            +
            # Operation to block a worker
         | 
| 2 | 
            +
            #
         | 
| 3 | 
            +
            # The worker does not see the reason you gave. It's for your records
         | 
| 4 | 
            +
            # only.
         | 
| 5 | 
            +
             | 
| 6 | 
            +
             | 
| 7 | 
            +
            module RTurk
         | 
| 8 | 
            +
              class UnblockWorker < Operation
         | 
| 9 | 
            +
             | 
| 10 | 
            +
                attr_accessor :worker_id, :reason
         | 
| 11 | 
            +
                require_params :worker_id
         | 
| 12 | 
            +
                
         | 
| 13 | 
            +
                def to_params
         | 
| 14 | 
            +
                  {'WorkerId' => self.worker_id,
         | 
| 15 | 
            +
                    'Reason' => self.reason}
         | 
| 16 | 
            +
                end
         | 
| 17 | 
            +
                
         | 
| 18 | 
            +
              end
         | 
| 19 | 
            +
              def self.UnblockWorker(*args)
         | 
| 20 | 
            +
                RTurk::UnblockWorker.create(*args)
         | 
| 21 | 
            +
              end
         | 
| 22 | 
            +
             | 
| 23 | 
            +
            end
         | 
    
        data/lib/rturk/requester.rb
    CHANGED
    
    | @@ -30,7 +30,7 @@ module RTurk | |
| 30 30 | 
             
                    signature = sign(credentials.secret_key, params['Service'], params['Operation'], params["Timestamp"])
         | 
| 31 31 | 
             
                    params['Signature'] = signature
         | 
| 32 32 | 
             
                    querystring = params.collect { |key, value| [CGI.escape(key.to_s), CGI.escape(value.to_s)].join('=') }.join('&') # order doesn't matter for the actual request
         | 
| 33 | 
            -
                    RTurk. | 
| 33 | 
            +
                    RTurk.logger.debug "Sending request:\n\t #{credentials.host}?#{querystring}"
         | 
| 34 34 | 
             
                    RestClient.get("#{credentials.host}?#{querystring}")
         | 
| 35 35 | 
             
                  end
         | 
| 36 36 |  | 
    
        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.0. | 
| 8 | 
            +
              s.version = "2.0.2"
         | 
| 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{2009-10- | 
| 12 | 
            +
              s.date = %q{2009-10-27}
         | 
| 13 13 | 
             
              s.email = %q{mark@mpercival.com}
         | 
| 14 14 | 
             
              s.extra_rdoc_files = [
         | 
| 15 15 | 
             
                "LICENSE",
         | 
| @@ -41,6 +41,7 @@ Gem::Specification.new do |s| | |
| 41 41 | 
             
                 "lib/rturk/macros.rb",
         | 
| 42 42 | 
             
                 "lib/rturk/operation.rb",
         | 
| 43 43 | 
             
                 "lib/rturk/operations/approve_assignment.rb",
         | 
| 44 | 
            +
                 "lib/rturk/operations/block_worker.rb",
         | 
| 44 45 | 
             
                 "lib/rturk/operations/create_hit.rb",
         | 
| 45 46 | 
             
                 "lib/rturk/operations/disable_hit.rb",
         | 
| 46 47 | 
             
                 "lib/rturk/operations/dispose_hit.rb",
         | 
| @@ -51,6 +52,7 @@ Gem::Specification.new do |s| | |
| 51 52 | 
             
                 "lib/rturk/operations/get_reviewable_hits.rb",
         | 
| 52 53 | 
             
                 "lib/rturk/operations/grant_bonus.rb",
         | 
| 53 54 | 
             
                 "lib/rturk/operations/reject_assignment.rb",
         | 
| 55 | 
            +
                 "lib/rturk/operations/unblock_worker.rb",
         | 
| 54 56 | 
             
                 "lib/rturk/requester.rb",
         | 
| 55 57 | 
             
                 "lib/rturk/response.rb",
         | 
| 56 58 | 
             
                 "lib/rturk/responses/create_hit_response.rb",
         | 
| @@ -68,6 +70,7 @@ Gem::Specification.new do |s| | |
| 68 70 | 
             
                 "spec/builders/qualifications_spec.rb",
         | 
| 69 71 | 
             
                 "spec/builders/question_spec.rb",
         | 
| 70 72 | 
             
                 "spec/fake_responses/approve_assignment.xml",
         | 
| 73 | 
            +
                 "spec/fake_responses/block_worker.xml",
         | 
| 71 74 | 
             
                 "spec/fake_responses/create_hit.xml",
         | 
| 72 75 | 
             
                 "spec/fake_responses/disable_hit.xml",
         | 
| 73 76 | 
             
                 "spec/fake_responses/dispose_hit.xml",
         | 
| @@ -80,8 +83,10 @@ Gem::Specification.new do |s| | |
| 80 83 | 
             
                 "spec/fake_responses/grant_bonus.xml",
         | 
| 81 84 | 
             
                 "spec/fake_responses/invalid_credentials.xml",
         | 
| 82 85 | 
             
                 "spec/fake_responses/reject_assignment.xml",
         | 
| 86 | 
            +
                 "spec/fake_responses/unblock_worker.xml",
         | 
| 83 87 | 
             
                 "spec/mturk.sample.yml",
         | 
| 84 88 | 
             
                 "spec/operations/approve_assignment_spec.rb",
         | 
| 89 | 
            +
                 "spec/operations/block_worker_spec.rb",
         | 
| 85 90 | 
             
                 "spec/operations/create_hit_spec.rb",
         | 
| 86 91 | 
             
                 "spec/operations/disable_hit_spec.rb",
         | 
| 87 92 | 
             
                 "spec/operations/dispose_hit_spec.rb",
         | 
| @@ -92,6 +97,7 @@ Gem::Specification.new do |s| | |
| 92 97 | 
             
                 "spec/operations/get_reviewable_hits_spec.rb",
         | 
| 93 98 | 
             
                 "spec/operations/grant_bonus_spec.rb",
         | 
| 94 99 | 
             
                 "spec/operations/reject_assignment_spec.rb",
         | 
| 100 | 
            +
                 "spec/operations/unblock_worker_spec.rb",
         | 
| 95 101 | 
             
                 "spec/requester_spec.rb",
         | 
| 96 102 | 
             
                 "spec/response_spec.rb",
         | 
| 97 103 | 
             
                 "spec/rturk_spec.rb",
         | 
| @@ -112,6 +118,7 @@ Gem::Specification.new do |s| | |
| 112 118 | 
             
                 "spec/builders/qualifications_spec.rb",
         | 
| 113 119 | 
             
                 "spec/builders/question_spec.rb",
         | 
| 114 120 | 
             
                 "spec/operations/approve_assignment_spec.rb",
         | 
| 121 | 
            +
                 "spec/operations/block_worker_spec.rb",
         | 
| 115 122 | 
             
                 "spec/operations/create_hit_spec.rb",
         | 
| 116 123 | 
             
                 "spec/operations/disable_hit_spec.rb",
         | 
| 117 124 | 
             
                 "spec/operations/dispose_hit_spec.rb",
         | 
| @@ -122,6 +129,7 @@ Gem::Specification.new do |s| | |
| 122 129 | 
             
                 "spec/operations/get_reviewable_hits_spec.rb",
         | 
| 123 130 | 
             
                 "spec/operations/grant_bonus_spec.rb",
         | 
| 124 131 | 
             
                 "spec/operations/reject_assignment_spec.rb",
         | 
| 132 | 
            +
                 "spec/operations/unblock_worker_spec.rb",
         | 
| 125 133 | 
             
                 "spec/requester_spec.rb",
         | 
| 126 134 | 
             
                 "spec/response_spec.rb",
         | 
| 127 135 | 
             
                 "spec/rturk_spec.rb",
         | 
| @@ -0,0 +1,26 @@ | |
| 1 | 
            +
            require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper'))
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            describe RTurk::BlockWorker 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('block_worker', :operation => 'BlockWorker')
         | 
| 9 | 
            +
              end
         | 
| 10 | 
            +
             | 
| 11 | 
            +
              it "should ensure required params" do
         | 
| 12 | 
            +
                lambda{RTurk::BlockWorker(:worker_id => "123456789")}.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' => 'BlockWorker'))
         | 
| 18 | 
            +
                RTurk::BlockWorker(:worker_id => "123456789", :reason => "Really poor work") rescue RTurk::InvalidRequest
         | 
| 19 | 
            +
              end
         | 
| 20 | 
            +
              
         | 
| 21 | 
            +
              it "should parse and return the result" do
         | 
| 22 | 
            +
                RTurk::BlockWorker(:worker_id => "123456789", :reason => "Really poor work").should
         | 
| 23 | 
            +
                  be_a_kind_of RTurk::Response
         | 
| 24 | 
            +
              end
         | 
| 25 | 
            +
             | 
| 26 | 
            +
            end
         | 
| @@ -0,0 +1,26 @@ | |
| 1 | 
            +
            require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper'))
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            describe RTurk::UnblockWorker 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('unblock_worker', :operation => 'UnblockWorker')
         | 
| 9 | 
            +
              end
         | 
| 10 | 
            +
             | 
| 11 | 
            +
              it "should ensure required params" do
         | 
| 12 | 
            +
                lambda{RTurk::UnblockWorker(:reason => 'foo')}.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' => 'UnblockWorker'))
         | 
| 18 | 
            +
                RTurk::UnblockWorker(:worker_id => "123456789", :reason => "Really poor work") rescue RTurk::InvalidRequest
         | 
| 19 | 
            +
              end
         | 
| 20 | 
            +
              
         | 
| 21 | 
            +
              it "should parse and return the result" do
         | 
| 22 | 
            +
                RTurk::UnblockWorker(:worker_id => "123456789", :reason => "Really poor work").should
         | 
| 23 | 
            +
                  be_a_kind_of RTurk::Response
         | 
| 24 | 
            +
              end
         | 
| 25 | 
            +
             | 
| 26 | 
            +
            end
         | 
    
        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.0. | 
| 4 | 
            +
              version: 2.0.2
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors: 
         | 
| 7 7 | 
             
            - Mark Percival
         | 
| @@ -9,7 +9,7 @@ autorequire: | |
| 9 9 | 
             
            bindir: bin
         | 
| 10 10 | 
             
            cert_chain: []
         | 
| 11 11 |  | 
| 12 | 
            -
            date: 2009-10- | 
| 12 | 
            +
            date: 2009-10-27 00:00:00 -04:00
         | 
| 13 13 | 
             
            default_executable: 
         | 
| 14 14 | 
             
            dependencies: []
         | 
| 15 15 |  | 
| @@ -48,6 +48,7 @@ files: | |
| 48 48 | 
             
            - lib/rturk/macros.rb
         | 
| 49 49 | 
             
            - lib/rturk/operation.rb
         | 
| 50 50 | 
             
            - lib/rturk/operations/approve_assignment.rb
         | 
| 51 | 
            +
            - lib/rturk/operations/block_worker.rb
         | 
| 51 52 | 
             
            - lib/rturk/operations/create_hit.rb
         | 
| 52 53 | 
             
            - lib/rturk/operations/disable_hit.rb
         | 
| 53 54 | 
             
            - lib/rturk/operations/dispose_hit.rb
         | 
| @@ -58,6 +59,7 @@ files: | |
| 58 59 | 
             
            - lib/rturk/operations/get_reviewable_hits.rb
         | 
| 59 60 | 
             
            - lib/rturk/operations/grant_bonus.rb
         | 
| 60 61 | 
             
            - lib/rturk/operations/reject_assignment.rb
         | 
| 62 | 
            +
            - lib/rturk/operations/unblock_worker.rb
         | 
| 61 63 | 
             
            - lib/rturk/requester.rb
         | 
| 62 64 | 
             
            - lib/rturk/response.rb
         | 
| 63 65 | 
             
            - lib/rturk/responses/create_hit_response.rb
         | 
| @@ -75,6 +77,7 @@ files: | |
| 75 77 | 
             
            - spec/builders/qualifications_spec.rb
         | 
| 76 78 | 
             
            - spec/builders/question_spec.rb
         | 
| 77 79 | 
             
            - spec/fake_responses/approve_assignment.xml
         | 
| 80 | 
            +
            - spec/fake_responses/block_worker.xml
         | 
| 78 81 | 
             
            - spec/fake_responses/create_hit.xml
         | 
| 79 82 | 
             
            - spec/fake_responses/disable_hit.xml
         | 
| 80 83 | 
             
            - spec/fake_responses/dispose_hit.xml
         | 
| @@ -87,8 +90,10 @@ files: | |
| 87 90 | 
             
            - spec/fake_responses/grant_bonus.xml
         | 
| 88 91 | 
             
            - spec/fake_responses/invalid_credentials.xml
         | 
| 89 92 | 
             
            - spec/fake_responses/reject_assignment.xml
         | 
| 93 | 
            +
            - spec/fake_responses/unblock_worker.xml
         | 
| 90 94 | 
             
            - spec/mturk.sample.yml
         | 
| 91 95 | 
             
            - spec/operations/approve_assignment_spec.rb
         | 
| 96 | 
            +
            - spec/operations/block_worker_spec.rb
         | 
| 92 97 | 
             
            - spec/operations/create_hit_spec.rb
         | 
| 93 98 | 
             
            - spec/operations/disable_hit_spec.rb
         | 
| 94 99 | 
             
            - spec/operations/dispose_hit_spec.rb
         | 
| @@ -99,6 +104,7 @@ files: | |
| 99 104 | 
             
            - spec/operations/get_reviewable_hits_spec.rb
         | 
| 100 105 | 
             
            - spec/operations/grant_bonus_spec.rb
         | 
| 101 106 | 
             
            - spec/operations/reject_assignment_spec.rb
         | 
| 107 | 
            +
            - spec/operations/unblock_worker_spec.rb
         | 
| 102 108 | 
             
            - spec/requester_spec.rb
         | 
| 103 109 | 
             
            - spec/response_spec.rb
         | 
| 104 110 | 
             
            - spec/rturk_spec.rb
         | 
| @@ -141,6 +147,7 @@ test_files: | |
| 141 147 | 
             
            - spec/builders/qualifications_spec.rb
         | 
| 142 148 | 
             
            - spec/builders/question_spec.rb
         | 
| 143 149 | 
             
            - spec/operations/approve_assignment_spec.rb
         | 
| 150 | 
            +
            - spec/operations/block_worker_spec.rb
         | 
| 144 151 | 
             
            - spec/operations/create_hit_spec.rb
         | 
| 145 152 | 
             
            - spec/operations/disable_hit_spec.rb
         | 
| 146 153 | 
             
            - spec/operations/dispose_hit_spec.rb
         | 
| @@ -151,6 +158,7 @@ test_files: | |
| 151 158 | 
             
            - spec/operations/get_reviewable_hits_spec.rb
         | 
| 152 159 | 
             
            - spec/operations/grant_bonus_spec.rb
         | 
| 153 160 | 
             
            - spec/operations/reject_assignment_spec.rb
         | 
| 161 | 
            +
            - spec/operations/unblock_worker_spec.rb
         | 
| 154 162 | 
             
            - spec/requester_spec.rb
         | 
| 155 163 | 
             
            - spec/response_spec.rb
         | 
| 156 164 | 
             
            - spec/rturk_spec.rb
         |