houdini 0.3.2 → 0.3.3
Sign up to get free protection for your applications and to get access to all the features.
- data/.travis.yml +3 -0
- data/Gemfile.lock +1 -1
- data/README.markdown +26 -19
- data/lib/houdini/postback_processor.rb +3 -4
- data/lib/houdini/version.rb +1 -1
- data/spec/houdini/postback_processor_spec.rb +0 -1
- data/spec/spec_helper.rb +3 -3
- metadata +6 -5
data/.travis.yml
ADDED
data/Gemfile.lock
CHANGED
data/README.markdown
CHANGED
@@ -1,8 +1,9 @@
|
|
1
|
+
[![Build Status](https://travis-ci.org/chrisconley/houdini-gem.png?branch=master)](https://travis-ci.org/chrisconley/houdini-gem)
|
1
2
|
# Overview
|
2
3
|
|
3
4
|
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
5
|
|
5
|
-
Check out the [Houdini Documentation](http://
|
6
|
+
Check out the [Houdini Documentation](http://support.houdiniapp.com/customer/portal/topics/409711-developer-docs/articles) for more info about the API.
|
6
7
|
|
7
8
|
# Installation (Rails 3.x)
|
8
9
|
|
@@ -18,26 +19,28 @@ You may want to configure Houdini differently for each of you environments.
|
|
18
19
|
|
19
20
|
# Example Usage
|
20
21
|
|
21
|
-
Request a beta account at http://
|
22
|
+
Request a beta account at http://houdiniapp.com to gain access to the Houdini Blueprint Editor.
|
22
23
|
|
23
24
|
Setup Houdini in your ActiveRecord model:
|
24
25
|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
26
|
+
``` ruby
|
27
|
+
class Post < ActiveRecord::Base
|
28
|
+
include Houdini::Model
|
29
|
+
|
30
|
+
houdini :image_moderation,
|
31
|
+
:input => {
|
32
|
+
:image_url => :image_url, # call the input_url method for
|
33
|
+
:image_caption => lambda{ self.caption.titleize }, # use a lambda, called in the model's context
|
34
|
+
:image_size => "100x100" # just send this string
|
35
|
+
},
|
36
|
+
:on => :after_create,
|
37
|
+
:on_task_completion => :process_image_moderation_answer
|
38
|
+
|
39
|
+
def process_image_moderation_answer(params, verbose={})
|
40
|
+
update_attribute :flagged => params[:category] == 'flagged'
|
41
|
+
end
|
42
|
+
end
|
43
|
+
```
|
41
44
|
|
42
45
|
# Usage
|
43
46
|
|
@@ -54,10 +57,14 @@ Setup Houdini in your ActiveRecord model:
|
|
54
57
|
* `:id_method` - Method to get an identifier for the object. It is `id` by default, but you may want to use `to_param` with your app. Can be a symbol or lambda/proc. Use this in conjunction with `:finder`.
|
55
58
|
* `:finder` - Method by which to find the model by an identifier. It is `find` by default. Can be a symbol or lambda/proc. Use this in conjunction with `:id_method`.
|
56
59
|
|
60
|
+
# Example Application
|
61
|
+
|
62
|
+
An example Rails 3.2 & Mongoid application can be found here: [https://github.com/chrisconley/houdini-rails-32](https://github.com/chrisconley/houdini-rails-32)
|
63
|
+
|
57
64
|
## Credits
|
58
65
|
|
59
66
|
* Thanks to Mike Nicholaides (https://github.com/nicholaides) for a huge refactoring to bring the gem up to date with the new version of Houdini.
|
60
67
|
|
61
68
|
## License
|
62
69
|
|
63
|
-
MIT License. Copyright
|
70
|
+
MIT License. Copyright 2013 Houdini Inc. http://houdiniapi.com
|
@@ -10,10 +10,9 @@ module Houdini
|
|
10
10
|
raise EnvironmentMismatchError, "Environment received does not match Houdini.environment"
|
11
11
|
end
|
12
12
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
# end
|
13
|
+
if params[:api_key] != Houdini.api_key
|
14
|
+
raise APIKeyMistmatchError, "API key received doesn't match our API key."
|
15
|
+
end
|
17
16
|
|
18
17
|
task_manager.process class_name, model_id, params[:blueprint], params[:output], params[:verbose_output]
|
19
18
|
end
|
data/lib/houdini/version.rb
CHANGED
@@ -18,7 +18,6 @@ describe Houdini::PostbackProcessor, ".process!" do
|
|
18
18
|
|
19
19
|
context "when in production and given API key doesn't match" do
|
20
20
|
it "should raise an APIKeyMistmatchError" do
|
21
|
-
pending "Houdini doesn't send the API key back."
|
22
21
|
lambda{
|
23
22
|
Houdini::PostbackProcessor.process 'Class', 42, :environment => "production", :api_key => "ANOTHER_KEY"
|
24
23
|
}.should raise_error(Houdini::PostbackProcessor::APIKeyMistmatchError)
|
data/spec/spec_helper.rb
CHANGED
@@ -16,9 +16,9 @@ Capybara.default_driver = :rack_test
|
|
16
16
|
Capybara.default_selector = :css
|
17
17
|
|
18
18
|
# Run migrations
|
19
|
-
|
20
|
-
|
21
|
-
|
19
|
+
db_path = File.expand_path("../dummy/db/test.sqlite3/", __FILE__)
|
20
|
+
`rm #{db_path}` if File.exists?(db_path)
|
21
|
+
ActiveRecord::Migrator.migrate File.expand_path("../dummy/db/migrate/", __FILE__)
|
22
22
|
|
23
23
|
# Load support files
|
24
24
|
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
|
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.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2013-02-21 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
@@ -100,6 +100,7 @@ files:
|
|
100
100
|
- .document
|
101
101
|
- .gitignore
|
102
102
|
- .rspec
|
103
|
+
- .travis.yml
|
103
104
|
- Gemfile
|
104
105
|
- Gemfile.lock
|
105
106
|
- LICENSE
|
@@ -160,7 +161,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
160
161
|
version: '0'
|
161
162
|
segments:
|
162
163
|
- 0
|
163
|
-
hash:
|
164
|
+
hash: 2863160700506716491
|
164
165
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
165
166
|
none: false
|
166
167
|
requirements:
|
@@ -169,10 +170,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
169
170
|
version: '0'
|
170
171
|
segments:
|
171
172
|
- 0
|
172
|
-
hash:
|
173
|
+
hash: 2863160700506716491
|
173
174
|
requirements: []
|
174
175
|
rubyforge_project:
|
175
|
-
rubygems_version: 1.8.
|
176
|
+
rubygems_version: 1.8.23
|
176
177
|
signing_key:
|
177
178
|
specification_version: 3
|
178
179
|
summary: Rails 3 Engine for using the Houdini Mechanical Turk API
|