taxa 0.1.1 → 0.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: 9326adca4c92b4369f90c78c0407bd7d2b03d01ed090dfa7de9316f433b9c075
4
- data.tar.gz: 7d9e7ae022d84889381b95bd8176287789cef60144100d8e507f224483919675
3
+ metadata.gz: f193e48919a8c656ca30f3d15684f312d2366f429cf9aa2fefc6898799209cdc
4
+ data.tar.gz: c18067f427688d65538158f3649bfad96e180f211b7d85d84370db14827bc43c
5
5
  SHA512:
6
- metadata.gz: f4245d41126fbb024c57eddcb53696b4e143725980c0aa08de6b3d8068ef2bd8d393e6835c5494055c40a652c21001a419af145cabc2a2f9b36601988aa098ac
7
- data.tar.gz: 7276d724cfb346763a9c5a2db940fa75cd1e49a221c506f8bda2f1560f2ba3a34390e047000fd564978a01f44a1ac8a6e3ed3a05544d9aebb2a8e76a352e6bdc
6
+ metadata.gz: 9d4617f0daab6dcbeed3f06491f9430c1da29b9ceb3aae4cd31f0e80880d77aa8e7e899811d08baaf15f87f14fd63aa9d5daa14a63dbdd76ba190a8bc58aa414
7
+ data.tar.gz: bfb6575de0de6958a86c46d0096de0fb3149c08387ea5836e68b86f94c3556ab50fada6acd91aae5c0631814985a3a6c26a23f83d10ef4892274cbf8217dd98c
@@ -1 +1,13 @@
1
- nothing yet
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
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- taxa (0.1.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.1.0)
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 is implemented.
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
- client = Taxa::OpenTreeOfLife::Client.new
26
+ eol_client = Taxa::EOLClassic::Client.new
27
+ eol_client.hierarchy_entries(7834469)
28
+ ```
24
29
 
25
30
  ## Development
26
31
 
@@ -1,7 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'taxa/version'
4
+ require 'faraday'
4
5
  require_relative './taxa/open_tree_of_life/client'
6
+ require_relative './taxa/eol_classic/client'
5
7
 
6
8
  module Taxa
7
9
  # include OpenTreeOfLife
@@ -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
@@ -4,7 +4,6 @@ require_relative './tnrs/base'
4
4
  require_relative './tree_of_life/base'
5
5
  require_relative './taxonomy/base'
6
6
  require_relative './studies/base'
7
- require 'faraday'
8
7
 
9
8
  module Taxa
10
9
  module OpenTreeOfLife
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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) }), 'Content-Type' => 'application/json')
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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Taxa
4
- VERSION = '0.1.1'
4
+ VERSION = '0.2.0'
5
5
  end
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.1.1
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: 2020-12-28 00:00:00.000000000 Z
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