pybossa-api 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.travis.yml +3 -0
- data/.yardopts +4 -0
- data/Gemfile +6 -1
- data/README.md +7 -4
- data/lib/pybossa-api.rb +7 -8
- data/lib/pybossa-api/app.rb +1 -1
- data/lib/pybossa-api/task.rb +1 -1
- data/lib/pybossa-api/task_run.rb +1 -1
- data/lib/pybossa-api/version.rb +1 -1
- data/pybossa-api.gemspec +6 -6
- data/spec/pybossa-api/app_spec.rb +19 -21
- data/spec/pybossa-api/task_run_spec.rb +19 -21
- data/spec/pybossa-api/task_spec.rb +19 -21
- data/spec/pybossa-api_spec.rb +10 -10
- data/spec/spec_helper.rb +4 -0
- metadata +56 -41
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: dca31965b81e141edf2e9a561480383d9cea36e2
|
4
|
+
data.tar.gz: 7c7e56826febfa2d691e99744d017e3c3e23ae71
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 3d320a66d03db7522a2a106bb7860c2e069bf6040fbc2020996fbe293c85b0cb172efe17a4b93031f3e6830cf49a7323a2f60f1ed8d2896e36ec66ded441d5f9
|
7
|
+
data.tar.gz: 68c1d0173266e1df701b286819f7baac1275dbb2981a1edb3e6432d53f7b381d7c7701eea873f54e0553e8f2ddff1e4729fd89afe2bc840b450898012fe17b84
|
data/.travis.yml
CHANGED
data/.yardopts
ADDED
data/Gemfile
CHANGED
@@ -1,4 +1,9 @@
|
|
1
1
|
source "http://rubygems.org"
|
2
2
|
|
3
|
-
#
|
3
|
+
# Nokogiri 1.6.0 requires Ruby >= 1.9.2
|
4
|
+
gem 'nokogiri', '~> 1.5.10'
|
5
|
+
# Sanitize 2.0.4 requires Nokogiri >= 1.6.0 or Ruby >= 1.9.2
|
6
|
+
gem 'sanitize', '2.0.3'
|
7
|
+
|
8
|
+
# Specify your gem's dependencies in the gemspec
|
4
9
|
gemspec
|
data/README.md
CHANGED
@@ -1,9 +1,12 @@
|
|
1
1
|
# The PyBossa API Ruby Gem
|
2
2
|
|
3
|
-
A Ruby wrapper for the PyBossa API.
|
3
|
+
A Ruby wrapper for the [PyBossa](http://pybossa.com/) [API](http://docs.pybossa.com/en/latest/model.html).
|
4
4
|
|
5
|
+
[![Gem Version](https://badge.fury.io/rb/pybossa-api.svg)](http://badge.fury.io/rb/pybossa-api)
|
5
6
|
[![Build Status](https://secure.travis-ci.org/opennorth/pybossa-api-ruby.png)](http://travis-ci.org/opennorth/pybossa-api-ruby)
|
6
|
-
[![
|
7
|
+
[![Dependency Status](https://gemnasium.com/opennorth/pybossa-api-ruby.png)](https://gemnasium.com/opennorth/pybossa-api-ruby)
|
8
|
+
[![Coverage Status](https://coveralls.io/repos/opennorth/pybossa-api-ruby/badge.png?branch=master)](https://coveralls.io/r/opennorth/pybossa-api-ruby)
|
9
|
+
[![Code Climate](https://codeclimate.com/github/opennorth/pybossa-api-ruby.png)](https://codeclimate.com/github/opennorth/pybossa-api-ruby)
|
7
10
|
|
8
11
|
## Installation
|
9
12
|
|
@@ -22,7 +25,7 @@ A Ruby wrapper for the PyBossa API.
|
|
22
25
|
>> PyBossa::App.get 128
|
23
26
|
=> {"info"=>{"task_presenter"=>"...", "thumbnail"=>"..."}, ...}
|
24
27
|
|
25
|
-
>> PyBossa::
|
28
|
+
>> PyBossa::API.api_key = '21ec2020-3aea-1069-a2dd-08002b30309d'
|
26
29
|
|
27
30
|
>> app = PyBossa::App.create "info"=>{"task_presenter"=>"...", "thumbnail"=>"..."}, ...
|
28
31
|
=> {"info"=>{"task_presenter"=>"...", "thumbnail"=>"..."}, ...}
|
@@ -35,7 +38,7 @@ A Ruby wrapper for the PyBossa API.
|
|
35
38
|
|
36
39
|
You can perform similar operations on `PyBossa::Task` and `PyBossa::TaskRun`.
|
37
40
|
|
38
|
-
More documentation at [RubyDoc.info](http://rdoc.info/gems/pybossa-api/PyBossa
|
41
|
+
More documentation at [RubyDoc.info](http://rdoc.info/gems/pybossa-api/PyBossa).
|
39
42
|
|
40
43
|
## Bugs? Questions?
|
41
44
|
|
data/lib/pybossa-api.rb
CHANGED
@@ -1,19 +1,14 @@
|
|
1
|
-
|
1
|
+
require 'json'
|
2
2
|
|
3
3
|
require 'httparty'
|
4
4
|
require 'sanitize'
|
5
|
-
require 'yajl'
|
6
5
|
|
7
6
|
module PyBossa
|
8
|
-
autoload :App, 'pybossa-api/app'
|
9
|
-
autoload :Task, 'pybossa-api/task'
|
10
|
-
autoload :TaskRun, 'pybossa-api/task_run'
|
11
|
-
|
12
7
|
# A Ruby wrapper for the PyBossa API.
|
13
8
|
# @see http://docs.pybossa.com/en/latest/model.html#restful-api
|
14
9
|
class API
|
15
10
|
include HTTParty
|
16
|
-
base_uri '
|
11
|
+
base_uri 'crowdcrafting.org/api'
|
17
12
|
|
18
13
|
class Error < StandardError; end
|
19
14
|
|
@@ -94,7 +89,7 @@ module PyBossa
|
|
94
89
|
response = if [:get, :delete].include? http_method
|
95
90
|
send http_method, path, :query => opts
|
96
91
|
else
|
97
|
-
send http_method, path, :query => {:api_key => opts.delete(:api_key)}, :body =>
|
92
|
+
send http_method, path, :query => {:api_key => opts.delete(:api_key)}, :body => JSON.dump(opts), :headers => {'Content-type' => 'application/json'}
|
98
93
|
end
|
99
94
|
unless [200, 204].include? response.response.code.to_i
|
100
95
|
raise PyBossa::API::Error.new Sanitize.clean(response.response.body)
|
@@ -104,3 +99,7 @@ module PyBossa
|
|
104
99
|
end
|
105
100
|
end
|
106
101
|
end
|
102
|
+
|
103
|
+
require 'pybossa-api/app'
|
104
|
+
require 'pybossa-api/task'
|
105
|
+
require 'pybossa-api/task_run'
|
data/lib/pybossa-api/app.rb
CHANGED
data/lib/pybossa-api/task.rb
CHANGED
data/lib/pybossa-api/task_run.rb
CHANGED
data/lib/pybossa-api/version.rb
CHANGED
data/pybossa-api.gemspec
CHANGED
@@ -1,6 +1,5 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
|
-
|
3
|
-
require "pybossa-api/version"
|
2
|
+
require File.expand_path('../lib/pybossa-api/version', __FILE__)
|
4
3
|
|
5
4
|
Gem::Specification.new do |s|
|
6
5
|
s.name = "pybossa-api"
|
@@ -11,15 +10,16 @@ Gem::Specification.new do |s|
|
|
11
10
|
s.homepage = "http://github.com/opennorth/pybossa-api-ruby"
|
12
11
|
s.summary = %q{The PyBossa API Ruby Gem}
|
13
12
|
s.description = %q{A Ruby wrapper for the PyBossa API}
|
13
|
+
s.license = 'MIT'
|
14
14
|
|
15
15
|
s.files = `git ls-files`.split("\n")
|
16
16
|
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
17
17
|
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
18
18
|
s.require_paths = ["lib"]
|
19
19
|
|
20
|
-
s.add_runtime_dependency('
|
21
|
-
s.add_runtime_dependency('
|
22
|
-
s.
|
23
|
-
s.add_development_dependency('rspec', '~> 2.10')
|
20
|
+
s.add_runtime_dependency('httparty', '~> 0.10.0')
|
21
|
+
s.add_runtime_dependency('sanitize', '~> 2.0.3')
|
22
|
+
s.add_development_dependency('rspec', '~> 3.1.0')
|
24
23
|
s.add_development_dependency('rake')
|
24
|
+
s.add_development_dependency('coveralls')
|
25
25
|
end
|
@@ -1,31 +1,29 @@
|
|
1
1
|
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
2
2
|
|
3
|
-
|
4
|
-
describe
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
response.each{|x| x.should have_key('name')}
|
9
|
-
end
|
3
|
+
describe PyBossa::App do
|
4
|
+
describe '#list' do
|
5
|
+
it 'should return a list of apps' do
|
6
|
+
response = PyBossa::App.list
|
7
|
+
response.each{|x| expect(x).to have_key('name')}
|
10
8
|
end
|
9
|
+
end
|
11
10
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
end
|
11
|
+
describe '#get' do
|
12
|
+
it 'should get an app' do
|
13
|
+
response = PyBossa::App.get PyBossa::App.list.last['id']
|
14
|
+
expect(response).to have_key('name')
|
17
15
|
end
|
16
|
+
end
|
18
17
|
|
19
|
-
|
20
|
-
|
21
|
-
|
18
|
+
describe '#create' do
|
19
|
+
pending "Must use API key to test this method"
|
20
|
+
end
|
22
21
|
|
23
|
-
|
24
|
-
|
25
|
-
|
22
|
+
describe '#update' do
|
23
|
+
pending "Must use API key to test this method"
|
24
|
+
end
|
26
25
|
|
27
|
-
|
28
|
-
|
29
|
-
end
|
26
|
+
describe '#delete' do
|
27
|
+
pending "Must use API key to test this method"
|
30
28
|
end
|
31
29
|
end
|
@@ -1,31 +1,29 @@
|
|
1
1
|
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
2
2
|
|
3
|
-
|
4
|
-
describe
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
response.each{|x| x.should have_key('task_id')}
|
9
|
-
end
|
3
|
+
describe PyBossa::TaskRun do
|
4
|
+
describe '#list' do
|
5
|
+
it 'should return a list of task runs' do
|
6
|
+
response = PyBossa::TaskRun.list
|
7
|
+
response.each{|x| expect(x).to have_key('task_id')}
|
10
8
|
end
|
9
|
+
end
|
11
10
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
end
|
11
|
+
describe '#get' do
|
12
|
+
it 'should get an task run' do
|
13
|
+
response = PyBossa::TaskRun.get PyBossa::TaskRun.list.first['id']
|
14
|
+
expect(response).to have_key('task_id')
|
17
15
|
end
|
16
|
+
end
|
18
17
|
|
19
|
-
|
20
|
-
|
21
|
-
|
18
|
+
describe '#create' do
|
19
|
+
pending "Must use API key to test this method"
|
20
|
+
end
|
22
21
|
|
23
|
-
|
24
|
-
|
25
|
-
|
22
|
+
describe '#update' do
|
23
|
+
pending "Must use API key to test this method"
|
24
|
+
end
|
26
25
|
|
27
|
-
|
28
|
-
|
29
|
-
end
|
26
|
+
describe '#delete' do
|
27
|
+
pending "Must use API key to test this method"
|
30
28
|
end
|
31
29
|
end
|
@@ -1,31 +1,29 @@
|
|
1
1
|
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
2
2
|
|
3
|
-
|
4
|
-
describe
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
response.each{|x| x.should have_key('state')}
|
9
|
-
end
|
3
|
+
describe PyBossa::Task do
|
4
|
+
describe '#list' do
|
5
|
+
it 'should return a list of tasks' do
|
6
|
+
response = PyBossa::Task.list
|
7
|
+
response.each{|x| expect(x).to have_key('state')}
|
10
8
|
end
|
9
|
+
end
|
11
10
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
end
|
11
|
+
describe '#get' do
|
12
|
+
it 'should get an task' do
|
13
|
+
response = PyBossa::Task.get PyBossa::Task.list.first['id']
|
14
|
+
expect(response).to have_key('state')
|
17
15
|
end
|
16
|
+
end
|
18
17
|
|
19
|
-
|
20
|
-
|
21
|
-
|
18
|
+
describe '#create' do
|
19
|
+
pending "Must use API key to test this method"
|
20
|
+
end
|
22
21
|
|
23
|
-
|
24
|
-
|
25
|
-
|
22
|
+
describe '#update' do
|
23
|
+
pending "Must use API key to test this method"
|
24
|
+
end
|
26
25
|
|
27
|
-
|
28
|
-
|
29
|
-
end
|
26
|
+
describe '#delete' do
|
27
|
+
pending "Must use API key to test this method"
|
30
28
|
end
|
31
29
|
end
|
data/spec/pybossa-api_spec.rb
CHANGED
@@ -9,38 +9,38 @@ class PyBossa::API
|
|
9
9
|
describe '#many' do
|
10
10
|
it 'should return a non-empty array of hashes' do
|
11
11
|
response = PyBossa::API.many 'app'
|
12
|
-
response.
|
13
|
-
response.
|
14
|
-
response.each{|x| x.
|
12
|
+
expect(response).to be_an(Array)
|
13
|
+
expect(response.size).to be >= 1
|
14
|
+
response.each{|x| expect(x).to be_a(Hash)}
|
15
15
|
end
|
16
16
|
|
17
17
|
it 'should respect the :limit argument' do
|
18
|
-
PyBossa::API.many('app', limit
|
18
|
+
expect(PyBossa::API.many('app', :limit => 1).size).to eq(1)
|
19
19
|
end
|
20
20
|
|
21
21
|
it 'should respect a field argument' do
|
22
|
-
PyBossa::API.many('app', short_name
|
22
|
+
expect(PyBossa::API.many('app', :short_name => EXAMPLE_SHORT_NAME).find{|result|
|
23
23
|
result['short_name'] == EXAMPLE_SHORT_NAME
|
24
|
-
}.
|
24
|
+
}).to_not be_nil
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|
28
28
|
describe '#one' do
|
29
29
|
it 'should return a hash' do
|
30
|
-
PyBossa::API.
|
30
|
+
expect(PyBossa::API.retrieve('app', PyBossa::API.many('app').last['id'])).to be_a(Hash)
|
31
31
|
end
|
32
32
|
end
|
33
33
|
|
34
34
|
describe '#create' do
|
35
|
-
pending "Must use API key
|
35
|
+
pending "Must use API key. See http://about.travis-ci.org/docs/user/build-configuration/#Secure-environment-variables"
|
36
36
|
end
|
37
37
|
|
38
38
|
describe '#update' do
|
39
|
-
pending "Must use API key
|
39
|
+
pending "Must use API key. See http://about.travis-ci.org/docs/user/build-configuration/#Secure-environment-variables"
|
40
40
|
end
|
41
41
|
|
42
42
|
describe '#delete' do
|
43
|
-
pending "Must use API key
|
43
|
+
pending "Must use API key. See http://about.travis-ci.org/docs/user/build-configuration/#Secure-environment-variables"
|
44
44
|
end
|
45
45
|
end
|
46
46
|
end
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,71 +1,85 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pybossa-api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
5
|
-
prerelease:
|
4
|
+
version: 0.0.2
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Open North
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
11
|
+
date: 2014-09-12 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
|
-
name:
|
16
|
-
requirement:
|
17
|
-
none: false
|
14
|
+
name: httparty
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
18
16
|
requirements:
|
19
|
-
- - ~>
|
17
|
+
- - "~>"
|
20
18
|
- !ruby/object:Gem::Version
|
21
|
-
version:
|
19
|
+
version: 0.10.0
|
22
20
|
type: :runtime
|
23
21
|
prerelease: false
|
24
|
-
version_requirements:
|
25
|
-
- !ruby/object:Gem::Dependency
|
26
|
-
name: httparty
|
27
|
-
requirement: &70306081611700 !ruby/object:Gem::Requirement
|
28
|
-
none: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
29
23
|
requirements:
|
30
|
-
- - ~>
|
24
|
+
- - "~>"
|
31
25
|
- !ruby/object:Gem::Version
|
32
|
-
version: 0.
|
33
|
-
type: :runtime
|
34
|
-
prerelease: false
|
35
|
-
version_requirements: *70306081611700
|
26
|
+
version: 0.10.0
|
36
27
|
- !ruby/object:Gem::Dependency
|
37
28
|
name: sanitize
|
38
|
-
requirement:
|
39
|
-
none: false
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
40
30
|
requirements:
|
41
|
-
- - ~>
|
31
|
+
- - "~>"
|
42
32
|
- !ruby/object:Gem::Version
|
43
|
-
version: 2.0.
|
33
|
+
version: 2.0.3
|
44
34
|
type: :runtime
|
45
35
|
prerelease: false
|
46
|
-
version_requirements:
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 2.0.3
|
47
41
|
- !ruby/object:Gem::Dependency
|
48
42
|
name: rspec
|
49
|
-
requirement:
|
50
|
-
none: false
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
51
44
|
requirements:
|
52
|
-
- - ~>
|
45
|
+
- - "~>"
|
53
46
|
- !ruby/object:Gem::Version
|
54
|
-
version:
|
47
|
+
version: 3.1.0
|
55
48
|
type: :development
|
56
49
|
prerelease: false
|
57
|
-
version_requirements:
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 3.1.0
|
58
55
|
- !ruby/object:Gem::Dependency
|
59
56
|
name: rake
|
60
|
-
requirement:
|
61
|
-
none: false
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
62
58
|
requirements:
|
63
|
-
- -
|
59
|
+
- - ">="
|
64
60
|
- !ruby/object:Gem::Version
|
65
61
|
version: '0'
|
66
62
|
type: :development
|
67
63
|
prerelease: false
|
68
|
-
version_requirements:
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: coveralls
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
69
83
|
description: A Ruby wrapper for the PyBossa API
|
70
84
|
email:
|
71
85
|
- info@opennorth.ca
|
@@ -73,8 +87,9 @@ executables: []
|
|
73
87
|
extensions: []
|
74
88
|
extra_rdoc_files: []
|
75
89
|
files:
|
76
|
-
- .gitignore
|
77
|
-
- .travis.yml
|
90
|
+
- ".gitignore"
|
91
|
+
- ".travis.yml"
|
92
|
+
- ".yardopts"
|
78
93
|
- Gemfile
|
79
94
|
- LICENSE
|
80
95
|
- README.md
|
@@ -92,28 +107,28 @@ files:
|
|
92
107
|
- spec/pybossa-api_spec.rb
|
93
108
|
- spec/spec_helper.rb
|
94
109
|
homepage: http://github.com/opennorth/pybossa-api-ruby
|
95
|
-
licenses:
|
110
|
+
licenses:
|
111
|
+
- MIT
|
112
|
+
metadata: {}
|
96
113
|
post_install_message:
|
97
114
|
rdoc_options: []
|
98
115
|
require_paths:
|
99
116
|
- lib
|
100
117
|
required_ruby_version: !ruby/object:Gem::Requirement
|
101
|
-
none: false
|
102
118
|
requirements:
|
103
|
-
- -
|
119
|
+
- - ">="
|
104
120
|
- !ruby/object:Gem::Version
|
105
121
|
version: '0'
|
106
122
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
107
|
-
none: false
|
108
123
|
requirements:
|
109
|
-
- -
|
124
|
+
- - ">="
|
110
125
|
- !ruby/object:Gem::Version
|
111
126
|
version: '0'
|
112
127
|
requirements: []
|
113
128
|
rubyforge_project:
|
114
|
-
rubygems_version:
|
129
|
+
rubygems_version: 2.2.2
|
115
130
|
signing_key:
|
116
|
-
specification_version:
|
131
|
+
specification_version: 4
|
117
132
|
summary: The PyBossa API Ruby Gem
|
118
133
|
test_files:
|
119
134
|
- spec/pybossa-api/app_spec.rb
|