crowdflower 0.2.3 → 0.3.0

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/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.3
1
+ 0.3.0
Binary file
data/crowdflower.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{crowdflower}
8
- s.version = "0.2.3"
8
+ s.version = "0.3.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Brian P O'Rourke", "Chris Van Pelt"]
12
- s.date = %q{2010-02-22}
12
+ s.date = %q{2010-03-17}
13
13
  s.description = %q{A toolkit for interacting with CrowdFlower via the REST API.
14
14
 
15
15
  This is alpha software. Have fun!
@@ -30,6 +30,7 @@ This is alpha software. Have fun!
30
30
  "VERSION",
31
31
  "bindev/cl_skel.rb",
32
32
  "bindev/crowdflower.rb",
33
+ "crowdflower-0.2.3.gem",
33
34
  "crowdflower.gemspec",
34
35
  "lib/crowdflower.rb",
35
36
  "lib/crowdflower/base.rb",
@@ -33,7 +33,7 @@ module CrowdFlower
33
33
  end
34
34
 
35
35
  def self.connect!(key, development = false)
36
- @@domain = development ? "http://api.tsujigiri.local:4000/v1" : "https://api.crowdflower.com/v1"
36
+ @@domain = development ? "http://api.localhost.com:4000/v1" : "https://api.crowdflower.com/v1"
37
37
  @@key = key
38
38
  end
39
39
 
@@ -109,7 +109,7 @@ module CrowdFlower
109
109
  end
110
110
 
111
111
  def update(data)
112
- res = Job.put("#{resource_uri}/#{@id}.json", {:query => { :job => data }, :headers => { "Content-Length" => "0" } } )
112
+ res = Job.put("#{resource_uri}/#{@id}.json", {:body => { :job => data }, :headers => { "Content-Length" => "0" } } )
113
113
  if res["error"]
114
114
  raise CrowdFlower::APIError.new(res["error"])
115
115
  end
@@ -9,11 +9,11 @@ module CrowdFlower
9
9
  end
10
10
 
11
11
  def resource_uri
12
- "/jobs/#{@job.id}/orders"
12
+ "/jobs/#{@job.id}/orders.json"
13
13
  end
14
14
 
15
- def debit(percentage = 100, channels = ["amt"])
16
- Order.post(resource_uri, {:body => {:percentage => percentage, :channels => channels}})
15
+ def debit(units_count = 1, channels = ["amt"])
16
+ Order.post(resource_uri, {:query => {:debit => {:units_count => units_count}, :channels => channels}})
17
17
  end
18
18
  end
19
19
  end
@@ -35,5 +35,9 @@ module CrowdFlower
35
35
  def split(on, with = " ")
36
36
  Unit.get("#{resource_uri}/split", {:query => {:on => on, :with => with}})
37
37
  end
38
+
39
+ def cancel(unit_id)
40
+ Unit.post("#{resource_uri}/#{unit_id}/cancel.json")
41
+ end
38
42
  end
39
43
  end
@@ -1,7 +1,7 @@
1
1
  $: << File.dirname(__FILE__) + "/../lib"
2
2
 
3
3
  require 'rubygems'
4
- require 'ruby-crowdflower'
4
+ require 'crowdflower'
5
5
  require 'json'
6
6
 
7
7
  API_KEY = ENV["API_KEY"]
@@ -88,6 +88,22 @@ assert job.status["tainted_judgments"] == 0
88
88
  say "Registering a webhook."
89
89
  job.update :webhook_uri => "http://localhost:8080/crowdflower"
90
90
 
91
+ say "Adding title, instructions, and problem to the job."
92
+ job.update({:title => 'testtt', :instructions => 'testttt fdsf sfds fsdfs fesfsdf', :problem => '<cml:text label="Text" class="unmodified"/>' })
93
+
94
+ say "Ordering the job."
95
+ order = CrowdFlower::Order.new(job)
96
+ unit_count = 8
97
+ order.debit(8)
98
+ wait_until { job.status["needed_judgments"] == 24}
99
+
100
+ say "Canceling the unit."
101
+ unit_id = job.units.all.to_a[0][0]
102
+ unit = CrowdFlower::Unit.new(job)
103
+ assert unit.get(unit_id)['state'] == 'judgable'
104
+ puts unit.cancel(unit_id).inspect
105
+ assert unit.get(unit_id)['state'] == 'new'
106
+
91
107
  say "Webhook test needs to be written."
92
108
  #job.test_webhook
93
109
 
metadata CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
4
4
  prerelease: false
5
5
  segments:
6
6
  - 0
7
- - 2
8
7
  - 3
9
- version: 0.2.3
8
+ - 0
9
+ version: 0.3.0
10
10
  platform: ruby
11
11
  authors:
12
12
  - Brian P O'Rourke
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-02-22 00:00:00 -08:00
18
+ date: 2010-03-17 00:00:00 -07:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -55,6 +55,7 @@ files:
55
55
  - VERSION
56
56
  - bindev/cl_skel.rb
57
57
  - bindev/crowdflower.rb
58
+ - crowdflower-0.2.3.gem
58
59
  - crowdflower.gemspec
59
60
  - lib/crowdflower.rb
60
61
  - lib/crowdflower/base.rb