houdini 0.3.0 → 0.3.1
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/Gemfile.lock +3 -3
- data/README.markdown +2 -2
- data/app/controllers/houdini/postbacks_controller.rb +2 -1
- data/lib/houdini.rb +2 -1
- data/lib/houdini/version.rb +1 -1
- data/spec/dummy/app/models/article.rb +20 -18
- data/spec/requests/integration_spec.rb +4 -4
- metadata +40 -15
    
        data/Gemfile.lock
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            PATH
         | 
| 2 2 | 
             
              remote: .
         | 
| 3 3 | 
             
              specs:
         | 
| 4 | 
            -
                houdini (0.3. | 
| 4 | 
            +
                houdini (0.3.1)
         | 
| 5 5 | 
             
                  rails (> 3.0.0)
         | 
| 6 6 |  | 
| 7 7 | 
             
            GEM
         | 
| @@ -113,10 +113,10 @@ GEM | |
| 113 113 | 
             
                  sqlite3 (>= 1.3.3)
         | 
| 114 114 | 
             
                thor (0.14.6)
         | 
| 115 115 | 
             
                tilt (1.3.3)
         | 
| 116 | 
            -
                treetop (1.4. | 
| 116 | 
            +
                treetop (1.4.11)
         | 
| 117 117 | 
             
                  polyglot
         | 
| 118 118 | 
             
                  polyglot (>= 0.3.1)
         | 
| 119 | 
            -
                tzinfo (0.3. | 
| 119 | 
            +
                tzinfo (0.3.34)
         | 
| 120 120 | 
             
                xpath (0.1.4)
         | 
| 121 121 | 
             
                  nokogiri (~> 1.3)
         | 
| 122 122 |  | 
    
        data/README.markdown
    CHANGED
    
    | @@ -2,7 +2,7 @@ | |
| 2 2 |  | 
| 3 3 | 
             
            This ruby gem is a Rails Engine for using the Houdini Mechanical Turk API. It provides easy integration into your models and sets up the necessary controllers to receive answers posted back to your app from Houdini.
         | 
| 4 4 |  | 
| 5 | 
            -
            Check out the [Houdini Documentation](http:// | 
| 5 | 
            +
            Check out the [Houdini Documentation](http://houdini.tenderapp.com/kb/developer-docs/api-v1) for more info about the API.
         | 
| 6 6 |  | 
| 7 7 | 
             
            # Installation (Rails 3.x)
         | 
| 8 8 |  | 
| @@ -47,7 +47,7 @@ Setup Houdini in your ActiveRecord model: | |
| 47 47 | 
             
            * `options` - Hash of options to use.
         | 
| 48 48 |  | 
| 49 49 | 
             
            ## Options
         | 
| 50 | 
            -
            * `:input` -  | 
| 50 | 
            +
            * `:input` - Required. Hash: any task specific info needed to populate your blueprint. Keys must match the blueprint's required input, and values must a `Symbol` of the method to call, a lambdas/procs to be called in the model's context, or just a value to send along.
         | 
| 51 51 | 
             
            * `:on_task_completion` - Method that should be called when the answer is posted back to your app. Can by a symbol or a lambda/proc. The method will be called with a hash of the returned output from Houdini.
         | 
| 52 52 | 
             
            * `:on` - Name of a callback to use in order to trigger the submission to Houdini. Must be a symbol/string. If you don't want to use a callback, call the model instance's `houdini_submit_#{blueprint}!` method, where `blueprint` is the first argument you provided for the `houdini` method.
         | 
| 53 53 | 
             
            * `:after_submit` - Method that should be called after submitting the task to Houdini. Can by a symbol or a lambda/proc.
         | 
| @@ -1,10 +1,11 @@ | |
| 1 | 
            +
            require 'cgi'
         | 
| 1 2 | 
             
            class Houdini::PostbacksController < ApplicationController
         | 
| 2 3 | 
             
              skip_before_filter :protect_from_forgery
         | 
| 3 4 |  | 
| 4 5 | 
             
              def create
         | 
| 5 6 | 
             
                task_results = HashWithIndifferentAccess.new ActiveSupport::JSON.decode(request.raw_post)
         | 
| 6 7 |  | 
| 7 | 
            -
                Houdini::PostbackProcessor.process params[:object_class], params[:object_id], task_results
         | 
| 8 | 
            +
                Houdini::PostbackProcessor.process CGI.unescape(params[:object_class]), params[:object_id], task_results
         | 
| 8 9 | 
             
                render :json => { :success => true }
         | 
| 9 10 | 
             
              end
         | 
| 10 11 | 
             
            end
         | 
    
        data/lib/houdini.rb
    CHANGED
    
    | @@ -1,5 +1,6 @@ | |
| 1 1 | 
             
            require 'net/https'
         | 
| 2 2 | 
             
            require 'uri'
         | 
| 3 | 
            +
            require 'cgi'
         | 
| 3 4 |  | 
| 4 5 | 
             
            require 'houdini/model'
         | 
| 5 6 | 
             
            require 'houdini/task'
         | 
| @@ -30,7 +31,7 @@ module Houdini | |
| 30 31 | 
             
                    :api_key      => api_key,
         | 
| 31 32 | 
             
                    :blueprint    => blueprint,
         | 
| 32 33 | 
             
                    :input        => input_params,
         | 
| 33 | 
            -
                    :postback_url => "#{app_uri.scheme}://#{app_uri.host}:#{app_uri.port}/houdini/#{class_name}/#{object_id}/postbacks"
         | 
| 34 | 
            +
                    :postback_url => "#{app_uri.scheme}://#{app_uri.host}:#{app_uri.port}/houdini/#{CGI.escape(class_name)}/#{object_id}/postbacks"
         | 
| 34 35 | 
             
                  )
         | 
| 35 36 | 
             
                end
         | 
| 36 37 | 
             
              end
         | 
    
        data/lib/houdini/version.rb
    CHANGED
    
    
| @@ -1,23 +1,25 @@ | |
| 1 | 
            -
             | 
| 2 | 
            -
               | 
| 1 | 
            +
            module DummyApp
         | 
| 2 | 
            +
              class Article < ActiveRecord::Base
         | 
| 3 | 
            +
                include Houdini::Model
         | 
| 3 4 |  | 
| 4 | 
            -
             | 
| 5 | 
            -
             | 
| 6 | 
            -
             | 
| 7 | 
            -
             | 
| 8 | 
            -
             | 
| 9 | 
            -
             | 
| 10 | 
            -
             | 
| 11 | 
            -
             | 
| 12 | 
            -
             | 
| 13 | 
            -
             | 
| 14 | 
            -
             | 
| 5 | 
            +
                houdini :edit_for_grammar,
         | 
| 6 | 
            +
                  :input => {
         | 
| 7 | 
            +
                    'input1' => :original_text,
         | 
| 8 | 
            +
                    'input2' => proc{ original_text },
         | 
| 9 | 
            +
                    'input3' => "some text"
         | 
| 10 | 
            +
                  },
         | 
| 11 | 
            +
                  :on                 => :after_create,
         | 
| 12 | 
            +
                  :after_submit       => :update_houdini_attributes,
         | 
| 13 | 
            +
                  :on_task_completion => :process_houdini_edited_text,
         | 
| 14 | 
            +
                  :finder             => lambda{|id| last },
         | 
| 15 | 
            +
                  :id_method          => lambda{ 'model-slug' }
         | 
| 15 16 |  | 
| 16 | 
            -
             | 
| 17 | 
            -
             | 
| 18 | 
            -
             | 
| 17 | 
            +
                def update_houdini_attributes
         | 
| 18 | 
            +
                  update_attribute(:houdini_request_sent_at, Date.today.to_time)
         | 
| 19 | 
            +
                end
         | 
| 19 20 |  | 
| 20 | 
            -
             | 
| 21 | 
            -
             | 
| 21 | 
            +
                def process_houdini_edited_text(output, verbose_output)
         | 
| 22 | 
            +
                  update_attribute(:edited_text, output[:edited_text])
         | 
| 23 | 
            +
                end
         | 
| 22 24 | 
             
              end
         | 
| 23 25 | 
             
            end
         | 
| @@ -3,16 +3,16 @@ require 'spec_helper' | |
| 3 3 | 
             
            describe "End-to-end" do
         | 
| 4 4 | 
             
              before do
         | 
| 5 5 | 
             
                Houdini.setup 'production', :app_url => "http://my-app:3333/"
         | 
| 6 | 
            -
                Article.delete_all
         | 
| 6 | 
            +
                DummyApp::Article.delete_all
         | 
| 7 7 | 
             
              end
         | 
| 8 8 |  | 
| 9 9 | 
             
              it "should send task to Houdini and properly receive the postback" do
         | 
| 10 | 
            -
                article = Article.new :original_text => 'This is incorect.'
         | 
| 10 | 
            +
                article = DummyApp::Article.new :original_text => 'This is incorect.'
         | 
| 11 11 |  | 
| 12 12 | 
             
                params = {
         | 
| 13 13 | 
             
                  "api_key"      => Houdini.api_key,
         | 
| 14 14 | 
             
                  "environment"  => Houdini.environment,
         | 
| 15 | 
            -
                  "postback_url" => "http://my-app:3333/houdini/ | 
| 15 | 
            +
                  "postback_url" => "http://my-app:3333/houdini/DummyApp%3A%3AArticle/model-slug/postbacks",
         | 
| 16 16 | 
             
                  "blueprint"    => "edit_for_grammar",
         | 
| 17 17 | 
             
                  "input"    => {
         | 
| 18 18 | 
             
                    "input1" => "This is incorect.",
         | 
| @@ -29,7 +29,7 @@ describe "End-to-end" do | |
| 29 29 |  | 
| 30 30 | 
             
                output_params = {"edited_text"=>"This is incorrect."}
         | 
| 31 31 |  | 
| 32 | 
            -
                post "houdini/ | 
| 32 | 
            +
                post "houdini/DummyApp%3A%3AArticle/model-slug/postbacks", params.merge("id" => "000000000000", "status"=>"complete", "output" => output_params, "verbose_output"=> output_params).to_json
         | 
| 33 33 |  | 
| 34 34 | 
             
                article.reload
         | 
| 35 35 | 
             
                article.edited_text.should == "This is incorrect."
         | 
    
        metadata
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: houdini
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 0.3. | 
| 4 | 
            +
              version: 0.3.1
         | 
| 5 5 | 
             
              prerelease: 
         | 
| 6 6 | 
             
            platform: ruby
         | 
| 7 7 | 
             
            authors:
         | 
| @@ -9,11 +9,11 @@ authors: | |
| 9 9 | 
             
            autorequire: 
         | 
| 10 10 | 
             
            bindir: bin
         | 
| 11 11 | 
             
            cert_chain: []
         | 
| 12 | 
            -
            date: 2012- | 
| 12 | 
            +
            date: 2012-11-20 00:00:00.000000000 Z
         | 
| 13 13 | 
             
            dependencies:
         | 
| 14 14 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 15 15 | 
             
              name: rails
         | 
| 16 | 
            -
              requirement:  | 
| 16 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 17 17 | 
             
                none: false
         | 
| 18 18 | 
             
                requirements:
         | 
| 19 19 | 
             
                - - ! '>'
         | 
| @@ -21,10 +21,15 @@ dependencies: | |
| 21 21 | 
             
                    version: 3.0.0
         | 
| 22 22 | 
             
              type: :runtime
         | 
| 23 23 | 
             
              prerelease: false
         | 
| 24 | 
            -
              version_requirements:  | 
| 24 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 25 | 
            +
                none: false
         | 
| 26 | 
            +
                requirements:
         | 
| 27 | 
            +
                - - ! '>'
         | 
| 28 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 29 | 
            +
                    version: 3.0.0
         | 
| 25 30 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 26 31 | 
             
              name: rspec-rails
         | 
| 27 | 
            -
              requirement:  | 
| 32 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 28 33 | 
             
                none: false
         | 
| 29 34 | 
             
                requirements:
         | 
| 30 35 | 
             
                - - ! '>='
         | 
| @@ -32,10 +37,15 @@ dependencies: | |
| 32 37 | 
             
                    version: 2.8.1
         | 
| 33 38 | 
             
              type: :development
         | 
| 34 39 | 
             
              prerelease: false
         | 
| 35 | 
            -
              version_requirements:  | 
| 40 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 41 | 
            +
                none: false
         | 
| 42 | 
            +
                requirements:
         | 
| 43 | 
            +
                - - ! '>='
         | 
| 44 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 45 | 
            +
                    version: 2.8.1
         | 
| 36 46 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 37 47 | 
             
              name: capybara
         | 
| 38 | 
            -
              requirement:  | 
| 48 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 39 49 | 
             
                none: false
         | 
| 40 50 | 
             
                requirements:
         | 
| 41 51 | 
             
                - - ! '>='
         | 
| @@ -43,10 +53,15 @@ dependencies: | |
| 43 53 | 
             
                    version: 0.4.1
         | 
| 44 54 | 
             
              type: :development
         | 
| 45 55 | 
             
              prerelease: false
         | 
| 46 | 
            -
              version_requirements:  | 
| 56 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 57 | 
            +
                none: false
         | 
| 58 | 
            +
                requirements:
         | 
| 59 | 
            +
                - - ! '>='
         | 
| 60 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 61 | 
            +
                    version: 0.4.1
         | 
| 47 62 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 48 63 | 
             
              name: sqlite3-ruby
         | 
| 49 | 
            -
              requirement:  | 
| 64 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 50 65 | 
             
                none: false
         | 
| 51 66 | 
             
                requirements:
         | 
| 52 67 | 
             
                - - ! '>='
         | 
| @@ -54,10 +69,15 @@ dependencies: | |
| 54 69 | 
             
                    version: '0'
         | 
| 55 70 | 
             
              type: :development
         | 
| 56 71 | 
             
              prerelease: false
         | 
| 57 | 
            -
              version_requirements:  | 
| 72 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 73 | 
            +
                none: false
         | 
| 74 | 
            +
                requirements:
         | 
| 75 | 
            +
                - - ! '>='
         | 
| 76 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 77 | 
            +
                    version: '0'
         | 
| 58 78 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 59 79 | 
             
              name: rake
         | 
| 60 | 
            -
              requirement:  | 
| 80 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 61 81 | 
             
                none: false
         | 
| 62 82 | 
             
                requirements:
         | 
| 63 83 | 
             
                - - ~>
         | 
| @@ -65,7 +85,12 @@ dependencies: | |
| 65 85 | 
             
                    version: 0.8.7
         | 
| 66 86 | 
             
              type: :development
         | 
| 67 87 | 
             
              prerelease: false
         | 
| 68 | 
            -
              version_requirements:  | 
| 88 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 89 | 
            +
                none: false
         | 
| 90 | 
            +
                requirements:
         | 
| 91 | 
            +
                - - ~>
         | 
| 92 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 93 | 
            +
                    version: 0.8.7
         | 
| 69 94 | 
             
            description: Rails 3 Engine for using the Houdini Mechanical Turk API
         | 
| 70 95 | 
             
            email: chris@houdiniapi.com
         | 
| 71 96 | 
             
            executables: []
         | 
| @@ -135,7 +160,7 @@ required_ruby_version: !ruby/object:Gem::Requirement | |
| 135 160 | 
             
                  version: '0'
         | 
| 136 161 | 
             
                  segments:
         | 
| 137 162 | 
             
                  - 0
         | 
| 138 | 
            -
                  hash:  | 
| 163 | 
            +
                  hash: 2466568904906734971
         | 
| 139 164 | 
             
            required_rubygems_version: !ruby/object:Gem::Requirement
         | 
| 140 165 | 
             
              none: false
         | 
| 141 166 | 
             
              requirements:
         | 
| @@ -144,10 +169,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement | |
| 144 169 | 
             
                  version: '0'
         | 
| 145 170 | 
             
                  segments:
         | 
| 146 171 | 
             
                  - 0
         | 
| 147 | 
            -
                  hash:  | 
| 172 | 
            +
                  hash: 2466568904906734971
         | 
| 148 173 | 
             
            requirements: []
         | 
| 149 174 | 
             
            rubyforge_project: 
         | 
| 150 | 
            -
            rubygems_version: 1.8. | 
| 175 | 
            +
            rubygems_version: 1.8.24
         | 
| 151 176 | 
             
            signing_key: 
         | 
| 152 177 | 
             
            specification_version: 3
         | 
| 153 178 | 
             
            summary: Rails 3 Engine for using the Houdini Mechanical Turk API
         |