panoptes-client 1.0.0.pre1 → 1.0.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.
- checksums.yaml +4 -4
- data/.hound.yml +2 -2
- data/.rubocop.yml +2 -0
- data/.travis.yml +3 -1
- data/Gemfile +2 -0
- data/Rakefile +6 -4
- data/bin/console +4 -3
- data/lib/panoptes-client.rb +2 -0
- data/lib/panoptes/client.rb +8 -6
- data/lib/panoptes/client/authentication.rb +13 -6
- data/lib/panoptes/client/cellect.rb +2 -0
- data/lib/panoptes/client/classifications.rb +12 -10
- data/lib/panoptes/client/collections.rb +3 -1
- data/lib/panoptes/client/comments.rb +5 -3
- data/lib/panoptes/client/discussions.rb +4 -2
- data/lib/panoptes/client/me.rb +3 -1
- data/lib/panoptes/client/project_preferences.rb +12 -13
- data/lib/panoptes/client/projects.rb +29 -12
- data/lib/panoptes/client/subject_sets.rb +8 -6
- data/lib/panoptes/client/subjects.rb +9 -8
- data/lib/panoptes/client/user_groups.rb +11 -9
- data/lib/panoptes/client/users.rb +3 -1
- data/lib/panoptes/client/version.rb +3 -1
- data/lib/panoptes/client/workflows.rb +11 -4
- data/lib/panoptes/endpoints/base_endpoint.rb +7 -4
- data/lib/panoptes/endpoints/json_api_endpoint.rb +2 -0
- data/lib/panoptes/endpoints/json_endpoint.rb +3 -1
- data/lib/panoptes/session.rb +3 -2
- data/lib/panoptes/talk_client.rb +2 -0
- data/panoptes-client.gemspec +18 -17
- metadata +5 -5
- data/.ruby-style.yml +0 -206
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a209f63256bf9a1ca45ab23ad64e49e0c41829210b6a29a268b20c225f3750f0
|
4
|
+
data.tar.gz: efe6d6066ea962c1042e116cf233d14c61919ee3a0fac1e8216175ca98230f90
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ca1ae7ddf8b1ff0b5c9f39a4c3cc93e34d521b7aa8530dab38ac688f3a192dfbcdfa25968b4ee2454d46772a434c1aa64c80aeae4e7ce3847fff17376c73d84c
|
7
|
+
data.tar.gz: babbdaf433fbfe2557b97920439fb6a10af73f0d328fcd8d5dc529ffbf84cb9a8c65e13880dbfa783bc2b14e652e1e1d2fe7688176e3443e54652f309b757112
|
data/.hound.yml
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
|
2
|
-
config_file: .
|
1
|
+
rubocop:
|
2
|
+
config_file: .rubocop.yml
|
data/.rubocop.yml
ADDED
data/.travis.yml
CHANGED
data/Gemfile
CHANGED
data/Rakefile
CHANGED
@@ -1,13 +1,15 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
3
|
+
require 'bundler/gem_tasks'
|
4
|
+
|
5
|
+
require 'rspec/core/rake_task'
|
4
6
|
RSpec::Core::RakeTask.new(:spec)
|
5
7
|
|
6
8
|
require 'yard'
|
7
9
|
YARD::Rake::YardocTask.new do |t|
|
8
|
-
t.files = ['lib/**/*.rb']
|
10
|
+
t.files = ['lib/**/*.rb'] # optional
|
9
11
|
t.options = ['--any', '--extra', '--opts'] # optional
|
10
12
|
t.stats_options = ['--list-undoc'] # optional
|
11
13
|
end
|
12
14
|
|
13
|
-
task :
|
15
|
+
task default: :spec
|
data/bin/console
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
2
3
|
|
3
|
-
require
|
4
|
-
require
|
4
|
+
require 'bundler/setup'
|
5
|
+
require 'panoptes/client'
|
5
6
|
|
6
7
|
# You can add fixtures and/or initialization code here to make experimenting
|
7
8
|
# with your gem easier. You can also use a different console, if you like.
|
@@ -10,5 +11,5 @@ require "panoptes/client"
|
|
10
11
|
# require "pry"
|
11
12
|
# Pry.start
|
12
13
|
|
13
|
-
require
|
14
|
+
require 'irb'
|
14
15
|
IRB.start
|
data/lib/panoptes-client.rb
CHANGED
data/lib/panoptes/client.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'panoptes/endpoints/json_api_endpoint'
|
2
4
|
require 'panoptes/endpoints/json_endpoint'
|
3
5
|
|
@@ -66,19 +68,19 @@ module Panoptes
|
|
66
68
|
|
67
69
|
def panoptes_url
|
68
70
|
case env
|
69
|
-
when :production, 'production'
|
70
|
-
'https://panoptes.zooniverse.org'
|
71
|
+
when :production, 'production'
|
72
|
+
'https://panoptes.zooniverse.org'
|
71
73
|
else
|
72
|
-
'https://panoptes-staging.zooniverse.org'
|
74
|
+
'https://panoptes-staging.zooniverse.org'
|
73
75
|
end
|
74
76
|
end
|
75
77
|
|
76
78
|
def talk_url
|
77
79
|
case env
|
78
|
-
when :production, 'production'
|
79
|
-
'https://talk.zooniverse.org'
|
80
|
+
when :production, 'production'
|
81
|
+
'https://talk.zooniverse.org'
|
80
82
|
else
|
81
|
-
'https://talk-staging.zooniverse.org'
|
83
|
+
'https://talk-staging.zooniverse.org'
|
82
84
|
end
|
83
85
|
end
|
84
86
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'deprecate'
|
2
4
|
|
3
5
|
module Panoptes
|
@@ -82,14 +84,19 @@ module Panoptes
|
|
82
84
|
|
83
85
|
def public_key_for_env(env)
|
84
86
|
case env.to_s
|
85
|
-
when
|
86
|
-
|
87
|
-
when
|
88
|
-
|
89
|
-
else
|
90
|
-
nil
|
87
|
+
when 'staging'
|
88
|
+
key_file_path('doorkeeper-jwt-staging.pub')
|
89
|
+
when 'production'
|
90
|
+
key_file_path('doorkeeper-jwt-production.pub')
|
91
91
|
end
|
92
92
|
end
|
93
|
+
|
94
|
+
def key_file_path(file_name)
|
95
|
+
File.expand_path(
|
96
|
+
File.join('..', '..', '..', '..', 'data', file_name),
|
97
|
+
__FILE__
|
98
|
+
)
|
99
|
+
end
|
93
100
|
end
|
94
101
|
end
|
95
102
|
end
|
@@ -1,20 +1,22 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Panoptes
|
2
4
|
class Client
|
3
5
|
module Classifications
|
4
6
|
def get_subject_classifications(subject_id, workflow_id)
|
5
|
-
panoptes.paginate(
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
7
|
+
panoptes.paginate('/classifications/project', {
|
8
|
+
admin: true,
|
9
|
+
workflow_id: workflow_id,
|
10
|
+
subject_id: subject_id
|
11
|
+
}, resource: 'classifications')
|
10
12
|
end
|
11
13
|
|
12
14
|
def get_user_classifications(user_id, workflow_id)
|
13
|
-
panoptes.paginate(
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
15
|
+
panoptes.paginate('/classifications/project', {
|
16
|
+
admin: true,
|
17
|
+
workflow_id: workflow_id,
|
18
|
+
user_id: user_id
|
19
|
+
}, resource: 'classifications')
|
18
20
|
end
|
19
21
|
end
|
20
22
|
end
|
@@ -1,8 +1,10 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Panoptes
|
2
4
|
class Client
|
3
5
|
module Collections
|
4
6
|
def add_subjects_to_collection(collection_id, subject_ids)
|
5
|
-
panoptes.post("/collections/#{collection_id}/links/subjects",subjects: subject_ids)
|
7
|
+
panoptes.post("/collections/#{collection_id}/links/subjects", subjects: subject_ids)
|
6
8
|
end
|
7
9
|
end
|
8
10
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Panoptes
|
2
4
|
class Client
|
3
5
|
module Comments
|
@@ -7,9 +9,9 @@ module Panoptes
|
|
7
9
|
# @param focus_type [String] filter by focussable type
|
8
10
|
# @return list of discussions
|
9
11
|
def create_comment(discussion_id:, body:)
|
10
|
-
user_id = token_contents[
|
11
|
-
response = talk.post(
|
12
|
-
response.fetch(
|
12
|
+
user_id = token_contents['id']
|
13
|
+
response = talk.post('/comments', comments: { discussion_id: discussion_id, body: body, user_id: user_id })
|
14
|
+
response.fetch('comments')[0]
|
13
15
|
end
|
14
16
|
end
|
15
17
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Panoptes
|
2
4
|
class Client
|
3
5
|
module Discussions
|
@@ -11,8 +13,8 @@ module Panoptes
|
|
11
13
|
query[:focus_id] = focus_id
|
12
14
|
query[:focus_type] = focus_type
|
13
15
|
|
14
|
-
response = talk.get(
|
15
|
-
response.fetch(
|
16
|
+
response = talk.get('/discussions', query)
|
17
|
+
response.fetch('discussions')
|
16
18
|
end
|
17
19
|
end
|
18
20
|
end
|
data/lib/panoptes/client/me.rb
CHANGED
@@ -1,32 +1,31 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
|
2
3
|
module Panoptes
|
3
4
|
class Client
|
4
5
|
module ProjectPreferences
|
5
6
|
def project_preferences(id)
|
6
7
|
response = panoptes.get("project_preferences/#{id}")
|
7
|
-
response.fetch(
|
8
|
+
response.fetch('project_preferences').first
|
8
9
|
end
|
9
10
|
|
10
11
|
def user_project_preferences(user_id, project_id)
|
11
|
-
response = panoptes.get(
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
response.fetch("project_preferences").first
|
12
|
+
response = panoptes.get('project_preferences',
|
13
|
+
user_id: user_id,
|
14
|
+
project_id: project_id)
|
15
|
+
response.fetch('project_preferences').first
|
16
16
|
end
|
17
17
|
|
18
18
|
def promote_user_to_workflow(user_id, project_id, workflow_id)
|
19
|
-
id = panoptes.get(
|
20
|
-
|
21
|
-
|
22
|
-
}).fetch("project_preferences").first["id"]
|
19
|
+
id = panoptes.get('project_preferences',
|
20
|
+
user_id: user_id,
|
21
|
+
project_id: project_id).fetch('project_preferences').first['id']
|
23
22
|
|
24
23
|
response = panoptes.connection.get("/api/project_preferences/#{id}")
|
25
|
-
etag = response.headers[
|
24
|
+
etag = response.headers['ETag']
|
26
25
|
|
27
26
|
panoptes.put("project_preferences/#{id}", {
|
28
|
-
|
29
|
-
|
27
|
+
project_preferences: { settings: { workflow_id: workflow_id } }
|
28
|
+
}, etag: etag)
|
30
29
|
end
|
31
30
|
end
|
32
31
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Panoptes
|
2
4
|
class Client
|
3
5
|
module Projects
|
@@ -10,7 +12,7 @@ module Panoptes
|
|
10
12
|
params = {}
|
11
13
|
params[:search] = search if search
|
12
14
|
|
13
|
-
panoptes.paginate(
|
15
|
+
panoptes.paginate('/projects', params)['projects']
|
14
16
|
end
|
15
17
|
|
16
18
|
# Fetches the specified project
|
@@ -20,7 +22,7 @@ module Panoptes
|
|
20
22
|
# @return [Hash] The requested project
|
21
23
|
def project(project_id)
|
22
24
|
response = panoptes.get("/projects/#{project_id}")
|
23
|
-
response.fetch(
|
25
|
+
response.fetch('projects').find { |i| i.fetch('id').to_s == project_id.to_s }
|
24
26
|
end
|
25
27
|
|
26
28
|
# Starts a background process to generate a new CSV export of all the classifications in the project.
|
@@ -28,8 +30,9 @@ module Panoptes
|
|
28
30
|
# @param project_id [Integer] the id of the project to export
|
29
31
|
# @return [Hash] the medium information where the export will be stored when it's generated
|
30
32
|
def create_classifications_export(project_id)
|
31
|
-
params =
|
32
|
-
|
33
|
+
params = export_params('text/csv')
|
34
|
+
path = export_path(project_id, 'classifications_export')
|
35
|
+
panoptes.post(path, params)['media'].first
|
33
36
|
end
|
34
37
|
|
35
38
|
# Starts a background process to generate a new CSV export of all the subjects in the project.
|
@@ -37,8 +40,9 @@ module Panoptes
|
|
37
40
|
# @param project_id [Integer] the id of the project to export
|
38
41
|
# @return [Hash] the medium information where the export will be stored when it's generated
|
39
42
|
def create_subjects_export(project_id)
|
40
|
-
params =
|
41
|
-
|
43
|
+
params = export_params('text/csv')
|
44
|
+
path = export_path(project_id, 'subjects_export')
|
45
|
+
panoptes.post(path, params)['media'].first
|
42
46
|
end
|
43
47
|
|
44
48
|
# Starts a background process to generate a new CSV export of all the workflows in the project.
|
@@ -46,8 +50,9 @@ module Panoptes
|
|
46
50
|
# @param project_id [Integer] the id of the project to export
|
47
51
|
# @return [Hash] the medium information where the export will be stored when it's generated
|
48
52
|
def create_workflows_export(project_id)
|
49
|
-
params =
|
50
|
-
|
53
|
+
params = export_params('text/csv')
|
54
|
+
path = export_path(project_id, 'workflows_export')
|
55
|
+
panoptes.post(path, params)['media'].first
|
51
56
|
end
|
52
57
|
|
53
58
|
# Starts a background process to generate a new CSV export of all the workflow_contents in the project.
|
@@ -55,8 +60,9 @@ module Panoptes
|
|
55
60
|
# @param project_id [Integer] the id of the project to export
|
56
61
|
# @return [Hash] the medium information where the export will be stored when it's generated
|
57
62
|
def create_workflow_contents_export(project_id)
|
58
|
-
params =
|
59
|
-
|
63
|
+
params = export_params('text/csv')
|
64
|
+
path = export_path(project_id, 'workflow_contents_export')
|
65
|
+
panoptes.post(path, params)['media'].first
|
60
66
|
end
|
61
67
|
|
62
68
|
# Starts a background process to generate a new CSV export of the aggretation results of the project.
|
@@ -64,8 +70,19 @@ module Panoptes
|
|
64
70
|
# @param project_id [Integer] the id of the project to export
|
65
71
|
# @return [Hash] the medium information where the export will be stored when it's generated
|
66
72
|
def create_aggregations_export(project_id)
|
67
|
-
params =
|
68
|
-
|
73
|
+
params = export_params('application/x-gzip')
|
74
|
+
path = export_path(project_id, 'aggregations_export')
|
75
|
+
panoptes.post(path, params)['media'].first
|
76
|
+
end
|
77
|
+
|
78
|
+
private
|
79
|
+
|
80
|
+
def export_params(content_type)
|
81
|
+
{ media: { content_type: content_type, metadata: { recipients: [] } } }
|
82
|
+
end
|
83
|
+
|
84
|
+
def export_path(project_id, export_type)
|
85
|
+
"/projects/#{project_id}/#{export_type}"
|
69
86
|
end
|
70
87
|
end
|
71
88
|
end
|
@@ -1,22 +1,24 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Panoptes
|
2
4
|
class Client
|
3
5
|
module SubjectSets
|
4
6
|
def subject_set(subject_set_id)
|
5
7
|
response = panoptes.get("/subject_sets/#{subject_set_id}")
|
6
|
-
response.fetch(
|
8
|
+
response.fetch('subject_sets').find { |i| i.fetch('id').to_s == subject_set_id.to_s }
|
7
9
|
end
|
8
10
|
|
9
11
|
def create_subject_set(attributes)
|
10
|
-
response = panoptes.post(
|
11
|
-
response.fetch(
|
12
|
+
response = panoptes.post('/subject_sets', subject_sets: attributes)
|
13
|
+
response.fetch('subject_sets').first
|
12
14
|
end
|
13
15
|
|
14
16
|
def update_subject_set(subject_set_id, attributes)
|
15
17
|
response = panoptes.connection.get("/api/subject_sets/#{subject_set_id}")
|
16
|
-
etag = response.headers[
|
18
|
+
etag = response.headers['ETag']
|
17
19
|
|
18
|
-
response = panoptes.put("/subject_sets/#{subject_set_id}", {subject_sets: attributes}, etag: etag)
|
19
|
-
response.fetch(
|
20
|
+
response = panoptes.put("/subject_sets/#{subject_set_id}", { subject_sets: attributes }, etag: etag)
|
21
|
+
response.fetch('subject_sets').first
|
20
22
|
end
|
21
23
|
|
22
24
|
def add_subjects_to_subject_set(subject_set_id, subject_ids)
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Panoptes
|
2
4
|
class Client
|
3
5
|
module Subjects
|
@@ -12,8 +14,8 @@ module Panoptes
|
|
12
14
|
|
13
15
|
raise 'Must filter on at least one of subject_set_id, workflow_id' if query.empty?
|
14
16
|
|
15
|
-
response = panoptes.paginate(
|
16
|
-
response.fetch(
|
17
|
+
response = panoptes.paginate('/subjects', query)
|
18
|
+
response.fetch('subjects')
|
17
19
|
end
|
18
20
|
|
19
21
|
# Fetch a subject given filters (including permissions)
|
@@ -27,7 +29,7 @@ module Panoptes
|
|
27
29
|
|
28
30
|
response = panoptes.get("/subjects/#{subject_id}", query)
|
29
31
|
if response.fetch('subjects', []).count > 1
|
30
|
-
raise StandardError
|
32
|
+
raise StandardError, 'Unexpectedly many subjects returned'
|
31
33
|
end
|
32
34
|
|
33
35
|
response.fetch('subjects', []).fetch(0, nil)
|
@@ -40,11 +42,10 @@ module Panoptes
|
|
40
42
|
# @param subject_id [Integer] the ID of a subject associated with that workflow (through one of the assigned subject_sets)
|
41
43
|
# @return nothing
|
42
44
|
def retire_subject(workflow_id, subject_id, reason: nil)
|
43
|
-
panoptes.post("/workflows/#{workflow_id}/retired_subjects",
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
})
|
45
|
+
panoptes.post("/workflows/#{workflow_id}/retired_subjects",
|
46
|
+
admin: true,
|
47
|
+
subject_id: subject_id,
|
48
|
+
retirement_reason: reason)
|
48
49
|
true
|
49
50
|
end
|
50
51
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Panoptes
|
2
4
|
class Client
|
3
5
|
module UserGroups
|
@@ -7,20 +9,20 @@ module Panoptes
|
|
7
9
|
# @param name [String] The name of the user group. Must be unique for the entirity of Zooniverse.
|
8
10
|
# @return [Hash] The created user group.
|
9
11
|
def create_user_group(name)
|
10
|
-
panoptes.post(
|
11
|
-
|
12
|
-
|
12
|
+
panoptes.post('/user_groups', user_groups: {
|
13
|
+
name: name
|
14
|
+
})['user_groups'][0]
|
13
15
|
end
|
14
16
|
|
15
17
|
def user_groups
|
16
|
-
panoptes.get(
|
18
|
+
panoptes.get('/user_groups')['user_groups']
|
17
19
|
end
|
18
20
|
|
19
21
|
def join_user_group(user_group_id, user_id, join_token:)
|
20
|
-
panoptes.post(
|
21
|
-
|
22
|
-
|
23
|
-
|
22
|
+
panoptes.post('/memberships', memberships: {
|
23
|
+
join_token: join_token,
|
24
|
+
links: { user: user_id, user_group: user_group_id }
|
25
|
+
})['memberships'][0]
|
24
26
|
end
|
25
27
|
|
26
28
|
def remove_user_from_user_group(user_group_id, user_id)
|
@@ -29,7 +31,7 @@ module Panoptes
|
|
29
31
|
|
30
32
|
def delete_user_group(user_group_id)
|
31
33
|
response = panoptes.connection.get("/api/user_groups/#{user_group_id}")
|
32
|
-
etag = response.headers[
|
34
|
+
etag = response.headers['ETag']
|
33
35
|
|
34
36
|
panoptes.delete("/user_groups/#{user_group_id}", {}, etag: etag)
|
35
37
|
end
|
@@ -1,9 +1,11 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Panoptes
|
2
4
|
class Client
|
3
5
|
module Users
|
4
6
|
def user(user_id)
|
5
7
|
response = panoptes.get("users/#{user_id}")
|
6
|
-
response.fetch(
|
8
|
+
response.fetch('users').find { |i| i.fetch('id').to_s == user_id.to_s }
|
7
9
|
end
|
8
10
|
end
|
9
11
|
end
|
@@ -1,18 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Panoptes
|
2
4
|
class Client
|
3
5
|
module Workflows
|
4
6
|
def workflow(workflow_id)
|
5
7
|
response = panoptes.get("/workflows/#{workflow_id}")
|
6
|
-
response.fetch(
|
8
|
+
response.fetch('workflows').find do |i|
|
9
|
+
i.fetch('id').to_s == workflow_id.to_s
|
10
|
+
end
|
7
11
|
end
|
8
12
|
|
9
13
|
def create_workflow(attributes)
|
10
|
-
response = panoptes.post(
|
11
|
-
response.fetch(
|
14
|
+
response = panoptes.post('/workflows', workflows: attributes)
|
15
|
+
response.fetch('workflows').first
|
12
16
|
end
|
13
17
|
|
14
18
|
def add_subject_set_to_workflow(workflow_id, subject_set_id)
|
15
|
-
panoptes.post(
|
19
|
+
panoptes.post(
|
20
|
+
"/workflows/#{workflow_id}/links/subject_sets",
|
21
|
+
subject_sets: subject_set_id
|
22
|
+
)
|
16
23
|
end
|
17
24
|
end
|
18
25
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'faraday'
|
2
4
|
require 'faraday_middleware'
|
3
5
|
require 'faraday/panoptes'
|
@@ -58,7 +60,10 @@ module Panoptes
|
|
58
60
|
end
|
59
61
|
|
60
62
|
def request(method, path, *args)
|
61
|
-
|
63
|
+
if prefix
|
64
|
+
sep = path[0] == '/' ? nil : '/'
|
65
|
+
path = "#{prefix}#{sep}#{path}"
|
66
|
+
end
|
62
67
|
handle_response connection.send(method, path, *args)
|
63
68
|
end
|
64
69
|
|
@@ -83,9 +88,7 @@ module Panoptes
|
|
83
88
|
faraday.request :json
|
84
89
|
faraday.response :json
|
85
90
|
faraday.adapter Faraday.default_adapter
|
86
|
-
if @params
|
87
|
-
faraday.params = @params
|
88
|
-
end
|
91
|
+
faraday.params = @params if @params
|
89
92
|
end
|
90
93
|
end
|
91
94
|
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require_relative 'base_endpoint'
|
2
4
|
|
3
5
|
module Panoptes
|
@@ -7,7 +9,7 @@ module Panoptes
|
|
7
9
|
# @see Panoptes::Endpoints::BaseEndpoint#initialize
|
8
10
|
def initialize(auth: {}, url: nil, prefix: nil, &config)
|
9
11
|
super auth: auth, url: url, prefix: prefix do |faraday|
|
10
|
-
|
12
|
+
yield(faraday) if config
|
11
13
|
faraday.request :json
|
12
14
|
faraday.response :json
|
13
15
|
faraday.adapter Faraday.default_adapter
|
data/lib/panoptes/session.rb
CHANGED
data/lib/panoptes/talk_client.rb
CHANGED
data/panoptes-client.gemspec
CHANGED
@@ -1,31 +1,32 @@
|
|
1
|
-
#
|
2
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
lib = File.expand_path('lib', __dir__)
|
3
4
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
5
|
require 'panoptes/client/version'
|
5
6
|
|
6
7
|
Gem::Specification.new do |spec|
|
7
|
-
spec.name =
|
8
|
+
spec.name = 'panoptes-client'
|
8
9
|
spec.version = Panoptes::Client::VERSION
|
9
10
|
spec.authors = ['Marten Veldthuis', 'Zach Wolfenbarger', 'Amy Boyer']
|
10
11
|
spec.email = ['marten@veldthuis.com', 'zach@zooniverse.org', 'amy@zooniverse.org']
|
11
12
|
|
12
|
-
spec.summary =
|
13
|
-
spec.homepage =
|
14
|
-
spec.license =
|
13
|
+
spec.summary = 'API wrapper for https://panoptes.zooniverse.org'
|
14
|
+
spec.homepage = 'https://github.com/zooniverse/panoptes-client.rb'
|
15
|
+
spec.license = 'Apache 2.0'
|
15
16
|
|
16
17
|
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
17
|
-
spec.bindir =
|
18
|
+
spec.bindir = 'exe'
|
18
19
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
19
|
-
spec.require_paths = [
|
20
|
+
spec.require_paths = ['lib']
|
20
21
|
|
21
|
-
spec.add_dependency
|
22
|
-
spec.add_dependency
|
23
|
-
spec.add_dependency
|
24
|
-
spec.add_dependency
|
22
|
+
spec.add_dependency 'deprecate'
|
23
|
+
spec.add_dependency 'faraday'
|
24
|
+
spec.add_dependency 'faraday-panoptes', '~> 0.3.0'
|
25
|
+
spec.add_dependency 'jwt', '~> 1.5.0'
|
25
26
|
|
26
|
-
spec.add_development_dependency
|
27
|
-
spec.add_development_dependency
|
28
|
-
spec.add_development_dependency
|
29
|
-
spec.add_development_dependency
|
30
|
-
spec.add_development_dependency
|
27
|
+
spec.add_development_dependency 'bundler', '~> 1.11'
|
28
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
29
|
+
spec.add_development_dependency 'rspec', '~> 3.0'
|
30
|
+
spec.add_development_dependency 'timecop', '~> 0.8.0'
|
31
|
+
spec.add_development_dependency 'yard'
|
31
32
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: panoptes-client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.0
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Marten Veldthuis
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: exe
|
12
12
|
cert_chain: []
|
13
|
-
date: 2019-12-
|
13
|
+
date: 2019-12-17 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: deprecate
|
@@ -150,7 +150,7 @@ files:
|
|
150
150
|
- ".gitignore"
|
151
151
|
- ".hound.yml"
|
152
152
|
- ".rspec"
|
153
|
-
- ".
|
153
|
+
- ".rubocop.yml"
|
154
154
|
- ".travis.yml"
|
155
155
|
- CHANGELOG.md
|
156
156
|
- CODE_OF_CONDUCT.md
|
@@ -200,9 +200,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
200
200
|
version: '0'
|
201
201
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
202
202
|
requirements:
|
203
|
-
- - "
|
203
|
+
- - ">="
|
204
204
|
- !ruby/object:Gem::Version
|
205
|
-
version:
|
205
|
+
version: '0'
|
206
206
|
requirements: []
|
207
207
|
rubygems_version: 3.0.4
|
208
208
|
signing_key:
|
data/.ruby-style.yml
DELETED
@@ -1,206 +0,0 @@
|
|
1
|
-
inherit_from: .rubocop_todo.yml
|
2
|
-
|
3
|
-
AllCops:
|
4
|
-
Exclude:
|
5
|
-
- "vendor/**/*"
|
6
|
-
- "db/schema.rb"
|
7
|
-
UseCache: false
|
8
|
-
|
9
|
-
Style/DotPosition:
|
10
|
-
Description: Checks the position of the dot in multi-line method calls.
|
11
|
-
StyleGuide: https://github.com/bbatsov/ruby-style-guide#consistent-multi-line-chains
|
12
|
-
Enabled: true
|
13
|
-
EnforcedStyle: leading
|
14
|
-
SupportedStyles:
|
15
|
-
- leading
|
16
|
-
- trailing
|
17
|
-
Style/FileName:
|
18
|
-
Description: Use snake_case for source file names.
|
19
|
-
StyleGuide: https://github.com/bbatsov/ruby-style-guide#snake-case-files
|
20
|
-
Enabled: true
|
21
|
-
Exclude: []
|
22
|
-
Style/GuardClause:
|
23
|
-
Description: Check for conditionals that can be replaced with guard clauses
|
24
|
-
StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-nested-conditionals
|
25
|
-
Enabled: false
|
26
|
-
MinBodyLength: 1
|
27
|
-
Style/IfUnlessModifier:
|
28
|
-
Description: Favor modifier if/unless usage when you have a single-line body.
|
29
|
-
StyleGuide: https://github.com/bbatsov/ruby-style-guide#if-as-a-modifier
|
30
|
-
Enabled: false
|
31
|
-
MaxLineLength: 80
|
32
|
-
Style/OptionHash:
|
33
|
-
Description: Don't use option hashes when you can use keyword arguments.
|
34
|
-
Enabled: false
|
35
|
-
Style/ParallelAssignment:
|
36
|
-
Enabled: false
|
37
|
-
Style/PercentLiteralDelimiters:
|
38
|
-
Description: Use `%`-literal delimiters consistently
|
39
|
-
StyleGuide: https://github.com/bbatsov/ruby-style-guide#percent-literal-braces
|
40
|
-
Enabled: false
|
41
|
-
PreferredDelimiters:
|
42
|
-
"%": "()"
|
43
|
-
"%i": "()"
|
44
|
-
"%q": "()"
|
45
|
-
"%Q": "()"
|
46
|
-
"%r": "{}"
|
47
|
-
"%s": "()"
|
48
|
-
"%w": "()"
|
49
|
-
"%W": "()"
|
50
|
-
"%x": "()"
|
51
|
-
Style/PredicateName:
|
52
|
-
Description: Check the names of predicate methods.
|
53
|
-
StyleGuide: https://github.com/bbatsov/ruby-style-guide#bool-methods-qmark
|
54
|
-
Enabled: true
|
55
|
-
NamePrefix:
|
56
|
-
- is_
|
57
|
-
- has_
|
58
|
-
- have_
|
59
|
-
NamePrefixBlacklist:
|
60
|
-
- is_
|
61
|
-
Exclude:
|
62
|
-
- spec/**/*
|
63
|
-
Style/RaiseArgs:
|
64
|
-
Description: Checks the arguments passed to raise/fail.
|
65
|
-
StyleGuide: https://github.com/bbatsov/ruby-style-guide#exception-class-messages
|
66
|
-
Enabled: false
|
67
|
-
EnforcedStyle: exploded
|
68
|
-
SupportedStyles:
|
69
|
-
- compact
|
70
|
-
- exploded
|
71
|
-
Style/SignalException:
|
72
|
-
Description: Checks for proper usage of fail and raise.
|
73
|
-
StyleGuide: https://github.com/bbatsov/ruby-style-guide#fail-method
|
74
|
-
Enabled: false
|
75
|
-
EnforcedStyle: semantic
|
76
|
-
SupportedStyles:
|
77
|
-
- only_raise
|
78
|
-
- only_fail
|
79
|
-
- semantic
|
80
|
-
Style/SingleLineBlockParams:
|
81
|
-
Description: Enforces the names of some block params.
|
82
|
-
StyleGuide: https://github.com/bbatsov/ruby-style-guide#reduce-blocks
|
83
|
-
Enabled: false
|
84
|
-
Methods:
|
85
|
-
- reduce:
|
86
|
-
- a
|
87
|
-
- e
|
88
|
-
- inject:
|
89
|
-
- a
|
90
|
-
- e
|
91
|
-
Style/SingleLineMethods:
|
92
|
-
Description: Avoid single-line methods.
|
93
|
-
StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-single-line-methods
|
94
|
-
Enabled: false
|
95
|
-
AllowIfMethodIsEmpty: true
|
96
|
-
Metrics/AbcSize:
|
97
|
-
Description: A calculated magnitude based on number of assignments, branches, and
|
98
|
-
conditions.
|
99
|
-
Enabled: false
|
100
|
-
Max: 15
|
101
|
-
Metrics/ClassLength:
|
102
|
-
Description: Avoid classes longer than 100 lines of code.
|
103
|
-
Enabled: false
|
104
|
-
CountComments: false
|
105
|
-
Max: 100
|
106
|
-
Metrics/LineLength:
|
107
|
-
Enabled: false
|
108
|
-
Metrics/ModuleLength:
|
109
|
-
CountComments: false
|
110
|
-
Max: 100
|
111
|
-
Description: Avoid modules longer than 100 lines of code.
|
112
|
-
Enabled: false
|
113
|
-
Metrics/CyclomaticComplexity:
|
114
|
-
Description: A complexity metric that is strongly correlated to the number of test
|
115
|
-
cases needed to validate a method.
|
116
|
-
Enabled: false
|
117
|
-
Max: 6
|
118
|
-
Metrics/MethodLength:
|
119
|
-
Description: Avoid methods longer than 10 lines of code.
|
120
|
-
StyleGuide: https://github.com/bbatsov/ruby-style-guide#short-methods
|
121
|
-
Enabled: false
|
122
|
-
CountComments: false
|
123
|
-
Max: 10
|
124
|
-
Metrics/ParameterLists:
|
125
|
-
Description: Avoid parameter lists longer than three or four parameters.
|
126
|
-
StyleGuide: https://github.com/bbatsov/ruby-style-guide#too-many-params
|
127
|
-
Enabled: false
|
128
|
-
Max: 5
|
129
|
-
CountKeywordArgs: true
|
130
|
-
Metrics/PerceivedComplexity:
|
131
|
-
Description: A complexity metric geared towards measuring complexity for a human
|
132
|
-
reader.
|
133
|
-
Enabled: false
|
134
|
-
Max: 7
|
135
|
-
Lint/AssignmentInCondition:
|
136
|
-
Description: Don't use assignment in conditions.
|
137
|
-
StyleGuide: https://github.com/bbatsov/ruby-style-guide#safe-assignment-in-condition
|
138
|
-
Enabled: false
|
139
|
-
AllowSafeAssignment: true
|
140
|
-
Style/InlineComment:
|
141
|
-
Description: Avoid inline comments.
|
142
|
-
Enabled: false
|
143
|
-
Style/AccessorMethodName:
|
144
|
-
Description: Check the naming of accessor methods for get_/set_.
|
145
|
-
Enabled: false
|
146
|
-
Style/Alias:
|
147
|
-
Description: Use alias_method instead of alias.
|
148
|
-
StyleGuide: https://github.com/bbatsov/ruby-style-guide#alias-method
|
149
|
-
Enabled: false
|
150
|
-
Style/Documentation:
|
151
|
-
Description: Document classes and non-namespace modules.
|
152
|
-
Enabled: false
|
153
|
-
Style/DoubleNegation:
|
154
|
-
Description: Checks for uses of double negation (!!).
|
155
|
-
StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-bang-bang
|
156
|
-
Enabled: false
|
157
|
-
Style/EachWithObject:
|
158
|
-
Description: Prefer `each_with_object` over `inject` or `reduce`.
|
159
|
-
Enabled: false
|
160
|
-
Style/EmptyLiteral:
|
161
|
-
Description: Prefer literals to Array.new/Hash.new/String.new.
|
162
|
-
StyleGuide: https://github.com/bbatsov/ruby-style-guide#literal-array-hash
|
163
|
-
Enabled: false
|
164
|
-
Style/ModuleFunction:
|
165
|
-
Description: Checks for usage of `extend self` in modules.
|
166
|
-
StyleGuide: https://github.com/bbatsov/ruby-style-guide#module-function
|
167
|
-
Enabled: false
|
168
|
-
Style/OneLineConditional:
|
169
|
-
Description: Favor the ternary operator(?:) over if/then/else/end constructs.
|
170
|
-
StyleGuide: https://github.com/bbatsov/ruby-style-guide#ternary-operator
|
171
|
-
Enabled: false
|
172
|
-
Style/PerlBackrefs:
|
173
|
-
Description: Avoid Perl-style regex back references.
|
174
|
-
StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-perl-regexp-last-matchers
|
175
|
-
Enabled: false
|
176
|
-
Style/Send:
|
177
|
-
Description: Prefer `Object#__send__` or `Object#public_send` to `send`, as `send`
|
178
|
-
may overlap with existing methods.
|
179
|
-
StyleGuide: https://github.com/bbatsov/ruby-style-guide#prefer-public-send
|
180
|
-
Enabled: false
|
181
|
-
Style/SpecialGlobalVars:
|
182
|
-
Description: Avoid Perl-style global variables.
|
183
|
-
StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-cryptic-perlisms
|
184
|
-
Enabled: false
|
185
|
-
Style/VariableInterpolation:
|
186
|
-
Description: Don't interpolate global, instance and class variables directly in
|
187
|
-
strings.
|
188
|
-
StyleGuide: https://github.com/bbatsov/ruby-style-guide#curlies-interpolate
|
189
|
-
Enabled: false
|
190
|
-
Style/WhenThen:
|
191
|
-
Description: Use when x then ... for one-line cases.
|
192
|
-
StyleGuide: https://github.com/bbatsov/ruby-style-guide#one-line-cases
|
193
|
-
Enabled: false
|
194
|
-
Lint/EachWithObjectArgument:
|
195
|
-
Description: Check for immutable argument given to each_with_object.
|
196
|
-
Enabled: true
|
197
|
-
Lint/HandleExceptions:
|
198
|
-
Description: Don't suppress exception.
|
199
|
-
StyleGuide: https://github.com/bbatsov/ruby-style-guide#dont-hide-exceptions
|
200
|
-
Enabled: false
|
201
|
-
Lint/LiteralInCondition:
|
202
|
-
Description: Checks of literals used in conditions.
|
203
|
-
Enabled: false
|
204
|
-
Lint/LiteralInInterpolation:
|
205
|
-
Description: Checks for literals used in interpolation.
|
206
|
-
Enabled: false
|