shared_workforce 0.2.3 → 0.2.4

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  Shared Workforce Client
2
2
  =======================
3
3
 
4
- [![Build Status](https://secure.travis-ci.org/samoli/shared-workforce.png)](http://travis-ci.org/#!/samoli/shared-workforce)
4
+ [![Build Status](https://secure.travis-ci.org/sharedworkforce/sharedworkforce.png)](http://travis-ci.org/#!/sharedworkforce/sharedworkforce)
5
5
 
6
6
  Shared Workforce is a platform for managing and completing repetitive tasks that require human intelligence. For example, tagging photos, approving text and answering simple questions.
7
7
 
@@ -1,11 +1,11 @@
1
1
  module SharedWorkforce
2
2
  class Configuration
3
3
 
4
- attr_accessor :api_key
4
+ attr_writer :callback_host
5
+ attr_writer :callback_path
6
+ attr_writer :api_key
5
7
  attr_accessor :http_end_point
6
- attr_accessor :callback_host
7
8
  attr_accessor :request_class
8
- attr_writer :callback_path
9
9
 
10
10
  def initialize
11
11
  @http_end_point = "http://api.sharedworkforce.com"
@@ -20,6 +20,14 @@ module SharedWorkforce
20
20
  @callback_path ||= "hci_task_result"
21
21
  end
22
22
 
23
+ def api_key
24
+ @api_key ||= ENV['SHAREDWORKFORCE_API_KEY']
25
+ end
26
+
27
+ def callback_host
28
+ @callback_host ||= ENV['SHAREDWORKFORCE_CALLBACK_HOST']
29
+ end
30
+
23
31
  private
24
32
 
25
33
  def default_request_class
@@ -7,6 +7,7 @@ module SharedWorkforce
7
7
  :title,
8
8
  :answer_type,
9
9
  :instruction,
10
+ :guidelines,
10
11
  :responses_required,
11
12
  :replace,
12
13
  :answer_options,
@@ -123,6 +124,7 @@ module SharedWorkforce
123
124
  {
124
125
  :title => title,
125
126
  :instruction => instruction,
127
+ :guidelines => guidelines,
126
128
  :image_url => image_url,
127
129
  :answer_options => answer_options,
128
130
  :responses_required => responses_required,
@@ -1,4 +1,4 @@
1
1
  module SharedWorkforce
2
- VERSION = "0.2.3"
2
+ VERSION = "0.2.4"
3
3
 
4
4
  end
@@ -0,0 +1,41 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+
3
+ describe "Configuration" do
4
+
5
+ let(:configuration) { SharedWorkforce::Configuration.new }
6
+
7
+ describe "#api_key" do
8
+ it "should use the API key set in ENV['SHAREDWORKFORCE_API_KEY']" do
9
+ old_env = ENV['SHAREDWORKFORCE_API_KEY']
10
+ ENV['SHAREDWORKFORCE_API_KEY'] = "API_KEY_FROM_ENV"
11
+ configuration.api_key.should == "API_KEY_FROM_ENV"
12
+ ENV['SHAREDWORKFORCE_API_KEY'] = old_env
13
+ end
14
+
15
+ it "should be overridable with a custom value" do
16
+ old_env = ENV['SHAREDWORKFORCE_API_KEY']
17
+ ENV['SHAREDWORKFORCE_API_KEY'] = "API_KEY_FROM_ENV"
18
+ configuration.api_key = "CUSTOM_API_KEY"
19
+ configuration.api_key.should == "CUSTOM_API_KEY"
20
+ ENV['SHAREDWORKFORCE_API_KEY'] = old_env
21
+ end
22
+ end
23
+
24
+ describe "#callback_host" do
25
+ it "should use the callback host set in ENV['SHAREDWORKFORCE_CALLBACK_HOST']" do
26
+ old_env = ENV['SHAREDWORKFORCE_CALLBACK_HOST']
27
+ ENV['SHAREDWORKFORCE_CALLBACK_HOST'] = "http://env.example.com"
28
+ configuration.callback_host.should == "http://env.example.com"
29
+ ENV['SHAREDWORKFORCE_CALLBACK_HOST'] = old_env
30
+ end
31
+
32
+ it "should be overridable with a custom value" do
33
+ old_env = ENV['SHAREDWORKFORCE_CALLBACK_HOST']
34
+ ENV['SHAREDWORKFORCE_CALLBACK_HOST'] = "env.example.com"
35
+ configuration.callback_host = "custom.example.com"
36
+ configuration.callback_host.should == "custom.example.com"
37
+ ENV['SHAREDWORKFORCE_CALLBACK_HOST'] = old_env
38
+ end
39
+ end
40
+
41
+ end
@@ -1,5 +1,5 @@
1
1
  require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
- require 'rack'
2
+
3
3
  describe "EndPoint" do
4
4
 
5
5
  describe "#process_request" do
data/spec/task_spec.rb CHANGED
@@ -17,6 +17,7 @@ describe "Task" do
17
17
  image_url "http://www.google.com/logo.png"
18
18
  answer_type :crop
19
19
  image_crop_ratio 1.7
20
+ guidelines "* be careful"
20
21
 
21
22
  answer_options ['Obscenity', 'Nudity', 'Blurry', 'Upside down or sideways']
22
23
 
@@ -39,6 +40,7 @@ describe "Task" do
39
40
  task.image_url.should == "http://www.google.com/logo.png"
40
41
  task.image_crop_ratio.should == 1.7
41
42
  task.answer_options.should == ['Obscenity', 'Nudity', 'Blurry', 'Upside down or sideways']
43
+ task.guidelines.should == "* be careful"
42
44
  end
43
45
 
44
46
  it "should allow certain default attributes to be overwritten" do
@@ -326,6 +328,12 @@ describe "Task" do
326
328
  task.to_hash[:callback_params][:_task][:resource][:class_name].should == "Resource"
327
329
  task.to_hash[:callback_params][:_task][:class_name].should == 'ApprovePhotoTask'
328
330
  end
331
+
332
+ it "should include the guidelines" do
333
+ task = ApprovePhotoTask.new(@resource_class.new)
334
+ task.guidelines = "* be careful"
335
+ task.to_hash[:guidelines].should == '* be careful'
336
+ end
329
337
  end
330
338
  end
331
339
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: shared_workforce
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.3
4
+ version: 0.2.4
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-04-14 00:00:00.000000000 Z
12
+ date: 2012-04-25 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rest-client
16
- requirement: &70269574726440 !ruby/object:Gem::Requirement
16
+ requirement: &70160649037520 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70269574726440
24
+ version_requirements: *70160649037520
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: json
27
- requirement: &70269574725980 !ruby/object:Gem::Requirement
27
+ requirement: &70160649037040 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '0'
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *70269574725980
35
+ version_requirements: *70160649037040
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: activesupport
38
- requirement: &70269574725520 !ruby/object:Gem::Requirement
38
+ requirement: &70160649036480 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: '0'
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *70269574725520
46
+ version_requirements: *70160649036480
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: rspec
49
- requirement: &70269574724960 !ruby/object:Gem::Requirement
49
+ requirement: &70160649035640 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: 1.2.9
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *70269574724960
57
+ version_requirements: *70160649035640
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: webmock
60
- requirement: &70269574724540 !ruby/object:Gem::Requirement
60
+ requirement: &70160649034840 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ! '>='
@@ -65,7 +65,7 @@ dependencies:
65
65
  version: '0'
66
66
  type: :development
67
67
  prerelease: false
68
- version_requirements: *70269574724540
68
+ version_requirements: *70160649034840
69
69
  description: Shared Workforce is a service and simple API for human intelligence tasks
70
70
  email:
71
71
  - sam@samoliver.com
@@ -96,6 +96,7 @@ files:
96
96
  - shared_workforce.gemspec
97
97
  - spec/.rspec
98
98
  - spec/client_spec.rb
99
+ - spec/configuration_spec.rb
99
100
  - spec/end_point_spec.rb
100
101
  - spec/spec_helper.rb
101
102
  - spec/support/configuration_helper.rb
@@ -131,6 +132,7 @@ specification_version: 3
131
132
  summary: Shared Workforce Client
132
133
  test_files:
133
134
  - spec/client_spec.rb
135
+ - spec/configuration_spec.rb
134
136
  - spec/end_point_spec.rb
135
137
  - spec/spec_helper.rb
136
138
  - spec/support/configuration_helper.rb