taxa 0.1.1 → 0.2.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/CHANGELOG.md +13 -1
- data/Gemfile.lock +4 -2
- data/README.md +7 -2
- data/lib/taxa.rb +2 -0
- data/lib/taxa/eol_classic/client.rb +65 -0
- data/lib/taxa/open_tree_of_life/client.rb +0 -1
- data/lib/taxa/open_tree_of_life/studies/find_studies.rb +0 -1
- data/lib/taxa/open_tree_of_life/studies/find_trees.rb +0 -1
- data/lib/taxa/open_tree_of_life/studies/properties.rb +0 -1
- data/lib/taxa/open_tree_of_life/studies/study.rb +0 -1
- data/lib/taxa/open_tree_of_life/studies/tree.rb +0 -1
- data/lib/taxa/open_tree_of_life/taxonomy/about.rb +0 -1
- data/lib/taxa/open_tree_of_life/taxonomy/mrca.rb +2 -2
- data/lib/taxa/open_tree_of_life/taxonomy/subtree.rb +0 -1
- data/lib/taxa/open_tree_of_life/taxonomy/taxon_info.rb +0 -1
- data/lib/taxa/open_tree_of_life/tnrs/autocomplete_name.rb +0 -1
- data/lib/taxa/open_tree_of_life/tnrs/contexts.rb +0 -1
- data/lib/taxa/open_tree_of_life/tnrs/infer_context.rb +0 -1
- data/lib/taxa/open_tree_of_life/tnrs/match_names.rb +0 -1
- data/lib/taxa/open_tree_of_life/tree_of_life/about.rb +0 -1
- data/lib/taxa/open_tree_of_life/tree_of_life/induced_subtree.rb +0 -1
- data/lib/taxa/open_tree_of_life/tree_of_life/mrca.rb +0 -1
- data/lib/taxa/open_tree_of_life/tree_of_life/node_info.rb +0 -1
- data/lib/taxa/open_tree_of_life/tree_of_life/subtree.rb +0 -1
- data/lib/taxa/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f193e48919a8c656ca30f3d15684f312d2366f429cf9aa2fefc6898799209cdc
|
4
|
+
data.tar.gz: c18067f427688d65538158f3649bfad96e180f211b7d85d84370db14827bc43c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9d4617f0daab6dcbeed3f06491f9430c1da29b9ceb3aae4cd31f0e80880d77aa8e7e899811d08baaf15f87f14fd63aa9d5daa14a63dbdd76ba190a8bc58aa414
|
7
|
+
data.tar.gz: bfb6575de0de6958a86c46d0096de0fb3149c08387ea5836e68b86f94c3556ab50fada6acd91aae5c0631814985a3a6c26a23f83d10ef4892274cbf8217dd98c
|
data/CHANGELOG.md
CHANGED
@@ -1 +1,13 @@
|
|
1
|
-
|
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
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
taxa (0.
|
4
|
+
taxa (0.2.0)
|
5
5
|
faraday (~> 1.1)
|
6
6
|
json (~> 1.8)
|
7
7
|
|
@@ -9,9 +9,11 @@ GEM
|
|
9
9
|
remote: https://rubygems.org/
|
10
10
|
specs:
|
11
11
|
ast (2.4.1)
|
12
|
-
faraday (1.
|
12
|
+
faraday (1.3.0)
|
13
|
+
faraday-net_http (~> 1.0)
|
13
14
|
multipart-post (>= 1.2, < 3)
|
14
15
|
ruby2_keywords
|
16
|
+
faraday-net_http (1.0.0)
|
15
17
|
json (1.8.6)
|
16
18
|
minitest (5.14.2)
|
17
19
|
multipart-post (2.1.1)
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# Taxa
|
2
2
|
|
3
|
-
Taxa allows users to search multiple taxonomic data sources. Currently only Open Tree of Life
|
3
|
+
Taxa allows users to search multiple taxonomic data sources. Currently only Open Tree of Life and EOL classic APIs are implemented.
|
4
4
|
|
5
5
|
## Installation
|
6
6
|
|
@@ -19,8 +19,13 @@ Or install it yourself as:
|
|
19
19
|
$ gem install taxa
|
20
20
|
|
21
21
|
## Usage
|
22
|
+
```ruby
|
23
|
+
tol_client = Taxa::OpenTreeOfLife::Client.new
|
24
|
+
tol_client.tnrs.match_names('Cotyledon') # can be an array or a string
|
22
25
|
|
23
|
-
|
26
|
+
eol_client = Taxa::EOLClassic::Client.new
|
27
|
+
eol_client.hierarchy_entries(7834469)
|
28
|
+
```
|
24
29
|
|
25
30
|
## Development
|
26
31
|
|
data/lib/taxa.rb
CHANGED
@@ -0,0 +1,65 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Taxa
|
4
|
+
module EOLClassic
|
5
|
+
# API client for Open Tree of Life
|
6
|
+
class Client
|
7
|
+
attr_accessor :options
|
8
|
+
attr_reader :http_client
|
9
|
+
|
10
|
+
def initialize(**options)
|
11
|
+
@options = options
|
12
|
+
|
13
|
+
@http_client = options[:http_client] || Faraday.new
|
14
|
+
end
|
15
|
+
|
16
|
+
def search(query, **parameters)
|
17
|
+
raise ArgumentError, 'query can not be nil' if query.nil?
|
18
|
+
|
19
|
+
url = 'https://eol.org/api/search/1.0.json'
|
20
|
+
response = @http_client.get(url, { q: query }.merge(parameters), { 'Accept' => 'application/json' })
|
21
|
+
parse_response(response)
|
22
|
+
end
|
23
|
+
|
24
|
+
def collections(id, **parameters)
|
25
|
+
raise ArgumentError, 'id can not be nil' if id.nil?
|
26
|
+
|
27
|
+
url = "https://eol.org/api/collections/1.0/#{id}.json"
|
28
|
+
response = @http_client.get(url, parameters, { 'Accept' => 'application/json' })
|
29
|
+
parse_response(response)
|
30
|
+
end
|
31
|
+
|
32
|
+
def pages(id, **parameters)
|
33
|
+
raise ArgumentError, 'id can not be nil' if id.nil?
|
34
|
+
|
35
|
+
url = "https://eol.org/api/pages/1.0/#{id}.json"
|
36
|
+
response = @http_client.get(url, parameters, { 'Accept' => 'application/json' })
|
37
|
+
parse_response(response)
|
38
|
+
end
|
39
|
+
|
40
|
+
def data_objects(id, **parameters)
|
41
|
+
raise ArgumentError, 'id can not be nil' if id.nil?
|
42
|
+
|
43
|
+
url = "https://eol.org/api/data_objects/1.0/#{id}.json"
|
44
|
+
response = @http_client.get(url, parameters, { 'Accept' => 'application/json' })
|
45
|
+
parse_response(response)
|
46
|
+
end
|
47
|
+
|
48
|
+
def hierarchy_entries(id, **parameters)
|
49
|
+
raise ArgumentError, 'id can not be nil' if id.nil?
|
50
|
+
|
51
|
+
url = "https://eol.org/api/hierarchy_entries/1.0/#{id}.json"
|
52
|
+
response = @http_client.get(url, parameters, { 'Accept' => 'application/json' })
|
53
|
+
parse_response(response)
|
54
|
+
end
|
55
|
+
|
56
|
+
private
|
57
|
+
|
58
|
+
def parse_response(response)
|
59
|
+
JSON.parse(response.body)
|
60
|
+
rescue StandardError
|
61
|
+
nil
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
@@ -1,6 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require 'faraday'
|
4
3
|
require 'json'
|
5
4
|
|
6
5
|
module Taxa
|
@@ -12,7 +11,8 @@ module Taxa
|
|
12
11
|
raise ArgumentError, 'ott_ids required' if ott_ids.nil?
|
13
12
|
|
14
13
|
url = 'https://api.opentreeoflife.org/v3/taxonomy/mrca'
|
15
|
-
response = @http_client.post(url, JSON.generate({ ott_ids: Array(ott_ids) }),
|
14
|
+
response = @http_client.post(url, JSON.generate({ ott_ids: Array(ott_ids) }),
|
15
|
+
'Content-Type' => 'application/json')
|
16
16
|
JSON.parse(response.body)
|
17
17
|
end
|
18
18
|
end
|
data/lib/taxa/version.rb
CHANGED
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.2.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:
|
11
|
+
date: 2021-01-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rubocop
|
@@ -72,6 +72,7 @@ files:
|
|
72
72
|
- bin/console
|
73
73
|
- bin/setup
|
74
74
|
- lib/taxa.rb
|
75
|
+
- lib/taxa/eol_classic/client.rb
|
75
76
|
- lib/taxa/open_tree_of_life/client.rb
|
76
77
|
- lib/taxa/open_tree_of_life/label_format_helper.rb
|
77
78
|
- lib/taxa/open_tree_of_life/studies/base.rb
|