gbifrb 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.github/dependabot.yml +21 -0
- data/.github/workflows/ruby.yml +28 -0
- data/.gitignore +2 -0
- data/CHANGELOG.md +5 -0
- data/Gemfile +6 -0
- data/LICENSE +1 -1
- data/README.md +29 -4
- data/gbifrb.gemspec +9 -14
- data/lib/gbifrb/Occurrences.rb +0 -2
- data/lib/gbifrb/Registry.rb +0 -2
- data/lib/gbifrb/Species.rb +2 -21
- data/lib/gbifrb/constants.rb +1 -1
- data/lib/gbifrb/request.rb +3 -5
- data/lib/gbifrb/version.rb +1 -1
- metadata +30 -112
- data/.travis.yml +0 -8
- data/Gemfile.lock +0 -64
- data/lib/gbifrb/faraday.rb +0 -71
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: c12817ecbe5432e7b4652e4e8fd3f4220855153757665b2f05409f74d871dc99
|
4
|
+
data.tar.gz: a4c5eb799e941b709e72068d7df89c0a5ac4be6f86b2261b6ea76f76397f7359
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2a25057d092320c81b0891ab05e0ca001e38e6798b0e417f368b08679b12d34e9c85ab5a3d441207c036958e854185d49af608d0253f4d7a42c95592dcc18565
|
7
|
+
data.tar.gz: f2ebeb2949b1105e451c24cac22d99d02061c672943413ac2cfc6b641e01e41f0fbaf4531eea23af9d66a68a10138eaf01200db44d149e14a6f6b8efb96df0a8
|
@@ -0,0 +1,21 @@
|
|
1
|
+
version: 2
|
2
|
+
updates:
|
3
|
+
- package-ecosystem: bundler
|
4
|
+
directory: "/"
|
5
|
+
schedule:
|
6
|
+
interval: daily
|
7
|
+
time: "13:00"
|
8
|
+
open-pull-requests-limit: 10
|
9
|
+
ignore:
|
10
|
+
- dependency-name: codecov
|
11
|
+
versions:
|
12
|
+
- "> 0.1.17, < 0.2"
|
13
|
+
- dependency-name: codecov
|
14
|
+
versions:
|
15
|
+
- "> 0.2.1, < 0.3"
|
16
|
+
- dependency-name: test-unit
|
17
|
+
versions:
|
18
|
+
- "> 3.3.4, < 3.4"
|
19
|
+
- dependency-name: webmock
|
20
|
+
versions:
|
21
|
+
- "> 3.9.3, < 3.10"
|
@@ -0,0 +1,28 @@
|
|
1
|
+
name: Ruby
|
2
|
+
|
3
|
+
on:
|
4
|
+
push:
|
5
|
+
branches: [ main ]
|
6
|
+
pull_request:
|
7
|
+
branches: [ main ]
|
8
|
+
|
9
|
+
jobs:
|
10
|
+
test:
|
11
|
+
strategy:
|
12
|
+
fail-fast: false
|
13
|
+
matrix:
|
14
|
+
ruby: [ 2.6, 2.7, 3.1.2 ]
|
15
|
+
runs-on: ubuntu-latest
|
16
|
+
env:
|
17
|
+
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
|
18
|
+
steps:
|
19
|
+
- uses: actions/checkout@v2
|
20
|
+
- name: Setup Ruby
|
21
|
+
uses: ruby/setup-ruby@v1
|
22
|
+
with:
|
23
|
+
ruby-version: ${{ matrix.ruby }}
|
24
|
+
- name: Install dependencies
|
25
|
+
run: |
|
26
|
+
bundle install
|
27
|
+
- name: Run tests
|
28
|
+
run: bundle exec rake test TESTOPTS="-v"
|
data/.gitignore
CHANGED
data/CHANGELOG.md
CHANGED
data/Gemfile
CHANGED
data/LICENSE
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
Copyright (C)
|
1
|
+
Copyright (C) 2021 Scott Chamberlain
|
2
2
|
|
3
3
|
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
4
4
|
|
data/README.md
CHANGED
@@ -2,8 +2,8 @@ gbifrb
|
|
2
2
|
======
|
3
3
|
|
4
4
|
[![gem version](https://img.shields.io/gem/v/gbifrb.svg)](https://rubygems.org/gems/gbifrb)
|
5
|
-
[![
|
6
|
-
[![codecov.io](http://codecov.io/github/sckott/gbifrb/coverage.svg?branch=
|
5
|
+
[![Ruby](https://github.com/sckott/gbifrb/actions/workflows/ruby.yml/badge.svg)](https://github.com/sckott/gbifrb/actions/workflows/ruby.yml)
|
6
|
+
[![codecov.io](http://codecov.io/github/sckott/gbifrb/coverage.svg?branch=main)](http://codecov.io/github/sckott/gbifrb?branch=main)
|
7
7
|
|
8
8
|
`gbifrb` is a low level client for the GBIF API
|
9
9
|
|
@@ -11,6 +11,7 @@ Other GBIF API clients:
|
|
11
11
|
|
12
12
|
- Python: [pygbif](https://github.com/sckott/pygbif)
|
13
13
|
- R: [rgbif](https://github.com/ropensci/rgbif)
|
14
|
+
- PHP: [php-gbif](https://gitlab.res-telae.cat/restelae/php-gbif)
|
14
15
|
|
15
16
|
## Changes
|
16
17
|
|
@@ -92,7 +93,31 @@ species.name_backbone(name: "Helianthus")
|
|
92
93
|
Suggester
|
93
94
|
|
94
95
|
```ruby
|
95
|
-
species.name_suggest("Helianthus")
|
96
|
+
species.name_suggest(q: "Helianthus")
|
97
|
+
```
|
98
|
+
|
99
|
+
Lookup
|
100
|
+
|
101
|
+
```ruby
|
102
|
+
species.name_lookup(q: "Helianthus")
|
103
|
+
```
|
104
|
+
|
105
|
+
Lookup example with more parameters: name usages of plants where accepted scientific name includes 'reptans':
|
106
|
+
|
107
|
+
```ruby
|
108
|
+
species.name_lookup(q: 'reptans', higherTaxonKey: 6, nameType: 'SCIENTIFIC', status: 'ACCEPTED')
|
109
|
+
```
|
110
|
+
|
111
|
+
Name usage (`/species`)
|
112
|
+
|
113
|
+
```ruby
|
114
|
+
species.name_usage(name: "Helianthus")
|
115
|
+
```
|
116
|
+
|
117
|
+
Name usage example with more parameters: name usages of 'Andropogon' in Database of Vascular Plants of Canada (VASCAN) checklist:
|
118
|
+
|
119
|
+
```ruby
|
120
|
+
species.name_usage(name: 'Andropogon', datasetKey: '3f8a1297-3259-4700-91fc-acc4170b27ce')
|
96
121
|
```
|
97
122
|
|
98
123
|
### Occurrences
|
@@ -124,4 +149,4 @@ species.name_backbone("Helianthus", verbose: true)
|
|
124
149
|
* License: MIT
|
125
150
|
|
126
151
|
[gbifapi]: https://www.gbif.org/developer/summary
|
127
|
-
[changelog]: https://github.com/sckott/gbifrb/blob/
|
152
|
+
[changelog]: https://github.com/sckott/gbifrb/blob/main/CHANGELOG.md
|
data/gbifrb.gemspec
CHANGED
@@ -8,7 +8,7 @@ Gem::Specification.new do |s|
|
|
8
8
|
s.version = Gbif::VERSION
|
9
9
|
s.platform = Gem::Platform::RUBY
|
10
10
|
s.required_ruby_version = '>= 2.0'
|
11
|
-
s.date = '
|
11
|
+
s.date = '2022-08-27'
|
12
12
|
s.summary = "GBIF Client"
|
13
13
|
s.description = "Low Level Ruby Client for the GBIF API"
|
14
14
|
s.authors = "Scott Chamberlain"
|
@@ -19,17 +19,12 @@ Gem::Specification.new do |s|
|
|
19
19
|
s.files = `git ls-files -z`.split("\x0").reject {|f| f.match(%r{^(test|spec|features)/}) }
|
20
20
|
s.require_paths = ["lib"]
|
21
21
|
|
22
|
-
s.add_development_dependency 'bundler', '~>
|
23
|
-
s.add_development_dependency 'rake', '~>
|
24
|
-
s.add_development_dependency 'test-unit', '~> 3.
|
25
|
-
s.add_development_dependency 'simplecov', '~> 0.
|
26
|
-
s.add_development_dependency 'codecov', '~> 0.
|
27
|
-
s.add_development_dependency 'json', '~> 2.
|
28
|
-
s.add_development_dependency 'vcr', '~>
|
29
|
-
s.add_development_dependency 'webmock', '~>
|
30
|
-
|
31
|
-
s.add_runtime_dependency 'faraday', '~> 0.12.0.1'
|
32
|
-
s.add_runtime_dependency 'faraday_middleware', '~> 0.11.0.1'
|
33
|
-
s.add_runtime_dependency 'thor', '~> 0.19.4'
|
34
|
-
s.add_runtime_dependency 'multi_json', '~> 1.12', '>= 1.12.1'
|
22
|
+
s.add_development_dependency 'bundler', '~> 2.2', '>= 2.2.1'
|
23
|
+
s.add_development_dependency 'rake', '~> 13.0', '>= 13.0.1'
|
24
|
+
s.add_development_dependency 'test-unit', '~> 3.3', '>= 3.3.7'
|
25
|
+
s.add_development_dependency 'simplecov', '~> 0.21.2'
|
26
|
+
s.add_development_dependency 'codecov', '~> 0.6.0'
|
27
|
+
s.add_development_dependency 'json', '~> 2.6.1'
|
28
|
+
s.add_development_dependency 'vcr', '~> 6.0'
|
29
|
+
s.add_development_dependency 'webmock', '~> 3.16.0'
|
35
30
|
end
|
data/lib/gbifrb/Occurrences.rb
CHANGED
data/lib/gbifrb/Registry.rb
CHANGED
@@ -1,11 +1,9 @@
|
|
1
1
|
require "faraday"
|
2
|
-
require 'faraday_middleware'
|
3
2
|
require "multi_json"
|
4
3
|
require "gbifrb/error"
|
5
4
|
require "gbifrb/request"
|
6
5
|
require "gbifrb/constants"
|
7
6
|
require 'gbifrb/helpers/configuration'
|
8
|
-
require 'gbifrb/faraday'
|
9
7
|
require 'gbifrb/utils'
|
10
8
|
require 'gbifrb/get_data'
|
11
9
|
|
data/lib/gbifrb/Species.rb
CHANGED
@@ -1,11 +1,9 @@
|
|
1
1
|
require "faraday"
|
2
|
-
require 'faraday_middleware'
|
3
2
|
require "multi_json"
|
4
3
|
require "gbifrb/error"
|
5
4
|
require "gbifrb/request"
|
6
5
|
require "gbifrb/constants"
|
7
6
|
require 'gbifrb/helpers/configuration'
|
8
|
-
require 'gbifrb/faraday'
|
9
7
|
require 'gbifrb/utils'
|
10
8
|
|
11
9
|
##
|
@@ -96,25 +94,11 @@ module Gbif
|
|
96
94
|
#
|
97
95
|
# @!macro gbif_params
|
98
96
|
# @!macro gbif_options
|
99
|
-
# @param key [Fixnum] A GBIF key for a taxon
|
100
97
|
# @param name [String] Filters by a case insensitive, canonical namestring,
|
101
98
|
# e.g. 'Puma concolor'
|
102
|
-
# @param data [String] The type of data to get. Default: 'all'. Options: 'all',
|
103
|
-
# 'verbatim', 'name', 'parents', 'children', 'related', 'synonyms', 'descriptions',
|
104
|
-
# 'distributions', 'media', 'references', 'speciesProfiles', 'vernacularNames',
|
105
|
-
# 'typeSpecimens', 'root'
|
106
99
|
# @param language [String] Language, default is english
|
107
100
|
# @param datasetKey [String] Filters by the dataset's key (a uuid)
|
108
|
-
# @param uuid [String] A uuid for a dataset. Should give exact same results as datasetKey.
|
109
101
|
# @param sourceId [Fixnum] Filters by the source identifier.
|
110
|
-
# @param rank [String] Taxonomic rank. Filters by taxonomic rank as one of:
|
111
|
-
# 'CLASS', 'CULTIVAR', 'CULTIVAR_GROUP', 'DOMAIN', 'FAMILY', 'FORM', 'GENUS', 'INFORMAL',
|
112
|
-
# 'INFRAGENERIC_NAME', 'INFRAORDER', 'INFRASPECIFIC_NAME', 'INFRASUBSPECIFIC_NAME',
|
113
|
-
# 'KINGDOM', 'ORDER', 'PHYLUM', 'SECTION', 'SERIES', 'SPECIES', 'STRAIN', 'SUBCLASS', 'SUBFAMILY',
|
114
|
-
# 'SUBFORM', 'SUBGENUS', 'SUBKINGDOM', 'SUBORDER', 'SUBPHYLUM', 'SUBSECTION', 'SUBSERIES',
|
115
|
-
# 'SUBSPECIES', 'SUBTRIBE', 'SUBVARIETY', 'SUPERCLASS', 'SUPERFAMILY', 'SUPERORDER',
|
116
|
-
# 'SUPERPHYLUM', 'SUPRAGENERIC_NAME', 'TRIBE', 'UNRANKED', 'VARIETY'
|
117
|
-
# @param shortname [String] A short name..need more info on this?
|
118
102
|
# @return [Array] An array of hashes
|
119
103
|
#
|
120
104
|
# @example
|
@@ -123,13 +107,10 @@ module Gbif
|
|
123
107
|
# speices = Gbif::Species
|
124
108
|
# speices.name_usage(name: "Helianthus")
|
125
109
|
# speices.name_usage(name: "Poa")
|
126
|
-
def self.name_usage(
|
127
|
-
datasetKey: nil, uuid: nil, sourceId: nil, rank: nil, shortname: nil,
|
110
|
+
def self.name_usage(name: nil, language: nil, datasetKey: nil, sourceId: nil,
|
128
111
|
limit: 100, offset: nil, verbose: nil, options: nil)
|
129
112
|
|
130
|
-
arguments = {
|
131
|
-
language: language, datasetKey: datasetKey, uuid: uuid,
|
132
|
-
sourceId: sourceId, rank: rank, shortname: shortname,
|
113
|
+
arguments = { name: name, language: language, datasetKey: datasetKey, sourceId: sourceId,
|
133
114
|
limit: limit, offset: offset }.tostrings
|
134
115
|
opts = arguments.delete_if { |k, v| v.nil? }
|
135
116
|
Request.new("species/", opts, verbose, options).perform
|
data/lib/gbifrb/constants.rb
CHANGED
data/lib/gbifrb/request.rb
CHANGED
@@ -21,21 +21,19 @@ module Gbif
|
|
21
21
|
self.endpt = endpt
|
22
22
|
self.args = args
|
23
23
|
self.verbose = verbose
|
24
|
-
self.options = options
|
24
|
+
self.options = (options or {}).merge({params_encoder: Faraday::FlatParamsEncoder})
|
25
25
|
end
|
26
26
|
|
27
27
|
def perform
|
28
28
|
if verbose
|
29
29
|
conn = Faraday.new(:url => Gbif.base_url, :request => self.options || []) do |f|
|
30
30
|
f.response :logger
|
31
|
-
f.
|
32
|
-
f.options.params_encoder = Faraday::FlatParamsEncoder
|
31
|
+
f.response :raise_error
|
33
32
|
f.adapter Faraday.default_adapter
|
34
33
|
end
|
35
34
|
else
|
36
35
|
conn = Faraday.new(:url => Gbif.base_url, :request => self.options || []) do |f|
|
37
|
-
f.
|
38
|
-
f.options.params_encoder = Faraday::FlatParamsEncoder
|
36
|
+
f.response :raise_error
|
39
37
|
f.adapter Faraday.default_adapter
|
40
38
|
end
|
41
39
|
end
|
data/lib/gbifrb/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gbifrb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Scott Chamberlain
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-08-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -16,222 +16,142 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '2.2'
|
20
20
|
- - ">="
|
21
21
|
- !ruby/object:Gem::Version
|
22
|
-
version:
|
22
|
+
version: 2.2.1
|
23
23
|
type: :development
|
24
24
|
prerelease: false
|
25
25
|
version_requirements: !ruby/object:Gem::Requirement
|
26
26
|
requirements:
|
27
27
|
- - "~>"
|
28
28
|
- !ruby/object:Gem::Version
|
29
|
-
version: '
|
29
|
+
version: '2.2'
|
30
30
|
- - ">="
|
31
31
|
- !ruby/object:Gem::Version
|
32
|
-
version:
|
32
|
+
version: 2.2.1
|
33
33
|
- !ruby/object:Gem::Dependency
|
34
34
|
name: rake
|
35
35
|
requirement: !ruby/object:Gem::Requirement
|
36
36
|
requirements:
|
37
37
|
- - "~>"
|
38
38
|
- !ruby/object:Gem::Version
|
39
|
-
version: '
|
39
|
+
version: '13.0'
|
40
40
|
- - ">="
|
41
41
|
- !ruby/object:Gem::Version
|
42
|
-
version:
|
42
|
+
version: 13.0.1
|
43
43
|
type: :development
|
44
44
|
prerelease: false
|
45
45
|
version_requirements: !ruby/object:Gem::Requirement
|
46
46
|
requirements:
|
47
47
|
- - "~>"
|
48
48
|
- !ruby/object:Gem::Version
|
49
|
-
version: '
|
49
|
+
version: '13.0'
|
50
50
|
- - ">="
|
51
51
|
- !ruby/object:Gem::Version
|
52
|
-
version:
|
52
|
+
version: 13.0.1
|
53
53
|
- !ruby/object:Gem::Dependency
|
54
54
|
name: test-unit
|
55
55
|
requirement: !ruby/object:Gem::Requirement
|
56
56
|
requirements:
|
57
57
|
- - "~>"
|
58
58
|
- !ruby/object:Gem::Version
|
59
|
-
version: '3.
|
59
|
+
version: '3.3'
|
60
60
|
- - ">="
|
61
61
|
- !ruby/object:Gem::Version
|
62
|
-
version: 3.
|
62
|
+
version: 3.3.7
|
63
63
|
type: :development
|
64
64
|
prerelease: false
|
65
65
|
version_requirements: !ruby/object:Gem::Requirement
|
66
66
|
requirements:
|
67
67
|
- - "~>"
|
68
68
|
- !ruby/object:Gem::Version
|
69
|
-
version: '3.
|
69
|
+
version: '3.3'
|
70
70
|
- - ">="
|
71
71
|
- !ruby/object:Gem::Version
|
72
|
-
version: 3.
|
72
|
+
version: 3.3.7
|
73
73
|
- !ruby/object:Gem::Dependency
|
74
74
|
name: simplecov
|
75
75
|
requirement: !ruby/object:Gem::Requirement
|
76
76
|
requirements:
|
77
77
|
- - "~>"
|
78
78
|
- !ruby/object:Gem::Version
|
79
|
-
version: 0.
|
79
|
+
version: 0.21.2
|
80
80
|
type: :development
|
81
81
|
prerelease: false
|
82
82
|
version_requirements: !ruby/object:Gem::Requirement
|
83
83
|
requirements:
|
84
84
|
- - "~>"
|
85
85
|
- !ruby/object:Gem::Version
|
86
|
-
version: 0.
|
86
|
+
version: 0.21.2
|
87
87
|
- !ruby/object:Gem::Dependency
|
88
88
|
name: codecov
|
89
89
|
requirement: !ruby/object:Gem::Requirement
|
90
90
|
requirements:
|
91
91
|
- - "~>"
|
92
92
|
- !ruby/object:Gem::Version
|
93
|
-
version: 0.
|
93
|
+
version: 0.6.0
|
94
94
|
type: :development
|
95
95
|
prerelease: false
|
96
96
|
version_requirements: !ruby/object:Gem::Requirement
|
97
97
|
requirements:
|
98
98
|
- - "~>"
|
99
99
|
- !ruby/object:Gem::Version
|
100
|
-
version: 0.
|
100
|
+
version: 0.6.0
|
101
101
|
- !ruby/object:Gem::Dependency
|
102
102
|
name: json
|
103
103
|
requirement: !ruby/object:Gem::Requirement
|
104
104
|
requirements:
|
105
105
|
- - "~>"
|
106
106
|
- !ruby/object:Gem::Version
|
107
|
-
version:
|
108
|
-
- - ">="
|
109
|
-
- !ruby/object:Gem::Version
|
110
|
-
version: 2.0.3
|
107
|
+
version: 2.6.1
|
111
108
|
type: :development
|
112
109
|
prerelease: false
|
113
110
|
version_requirements: !ruby/object:Gem::Requirement
|
114
111
|
requirements:
|
115
112
|
- - "~>"
|
116
113
|
- !ruby/object:Gem::Version
|
117
|
-
version:
|
118
|
-
- - ">="
|
119
|
-
- !ruby/object:Gem::Version
|
120
|
-
version: 2.0.3
|
114
|
+
version: 2.6.1
|
121
115
|
- !ruby/object:Gem::Dependency
|
122
116
|
name: vcr
|
123
117
|
requirement: !ruby/object:Gem::Requirement
|
124
118
|
requirements:
|
125
119
|
- - "~>"
|
126
120
|
- !ruby/object:Gem::Version
|
127
|
-
version: '
|
128
|
-
- - ">="
|
129
|
-
- !ruby/object:Gem::Version
|
130
|
-
version: 3.0.3
|
121
|
+
version: '6.0'
|
131
122
|
type: :development
|
132
123
|
prerelease: false
|
133
124
|
version_requirements: !ruby/object:Gem::Requirement
|
134
125
|
requirements:
|
135
126
|
- - "~>"
|
136
127
|
- !ruby/object:Gem::Version
|
137
|
-
version: '
|
138
|
-
- - ">="
|
139
|
-
- !ruby/object:Gem::Version
|
140
|
-
version: 3.0.3
|
128
|
+
version: '6.0'
|
141
129
|
- !ruby/object:Gem::Dependency
|
142
130
|
name: webmock
|
143
131
|
requirement: !ruby/object:Gem::Requirement
|
144
132
|
requirements:
|
145
133
|
- - "~>"
|
146
134
|
- !ruby/object:Gem::Version
|
147
|
-
version:
|
148
|
-
- - ">="
|
149
|
-
- !ruby/object:Gem::Version
|
150
|
-
version: 2.3.2
|
135
|
+
version: 3.16.0
|
151
136
|
type: :development
|
152
137
|
prerelease: false
|
153
138
|
version_requirements: !ruby/object:Gem::Requirement
|
154
139
|
requirements:
|
155
140
|
- - "~>"
|
156
141
|
- !ruby/object:Gem::Version
|
157
|
-
version:
|
158
|
-
- - ">="
|
159
|
-
- !ruby/object:Gem::Version
|
160
|
-
version: 2.3.2
|
161
|
-
- !ruby/object:Gem::Dependency
|
162
|
-
name: faraday
|
163
|
-
requirement: !ruby/object:Gem::Requirement
|
164
|
-
requirements:
|
165
|
-
- - "~>"
|
166
|
-
- !ruby/object:Gem::Version
|
167
|
-
version: 0.12.0.1
|
168
|
-
type: :runtime
|
169
|
-
prerelease: false
|
170
|
-
version_requirements: !ruby/object:Gem::Requirement
|
171
|
-
requirements:
|
172
|
-
- - "~>"
|
173
|
-
- !ruby/object:Gem::Version
|
174
|
-
version: 0.12.0.1
|
175
|
-
- !ruby/object:Gem::Dependency
|
176
|
-
name: faraday_middleware
|
177
|
-
requirement: !ruby/object:Gem::Requirement
|
178
|
-
requirements:
|
179
|
-
- - "~>"
|
180
|
-
- !ruby/object:Gem::Version
|
181
|
-
version: 0.11.0.1
|
182
|
-
type: :runtime
|
183
|
-
prerelease: false
|
184
|
-
version_requirements: !ruby/object:Gem::Requirement
|
185
|
-
requirements:
|
186
|
-
- - "~>"
|
187
|
-
- !ruby/object:Gem::Version
|
188
|
-
version: 0.11.0.1
|
189
|
-
- !ruby/object:Gem::Dependency
|
190
|
-
name: thor
|
191
|
-
requirement: !ruby/object:Gem::Requirement
|
192
|
-
requirements:
|
193
|
-
- - "~>"
|
194
|
-
- !ruby/object:Gem::Version
|
195
|
-
version: 0.19.4
|
196
|
-
type: :runtime
|
197
|
-
prerelease: false
|
198
|
-
version_requirements: !ruby/object:Gem::Requirement
|
199
|
-
requirements:
|
200
|
-
- - "~>"
|
201
|
-
- !ruby/object:Gem::Version
|
202
|
-
version: 0.19.4
|
203
|
-
- !ruby/object:Gem::Dependency
|
204
|
-
name: multi_json
|
205
|
-
requirement: !ruby/object:Gem::Requirement
|
206
|
-
requirements:
|
207
|
-
- - "~>"
|
208
|
-
- !ruby/object:Gem::Version
|
209
|
-
version: '1.12'
|
210
|
-
- - ">="
|
211
|
-
- !ruby/object:Gem::Version
|
212
|
-
version: 1.12.1
|
213
|
-
type: :runtime
|
214
|
-
prerelease: false
|
215
|
-
version_requirements: !ruby/object:Gem::Requirement
|
216
|
-
requirements:
|
217
|
-
- - "~>"
|
218
|
-
- !ruby/object:Gem::Version
|
219
|
-
version: '1.12'
|
220
|
-
- - ">="
|
221
|
-
- !ruby/object:Gem::Version
|
222
|
-
version: 1.12.1
|
142
|
+
version: 3.16.0
|
223
143
|
description: Low Level Ruby Client for the GBIF API
|
224
144
|
email: myrmecocystus@gmail.com
|
225
145
|
executables: []
|
226
146
|
extensions: []
|
227
147
|
extra_rdoc_files: []
|
228
148
|
files:
|
149
|
+
- ".github/dependabot.yml"
|
150
|
+
- ".github/workflows/ruby.yml"
|
229
151
|
- ".gitignore"
|
230
|
-
- ".travis.yml"
|
231
152
|
- CHANGELOG.md
|
232
153
|
- CONDUCT.md
|
233
154
|
- Gemfile
|
234
|
-
- Gemfile.lock
|
235
155
|
- LICENSE
|
236
156
|
- README.md
|
237
157
|
- Rakefile
|
@@ -242,7 +162,6 @@ files:
|
|
242
162
|
- lib/gbifrb/Species.rb
|
243
163
|
- lib/gbifrb/constants.rb
|
244
164
|
- lib/gbifrb/error.rb
|
245
|
-
- lib/gbifrb/faraday.rb
|
246
165
|
- lib/gbifrb/get_data.rb
|
247
166
|
- lib/gbifrb/helpers/configuration.rb
|
248
167
|
- lib/gbifrb/request.rb
|
@@ -253,7 +172,7 @@ homepage: https://github.com/sckott/gbifrb
|
|
253
172
|
licenses:
|
254
173
|
- MIT
|
255
174
|
metadata: {}
|
256
|
-
post_install_message:
|
175
|
+
post_install_message:
|
257
176
|
rdoc_options: []
|
258
177
|
require_paths:
|
259
178
|
- lib
|
@@ -268,9 +187,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
268
187
|
- !ruby/object:Gem::Version
|
269
188
|
version: '0'
|
270
189
|
requirements: []
|
271
|
-
|
272
|
-
|
273
|
-
signing_key:
|
190
|
+
rubygems_version: 3.3.7
|
191
|
+
signing_key:
|
274
192
|
specification_version: 4
|
275
193
|
summary: GBIF Client
|
276
194
|
test_files: []
|
data/.travis.yml
DELETED
data/Gemfile.lock
DELETED
@@ -1,64 +0,0 @@
|
|
1
|
-
PATH
|
2
|
-
remote: .
|
3
|
-
specs:
|
4
|
-
gbifrb (0.1.0)
|
5
|
-
faraday (~> 0.12.0.1)
|
6
|
-
faraday_middleware (~> 0.11.0.1)
|
7
|
-
multi_json (~> 1.12, >= 1.12.1)
|
8
|
-
thor (~> 0.19.4)
|
9
|
-
|
10
|
-
GEM
|
11
|
-
remote: https://rubygems.org/
|
12
|
-
specs:
|
13
|
-
addressable (2.5.0)
|
14
|
-
public_suffix (~> 2.0, >= 2.0.2)
|
15
|
-
codecov (0.1.10)
|
16
|
-
json
|
17
|
-
simplecov
|
18
|
-
url
|
19
|
-
crack (0.4.3)
|
20
|
-
safe_yaml (~> 1.0.0)
|
21
|
-
docile (1.1.5)
|
22
|
-
faraday (0.12.0.1)
|
23
|
-
multipart-post (>= 1.2, < 3)
|
24
|
-
faraday_middleware (0.11.0.1)
|
25
|
-
faraday (>= 0.7.4, < 1.0)
|
26
|
-
hashdiff (0.3.2)
|
27
|
-
json (2.0.3)
|
28
|
-
multi_json (1.12.1)
|
29
|
-
multipart-post (2.0.0)
|
30
|
-
power_assert (0.3.1)
|
31
|
-
public_suffix (2.0.5)
|
32
|
-
rake (12.0.0)
|
33
|
-
safe_yaml (1.0.4)
|
34
|
-
simplecov (0.14.1)
|
35
|
-
docile (~> 1.1.0)
|
36
|
-
json (>= 1.8, < 3)
|
37
|
-
simplecov-html (~> 0.10.0)
|
38
|
-
simplecov-html (0.10.0)
|
39
|
-
test-unit (3.2.1)
|
40
|
-
power_assert
|
41
|
-
thor (0.19.4)
|
42
|
-
url (0.3.2)
|
43
|
-
vcr (3.0.3)
|
44
|
-
webmock (2.3.2)
|
45
|
-
addressable (>= 2.3.6)
|
46
|
-
crack (>= 0.3.2)
|
47
|
-
hashdiff
|
48
|
-
|
49
|
-
PLATFORMS
|
50
|
-
ruby
|
51
|
-
|
52
|
-
DEPENDENCIES
|
53
|
-
bundler (~> 1.14, >= 1.14.6)
|
54
|
-
codecov (~> 0.1.10)
|
55
|
-
gbifrb!
|
56
|
-
json (~> 2.0, >= 2.0.3)
|
57
|
-
rake (~> 12.0, >= 12.0.0)
|
58
|
-
simplecov (~> 0.14.1)
|
59
|
-
test-unit (~> 3.2, >= 3.2.1)
|
60
|
-
vcr (~> 3.0, >= 3.0.3)
|
61
|
-
webmock (~> 2.3, >= 2.3.2)
|
62
|
-
|
63
|
-
BUNDLED WITH
|
64
|
-
1.15.3
|
data/lib/gbifrb/faraday.rb
DELETED
@@ -1,71 +0,0 @@
|
|
1
|
-
require 'faraday'
|
2
|
-
require 'multi_json'
|
3
|
-
|
4
|
-
# @private
|
5
|
-
module FaradayMiddleware
|
6
|
-
# @private
|
7
|
-
class RaiseHttpException < Faraday::Middleware
|
8
|
-
def call(env)
|
9
|
-
@app.call(env).on_complete do |response|
|
10
|
-
case response[:status].to_i
|
11
|
-
when 400
|
12
|
-
raise Gbif::BadRequest, error_message_400(response)
|
13
|
-
when 404
|
14
|
-
raise Gbif::NotFound, error_message_400(response)
|
15
|
-
when 500
|
16
|
-
raise Gbif::InternalServerError, error_message_500(response, "Something is technically wrong.")
|
17
|
-
when 502
|
18
|
-
raise Gbif::BadGateway, error_message_500(response, "The server returned an invalid or incomplete response.")
|
19
|
-
when 503
|
20
|
-
raise Gbif::ServiceUnavailable, error_message_500(response, "Crossref is rate limiting your requests.")
|
21
|
-
when 504
|
22
|
-
raise Gbif::GatewayTimeout, error_message_500(response, "504 Gateway Time-out")
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
def initialize(app)
|
28
|
-
super app
|
29
|
-
@parser = nil
|
30
|
-
end
|
31
|
-
|
32
|
-
private
|
33
|
-
|
34
|
-
def error_message_400(response)
|
35
|
-
"\n #{response[:method].to_s.upcase} #{response[:url].to_s}\n Status #{response[:status]}#{error_body(response[:body])}"
|
36
|
-
end
|
37
|
-
|
38
|
-
def error_body(body)
|
39
|
-
if not body.nil? and not body.empty? and body.kind_of?(String)
|
40
|
-
if is_json?(body)
|
41
|
-
body = ::MultiJson.load(body)
|
42
|
-
if body['message'].nil?
|
43
|
-
body = nil
|
44
|
-
elseif body['message'].length == 1
|
45
|
-
body = body['message']
|
46
|
-
else
|
47
|
-
body = body['message'].collect { |x| x['message'] }.join('; ')
|
48
|
-
end
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
|
-
if body.nil?
|
53
|
-
nil
|
54
|
-
else
|
55
|
-
": #{body}"
|
56
|
-
end
|
57
|
-
end
|
58
|
-
|
59
|
-
def error_message_500(response, body=nil)
|
60
|
-
"#{response[:method].to_s.upcase} #{response[:url].to_s}: #{[response[:status].to_s + ':', body].compact.join(' ')}"
|
61
|
-
end
|
62
|
-
|
63
|
-
def is_json?(string)
|
64
|
-
MultiJson.load(string)
|
65
|
-
return true
|
66
|
-
rescue MultiJson::ParseError
|
67
|
-
return false
|
68
|
-
end
|
69
|
-
|
70
|
-
end
|
71
|
-
end
|