panoptes-client 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +1 -0
- data/CHANGELOG.md +7 -0
- data/README.md +14 -14
- data/Rakefile +8 -1
- data/lib/panoptes-client.rb +1 -0
- data/lib/panoptes/client.rb +10 -3
- data/lib/panoptes/client/projects.rb +6 -1
- data/lib/panoptes/client/subjects.rb +6 -0
- data/lib/panoptes/client/user_groups.rb +5 -0
- data/lib/panoptes/client/version.rb +1 -1
- data/panoptes-client.gemspec +1 -0
- metadata +19 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5b5b3c142ba8e87d827573a68e823684e2314893
|
4
|
+
data.tar.gz: 6540b9be36075308a0880ea4c4aad04f8bc894c0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 40a3849e1e980634d7e53e7d307692b68db87a0de96fb613b403ed24924ce9fc8760c04fe5ada8ed47690012a5f4f26e874098788bb70afa0f9c149cefeefe9e
|
7
|
+
data.tar.gz: d4b003226c3dfc8d80426ecf57be03f5d4d5a74d6e988a58f9a90a4e58365957bb823d54f83fa07b35ddce314e905925d4056961d89cd6a4f6472a4b1df2fe41
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
ADDED
data/README.md
CHANGED
@@ -1,34 +1,34 @@
|
|
1
1
|
# Panoptes::Client
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
TODO: Delete this and the text above, and describe your gem
|
3
|
+
[![Build Status](https://travis-ci.org/zooniverse/panoptes-client.rb.svg?branch=master)](https://travis-ci.org/zooniverse/panoptes-client.rb)
|
4
|
+
[![Yard Docs](http://img.shields.io/badge/yard-docs-blue.svg)](http://rubydoc.info/github/zooniverse/panoptes-client.rb/)
|
6
5
|
|
7
6
|
## Installation
|
8
7
|
|
9
|
-
Add this line to your application's Gemfile:
|
10
|
-
|
11
8
|
```ruby
|
12
9
|
gem 'panoptes-client'
|
13
10
|
```
|
14
11
|
|
15
|
-
|
16
|
-
|
17
|
-
$ bundle
|
18
|
-
|
19
|
-
Or install it yourself as:
|
12
|
+
## Usage
|
20
13
|
|
21
|
-
|
14
|
+
In general, this library is supposed to be a thin, flat layer over our [HTTP-based API](http://docs.panoptes.apiary.io/). All public API methods can be found on the `Client` object.
|
22
15
|
|
23
|
-
|
16
|
+
**A lot of methods are still missing. We've only just started with this wrapper. You can either issue a PR adding the one you need, or use the generic `get` / `post` methods on `Client`.**
|
24
17
|
|
25
|
-
TODO: Write usage instructions here
|
26
18
|
|
27
19
|
## Development
|
28
20
|
|
29
21
|
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
30
22
|
|
31
|
-
|
23
|
+
The test suite uses VCR to record HTTP requests, so if you're not making any new requests you should be fine with the existing cassettes. If you are, the test suite uses environment variables to pull in authentication credentials. You'll need to [create an OAuth application on staging](https://panoptes-staging.zooniverse.org/oauth/applications), and set the following env vars:
|
24
|
+
|
25
|
+
| Variable | Value |
|
26
|
+
-----------------------------|-------|
|
27
|
+
| `ZOONIVERSE_CLIENT_ID` | The application id |
|
28
|
+
| `ZOONIVERSE_CLIENT_SECRET` | The application secret |
|
29
|
+
| `ZOONIVERSE_ACCESS_TOKEN` | An OAuth access token for the API |
|
30
|
+
|
31
|
+
We recommend [Direnv](https://github.com/direnv/direnv) as good utility to allow you to specify environment variables per directory.
|
32
32
|
|
33
33
|
## Contributing
|
34
34
|
|
data/Rakefile
CHANGED
@@ -1,6 +1,13 @@
|
|
1
1
|
require "bundler/gem_tasks"
|
2
|
-
require "rspec/core/rake_task"
|
3
2
|
|
3
|
+
require "rspec/core/rake_task"
|
4
4
|
RSpec::Core::RakeTask.new(:spec)
|
5
5
|
|
6
|
+
require 'yard'
|
7
|
+
YARD::Rake::YardocTask.new do |t|
|
8
|
+
t.files = ['lib/**/*.rb'] # optional
|
9
|
+
t.options = ['--any', '--extra', '--opts'] # optional
|
10
|
+
t.stats_options = ['--list-undoc'] # optional
|
11
|
+
end
|
12
|
+
|
6
13
|
task :default => :spec
|
@@ -0,0 +1 @@
|
|
1
|
+
require 'panoptes/client'
|
data/lib/panoptes/client.rb
CHANGED
@@ -15,6 +15,13 @@ module Panoptes
|
|
15
15
|
include Panoptes::Client::Subjects
|
16
16
|
include Panoptes::Client::UserGroups
|
17
17
|
|
18
|
+
# A client is the main interface to the API.
|
19
|
+
#
|
20
|
+
# @param auth [Hash] Authentication details
|
21
|
+
# * either nothing,
|
22
|
+
# * a hash with +:token+ (an existing OAuth user token),
|
23
|
+
# * or a hash with +:client_id+ and +:client_secret+ (a keypair for an OAuth Application).
|
24
|
+
# @param url [String] Optional override for the API location to use. Defaults to the official production environment.
|
18
25
|
def initialize(auth: {}, url: "https://panoptes.zooniverse.org")
|
19
26
|
@conn = Faraday.new(url: url) do |faraday|
|
20
27
|
case
|
@@ -40,12 +47,12 @@ module Panoptes
|
|
40
47
|
end
|
41
48
|
|
42
49
|
# Get a path and perform automatic depagination
|
43
|
-
def paginate(path, resource: nil)
|
50
|
+
def paginate(path, query, resource: nil)
|
44
51
|
resource = path.split("/").last if resource.nil?
|
45
|
-
data = last_response = get(path)
|
52
|
+
data = last_response = get(path, query)
|
46
53
|
|
47
54
|
while next_path = last_response["meta"][resource]["next_href"]
|
48
|
-
last_response = get(next_path)
|
55
|
+
last_response = get(next_path, query)
|
49
56
|
if block_given?
|
50
57
|
yield data, last_response
|
51
58
|
else
|
@@ -1,11 +1,16 @@
|
|
1
1
|
module Panoptes
|
2
2
|
class Client
|
3
3
|
module Projects
|
4
|
+
# Fetches the list of all projects.
|
5
|
+
#
|
6
|
+
# @see http://docs.panoptes.apiary.io/#reference/projects/project-collection/list-all-projects
|
7
|
+
# @param search [String] filter projects using full-text search on names (amongst others)
|
8
|
+
# @return [Array] the list of projects
|
4
9
|
def projects(search: nil)
|
5
10
|
params = {}
|
6
11
|
params[:search] = search if search
|
7
12
|
|
8
|
-
|
13
|
+
paginate("/projects", params)["projects"]
|
9
14
|
end
|
10
15
|
end
|
11
16
|
end
|
@@ -1,6 +1,12 @@
|
|
1
1
|
module Panoptes
|
2
2
|
class Client
|
3
3
|
module Subjects
|
4
|
+
# Retire a subject for a workflow
|
5
|
+
#
|
6
|
+
# @todo Add this endpoint to the Apiary docs and add a see-reference here.
|
7
|
+
# @param workflow_id [Integer] the ID of a workflow
|
8
|
+
# @param subject_id [Integer] the ID of a subject associated with that workflow (through one of the assigned subject_sets)
|
9
|
+
# @return nothing
|
4
10
|
def retire_subject(workflow_id, subject_id)
|
5
11
|
post("/workflows/#{workflow_id}/retired_subjects", {
|
6
12
|
admin: true,
|
@@ -1,6 +1,11 @@
|
|
1
1
|
module Panoptes
|
2
2
|
class Client
|
3
3
|
module UserGroups
|
4
|
+
# Creates a new user group and puts the current user in it as the initial member.
|
5
|
+
#
|
6
|
+
# @see http://docs.panoptes.apiary.io/#reference/user-group/usergroup-collection/create-a-user-group
|
7
|
+
# @param name [String] The name of the user group. Must be unique for the entirity of Zooniverse.
|
8
|
+
# @return [Hash] The created user group.
|
4
9
|
def create_user_group(name)
|
5
10
|
post("/user_groups", user_groups: {
|
6
11
|
name: name
|
data/panoptes-client.gemspec
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: panoptes-client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Marten Veldthuis
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-01-
|
11
|
+
date: 2016-01-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -80,6 +80,20 @@ dependencies:
|
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '3.0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: yard
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
83
97
|
description:
|
84
98
|
email:
|
85
99
|
- marten@veldthuis.com
|
@@ -90,6 +104,7 @@ files:
|
|
90
104
|
- ".gitignore"
|
91
105
|
- ".rspec"
|
92
106
|
- ".travis.yml"
|
107
|
+
- CHANGELOG.md
|
93
108
|
- CODE_OF_CONDUCT.md
|
94
109
|
- Gemfile
|
95
110
|
- LICENSE.txt
|
@@ -97,6 +112,7 @@ files:
|
|
97
112
|
- Rakefile
|
98
113
|
- bin/console
|
99
114
|
- bin/setup
|
115
|
+
- lib/panoptes-client.rb
|
100
116
|
- lib/panoptes/client.rb
|
101
117
|
- lib/panoptes/client/me.rb
|
102
118
|
- lib/panoptes/client/projects.rb
|
@@ -129,3 +145,4 @@ signing_key:
|
|
129
145
|
specification_version: 4
|
130
146
|
summary: API wrapper for https://panoptes.zooniverse.org
|
131
147
|
test_files: []
|
148
|
+
has_rdoc:
|