panoptes-client 1.1.0 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 39aeafa72adb7b23aa7f2c92feb0e0fa673c2fe88c85a4d007362ad5609a5aa1
4
- data.tar.gz: 35626ac17f0645ed4de74a9ec9e85515152a0b8b8f6a55bde827f9c2b29e779e
3
+ metadata.gz: c253f336c2bf15cc1477383fda0465cc2ca1a5a4d9a945007b229a2c577cdaef
4
+ data.tar.gz: 5806a295c165f072b5f27f9d5a950154b1b1fcbdb2d93e2152cc7c497f50a15c
5
5
  SHA512:
6
- metadata.gz: 0727eb9c0a4d26eec16972c82e6b122ce74e966458a8850de2197905d496dff2ab454fcd9e286f42d71d53d6240ab2faffedb5bf624ccfa02e361ced61174165
7
- data.tar.gz: 7505d21379cf1cff27d679c512267bbdde3ce2672410f9716dd4b6345f00e111c37a6f6c1aa8b26ddf49fed8f4da2de1c55d56a1ef30b5a71eaef35f8f4f5a4d
6
+ metadata.gz: 1b4c3bcd21024eb0f18454cf7187d3d3f4c9f678ac2936b62353435482b0bb2b560959b10da5c247d7241430387be71aeb8c93662c58e5e9fb44d60b08b6a256
7
+ data.tar.gz: 194b78af782c65bcf7b1458ed883ab037c517b8353e959bc172d3c43aefc11bc135d9d1fe27d43fcaa58e035ecf32a370442576173ecdd6cffc12794898dd8da
@@ -0,0 +1,72 @@
1
+ # For most projects, this workflow file will not need changing; you simply need
2
+ # to commit it to your repository.
3
+ #
4
+ # You may wish to alter this file to override the set of languages analyzed,
5
+ # or to provide custom queries or build logic.
6
+ #
7
+ # ******** NOTE ********
8
+ # We have attempted to detect the languages in your repository. Please check
9
+ # the `language` matrix defined below to confirm you have the correct set of
10
+ # supported CodeQL languages.
11
+ #
12
+ name: "CodeQL"
13
+
14
+ on:
15
+ push:
16
+ branches: [ "master" ]
17
+ pull_request:
18
+ schedule:
19
+ - cron: '23 9 * * 6'
20
+
21
+ jobs:
22
+ analyze:
23
+ name: Analyze
24
+ runs-on: ubuntu-latest
25
+ permissions:
26
+ actions: read
27
+ contents: read
28
+ security-events: write
29
+
30
+ strategy:
31
+ fail-fast: false
32
+ matrix:
33
+ language: [ 'ruby' ]
34
+ # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ]
35
+ # Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support
36
+
37
+ steps:
38
+ - name: Checkout repository
39
+ uses: actions/checkout@v3
40
+
41
+ # Initializes the CodeQL tools for scanning.
42
+ - name: Initialize CodeQL
43
+ uses: github/codeql-action/init@v2
44
+ with:
45
+ languages: ${{ matrix.language }}
46
+ # If you wish to specify custom queries, you can do so here or in a config file.
47
+ # By default, queries listed here will override any specified in a config file.
48
+ # Prefix the list here with "+" to use these queries and those in the config file.
49
+
50
+ # Details on CodeQL's query packs refer to : https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs
51
+ # queries: security-extended,security-and-quality
52
+
53
+
54
+ # Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
55
+ # If this step fails, then you should remove it and run the build manually (see below)
56
+ - name: Autobuild
57
+ uses: github/codeql-action/autobuild@v2
58
+
59
+ # ℹ️ Command-line programs to run using the OS shell.
60
+ # 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
61
+
62
+ # If the Autobuild fails above, remove it and uncomment the following three lines.
63
+ # modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance.
64
+
65
+ # - run: |
66
+ # echo "Run, Build Application using script"
67
+ # ./location_of_script_within_repo/buildscript.sh
68
+
69
+ - name: Perform CodeQL Analysis
70
+ uses: github/codeql-action/analyze@v2
71
+ with:
72
+ category: "/language:${{matrix.language}}"
@@ -0,0 +1,17 @@
1
+ name: Zooni CI
2
+ on:
3
+ pull_request:
4
+ push: { branches: master }
5
+ jobs:
6
+ test:
7
+ name: Run Tests
8
+ runs-on: ubuntu-latest
9
+ steps:
10
+ - uses: actions/checkout@v2
11
+ - name: Setup Ruby
12
+ uses: ruby/setup-ruby@v1
13
+ with:
14
+ ruby-version: 2.7
15
+ bundler-cache: true
16
+ - name: Run tests
17
+ run: bundle exec rspec
data/.rubocop.yml CHANGED
@@ -1,2 +1,9 @@
1
1
  Style/Documentation:
2
2
  Enabled: false
3
+
4
+ Layout/LineLength:
5
+ Max: 160
6
+
7
+ Metrics/BlockLength:
8
+ Exclude:
9
+ - '**/*_spec.rb'
data/CHANGELOG.md CHANGED
@@ -1,3 +1,18 @@
1
+ # 1.2.0
2
+
3
+ * Relax the `faraday-panoptes` gem version constraints to allow it to upgrade
4
+
5
+ # 1.1.1
6
+
7
+ * Fix a pagination bug that skipped the first page of API results when using a block to process results. Note this did not impact the use of the paginate method without a block.
8
+
9
+ ```ruby
10
+ # impacted
11
+ client.paginate('/subjects', {}) { |initial_page, page| .. }
12
+ # not impacted
13
+ all_page_results = client.paginate('/subjects', {})
14
+ ```
15
+
1
16
  # 1.1.0
2
17
 
3
18
  * Add method to get single collection
data/Dockerfile ADDED
@@ -0,0 +1,22 @@
1
+ FROM ruby:2.7-slim
2
+
3
+ WORKDIR /panoptes-client
4
+
5
+ RUN apt-get update && apt-get -y upgrade && \
6
+ apt-get install --no-install-recommends -y \
7
+ build-essential \
8
+ # git is required for installing gems from git repos
9
+ git \
10
+ nano \
11
+ vim
12
+
13
+ ADD ./Gemfile /panoptes-client/
14
+ ADD ./panoptes-client.gemspec /panoptes-client/
15
+ ADD ./lib/panoptes/client/version.rb /panoptes-client/lib/panoptes/client/
16
+ ADD .git/ /panoptes-client/
17
+
18
+ RUN bundle config --global jobs `cat /proc/cpuinfo | grep processor | wc -l | xargs -I % expr % - 1` && bundle install
19
+
20
+ ADD ./ /panoptes-client
21
+
22
+ CMD ["bundle", "exec", "rspec"]
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Panoptes::Client
2
2
 
3
- [![Build Status](https://travis-ci.org/zooniverse/panoptes-client.rb.svg?branch=master)](https://travis-ci.org/zooniverse/panoptes-client.rb)
3
+ [![Build Status](https://github.com/zooniverse/panoptes-client.rb/actions/workflows/run_tests_CI.yml/badge.svg?)
4
4
  [![Yard Docs](http://img.shields.io/badge/yard-docs-blue.svg)](http://rubydoc.info/github/zooniverse/panoptes-client.rb/)
5
5
 
6
6
  ## Installation
@@ -13,13 +13,23 @@ gem 'panoptes-client'
13
13
 
14
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.
15
15
 
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`.**
16
+ **A lot of methods are still missing. You can either issue a PR adding the one you need, or use the generic `get` / `post` methods on `Client`.**
17
17
 
18
18
 
19
19
  ## Development
20
20
 
21
21
  After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
22
22
 
23
+ Alternatively use docker and docker-compose to get your dev env setup.
24
+
25
+ ``` bash
26
+ docker-compose build # to build your dev docker image
27
+ docker-compose up # to run the tests in the dev container
28
+
29
+ # or run an interactive bash session in the dev container
30
+ docker-compose run --service-ports --rm panoptes-client bash
31
+ ```
32
+
23
33
  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
34
 
25
35
  | Variable | Value |
@@ -34,6 +44,16 @@ We recommend [Direnv](https://github.com/direnv/direnv) as good utility to allow
34
44
 
35
45
  Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/panoptes-client. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
36
46
 
47
+ ## Publishing
48
+
49
+ Follow these steps for publishing changes to the panoptes-client.rb ruby gem.
50
+
51
+ 1. Make sure changes have been outlined in CHANGELOG.md, and version has been updated in lib/panoptes/client/version.rb. Reference [Semantic Versioning](https://semver.org/) for guidance on how to update the version number.
52
+ 2. Tag a release when your PR has been merged into master. Use [this guide](https://help.github.com/en/github/administering-a-repository/managing-releases-in-a-repository) for reference on how to create release tags. Set the version number (e.g. v1.1.1) as the tag name. Select the master branch as the target branch. In the release description, list out the changes that have been made just as you did in CHANGELOG.md. Do not select pre-release unless it’s not yet ready for production, and then click ‘Publish Release’.
53
+ 3. Once the release tag is set, check out the release branch locally and test to make sure everything is working as expected, run tests and make sure they pass. Use the following command to check out a branch via its tag: `git checkout tags/<tag>`
54
+ 4. Create the package by running `rake build`. This will build the new version of the panoptes gem (e.g. panoptes-client-1.1.1.gem) into the pkg directory. Once you’ve done this, run `bundler console` to make sure everything works as expected. For more details on packaging and distributing ruby gems, check out [this article](https://www.digitalocean.com/community/tutorials/how-to-package-and-distribute-ruby-applications-as-a-gem-using-rubygems).
55
+ 5. To publish the gem, use the command `[sudo] gem push [gem file]`. You’ll need to enter your rubygem.org credentials. Make sure you are one of the owners of the gem, or else you will not have permission to publish. You should see the version updated shortly on https://rubygems.org/gems/panoptes-client. And that’s it!
56
+
37
57
 
38
58
  ## License
39
59
 
@@ -0,0 +1,11 @@
1
+ version: '3'
2
+ services:
3
+ panoptes-client:
4
+ build:
5
+ context: .
6
+ volumes:
7
+ - ./:/panoptes-client
8
+ - gem_cache:/usr/local/bundle
9
+
10
+ volumes:
11
+ gem_cache:
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Panoptes
4
4
  class Client
5
- VERSION = '1.1.0'
5
+ VERSION = '1.2.0'
6
6
  end
7
7
  end
@@ -10,17 +10,25 @@ module Panoptes
10
10
  resource = path.split('/').last if resource.nil?
11
11
  data = last_response = get(path, query)
12
12
 
13
- while next_path = last_response['meta'][resource]['next_href']
13
+ # ensure we yield the first page of data
14
+ yield data, last_response if block_given?
15
+
16
+ # while we have more result set pages
17
+ while (next_path = last_response['meta'][resource]['next_href'])
18
+ # fetch next page of data
14
19
  last_response = get(next_path, query)
15
20
  if block_given?
21
+ # if we pass a block then yield the first page and current page responses
16
22
  yield data, last_response
17
23
  else
24
+ # add to the data representation of all result set pages
18
25
  data[resource].concat(last_response[resource]) if data[resource].is_a?(Array)
19
26
  data['meta'][resource].merge!(last_response['meta'][resource])
20
27
  data['links'].merge!(last_response['links'])
21
28
  end
22
29
  end
23
30
 
31
+ # return the data results for when we don't use a block to process response pages
24
32
  data
25
33
  end
26
34
  end
@@ -21,12 +21,12 @@ Gem::Specification.new do |spec|
21
21
 
22
22
  spec.add_dependency 'deprecate'
23
23
  spec.add_dependency 'faraday'
24
- spec.add_dependency 'faraday-panoptes', '~> 0.3.0'
24
+ spec.add_dependency 'faraday-panoptes', '~> 0.3'
25
25
  spec.add_dependency 'jwt', '~> 1.5.0'
26
26
 
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'
27
+ spec.add_development_dependency 'bundler'
28
+ spec.add_development_dependency 'rake'
29
+ spec.add_development_dependency 'rspec'
30
+ spec.add_development_dependency 'timecop'
31
31
  spec.add_development_dependency 'yard'
32
32
  end
metadata CHANGED
@@ -1,16 +1,16 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: panoptes-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marten Veldthuis
8
8
  - Zach Wolfenbarger
9
9
  - Amy Boyer
10
- autorequire:
10
+ autorequire:
11
11
  bindir: exe
12
12
  cert_chain: []
13
- date: 2020-04-08 00:00:00.000000000 Z
13
+ date: 2022-10-21 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: deprecate
@@ -46,14 +46,14 @@ dependencies:
46
46
  requirements:
47
47
  - - "~>"
48
48
  - !ruby/object:Gem::Version
49
- version: 0.3.0
49
+ version: '0.3'
50
50
  type: :runtime
51
51
  prerelease: false
52
52
  version_requirements: !ruby/object:Gem::Requirement
53
53
  requirements:
54
54
  - - "~>"
55
55
  - !ruby/object:Gem::Version
56
- version: 0.3.0
56
+ version: '0.3'
57
57
  - !ruby/object:Gem::Dependency
58
58
  name: jwt
59
59
  requirement: !ruby/object:Gem::Requirement
@@ -72,58 +72,58 @@ dependencies:
72
72
  name: bundler
73
73
  requirement: !ruby/object:Gem::Requirement
74
74
  requirements:
75
- - - "~>"
75
+ - - ">="
76
76
  - !ruby/object:Gem::Version
77
- version: '1.11'
77
+ version: '0'
78
78
  type: :development
79
79
  prerelease: false
80
80
  version_requirements: !ruby/object:Gem::Requirement
81
81
  requirements:
82
- - - "~>"
82
+ - - ">="
83
83
  - !ruby/object:Gem::Version
84
- version: '1.11'
84
+ version: '0'
85
85
  - !ruby/object:Gem::Dependency
86
86
  name: rake
87
87
  requirement: !ruby/object:Gem::Requirement
88
88
  requirements:
89
- - - "~>"
89
+ - - ">="
90
90
  - !ruby/object:Gem::Version
91
- version: '10.0'
91
+ version: '0'
92
92
  type: :development
93
93
  prerelease: false
94
94
  version_requirements: !ruby/object:Gem::Requirement
95
95
  requirements:
96
- - - "~>"
96
+ - - ">="
97
97
  - !ruby/object:Gem::Version
98
- version: '10.0'
98
+ version: '0'
99
99
  - !ruby/object:Gem::Dependency
100
100
  name: rspec
101
101
  requirement: !ruby/object:Gem::Requirement
102
102
  requirements:
103
- - - "~>"
103
+ - - ">="
104
104
  - !ruby/object:Gem::Version
105
- version: '3.0'
105
+ version: '0'
106
106
  type: :development
107
107
  prerelease: false
108
108
  version_requirements: !ruby/object:Gem::Requirement
109
109
  requirements:
110
- - - "~>"
110
+ - - ">="
111
111
  - !ruby/object:Gem::Version
112
- version: '3.0'
112
+ version: '0'
113
113
  - !ruby/object:Gem::Dependency
114
114
  name: timecop
115
115
  requirement: !ruby/object:Gem::Requirement
116
116
  requirements:
117
- - - "~>"
117
+ - - ">="
118
118
  - !ruby/object:Gem::Version
119
- version: 0.8.0
119
+ version: '0'
120
120
  type: :development
121
121
  prerelease: false
122
122
  version_requirements: !ruby/object:Gem::Requirement
123
123
  requirements:
124
- - - "~>"
124
+ - - ">="
125
125
  - !ruby/object:Gem::Version
126
- version: 0.8.0
126
+ version: '0'
127
127
  - !ruby/object:Gem::Dependency
128
128
  name: yard
129
129
  requirement: !ruby/object:Gem::Requirement
@@ -138,7 +138,7 @@ dependencies:
138
138
  - - ">="
139
139
  - !ruby/object:Gem::Version
140
140
  version: '0'
141
- description:
141
+ description:
142
142
  email:
143
143
  - marten@veldthuis.com
144
144
  - zach@zooniverse.org
@@ -147,13 +147,15 @@ executables: []
147
147
  extensions: []
148
148
  extra_rdoc_files: []
149
149
  files:
150
+ - ".github/workflows/codeql-analysis.yml"
151
+ - ".github/workflows/run_tests_CI.yml"
150
152
  - ".gitignore"
151
153
  - ".hound.yml"
152
154
  - ".rspec"
153
155
  - ".rubocop.yml"
154
- - ".travis.yml"
155
156
  - CHANGELOG.md
156
157
  - CODE_OF_CONDUCT.md
158
+ - Dockerfile
157
159
  - Gemfile
158
160
  - LICENSE.txt
159
161
  - README.md
@@ -162,6 +164,7 @@ files:
162
164
  - bin/setup
163
165
  - data/doorkeeper-jwt-production.pub
164
166
  - data/doorkeeper-jwt-staging.pub
167
+ - docker-compose.yml
165
168
  - lib/panoptes-client.rb
166
169
  - lib/panoptes/client.rb
167
170
  - lib/panoptes/client/authentication.rb
@@ -189,7 +192,7 @@ homepage: https://github.com/zooniverse/panoptes-client.rb
189
192
  licenses:
190
193
  - Apache 2.0
191
194
  metadata: {}
192
- post_install_message:
195
+ post_install_message:
193
196
  rdoc_options: []
194
197
  require_paths:
195
198
  - lib
@@ -204,8 +207,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
204
207
  - !ruby/object:Gem::Version
205
208
  version: '0'
206
209
  requirements: []
207
- rubygems_version: 3.0.3
208
- signing_key:
210
+ rubygems_version: 3.1.4
211
+ signing_key:
209
212
  specification_version: 4
210
213
  summary: API wrapper for https://panoptes.zooniverse.org
211
214
  test_files: []
data/.travis.yml DELETED
@@ -1,7 +0,0 @@
1
- language: ruby
2
- cache: bundler
3
- rvm:
4
- - 2.4
5
- - 2.5
6
- - 2.6
7
- before_install: gem install bundler -v 1.11.2