taxa 0.2.1 → 0.3.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/.gitignore +0 -0
- data/.rubocop.yml +0 -0
- data/.ruby-version +1 -0
- data/.travis.yml +0 -0
- data/CHANGELOG.md +24 -18
- data/CODE_OF_CONDUCT.md +0 -0
- data/Gemfile +0 -0
- data/Gemfile.lock +4 -4
- data/LICENSE.txt +0 -0
- data/README.md +8 -0
- data/Rakefile +0 -0
- data/lib/taxa.rb +1 -0
- data/lib/taxa/eol_classic/client.rb +0 -0
- data/lib/taxa/open_tree_of_life/client.rb +0 -0
- data/lib/taxa/open_tree_of_life/label_format_helper.rb +0 -0
- data/lib/taxa/open_tree_of_life/studies/base.rb +0 -0
- data/lib/taxa/open_tree_of_life/studies/find_studies.rb +0 -0
- data/lib/taxa/open_tree_of_life/studies/find_trees.rb +0 -0
- data/lib/taxa/open_tree_of_life/studies/properties.rb +0 -0
- data/lib/taxa/open_tree_of_life/studies/study.rb +0 -0
- data/lib/taxa/open_tree_of_life/studies/tree.rb +0 -0
- data/lib/taxa/open_tree_of_life/taxonomy/about.rb +0 -0
- data/lib/taxa/open_tree_of_life/taxonomy/base.rb +0 -0
- data/lib/taxa/open_tree_of_life/taxonomy/mrca.rb +0 -0
- data/lib/taxa/open_tree_of_life/taxonomy/subtree.rb +0 -0
- data/lib/taxa/open_tree_of_life/taxonomy/taxon_info.rb +0 -0
- data/lib/taxa/open_tree_of_life/tnrs/autocomplete_name.rb +0 -0
- data/lib/taxa/open_tree_of_life/tnrs/base.rb +0 -0
- data/lib/taxa/open_tree_of_life/tnrs/contexts.rb +0 -0
- data/lib/taxa/open_tree_of_life/tnrs/infer_context.rb +0 -0
- data/lib/taxa/open_tree_of_life/tnrs/match_names.rb +0 -0
- data/lib/taxa/open_tree_of_life/tree_of_life/about.rb +0 -0
- data/lib/taxa/open_tree_of_life/tree_of_life/base.rb +0 -0
- data/lib/taxa/open_tree_of_life/tree_of_life/induced_subtree.rb +0 -0
- data/lib/taxa/open_tree_of_life/tree_of_life/mrca.rb +0 -0
- data/lib/taxa/open_tree_of_life/tree_of_life/node_info.rb +0 -0
- data/lib/taxa/open_tree_of_life/tree_of_life/subtree.rb +0 -0
- data/lib/taxa/plants_of_the_world_online/client.rb +63 -0
- data/lib/taxa/utils.rb +14 -0
- data/lib/taxa/version.rb +1 -1
- data/taxa.gemspec +0 -0
- metadata +5 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 2f22b781a534e5778cfe117a963ec4984f17eda86c757a05a21d012088644996
|
|
4
|
+
data.tar.gz: cd39b3a350ad83c26a7d1e60fece8964b7bb68fb82907305f8aec8d6c1e434d3
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: '09e294e750b886dc5a5248c66cc5c13d5ca284dfadea44fe8cdbfd3218b3f835907fe2158f1669b12741ae186f55a7b362e0c350b2735656b1582a89c99f6fe7'
|
|
7
|
+
data.tar.gz: 7239b7a6efcc5d822bb78ea6ab1cd3bfecabf1373036fbf53b1fce8e267d26a7e946fd104a53ea36bb04d4e010dfcdd89cc6f75d307579163f58d587beaa9b66
|
data/.gitignore
CHANGED
|
File without changes
|
data/.rubocop.yml
CHANGED
|
File without changes
|
data/.ruby-version
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
2.7.2
|
data/.travis.yml
CHANGED
|
File without changes
|
data/CHANGELOG.md
CHANGED
|
@@ -1,18 +1,24 @@
|
|
|
1
|
-
# Taxa Changelog
|
|
2
|
-
|
|
3
|
-
## [0.1.0]
|
|
4
|
-
|
|
5
|
-
### Highlights
|
|
6
|
-
Support for Open Tree of Life API v3
|
|
7
|
-
https://github.com/OpenTreeOfLife/germinator/wiki/Open-Tree-of-Life-Web-APIs
|
|
8
|
-
|
|
9
|
-
## [0.2.0]
|
|
10
|
-
|
|
11
|
-
### Highlights
|
|
12
|
-
Support for the classic API for EOL
|
|
13
|
-
https://eol.org/docs/what-is-eol/classic-apis
|
|
14
|
-
|
|
15
|
-
## [0.2.1]
|
|
16
|
-
|
|
17
|
-
### Highlights
|
|
18
|
-
Update JSON gem to 2.5.x
|
|
1
|
+
# Taxa Changelog
|
|
2
|
+
|
|
3
|
+
## [0.1.0]
|
|
4
|
+
|
|
5
|
+
### Highlights
|
|
6
|
+
Support for Open Tree of Life API v3
|
|
7
|
+
https://github.com/OpenTreeOfLife/germinator/wiki/Open-Tree-of-Life-Web-APIs
|
|
8
|
+
|
|
9
|
+
## [0.2.0]
|
|
10
|
+
|
|
11
|
+
### Highlights
|
|
12
|
+
Support for the classic API for EOL
|
|
13
|
+
https://eol.org/docs/what-is-eol/classic-apis
|
|
14
|
+
|
|
15
|
+
## [0.2.1]
|
|
16
|
+
|
|
17
|
+
### Highlights
|
|
18
|
+
Update JSON gem to 2.5.x
|
|
19
|
+
|
|
20
|
+
## [0.3.0]
|
|
21
|
+
|
|
22
|
+
### Highlights
|
|
23
|
+
Support for Plants of the World Online
|
|
24
|
+
http://plantsoftheworldonline.org/
|
data/CODE_OF_CONDUCT.md
CHANGED
|
File without changes
|
data/Gemfile
CHANGED
|
File without changes
|
data/Gemfile.lock
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
taxa (0.2.
|
|
4
|
+
taxa (0.2.1)
|
|
5
5
|
faraday (~> 1.1)
|
|
6
6
|
json (~> 2.5)
|
|
7
7
|
|
|
@@ -13,7 +13,7 @@ GEM
|
|
|
13
13
|
faraday-net_http (~> 1.0)
|
|
14
14
|
multipart-post (>= 1.2, < 3)
|
|
15
15
|
ruby2_keywords
|
|
16
|
-
faraday-net_http (1.0.
|
|
16
|
+
faraday-net_http (1.0.1)
|
|
17
17
|
json (2.5.1)
|
|
18
18
|
minitest (5.14.2)
|
|
19
19
|
multipart-post (2.1.1)
|
|
@@ -36,7 +36,7 @@ GEM
|
|
|
36
36
|
rubocop-ast (1.3.0)
|
|
37
37
|
parser (>= 2.7.1.5)
|
|
38
38
|
ruby-progressbar (1.10.1)
|
|
39
|
-
ruby2_keywords (0.0.
|
|
39
|
+
ruby2_keywords (0.0.4)
|
|
40
40
|
unicode-display_width (1.7.0)
|
|
41
41
|
|
|
42
42
|
PLATFORMS
|
|
@@ -49,4 +49,4 @@ DEPENDENCIES
|
|
|
49
49
|
taxa!
|
|
50
50
|
|
|
51
51
|
BUNDLED WITH
|
|
52
|
-
2.
|
|
52
|
+
2.2.3
|
data/LICENSE.txt
CHANGED
|
File without changes
|
data/README.md
CHANGED
|
@@ -25,8 +25,16 @@ tol_client.tnrs.match_names('Cotyledon') # can be an array or a string
|
|
|
25
25
|
|
|
26
26
|
eol_client = Taxa::EOLClassic::Client.new
|
|
27
27
|
eol_client.hierarchy_entries(7834469)
|
|
28
|
+
|
|
29
|
+
powo_client = Taxa::PlantsOfTheWorldOnline::Client.new
|
|
30
|
+
powo_client.search('Crassula alata')
|
|
31
|
+
powo_client.search('Crassula', ['species_f', 'has_images'])
|
|
32
|
+
powo_client.search('family:Crassulaceae', ['species_f', 'has_images'])
|
|
28
33
|
```
|
|
29
34
|
|
|
35
|
+
For Plants of the World Online please see their official python library for available search terms:
|
|
36
|
+
https://github.com/RBGKew/pykew#available-search-terms-1
|
|
37
|
+
|
|
30
38
|
## Development
|
|
31
39
|
|
|
32
40
|
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.
|
data/Rakefile
CHANGED
|
File without changes
|
data/lib/taxa.rb
CHANGED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative '../utils'
|
|
4
|
+
module Taxa
|
|
5
|
+
module PlantsOfTheWorldOnline
|
|
6
|
+
# API client for Open Tree of Life
|
|
7
|
+
class Client
|
|
8
|
+
attr_accessor :options
|
|
9
|
+
attr_reader :http_client
|
|
10
|
+
|
|
11
|
+
POWO_URL = 'http://www.plantsoftheworldonline.org/api/2'
|
|
12
|
+
|
|
13
|
+
FILTERS = %w[accepted_names has_images families_f genus_f species__f infraspecific_f].freeze
|
|
14
|
+
|
|
15
|
+
def initialize(**options)
|
|
16
|
+
@options = options
|
|
17
|
+
@http_client = options[:http_client] || Faraday.new
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def search(query, options = {})
|
|
21
|
+
options.transform_keys!(&:to_sym)
|
|
22
|
+
|
|
23
|
+
page = options[:page] || 0
|
|
24
|
+
filters = Array.wrap(options[:filters])
|
|
25
|
+
validate_search_parameters(query, page, filters)
|
|
26
|
+
|
|
27
|
+
payload = { q: query, p: page }
|
|
28
|
+
payload.merge!({ f: filters.join(',') }) unless filters.empty?
|
|
29
|
+
response = @http_client.get("#{POWO_URL}/search", payload, { 'Accept' => 'application/json' })
|
|
30
|
+
parse_response(response)
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def lookup(id, include = nil)
|
|
34
|
+
raise ArgumentError, 'id can not be nil' if id.nil?
|
|
35
|
+
|
|
36
|
+
include = Array.wrap(include)
|
|
37
|
+
payload = {}
|
|
38
|
+
payload.merge!({ fields: include.join(',') }) unless include.empty?
|
|
39
|
+
response = @http_client.get("#{POWO_URL}/taxon/#{id}", payload, { 'Accept' => 'application/json' })
|
|
40
|
+
parse_response(response)
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
private
|
|
44
|
+
|
|
45
|
+
def validate_search_parameters(query, page, filters)
|
|
46
|
+
raise ArgumentError, 'query can not be nil' if query.nil?
|
|
47
|
+
|
|
48
|
+
if !filters.empty? && (filters & FILTERS).empty?
|
|
49
|
+
raise ArgumentError,
|
|
50
|
+
"filter is invalid. It must be one of these: #{FILTERS.join(', ')} can not be nil"
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
raise ArgumentError, 'page must be an integer' unless page.is_a?(Integer)
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
def parse_response(response)
|
|
57
|
+
JSON.parse(response.body)
|
|
58
|
+
rescue StandardError
|
|
59
|
+
nil
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
end
|
|
63
|
+
end
|
data/lib/taxa/utils.rb
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# https://stackoverflow.com/questions/18358717/ruby-elegantly-convert-variable-to-an-array-if-not-an-array-already
|
|
4
|
+
class Array
|
|
5
|
+
def self.wrap(object)
|
|
6
|
+
if object.nil?
|
|
7
|
+
[]
|
|
8
|
+
elsif object.respond_to?(:to_ary)
|
|
9
|
+
object.to_ary || [object]
|
|
10
|
+
else
|
|
11
|
+
[object]
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
end
|
data/lib/taxa/version.rb
CHANGED
data/taxa.gemspec
CHANGED
|
File without changes
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: taxa
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.3.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Shane Sherman
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2021-
|
|
11
|
+
date: 2021-03-13 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: rubocop
|
|
@@ -61,6 +61,7 @@ extra_rdoc_files: []
|
|
|
61
61
|
files:
|
|
62
62
|
- ".gitignore"
|
|
63
63
|
- ".rubocop.yml"
|
|
64
|
+
- ".ruby-version"
|
|
64
65
|
- ".travis.yml"
|
|
65
66
|
- CHANGELOG.md
|
|
66
67
|
- CODE_OF_CONDUCT.md
|
|
@@ -97,6 +98,8 @@ files:
|
|
|
97
98
|
- lib/taxa/open_tree_of_life/tree_of_life/mrca.rb
|
|
98
99
|
- lib/taxa/open_tree_of_life/tree_of_life/node_info.rb
|
|
99
100
|
- lib/taxa/open_tree_of_life/tree_of_life/subtree.rb
|
|
101
|
+
- lib/taxa/plants_of_the_world_online/client.rb
|
|
102
|
+
- lib/taxa/utils.rb
|
|
100
103
|
- lib/taxa/version.rb
|
|
101
104
|
- taxa.gemspec
|
|
102
105
|
homepage: https://github.com/ssherman/taxa
|