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.
@@ -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
@@ -1,3 +1,6 @@
1
1
  language: ruby
2
2
  rvm:
3
+ - 1.9.2
3
4
  - 1.9.3
5
+ - 2.0.0
6
+ - 2.1.0
@@ -0,0 +1,4 @@
1
+ --no-private
2
+ --hide-void-return
3
+ --embed-mixin ClassMethods
4
+ --markup=markdown
data/Gemfile CHANGED
@@ -1,4 +1,9 @@
1
1
  source "http://rubygems.org"
2
2
 
3
- # Specify your gem's dependencies in scraperwiki-api.gemspec
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
- [![Code Climate](https://codeclimate.com/badge.png)](https://codeclimate.com/github/opennorth/pybossa-api-ruby)
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::App.api_key = '21ec2020-3aea-1069-a2dd-08002b30309d'
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/API).
41
+ More documentation at [RubyDoc.info](http://rdoc.info/gems/pybossa-api/PyBossa).
39
42
 
40
43
  ## Bugs? Questions?
41
44
 
@@ -1,19 +1,14 @@
1
- $LOAD_PATH.unshift(File.expand_path(File.dirname(__FILE__))) unless $LOAD_PATH.include?(File.expand_path(File.dirname(__FILE__)))
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 'pybossa.com/api'
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 => Yajl::Encoder.encode(opts), :headers => {'Content-type' => 'application/json'}
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'
@@ -1,5 +1,5 @@
1
1
  module PyBossa
2
- class App
2
+ module App
3
3
  class << self
4
4
  # @param [Hash] opts optional arguments
5
5
  # @option opts [Integer] :limit number of results to return [default 20]
@@ -1,5 +1,5 @@
1
1
  module PyBossa
2
- class Task
2
+ module Task
3
3
  class << self
4
4
  # @param [Hash] opts optional arguments
5
5
  # @option opts [Integer] :limit number of results to return [default 20]
@@ -1,5 +1,5 @@
1
1
  module PyBossa
2
- class TaskRun
2
+ module TaskRun
3
3
  class << self
4
4
  # @param [Hash] opts optional arguments
5
5
  # @option opts [Integer] :limit number of results to return [default 20]
@@ -1,5 +1,5 @@
1
1
  module PyBossa
2
2
  class API
3
- VERSION = "0.0.1"
3
+ VERSION = "0.0.2"
4
4
  end
5
5
  end
@@ -1,6 +1,5 @@
1
1
  # -*- encoding: utf-8 -*-
2
- $:.push File.expand_path("../lib", __FILE__)
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('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')
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
- 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
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
- 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
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
- describe '#create' do
20
- pending "Must use API key to test this method"
21
- end
18
+ describe '#create' do
19
+ pending "Must use API key to test this method"
20
+ end
22
21
 
23
- describe '#update' do
24
- pending "Must use API key to test this method"
25
- end
22
+ describe '#update' do
23
+ pending "Must use API key to test this method"
24
+ end
26
25
 
27
- describe '#delete' do
28
- pending "Must use API key to test this method"
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
- 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
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
- 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
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
- describe '#create' do
20
- pending "Must use API key to test this method"
21
- end
18
+ describe '#create' do
19
+ pending "Must use API key to test this method"
20
+ end
22
21
 
23
- describe '#update' do
24
- pending "Must use API key to test this method"
25
- end
22
+ describe '#update' do
23
+ pending "Must use API key to test this method"
24
+ end
26
25
 
27
- describe '#delete' do
28
- pending "Must use API key to test this method"
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
- 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
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
- 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
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
- describe '#create' do
20
- pending "Must use API key to test this method"
21
- end
18
+ describe '#create' do
19
+ pending "Must use API key to test this method"
20
+ end
22
21
 
23
- describe '#update' do
24
- pending "Must use API key to test this method"
25
- end
22
+ describe '#update' do
23
+ pending "Must use API key to test this method"
24
+ end
26
25
 
27
- describe '#delete' do
28
- pending "Must use API key to test this method"
29
- end
26
+ describe '#delete' do
27
+ pending "Must use API key to test this method"
30
28
  end
31
29
  end
@@ -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.should be_an(Array)
13
- response.should have_at_least(1).item
14
- response.each{|x| x.should be_a(Hash)}
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: 1).should have(1).item
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: EXAMPLE_SHORT_NAME).find{|result|
22
+ expect(PyBossa::API.many('app', :short_name => EXAMPLE_SHORT_NAME).find{|result|
23
23
  result['short_name'] == EXAMPLE_SHORT_NAME
24
- }.should_not be_nil
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.one('app', PyBossa::API.many('app').first['id']).should be_a(Hash)
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 to test this method"
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 to test this method"
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 to test this method"
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
@@ -1,3 +1,7 @@
1
1
  require 'rubygems'
2
+
3
+ require 'coveralls'
4
+ Coveralls.wear!
5
+
2
6
  require 'rspec'
3
7
  require File.dirname(__FILE__) + '/../lib/pybossa-api'
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.1
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: 2012-08-18 00:00:00.000000000 Z
11
+ date: 2014-09-12 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
- name: yajl-ruby
16
- requirement: &70306081612580 !ruby/object:Gem::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: '1.0'
19
+ version: 0.10.0
22
20
  type: :runtime
23
21
  prerelease: false
24
- version_requirements: *70306081612580
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.8.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: &70306081611140 !ruby/object:Gem::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.2
33
+ version: 2.0.3
44
34
  type: :runtime
45
35
  prerelease: false
46
- version_requirements: *70306081611140
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: &70306081610460 !ruby/object:Gem::Requirement
50
- none: false
43
+ requirement: !ruby/object:Gem::Requirement
51
44
  requirements:
52
- - - ~>
45
+ - - "~>"
53
46
  - !ruby/object:Gem::Version
54
- version: '2.10'
47
+ version: 3.1.0
55
48
  type: :development
56
49
  prerelease: false
57
- version_requirements: *70306081610460
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: &70306081629380 !ruby/object:Gem::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: *70306081629380
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: 1.8.15
129
+ rubygems_version: 2.2.2
115
130
  signing_key:
116
- specification_version: 3
131
+ specification_version: 4
117
132
  summary: The PyBossa API Ruby Gem
118
133
  test_files:
119
134
  - spec/pybossa-api/app_spec.rb