pybossa-api 0.0.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/.gitignore +6 -0
- data/.travis.yml +3 -0
- data/Gemfile +4 -0
- data/LICENSE +20 -0
- data/README.md +44 -0
- data/Rakefile +16 -0
- data/USAGE +1 -0
- data/lib/pybossa-api.rb +106 -0
- data/lib/pybossa-api/app.rb +67 -0
- data/lib/pybossa-api/task.rb +68 -0
- data/lib/pybossa-api/task_run.rb +62 -0
- data/lib/pybossa-api/version.rb +5 -0
- data/pybossa-api.gemspec +25 -0
- data/spec/pybossa-api/app_spec.rb +31 -0
- data/spec/pybossa-api/task_run_spec.rb +31 -0
- data/spec/pybossa-api/task_spec.rb +31 -0
- data/spec/pybossa-api_spec.rb +47 -0
- data/spec/spec_helper.rb +3 -0
- metadata +124 -0
data/.gitignore
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
Copyright (c) 2012 Open North Inc.
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
4
|
+
a copy of this software and associated documentation files (the
|
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
9
|
+
the following conditions:
|
|
10
|
+
|
|
11
|
+
The above copyright notice and this permission notice shall be
|
|
12
|
+
included in all copies or substantial portions of the Software.
|
|
13
|
+
|
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
# The PyBossa API Ruby Gem
|
|
2
|
+
|
|
3
|
+
A Ruby wrapper for the PyBossa API.
|
|
4
|
+
|
|
5
|
+
[](http://travis-ci.org/opennorth/pybossa-api-ruby)
|
|
6
|
+
[](https://codeclimate.com/github/opennorth/pybossa-api-ruby)
|
|
7
|
+
|
|
8
|
+
## Installation
|
|
9
|
+
|
|
10
|
+
gem install pybossa-api
|
|
11
|
+
|
|
12
|
+
## API Examples
|
|
13
|
+
|
|
14
|
+
>> require 'pybossa-api'
|
|
15
|
+
|
|
16
|
+
>> PyBossa::App.list limit: 100 # default limit is 20
|
|
17
|
+
=> [{"info"=>{"task_presenter"=>"...", "thumbnail"=>"..."}, ...}, ...]
|
|
18
|
+
|
|
19
|
+
>> PyBossa::App.list short_name: 'flickrperson'
|
|
20
|
+
=> [{"info"=>{"task_presenter"=>"...", "thumbnail"=>"..."}, ...}, ...]
|
|
21
|
+
|
|
22
|
+
>> PyBossa::App.get 128
|
|
23
|
+
=> {"info"=>{"task_presenter"=>"...", "thumbnail"=>"..."}, ...}
|
|
24
|
+
|
|
25
|
+
>> PyBossa::App.api_key = '21ec2020-3aea-1069-a2dd-08002b30309d'
|
|
26
|
+
|
|
27
|
+
>> app = PyBossa::App.create "info"=>{"task_presenter"=>"...", "thumbnail"=>"..."}, ...
|
|
28
|
+
=> {"info"=>{"task_presenter"=>"...", "thumbnail"=>"..."}, ...}
|
|
29
|
+
|
|
30
|
+
>> PyBossa::App.update app['id'], description: "An example API call"
|
|
31
|
+
=> nil # raises an error on failure
|
|
32
|
+
|
|
33
|
+
>> PyBossa::App.delete app['id']
|
|
34
|
+
=> nil # raises an error on failure
|
|
35
|
+
|
|
36
|
+
You can perform similar operations on `PyBossa::Task` and `PyBossa::TaskRun`.
|
|
37
|
+
|
|
38
|
+
More documentation at [RubyDoc.info](http://rdoc.info/gems/pybossa-api/PyBossa/API).
|
|
39
|
+
|
|
40
|
+
## Bugs? Questions?
|
|
41
|
+
|
|
42
|
+
This gem's main repository is on GitHub: [http://github.com/opennorth/pybossa-api-ruby](http://github.com/opennorth/pybossa-api-ruby), where your contributions, forks, bug reports, feature requests, and feedback are greatly welcomed.
|
|
43
|
+
|
|
44
|
+
Copyright (c) 2012 Open North Inc., released under the MIT license
|
data/Rakefile
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
require 'bundler'
|
|
2
|
+
Bundler::GemHelper.install_tasks
|
|
3
|
+
|
|
4
|
+
require 'rspec/core/rake_task'
|
|
5
|
+
RSpec::Core::RakeTask.new(:spec)
|
|
6
|
+
|
|
7
|
+
task :default => :spec
|
|
8
|
+
|
|
9
|
+
begin
|
|
10
|
+
require 'yard'
|
|
11
|
+
YARD::Rake::YardocTask.new
|
|
12
|
+
rescue LoadError
|
|
13
|
+
task :yard do
|
|
14
|
+
abort 'YARD is not available. In order to run yard, you must: gem install yard'
|
|
15
|
+
end
|
|
16
|
+
end
|
data/USAGE
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
See README.md for full usage details.
|
data/lib/pybossa-api.rb
ADDED
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
$LOAD_PATH.unshift(File.expand_path(File.dirname(__FILE__))) unless $LOAD_PATH.include?(File.expand_path(File.dirname(__FILE__)))
|
|
2
|
+
|
|
3
|
+
require 'httparty'
|
|
4
|
+
require 'sanitize'
|
|
5
|
+
require 'yajl'
|
|
6
|
+
|
|
7
|
+
module PyBossa
|
|
8
|
+
autoload :App, 'pybossa-api/app'
|
|
9
|
+
autoload :Task, 'pybossa-api/task'
|
|
10
|
+
autoload :TaskRun, 'pybossa-api/task_run'
|
|
11
|
+
|
|
12
|
+
# A Ruby wrapper for the PyBossa API.
|
|
13
|
+
# @see http://docs.pybossa.com/en/latest/model.html#restful-api
|
|
14
|
+
class API
|
|
15
|
+
include HTTParty
|
|
16
|
+
base_uri 'pybossa.com/api'
|
|
17
|
+
|
|
18
|
+
class Error < StandardError; end
|
|
19
|
+
|
|
20
|
+
class << self
|
|
21
|
+
attr_accessor :api_key
|
|
22
|
+
|
|
23
|
+
# Lists objects. To filter objects, add key-value pairs to the +:opts+
|
|
24
|
+
# argument in which each key is the name of a field on which you want to
|
|
25
|
+
# filter. For example, you may want to filter tasks by +app_id+.
|
|
26
|
+
#
|
|
27
|
+
# @param [String] klass one of "app", "task" or "taskrun"
|
|
28
|
+
# @param [Hash] opts optional arguments
|
|
29
|
+
# @option opts [Integer] :limit number of results to return [default 20]
|
|
30
|
+
# @option opts [String] :api_key an API key
|
|
31
|
+
# @return [Array] a list of objects
|
|
32
|
+
def many(klass, opts = {})
|
|
33
|
+
request :get, "/#{klass}", opts
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
# Gets an object by ID.
|
|
37
|
+
#
|
|
38
|
+
# @param [String] klass one of "app", "task" or "taskrun"
|
|
39
|
+
# @param [Integer] id an object ID
|
|
40
|
+
# @param [Hash] opts optional arguments
|
|
41
|
+
# @option opts [String] :api_key an API key
|
|
42
|
+
# @return [Hash] an object
|
|
43
|
+
def retrieve(klass, id, opts = {})
|
|
44
|
+
request :get, "/#{klass}/#{id}", opts
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
# Creates an object.
|
|
48
|
+
#
|
|
49
|
+
# @param [String] klass one of "app", "task" or "taskrun"
|
|
50
|
+
# @param [Hash] opts optional arguments
|
|
51
|
+
# @option opts [String] :api_key an API key
|
|
52
|
+
# @return [Hash] an object
|
|
53
|
+
# @raise [PyBossa::API::Error] if operation failed
|
|
54
|
+
#
|
|
55
|
+
# @see https://github.com/PyBossa/pybossa/blob/master/pybossa/api.py#L91
|
|
56
|
+
def create(klass, opts = {})
|
|
57
|
+
request :post, "/#{klass}", opts
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
# Updates an object.
|
|
61
|
+
#
|
|
62
|
+
# @param [String] klass one of "app", "task" or "taskrun"
|
|
63
|
+
# @param [Integer] id an object ID
|
|
64
|
+
# @param [Hash] opts optional arguments
|
|
65
|
+
# @option opts [String] :api_key an API key
|
|
66
|
+
# @raise [PyBossa::API::Error] if operation failed
|
|
67
|
+
#
|
|
68
|
+
# @see https://github.com/PyBossa/pybossa/blob/master/pybossa/api.py#L129
|
|
69
|
+
def update(klass, id, opts = {})
|
|
70
|
+
request :put, "/#{klass}/#{id}", opts
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
# Deletes an object.
|
|
74
|
+
#
|
|
75
|
+
# @param [String] klass one of "app", "task" or "taskrun"
|
|
76
|
+
# @param [Integer] id an object ID
|
|
77
|
+
# @param [Hash] opts optional arguments
|
|
78
|
+
# @option opts [String] :api_key an API key
|
|
79
|
+
# @raise [PyBossa::API::Error] if operation failed
|
|
80
|
+
#
|
|
81
|
+
# @see https://github.com/PyBossa/pybossa/blob/master/pybossa/api.py#L108
|
|
82
|
+
def destroy(klass, id, opts = {})
|
|
83
|
+
request :delete, "/#{klass}/#{id}", opts
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
# @todo new_task user_progress
|
|
87
|
+
# https://github.com/PyBossa/pybossa/blob/master/pybossa/api.py#L198
|
|
88
|
+
# https://github.com/PyBossa/pybossa/blob/master/pybossa/api.py#L238
|
|
89
|
+
|
|
90
|
+
private
|
|
91
|
+
|
|
92
|
+
def request(http_method, path, opts)
|
|
93
|
+
opts[:api_key] ||= api_key if api_key
|
|
94
|
+
response = if [:get, :delete].include? http_method
|
|
95
|
+
send http_method, path, :query => opts
|
|
96
|
+
else
|
|
97
|
+
send http_method, path, :query => {:api_key => opts.delete(:api_key)}, :body => Yajl::Encoder.encode(opts), :headers => {'Content-type' => 'application/json'}
|
|
98
|
+
end
|
|
99
|
+
unless [200, 204].include? response.response.code.to_i
|
|
100
|
+
raise PyBossa::API::Error.new Sanitize.clean(response.response.body)
|
|
101
|
+
end
|
|
102
|
+
response.parsed_response
|
|
103
|
+
end
|
|
104
|
+
end
|
|
105
|
+
end
|
|
106
|
+
end
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
module PyBossa
|
|
2
|
+
class App
|
|
3
|
+
class << self
|
|
4
|
+
# @param [Hash] opts optional arguments
|
|
5
|
+
# @option opts [Integer] :limit number of results to return [default 20]
|
|
6
|
+
# @option opts [String] :api_key an API key
|
|
7
|
+
# @return [Array] a list of apps
|
|
8
|
+
def list(opts = {})
|
|
9
|
+
PyBossa::API.many 'app', opts
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
# @param [Integer] id an app ID
|
|
13
|
+
# @param [Hash] opts optional arguments
|
|
14
|
+
# @option opts [String] :api_key an API key
|
|
15
|
+
# @return [Hash] an app
|
|
16
|
+
def get(id, opts = {})
|
|
17
|
+
PyBossa::API.retrieve 'app', id, opts
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
# Creates an app.
|
|
21
|
+
#
|
|
22
|
+
# @param [Hash] opts optional arguments
|
|
23
|
+
# @option opts [String] :name a name
|
|
24
|
+
# @option opts [String] :short_name a URL slug
|
|
25
|
+
# @option opts [String] :description a short description
|
|
26
|
+
# @option opts [String] :long_description a long HTML description
|
|
27
|
+
# @option opts [Integer] :long_tasks [not in use]
|
|
28
|
+
# @option opts [Boolean] :hidden whether to hide the app from the public
|
|
29
|
+
# @option opts [Integer] :time_estimate estimated time to complete [not in use]
|
|
30
|
+
# @option opts [Integer] :time_limit time limit to complete task [not in use]
|
|
31
|
+
# @option opts [Float] :calibration_frac [not in use]
|
|
32
|
+
# @option opts [Integer] :bolt_course_id [not in use]
|
|
33
|
+
# @option opts [Hash] :info all other task details
|
|
34
|
+
# @option opts [String] :api_key an API key
|
|
35
|
+
# @return [Hash] an app
|
|
36
|
+
#
|
|
37
|
+
# @see https://github.com/PyBossa/pybossa/blob/master/pybossa/model.py#L133
|
|
38
|
+
def create(opts = {})
|
|
39
|
+
if opts.has_key? :hidden
|
|
40
|
+
opts[:hidden] = opts[:hidden] ? 1 : 0
|
|
41
|
+
end
|
|
42
|
+
PyBossa::API.create 'app', opts
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
# Updates an app.
|
|
46
|
+
#
|
|
47
|
+
# @param [Integer] id an app ID
|
|
48
|
+
#
|
|
49
|
+
# @see PyBossa::App#create
|
|
50
|
+
def update(id, opts = {})
|
|
51
|
+
if opts.has_key? :calibration
|
|
52
|
+
opts[:calibration] = opts[:calibration] ? 1 : 0
|
|
53
|
+
end
|
|
54
|
+
PyBossa::API.update 'app', id, opts
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
# Deletes an app.
|
|
58
|
+
#
|
|
59
|
+
# @param [Integer] id an app ID
|
|
60
|
+
# @param [Hash] opts optional arguments
|
|
61
|
+
# @option opts [String] :api_key an API key
|
|
62
|
+
def delete(id, opts = {})
|
|
63
|
+
PyBossa::API.destroy 'app', id, opts
|
|
64
|
+
end
|
|
65
|
+
end
|
|
66
|
+
end
|
|
67
|
+
end
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
module PyBossa
|
|
2
|
+
class Task
|
|
3
|
+
class << self
|
|
4
|
+
# @param [Hash] opts optional arguments
|
|
5
|
+
# @option opts [Integer] :limit number of results to return [default 20]
|
|
6
|
+
# @option opts [String] :api_key an API key
|
|
7
|
+
# @return [Array] a list of tasks
|
|
8
|
+
def list(opts = {})
|
|
9
|
+
PyBossa::API.many 'task', opts
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
# @param [Integer] id a task ID
|
|
13
|
+
# @param [Hash] opts optional arguments
|
|
14
|
+
# @option opts [String] :api_key an API key
|
|
15
|
+
# @return [Hash] a task
|
|
16
|
+
def get(id, opts = {})
|
|
17
|
+
PyBossa::API.retrieve 'task', id, opts
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
# Creates a task.
|
|
21
|
+
#
|
|
22
|
+
# @param [Hash] opts optional arguments
|
|
23
|
+
# @option opts [Integer] :app_id the app ID to which this object belongs
|
|
24
|
+
# @option opts [String] :state one of:
|
|
25
|
+
# * "all": Default state
|
|
26
|
+
# * "in_progress": A user is running the task
|
|
27
|
+
# * "pending": The task is completed but requires validation
|
|
28
|
+
# * "valid": The task is completed and valid
|
|
29
|
+
# * "invalid": The task is completed and invalid
|
|
30
|
+
# * "error": The task has an error
|
|
31
|
+
# @option opts [Integer] :quorum number of users who should do this task [not in use]
|
|
32
|
+
# @option opts [Boolean] :calibration whether this is a calibration task [not in use]
|
|
33
|
+
# @option opts [Float] :priority_0 between 0 (low) and 1 (high) [not in use]
|
|
34
|
+
# @option opts [Hash] :info all other task details
|
|
35
|
+
# @option opts [String] :api_key an API key
|
|
36
|
+
# @return [Hash] a task
|
|
37
|
+
#
|
|
38
|
+
# @see https://github.com/PyBossa/pybossa/blob/master/pybossa/model.py#L214
|
|
39
|
+
def create(opts = {})
|
|
40
|
+
if opts.has_key? :calibration
|
|
41
|
+
opts[:calibration] = opts[:calibration] ? 1 : 0
|
|
42
|
+
end
|
|
43
|
+
PyBossa::API.create 'task', opts
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
# Updates a task.
|
|
47
|
+
#
|
|
48
|
+
# @param [Integer] id a task ID
|
|
49
|
+
#
|
|
50
|
+
# @see PyBossa::Task#create
|
|
51
|
+
def update(id, opts = {})
|
|
52
|
+
if opts.has_key? :calibration
|
|
53
|
+
opts[:calibration] = opts[:calibration] ? 1 : 0
|
|
54
|
+
end
|
|
55
|
+
PyBossa::API.update 'task', id, opts
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
# Deletes a task.
|
|
59
|
+
#
|
|
60
|
+
# @param [Integer] id a task ID
|
|
61
|
+
# @param [Hash] opts optional arguments
|
|
62
|
+
# @option opts [String] :api_key an API key
|
|
63
|
+
def delete(id, opts = {})
|
|
64
|
+
PyBossa::API.destroy 'task', id, opts
|
|
65
|
+
end
|
|
66
|
+
end
|
|
67
|
+
end
|
|
68
|
+
end
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
module PyBossa
|
|
2
|
+
class TaskRun
|
|
3
|
+
class << self
|
|
4
|
+
# @param [Hash] opts optional arguments
|
|
5
|
+
# @option opts [Integer] :limit number of results to return [default 20]
|
|
6
|
+
# @option opts [String] :api_key an API key
|
|
7
|
+
# @return [Array] a list of task runs
|
|
8
|
+
def list(opts = {})
|
|
9
|
+
PyBossa::API.many 'taskrun', opts
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
# @param [Integer] id a task run ID
|
|
13
|
+
# @param [Hash] opts optional arguments
|
|
14
|
+
# @option opts [String] :api_key an API key
|
|
15
|
+
# @return [Hash] a task run
|
|
16
|
+
def get(id, opts = {})
|
|
17
|
+
PyBossa::API.retrieve 'taskrun', id, opts
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
# Creates a task run.
|
|
21
|
+
#
|
|
22
|
+
# @param [Hash] opts optional arguments
|
|
23
|
+
# @option opts [Integer] :app_id the app ID to which this object belongs
|
|
24
|
+
# @option opts [Integer] :task_id the task ID to which this object belongs
|
|
25
|
+
# @option opts [Boolean] :timeout timeout for completing a task [not in use]
|
|
26
|
+
# @option opts [Boolean] :calibration whether this is a calibration task [not in use]
|
|
27
|
+
# @option opts [Hash] :info all other task run details
|
|
28
|
+
# @option opts [String] :api_key an API key
|
|
29
|
+
# @return [Hash] a task run
|
|
30
|
+
#
|
|
31
|
+
# @see https://github.com/PyBossa/pybossa/blob/master/pybossa/model.py#L261
|
|
32
|
+
# @see https://github.com/PyBossa/pybossa/blob/master/pybossa/api.py#L169
|
|
33
|
+
def create(opts = {})
|
|
34
|
+
if opts.has_key? :calibration
|
|
35
|
+
opts[:calibration] = opts[:calibration] ? 1 : 0
|
|
36
|
+
end
|
|
37
|
+
PyBossa::API.create 'taskrun', opts
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
# Updates a task run.
|
|
41
|
+
#
|
|
42
|
+
# @param [Integer] id a task run ID
|
|
43
|
+
#
|
|
44
|
+
# @see PyBossa::TaskRun#create
|
|
45
|
+
def update(id, opts = {})
|
|
46
|
+
if opts.has_key? :calibration
|
|
47
|
+
opts[:calibration] = opts[:calibration] ? 1 : 0
|
|
48
|
+
end
|
|
49
|
+
PyBossa::API.update 'taskrun', id, opts
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
# Deletes a task run.
|
|
53
|
+
#
|
|
54
|
+
# @param [Integer] id a task run ID
|
|
55
|
+
# @param [Hash] opts optional arguments
|
|
56
|
+
# @option opts [String] :api_key an API key
|
|
57
|
+
def delete(id, opts = {})
|
|
58
|
+
PyBossa::API.destroy 'taskrun', id, opts
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
end
|
data/pybossa-api.gemspec
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
|
3
|
+
require "pybossa-api/version"
|
|
4
|
+
|
|
5
|
+
Gem::Specification.new do |s|
|
|
6
|
+
s.name = "pybossa-api"
|
|
7
|
+
s.version = PyBossa::API::VERSION
|
|
8
|
+
s.platform = Gem::Platform::RUBY
|
|
9
|
+
s.authors = ["Open North"]
|
|
10
|
+
s.email = ["info@opennorth.ca"]
|
|
11
|
+
s.homepage = "http://github.com/opennorth/pybossa-api-ruby"
|
|
12
|
+
s.summary = %q{The PyBossa API Ruby Gem}
|
|
13
|
+
s.description = %q{A Ruby wrapper for the PyBossa API}
|
|
14
|
+
|
|
15
|
+
s.files = `git ls-files`.split("\n")
|
|
16
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
|
17
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
|
18
|
+
s.require_paths = ["lib"]
|
|
19
|
+
|
|
20
|
+
s.add_runtime_dependency('yajl-ruby', '~> 1.0')
|
|
21
|
+
s.add_runtime_dependency('httparty', '~> 0.8.0')
|
|
22
|
+
s.add_runtime_dependency('sanitize', '~> 2.0.2')
|
|
23
|
+
s.add_development_dependency('rspec', '~> 2.10')
|
|
24
|
+
s.add_development_dependency('rake')
|
|
25
|
+
end
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
|
2
|
+
|
|
3
|
+
class PyBossa::App
|
|
4
|
+
describe PyBossa::App do
|
|
5
|
+
describe '#list' do
|
|
6
|
+
it 'should return a list of apps' do
|
|
7
|
+
response = PyBossa::App.list
|
|
8
|
+
response.each{|x| x.should have_key('name')}
|
|
9
|
+
end
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
describe '#get' do
|
|
13
|
+
it 'should get an app' do
|
|
14
|
+
response = PyBossa::App.get PyBossa::App.list.first['id']
|
|
15
|
+
response.should have_key('name')
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
describe '#create' do
|
|
20
|
+
pending "Must use API key to test this method"
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
describe '#update' do
|
|
24
|
+
pending "Must use API key to test this method"
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
describe '#delete' do
|
|
28
|
+
pending "Must use API key to test this method"
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
|
2
|
+
|
|
3
|
+
class PyBossa::TaskRun
|
|
4
|
+
describe PyBossa::TaskRun do
|
|
5
|
+
describe '#list' do
|
|
6
|
+
it 'should return a list of task runs' do
|
|
7
|
+
response = PyBossa::TaskRun.list
|
|
8
|
+
response.each{|x| x.should have_key('task_id')}
|
|
9
|
+
end
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
describe '#get' do
|
|
13
|
+
it 'should get an task run' do
|
|
14
|
+
response = PyBossa::TaskRun.get PyBossa::TaskRun.list.first['id']
|
|
15
|
+
response.should have_key('task_id')
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
describe '#create' do
|
|
20
|
+
pending "Must use API key to test this method"
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
describe '#update' do
|
|
24
|
+
pending "Must use API key to test this method"
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
describe '#delete' do
|
|
28
|
+
pending "Must use API key to test this method"
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
|
2
|
+
|
|
3
|
+
class PyBossa::Task
|
|
4
|
+
describe PyBossa::Task do
|
|
5
|
+
describe '#list' do
|
|
6
|
+
it 'should return a list of tasks' do
|
|
7
|
+
response = PyBossa::Task.list
|
|
8
|
+
response.each{|x| x.should have_key('state')}
|
|
9
|
+
end
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
describe '#get' do
|
|
13
|
+
it 'should get an task' do
|
|
14
|
+
response = PyBossa::Task.get PyBossa::Task.list.first['id']
|
|
15
|
+
response.should have_key('state')
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
describe '#create' do
|
|
20
|
+
pending "Must use API key to test this method"
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
describe '#update' do
|
|
24
|
+
pending "Must use API key to test this method"
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
describe '#delete' do
|
|
28
|
+
pending "Must use API key to test this method"
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
|
2
|
+
|
|
3
|
+
class PyBossa::API
|
|
4
|
+
# We don't want to test the PyBossa API. We just want to check that the
|
|
5
|
+
# wrapper works.
|
|
6
|
+
describe PyBossa::API do
|
|
7
|
+
EXAMPLE_SHORT_NAME = PyBossa::API.many('app').first['short_name']
|
|
8
|
+
|
|
9
|
+
describe '#many' do
|
|
10
|
+
it 'should return a non-empty array of hashes' do
|
|
11
|
+
response = PyBossa::API.many 'app'
|
|
12
|
+
response.should be_an(Array)
|
|
13
|
+
response.should have_at_least(1).item
|
|
14
|
+
response.each{|x| x.should be_a(Hash)}
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
it 'should respect the :limit argument' do
|
|
18
|
+
PyBossa::API.many('app', limit: 1).should have(1).item
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
it 'should respect a field argument' do
|
|
22
|
+
PyBossa::API.many('app', short_name: EXAMPLE_SHORT_NAME).find{|result|
|
|
23
|
+
result['short_name'] == EXAMPLE_SHORT_NAME
|
|
24
|
+
}.should_not be_nil
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
describe '#one' do
|
|
29
|
+
it 'should return a hash' do
|
|
30
|
+
PyBossa::API.one('app', PyBossa::API.many('app').first['id']).should be_a(Hash)
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
describe '#create' do
|
|
35
|
+
pending "Must use API key to test this method"
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
describe '#update' do
|
|
39
|
+
pending "Must use API key to test this method"
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
describe '#delete' do
|
|
43
|
+
pending "Must use API key to test this method"
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: pybossa-api
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.0.1
|
|
5
|
+
prerelease:
|
|
6
|
+
platform: ruby
|
|
7
|
+
authors:
|
|
8
|
+
- Open North
|
|
9
|
+
autorequire:
|
|
10
|
+
bindir: bin
|
|
11
|
+
cert_chain: []
|
|
12
|
+
date: 2012-08-18 00:00:00.000000000 Z
|
|
13
|
+
dependencies:
|
|
14
|
+
- !ruby/object:Gem::Dependency
|
|
15
|
+
name: yajl-ruby
|
|
16
|
+
requirement: &70306081612580 !ruby/object:Gem::Requirement
|
|
17
|
+
none: false
|
|
18
|
+
requirements:
|
|
19
|
+
- - ~>
|
|
20
|
+
- !ruby/object:Gem::Version
|
|
21
|
+
version: '1.0'
|
|
22
|
+
type: :runtime
|
|
23
|
+
prerelease: false
|
|
24
|
+
version_requirements: *70306081612580
|
|
25
|
+
- !ruby/object:Gem::Dependency
|
|
26
|
+
name: httparty
|
|
27
|
+
requirement: &70306081611700 !ruby/object:Gem::Requirement
|
|
28
|
+
none: false
|
|
29
|
+
requirements:
|
|
30
|
+
- - ~>
|
|
31
|
+
- !ruby/object:Gem::Version
|
|
32
|
+
version: 0.8.0
|
|
33
|
+
type: :runtime
|
|
34
|
+
prerelease: false
|
|
35
|
+
version_requirements: *70306081611700
|
|
36
|
+
- !ruby/object:Gem::Dependency
|
|
37
|
+
name: sanitize
|
|
38
|
+
requirement: &70306081611140 !ruby/object:Gem::Requirement
|
|
39
|
+
none: false
|
|
40
|
+
requirements:
|
|
41
|
+
- - ~>
|
|
42
|
+
- !ruby/object:Gem::Version
|
|
43
|
+
version: 2.0.2
|
|
44
|
+
type: :runtime
|
|
45
|
+
prerelease: false
|
|
46
|
+
version_requirements: *70306081611140
|
|
47
|
+
- !ruby/object:Gem::Dependency
|
|
48
|
+
name: rspec
|
|
49
|
+
requirement: &70306081610460 !ruby/object:Gem::Requirement
|
|
50
|
+
none: false
|
|
51
|
+
requirements:
|
|
52
|
+
- - ~>
|
|
53
|
+
- !ruby/object:Gem::Version
|
|
54
|
+
version: '2.10'
|
|
55
|
+
type: :development
|
|
56
|
+
prerelease: false
|
|
57
|
+
version_requirements: *70306081610460
|
|
58
|
+
- !ruby/object:Gem::Dependency
|
|
59
|
+
name: rake
|
|
60
|
+
requirement: &70306081629380 !ruby/object:Gem::Requirement
|
|
61
|
+
none: false
|
|
62
|
+
requirements:
|
|
63
|
+
- - ! '>='
|
|
64
|
+
- !ruby/object:Gem::Version
|
|
65
|
+
version: '0'
|
|
66
|
+
type: :development
|
|
67
|
+
prerelease: false
|
|
68
|
+
version_requirements: *70306081629380
|
|
69
|
+
description: A Ruby wrapper for the PyBossa API
|
|
70
|
+
email:
|
|
71
|
+
- info@opennorth.ca
|
|
72
|
+
executables: []
|
|
73
|
+
extensions: []
|
|
74
|
+
extra_rdoc_files: []
|
|
75
|
+
files:
|
|
76
|
+
- .gitignore
|
|
77
|
+
- .travis.yml
|
|
78
|
+
- Gemfile
|
|
79
|
+
- LICENSE
|
|
80
|
+
- README.md
|
|
81
|
+
- Rakefile
|
|
82
|
+
- USAGE
|
|
83
|
+
- lib/pybossa-api.rb
|
|
84
|
+
- lib/pybossa-api/app.rb
|
|
85
|
+
- lib/pybossa-api/task.rb
|
|
86
|
+
- lib/pybossa-api/task_run.rb
|
|
87
|
+
- lib/pybossa-api/version.rb
|
|
88
|
+
- pybossa-api.gemspec
|
|
89
|
+
- spec/pybossa-api/app_spec.rb
|
|
90
|
+
- spec/pybossa-api/task_run_spec.rb
|
|
91
|
+
- spec/pybossa-api/task_spec.rb
|
|
92
|
+
- spec/pybossa-api_spec.rb
|
|
93
|
+
- spec/spec_helper.rb
|
|
94
|
+
homepage: http://github.com/opennorth/pybossa-api-ruby
|
|
95
|
+
licenses: []
|
|
96
|
+
post_install_message:
|
|
97
|
+
rdoc_options: []
|
|
98
|
+
require_paths:
|
|
99
|
+
- lib
|
|
100
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
101
|
+
none: false
|
|
102
|
+
requirements:
|
|
103
|
+
- - ! '>='
|
|
104
|
+
- !ruby/object:Gem::Version
|
|
105
|
+
version: '0'
|
|
106
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
107
|
+
none: false
|
|
108
|
+
requirements:
|
|
109
|
+
- - ! '>='
|
|
110
|
+
- !ruby/object:Gem::Version
|
|
111
|
+
version: '0'
|
|
112
|
+
requirements: []
|
|
113
|
+
rubyforge_project:
|
|
114
|
+
rubygems_version: 1.8.15
|
|
115
|
+
signing_key:
|
|
116
|
+
specification_version: 3
|
|
117
|
+
summary: The PyBossa API Ruby Gem
|
|
118
|
+
test_files:
|
|
119
|
+
- spec/pybossa-api/app_spec.rb
|
|
120
|
+
- spec/pybossa-api/task_run_spec.rb
|
|
121
|
+
- spec/pybossa-api/task_spec.rb
|
|
122
|
+
- spec/pybossa-api_spec.rb
|
|
123
|
+
- spec/spec_helper.rb
|
|
124
|
+
has_rdoc:
|