colrapi 0.1.2 → 0.1.3
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/.gitignore +2 -1
- data/CHANGELOG.md +4 -0
- data/LICENSE.txt +5 -16
- data/README.md +147 -4
- data/colrapi.gemspec +1 -1
- data/lib/colrapi/request.rb +3 -0
- data/lib/colrapi/version.rb +1 -1
- data/lib/colrapi.rb +8 -5
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8fdc3cd60c5c9678fa5f5feb8706a91ff121374f9a84966224b8824ff4a97397
|
4
|
+
data.tar.gz: b2a57d1fc5eaa08288359b44905358511d75a5dfa084368b9f77c8e70c488447
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6d0f6fc5211efc5da06e31c56188fd039d1ab8bef714a969d87db5398ea8ec1f5e9d49f0762019c51e11050ed85a80e4c18543d5310f29e5dcfe85161da8a9c6
|
7
|
+
data.tar.gz: 8101188650f8034ecc4ae36a51bdc57d132984f85a908ae35b906e5f79e00737c29b8b4d27f65e749e7e6f9586e47b11ce66e45e64523be619192e54fd2a41b1
|
data/.gitignore
CHANGED
data/CHANGELOG.md
CHANGED
data/LICENSE.txt
CHANGED
@@ -1,21 +1,10 @@
|
|
1
1
|
The MIT License (MIT)
|
2
2
|
|
3
|
-
Copyright
|
3
|
+
Copyright © 2024 Species File Group
|
4
4
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
7
|
-
in the Software without restriction, including without limitation the rights
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
10
|
-
furnished to do so, subject to the following conditions:
|
5
|
+
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:
|
11
6
|
|
12
|
-
The above copyright notice and this permission notice shall be included in
|
13
|
-
|
7
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
8
|
+
|
9
|
+
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
14
10
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
-
THE SOFTWARE.
|
data/README.md
CHANGED
@@ -18,11 +18,154 @@ Or install it yourself as:
|
|
18
18
|
|
19
19
|
$ gem install colrapi
|
20
20
|
|
21
|
-
## Usage
|
22
21
|
|
23
|
-
|
22
|
+
## Documentation
|
23
|
+
|
24
|
+
Most of the [ChecklistBank/Catalogue of Life API](https://api.checklistbank.org) is wrapped by the Colrapi gem, but not everything is documented yet. Looking through the [tests](https://github.com/SpeciesFileGroup/colrapi/tree/main/test) is a good way to see examples and learn how to use the Ruby gem. If you need something documented, please [open an issue](https://github.com/SpeciesFileGroup/colrapi/issues/new) ticket.
|
25
|
+
|
26
|
+
The Colrapi Ruby gem uses dataset_id to access information scoped within a dataset. There are [4 types of datasets](https://api.checklistbank.org/vocab/datasetorigin) in ChecklistBank: `external`, `project`, `release`, and `xrelease`. Most datasets are `external`, maintained outside of ChecklistBank and imported. A `project` is a draft version of a dataset assembled inside ChecklistBank from `external` datasets (e.g., [Catalogue of Life](https://www.checklistbank.org/dataset/3/about)). A `release` is a published dataset released from a `project` (e.g., [Catalogue of Life 2024 Annual Checklist](https://www.checklistbank.org/dataset/COL24/about)). An `xrelease` is a published dataset in which automated tools were used to extend a `release` dataset with additional information to fill in data gaps and have less editorial scrutiny. For example, this can mean that a very carefully scrutinized `external` dataset can be assembled into a project, published with some editorial decisions as a `release` and also extended to include missing names that a taxonomic expert might have deliberately excluded from their taxonomic database for various reasons in an `xrelease`. `xrelease` datasets aim to meet the use case of being able to attach occurrences and other data to a (nearly) complete list of scientific names. If you want the more expert scrutinized version of COL, then use a `release`. If you want to attach data to a complete list of scientific names and are less concerned about taxonomic scrutiny, then use an `xrelease`. (There may be no public COL `xrelease` datasets yet as the feature is currently under development.)
|
27
|
+
|
28
|
+
Catalogue of Life has dataset_id=3, but you should almost never use dataset_id=3 because it is a draft unreleased version of COL and can have errors while the releases are being produced. Instead use 3LR to get the COL latest release, or 3LXR to get the COL latest extended release. COL releases new editions each month and the monthly releases are eventually deleted. If you need stable data that will be persistently accessible, then use the dataset_id=COLYY, where YY is the Annual Checklist year (e.g. COL24 to get the 2024 Annual Checklist). COL aims to keep the annual checklists permanently accessible, but the best practice is to download a copy of the data and archive it permanently with any research papers that use COL. Download a copy here, replacing {dataset_id} with the dataset_id: https://www.checklistbank.org/dataset/{dataset_id}/download
|
29
|
+
|
30
|
+
### Dataset
|
31
|
+
|
32
|
+
Get a list of external datasets in ChecklistBank:
|
33
|
+
```ruby
|
34
|
+
Colrapi.dataset(origin: 'external')
|
35
|
+
```
|
36
|
+
|
37
|
+
#### [/dataset](http://api.checklistbank.org/#/default/search)
|
38
|
+
Get a list of projects in ChecklistBank:
|
39
|
+
```ruby
|
40
|
+
Colrapi.dataset(origin: 'project')
|
41
|
+
```
|
42
|
+
|
43
|
+
Get a list of releases in ChecklistBank released from Catalogue of Life:
|
44
|
+
```ruby
|
45
|
+
Colrapi.dataset(origin: 'release', released_from: 3)
|
46
|
+
```
|
47
|
+
|
48
|
+
Get a list of xreleases in ChecklistBank released from Catalogue of Life:
|
49
|
+
```ruby
|
50
|
+
Colrapi.dataset(origin: 'xrelease', released_from: 3)
|
51
|
+
```
|
52
|
+
|
53
|
+
Get a list of datasets that contribute to Catalogue of Life:
|
54
|
+
```ruby
|
55
|
+
Colrapi.dataset(contributes_to: 3)
|
56
|
+
```
|
57
|
+
|
58
|
+
Get a list of datasets under a specific [license](https://api.checklistbank.org/vocab/license):
|
59
|
+
```ruby
|
60
|
+
Colrapi.dataset(license: 'cc by')
|
61
|
+
```
|
62
|
+
|
63
|
+
### Names
|
64
|
+
|
65
|
+
|
66
|
+
|
67
|
+
|
68
|
+
### Metadata
|
69
|
+
|
70
|
+
Get metadata by dataset_id:
|
71
|
+
```ruby
|
72
|
+
Colrapi.dataset(dataset_id: 'COL24')
|
73
|
+
```
|
74
|
+
|
75
|
+
|
76
|
+
### Name usage search
|
77
|
+
|
78
|
+
There are a two ways to conduct name usage search in ChecklistBank/Catalogue of Life: 1) using Elasticsearch or 2) querying PostgreSQL directly. Elasticsearch offers more advanced search functionality and parameters while PostgreSQL might perform faster.
|
79
|
+
|
80
|
+
#### 1) Elasticsearch
|
81
|
+
##### [/nameusage/search](http://api.checklistbank.org/#/default/search_4) or [/dataset/{dataset_id}/nameusage/search](http://api.checklistbank.org/#/default/searchDataset)
|
82
|
+
|
83
|
+
Elasticsearch all of ChecklistBank:
|
84
|
+
```ruby
|
85
|
+
Colrapi.nameusage_search(q: 'Homo sapiens') # => MultiJson object
|
86
|
+
```
|
87
|
+
|
88
|
+
Elasticsearch the Catalogue of Life latest release:
|
89
|
+
```ruby
|
90
|
+
Colrapi.nameusage_search(dataset_id: '3LR', q: 'Homo sapiens') # => MultiJson object
|
91
|
+
```
|
92
|
+
|
93
|
+
Elasticsearch the Catalogue of Life 2024 Annual Checklist:
|
94
|
+
```ruby
|
95
|
+
Colrapi.nameusage_search(dataset_id: 'COL24', q: 'Homo sapiens') # => MultiJson object
|
96
|
+
```
|
97
|
+
|
98
|
+
Elasticsearch Orthoptera Species File:
|
99
|
+
```ruby
|
100
|
+
Colrapi.nameusage_search(dataset_id: 1021, q: 'Cyphoderris strepitans') # => MultiJson object
|
101
|
+
```
|
102
|
+
|
103
|
+
#### 2) PostgreSQL Search
|
104
|
+
##### [/dataset/{dataset_id}/nameusage](https://api.checklistbank.org/#/default/list_3)
|
105
|
+
Query PostgreSQL directly for *Homo sapiens* in the Catalogue of Life latest release:
|
106
|
+
```ruby
|
107
|
+
Colrapi.nameusage('3LR', q: 'Homo sapiens') # => MultiJson object
|
108
|
+
```
|
109
|
+
|
110
|
+
Query PostgreSQL directly for *Homo sapiens* in the Catalogue of Life 2024 Annual Checklist:
|
111
|
+
```ruby
|
112
|
+
Colrapi.nameusage('COL24', q: 'Homo sapiens') # => MultiJson object
|
113
|
+
```
|
114
|
+
|
115
|
+
Query PostgreSQL directly for *Cyphoderris strepitans* in Orthoptera Species File
|
116
|
+
```ruby
|
117
|
+
Colrapi.nameusage(1021, q: 'Cyphoderris strepitans') # => MultiJson object
|
118
|
+
```
|
119
|
+
|
120
|
+
## Taxon
|
121
|
+
Get a taxon from the Catalogue of Life latest release by taxon ID:
|
122
|
+
```ruby
|
123
|
+
Colrapi.taxon('3LR', taxon_id: 'BHC3') # => MultiJson object
|
124
|
+
```
|
125
|
+
|
126
|
+
Get the higher classification for a taxon from the Catalogue of Life latest release by taxon ID:
|
127
|
+
```ruby
|
128
|
+
Colrapi.taxon('3LR', taxon_id: 'BHC3', subresource: 'classification') # => MultiJson object
|
129
|
+
```
|
130
|
+
|
131
|
+
Get the distribution for a taxon from the Catalogue of Life latest release by taxon ID:
|
132
|
+
```ruby
|
133
|
+
Colrapi.taxon('3LR', taxon_id: 'BHC3', subresource: 'distribution') # => MultiJson object
|
134
|
+
```
|
135
|
+
|
136
|
+
Get additional info about a taxon from the Catalogue of Life latest release by taxon ID:
|
137
|
+
```ruby
|
138
|
+
Colrapi.taxon('3LR', taxon_id: 'BHC3', subresource: 'info') # => MultiJson object
|
139
|
+
```
|
140
|
+
|
141
|
+
Get species interactions for a taxon from 3i World Auchenorrhyncha Database by taxon ID:
|
142
|
+
```ruby
|
143
|
+
Colrapi.taxon(2317, taxon_id: 28472, subresource: 'interaction') # => MultiJson object
|
144
|
+
```
|
145
|
+
|
146
|
+
Get media for a taxon from WoRMS World Porifera Database by taxon ID:
|
147
|
+
```ruby
|
148
|
+
Colrapi.taxon(1044, taxon_id: 'urn:lsid:marinespecies.org:taxname:166055', subresource: 'media') # => MultiJson object
|
149
|
+
```
|
150
|
+
|
151
|
+
Get a source information from the Catalogue of Life latest release by taxon ID:
|
152
|
+
```ruby
|
153
|
+
Colrapi.taxon('3LR', taxon_id: 'BHC3', subresource: 'source') # => MultiJson object
|
154
|
+
```
|
155
|
+
|
156
|
+
Get synonyms from the Catalogue of Life latest release by taxon ID:
|
157
|
+
```ruby
|
158
|
+
Colrapi.taxon('3LR', taxon_id: 'BHC3', subresource: 'synonyms') # => MultiJson object
|
159
|
+
```
|
160
|
+
|
161
|
+
Get a taxonomic treatment from a Plazi dataset by taxon ID:
|
162
|
+
```ruby
|
163
|
+
Colrapi.taxon('49590', taxon_id: '03D087F29465E83AFCF39B19FA20FC96.taxon', subresource: 'treatment') # => MultiJson object
|
164
|
+
```
|
165
|
+
|
166
|
+
Get vernacular names from the Catalogue of Life latest release by taxon ID:
|
24
167
|
```ruby
|
25
|
-
|
168
|
+
Colrapi.taxon('3LR', taxon_id: 'BHC3', subresource: 'vernacular') # => MultiJson object
|
26
169
|
```
|
27
170
|
|
28
171
|
## Development
|
@@ -37,7 +180,7 @@ Bug reports and pull requests are welcome on GitHub at https://github.com/mjy/co
|
|
37
180
|
|
38
181
|
## License
|
39
182
|
|
40
|
-
The gem is available as open source under the terms of the [
|
183
|
+
The gem is available as open source under the terms of the [MIT](https://opensource.org/licenses/MIT) license.
|
41
184
|
|
42
185
|
## Code of Conduct
|
43
186
|
|
data/colrapi.gemspec
CHANGED
@@ -11,7 +11,7 @@ Gem::Specification.new do |s|
|
|
11
11
|
s.summary = "Catalog of Life Client"
|
12
12
|
s.description = "colrapi (a play on Kholrabi) is a low-level wrapper around the Catalog of Life API."
|
13
13
|
s.homepage = "https://github.com/SpeciesFileGroup/colrapi"
|
14
|
-
s.license = "
|
14
|
+
s.license = "MIT"
|
15
15
|
s.required_ruby_version = ">= 2.5.0"
|
16
16
|
|
17
17
|
# s.metadata["allowed_push_host"] = "TODO: Set to 'https://mygemserver.com'"
|
data/lib/colrapi/request.rb
CHANGED
@@ -29,6 +29,8 @@ module Colrapi
|
|
29
29
|
@facet = Array(args[:facet]) if args[:facet]
|
30
30
|
@min_rank = args[:min_rank]
|
31
31
|
@max_rank = args[:max_rank]
|
32
|
+
@environment = args[:environment]
|
33
|
+
@highest_taxon_id = args[:highest_taxon_id]
|
32
34
|
@parent_rank = args[:parent_rank]
|
33
35
|
@root_id = Array(args[:root_id]) if args[:root_id]
|
34
36
|
@root2_id = Array(args[:root2_id]) if args[:root2_id]
|
@@ -130,6 +132,7 @@ module Colrapi
|
|
130
132
|
subgenus: @within_subgenus, section: @within_section, species: @within_species,
|
131
133
|
nidx: @nidx_id, state: @state, running: @running, notCurrentOnly: @not_current_only,
|
132
134
|
broken: @broken, subjectDatasetKey: @subject_dataset_id, mode: @mode, subject: @subject,
|
135
|
+
TAXON_ID: @highest_taxon_id, environment: @environment,
|
133
136
|
sortBy: @sort_by, reverse: @reverse, url: @url, offset: @offset, limit: @limit}
|
134
137
|
opts = args.delete_if { |_k, v| v.nil? }
|
135
138
|
|
data/lib/colrapi/version.rb
CHANGED
data/lib/colrapi.rb
CHANGED
@@ -437,7 +437,7 @@ module Colrapi
|
|
437
437
|
end
|
438
438
|
|
439
439
|
# Get name usages or a nameusage from a dataset
|
440
|
-
# Note: Queries the
|
440
|
+
# Note: Queries the PostgreSQL database, whereas nameusage_search uses Elasticsearch
|
441
441
|
#
|
442
442
|
# @param dataset_id [String] The dataset id
|
443
443
|
# @param nameusage_id [String] The nameusage id
|
@@ -551,6 +551,8 @@ module Colrapi
|
|
551
551
|
# @param min_rank [String, nil] minimum taxonomic rank of name usages
|
552
552
|
# @param max_rank [String, nil] maximum taxonomic rank of name usages
|
553
553
|
# @param facet [Array, String, nil] the search facet
|
554
|
+
# @param environment [Array, String, nil] filter by environment (MARINE, TERRESTRIAL, FRESHWATER, BRACKISH)
|
555
|
+
# @param highest_taxon_id [String, nil] Filter by highest taxon ID
|
554
556
|
#
|
555
557
|
# @param sort_by [String, nil] sort results by NAME, TAXONOMIC, INDEX_NAME_ID, NATIVE, or RELEVANCE
|
556
558
|
# @param reverse [Boolean] sort in reverse order
|
@@ -560,8 +562,8 @@ module Colrapi
|
|
560
562
|
#
|
561
563
|
# @return [Array, Boolean] An array of hashes
|
562
564
|
def self.nameusage_search(q: nil, dataset_id: nil, endpoint: 'nameusage/search', content: nil, issue: nil,
|
563
|
-
type: nil, rank: nil, min_rank: nil, max_rank: nil, facet: nil,
|
564
|
-
sort_by: nil, reverse: nil, offset: nil, limit: nil,
|
565
|
+
type: nil, rank: nil, min_rank: nil, max_rank: nil, environment: nil, facet: nil,
|
566
|
+
highest_taxon_id: nil, sort_by: nil, reverse: nil, offset: nil, limit: nil,
|
565
567
|
verbose: false)
|
566
568
|
|
567
569
|
# a nil dataset_id will search name usages from all datasets in ChecklistBank
|
@@ -570,8 +572,9 @@ module Colrapi
|
|
570
572
|
end
|
571
573
|
|
572
574
|
Request.new(endpoint: endpoint, q: q, content: content, issue: issue, type: type,
|
573
|
-
rank: rank, min_rank: min_rank, max_rank: max_rank, facet: facet,
|
574
|
-
sort_by: sort_by, reverse: reverse,
|
575
|
+
rank: rank, min_rank: min_rank, max_rank: max_rank, facet: facet, environment: environment,
|
576
|
+
highest_taxon_id: highest_taxon_id, sort_by: sort_by, reverse: reverse,
|
577
|
+
offset: offset, limit: limit, verbose: verbose).perform
|
575
578
|
end
|
576
579
|
|
577
580
|
# Get a name usage suggestion
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: colrapi
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matt Yoder, Geoff Ower
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2025-03-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -194,11 +194,11 @@ files:
|
|
194
194
|
- lib/colrapi/version.rb
|
195
195
|
homepage: https://github.com/SpeciesFileGroup/colrapi
|
196
196
|
licenses:
|
197
|
-
-
|
197
|
+
- MIT
|
198
198
|
metadata:
|
199
199
|
homepage_uri: https://github.com/SpeciesFileGroup/colrapi
|
200
200
|
source_code_uri: https://github.com/SpeciesFileGroup/colrapi
|
201
|
-
changelog_uri: https://github.com/SpeciesFileGroup/colrapi/releases/tag/v0.1.
|
201
|
+
changelog_uri: https://github.com/SpeciesFileGroup/colrapi/releases/tag/v0.1.3
|
202
202
|
post_install_message:
|
203
203
|
rdoc_options: []
|
204
204
|
require_paths:
|
@@ -214,7 +214,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
214
214
|
- !ruby/object:Gem::Version
|
215
215
|
version: '0'
|
216
216
|
requirements: []
|
217
|
-
rubygems_version: 3.5.
|
217
|
+
rubygems_version: 3.5.22
|
218
218
|
signing_key:
|
219
219
|
specification_version: 4
|
220
220
|
summary: Catalog of Life Client
|