checkerberry 0.0.1

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 98225b806a036ab5a83cf053343e021804316f67d0375e3fa738c130e5afc871
4
+ data.tar.gz: 62a2b05f35b909ced824113273a7deee3c6b67cf78dedc42226335d513ef6ffa
5
+ SHA512:
6
+ metadata.gz: dde5f9a1b8673f05aa907a9c003f3a6a3f312a1680fec2ac9d2bf24f1dadf3789c9312d9575cee281e92a0a8de987250207aaa8599c08186cb196ee927b88056
7
+ data.tar.gz: b8f19ff5866d50730ea1a0079ba0e815b2fa13545b8605bcb05a049d6ba3d159e954c35ec2ac830e5a29449c5649565910292bbbf027aca71e8ca8bcc1b35fe8
@@ -0,0 +1,16 @@
1
+ name: Ruby
2
+
3
+ on: [push,pull_request]
4
+
5
+ jobs:
6
+ build:
7
+ runs-on: ubuntu-latest
8
+ steps:
9
+ - uses: actions/checkout@v2
10
+ - name: Set up Ruby
11
+ uses: ruby/setup-ruby@v1
12
+ with:
13
+ ruby-version: 3.3.4
14
+ bundler-cache: true
15
+ - name: Run the default task
16
+ run: bundle exec rake
data/.gitignore ADDED
@@ -0,0 +1,13 @@
1
+ .byebug_history
2
+ .vscode
3
+ .idea
4
+ /.bundle/
5
+ /.yardoc
6
+ /_yardoc/
7
+ /coverage/
8
+ /doc/
9
+ /pkg/
10
+ /spec/reports/
11
+ /tmp/
12
+ *.gem
13
+ Gemfile.lock
data/CHANGELOG.md ADDED
@@ -0,0 +1,16 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ ## [0.0.1] - 2025-10-22
9
+
10
+ ### Added
11
+ - Initial release
12
+ - GNverifier API wrapper based on colrapi structure
13
+ - Verify scientific names endpoint
14
+ - Data sources listing endpoint
15
+ - Version information endpoint
16
+ - Basic test suite with VCR cassettes
@@ -0,0 +1,84 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation.
6
+
7
+ We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.
8
+
9
+ ## Our Standards
10
+
11
+ Examples of behavior that contributes to a positive environment for our community include:
12
+
13
+ * Demonstrating empathy and kindness toward other people
14
+ * Being respectful of differing opinions, viewpoints, and experiences
15
+ * Giving and gracefully accepting constructive feedback
16
+ * Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience
17
+ * Focusing on what is best not just for us as individuals, but for the overall community
18
+
19
+ Examples of unacceptable behavior include:
20
+
21
+ * The use of sexualized language or imagery, and sexual attention or
22
+ advances of any kind
23
+ * Trolling, insulting or derogatory comments, and personal or political attacks
24
+ * Public or private harassment
25
+ * Publishing others' private information, such as a physical or email
26
+ address, without their explicit permission
27
+ * Other conduct which could reasonably be considered inappropriate in a
28
+ professional setting
29
+
30
+ ## Enforcement Responsibilities
31
+
32
+ Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful.
33
+
34
+ Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate.
35
+
36
+ ## Scope
37
+
38
+ This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event.
39
+
40
+ ## Enforcement
41
+
42
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at diapriid@gmail.com. All complaints will be reviewed and investigated promptly and fairly.
43
+
44
+ All community leaders are obligated to respect the privacy and security of the reporter of any incident.
45
+
46
+ ## Enforcement Guidelines
47
+
48
+ Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct:
49
+
50
+ ### 1. Correction
51
+
52
+ **Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community.
53
+
54
+ **Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested.
55
+
56
+ ### 2. Warning
57
+
58
+ **Community Impact**: A violation through a single incident or series of actions.
59
+
60
+ **Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban.
61
+
62
+ ### 3. Temporary Ban
63
+
64
+ **Community Impact**: A serious violation of community standards, including sustained inappropriate behavior.
65
+
66
+ **Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban.
67
+
68
+ ### 4. Permanent Ban
69
+
70
+ **Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals.
71
+
72
+ **Consequence**: A permanent ban from any sort of public interaction within the community.
73
+
74
+ ## Attribution
75
+
76
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.0,
77
+ available at https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
78
+
79
+ Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/diversity).
80
+
81
+ [homepage]: https://www.contributor-covenant.org
82
+
83
+ For answers to common questions about this code of conduct, see the FAQ at
84
+ https://www.contributor-covenant.org/faq. Translations are available at https://www.contributor-covenant.org/translations.
data/Gemfile ADDED
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+
5
+ # Specify your gem's dependencies in checkerberry.gemspec
6
+ gemspec
7
+
8
+ gem "rake", "~> 13.0"
9
+
10
+ gem "minitest", "~> 5.0"
data/LICENSE ADDED
@@ -0,0 +1,10 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright © 2024 Species File Group
4
+
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:
6
+
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.
10
+
data/README.md ADDED
@@ -0,0 +1,102 @@
1
+ # Checkerberry
2
+
3
+ Checkerberry is a Ruby wrapper on the [GNverifier](https://verifier.globalnames.org) API. Code follows the spirit/approach of the Gem [serrano](https://github.com/sckott/serrano), and indeed much of the wrapping utility is copied 1:1 from that repo, thanks [@sckott](https://github.com/sckott).
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'checkerberry'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle install
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install checkerberry
20
+
21
+ ## Usage
22
+
23
+ ### Verify scientific names
24
+
25
+ Verify a single scientific name:
26
+ ```ruby
27
+ Checkerberry.verify('Homo sapiens')
28
+ ```
29
+
30
+ Verify multiple scientific names:
31
+ ```ruby
32
+ Checkerberry.verify(['Homo sapiens', 'Mus musculus'])
33
+ ```
34
+
35
+ Verify with additional options:
36
+ ```ruby
37
+ Checkerberry.verify('Homo sapiens', data_sources: [1, 11], with_stats: true)
38
+ ```
39
+
40
+ ### Search for scientific names
41
+
42
+ Search for a species:
43
+ ```ruby
44
+ Checkerberry.search(name_string: "Homo sapiens", genus: 'Homo', species: 'sapiens')
45
+ ```
46
+
47
+ Search for a species within a parent taxon:
48
+ ```ruby
49
+ Checkerberry.search(parent_taxon: "Plantae", genus: 'Agathis', species: 'montana')
50
+ Checkerberry.search(parent_taxon: "Animalia", genus: 'Agathis', species: 'montana')
51
+ ```
52
+
53
+ Search for a species verified by specific data sources:
54
+ ```ruby
55
+ Checkerberry.search(name_string: "Homo sapiens", genus: 'Homo', species: 'sapiens', data_sources: 1)
56
+ Checkerberry.search(name_string: "Homo sapiens", genus: 'Homo', species: 'sapiens', data_sources: [1, 3])
57
+ ```
58
+
59
+
60
+ ### Get data sources
61
+
62
+ Get list of all data sources:
63
+ ```ruby
64
+ Checkerberry.data_sources
65
+ ```
66
+
67
+ Get a specific data source by ID:
68
+ ```ruby
69
+ Checkerberry.data_source(1)
70
+ ```
71
+
72
+ ### Ping service
73
+ Check if the GNverifier service is up
74
+ ```ruby
75
+ Checkerberry.ping
76
+ pong
77
+ ```
78
+
79
+ ### Get version
80
+
81
+ Get the GNVerifier API version information:
82
+ ```ruby
83
+ Checkerberry.version
84
+ ```
85
+
86
+ ## Development
87
+
88
+ 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.
89
+
90
+ To install this gem onto your local machine, run bundle exec rake install. To release a new version, update the version number in version.rb, update the CHANGELOG.md, and then run bundle exec rake release, which will create a git tag for the version, push git commits and the created tag, and push the .gem file to rubygems.org.
91
+
92
+ ## Contributing
93
+
94
+ Bug reports and pull requests are welcome on GitHub at https://github.com/SpeciesFileGroup/checkerberry. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/SpeciesFileGroup/checkerberry/blob/main/CODE_OF_CONDUCT.md).
95
+
96
+ ## License
97
+
98
+ The gem is available as open source under the terms of the [MIT license](https://github.com/SpeciesFileGroup/checkerberry/blob/main/LICENSE.txt). You can learn more about the MIT license on [Wikipedia](https://en.wikipedia.org/wiki/MIT_License) and compare it with other open source licenses at the [Open Source Initiative](https://opensource.org/license/mit/).
99
+
100
+ ## Code of Conduct
101
+
102
+ Everyone interacting in the Checkerberry project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/SpeciesFileGroup/checkerberry/blob/main/CODE_OF_CONDUCT.md).
data/Rakefile ADDED
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ require "rake/testtask"
5
+
6
+ Rake::TestTask.new(:test) do |t|
7
+ t.libs << "test"
8
+ t.libs << "lib"
9
+ t.test_files = FileList["test/**/*_test.rb"]
10
+ t.verbose = true
11
+ end
12
+
13
+ desc "Run tests"
14
+ task default: :test
data/bin/console ADDED
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require "bundler/setup"
5
+ require "checkerberry"
6
+
7
+ # You can add fixtures and/or initialization code here to make experimenting
8
+ # with your gem easier. You can also use a different console, if you like.
9
+
10
+ # (If you use this, don't forget to add pry to your Gemfile!)
11
+ # require "pry"
12
+ # Pry.start
13
+
14
+ require "irb"
15
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,40 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "lib/checkerberry/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "checkerberry"
7
+ s.version = Checkerberry::VERSION
8
+ s.authors = ["Geoff Ower"]
9
+ s.email = ["gdower@illinois.edu"]
10
+
11
+ s.summary = "GNverifier API Client"
12
+ s.description = "checkerberry is a low-level wrapper around the GNverifier API for scientific name verification."
13
+ s.homepage = "https://github.com/SpeciesFileGroup/checkerberry"
14
+ s.license = "MIT"
15
+ s.required_ruby_version = ">= 2.5.0"
16
+
17
+ s.metadata["homepage_uri"] = s.homepage
18
+ s.metadata["source_code_uri"] = "https://github.com/SpeciesFileGroup/checkerberry"
19
+ s.metadata["changelog_uri"] = "https://github.com/SpeciesFileGroup/checkerberry/releases/tag/v#{s.version}"
20
+
21
+ # Specify which files should be added to the gem when it is released.
22
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
23
+ s.files = Dir.chdir(File.expand_path(__dir__)) do
24
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{\A(?:test|s|features)/}) }
25
+ end
26
+ s.bindir = "exe"
27
+ s.executables = s.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
28
+ s.require_paths = ["lib"]
29
+
30
+ s.add_development_dependency "bundler", "~> 2.1", ">= 2.1.4"
31
+ s.add_development_dependency "rake", "~> 13.0", ">= 13.0.1"
32
+ s.add_development_dependency "test-unit", "~> 3.3", ">= 3.3.6"
33
+ s.add_development_dependency "vcr", "~> 6.0"
34
+ s.add_development_dependency "webmock", "~> 3.18"
35
+ s.add_development_dependency "rexml", "~> 3.3", ">= 3.3.6"
36
+
37
+ s.add_runtime_dependency "faraday", "~> 2.2"
38
+ s.add_runtime_dependency "faraday-follow_redirects", "~> 0.1"
39
+ s.add_runtime_dependency "multi_json", "~> 1.15"
40
+ end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Checkerberry
4
+ class Error < StandardError; end
5
+ class RequestError < Error; end
6
+ class Unauthorized < Error; end
7
+ class NotFound < Error; end
8
+ class InternalServerError < Error; end
9
+ class BadGateway < Error; end
10
+ class ServiceUnavailable < Error; end
11
+ end
@@ -0,0 +1,32 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "faraday"
4
+
5
+ module Faraday
6
+ class CheckerberryErrors < Faraday::Middleware
7
+ def on_complete(env)
8
+ @env = env
9
+ case env[:status]
10
+ when 400
11
+ raise Checkerberry::RequestError, error_message
12
+ when 401
13
+ raise Checkerberry::Unauthorized, error_message
14
+ when 404
15
+ raise Checkerberry::NotFound, error_message
16
+ when 500
17
+ raise Checkerberry::InternalServerError, error_message
18
+ when 502
19
+ raise Checkerberry::BadGateway, error_message
20
+ when 503
21
+ raise Checkerberry::ServiceUnavailable, error_message
22
+ end
23
+ end
24
+
25
+ def error_message
26
+ "#{@env[:method].to_s.upcase} #{@env[:url]}: #{@env[:status]} - #{@env[:body]}"
27
+ end
28
+
29
+ class Middleware < CheckerberryErrors
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,25 @@
1
+ # taken from https://raw.githubusercontent.com/sckott/serrano/main/lib/serrano/helpers/configuration.rb
2
+ # taken from: https://viget.com/extend/easy-gem-configuration-variables-with-defaults
3
+ module Configuration
4
+ def configuration
5
+ yield self
6
+ end
7
+
8
+ def define_setting(name, default = nil)
9
+ class_variable_set("@@#{name}", default)
10
+ define_class_method "#{name}=" do |value|
11
+ class_variable_set("@@#{name}", value)
12
+ end
13
+ define_class_method name do
14
+ class_variable_get("@@#{name}")
15
+ end
16
+ end
17
+
18
+ private
19
+
20
+ def define_class_method(name, &block)
21
+ (class << self; self; end).instance_eval do
22
+ define_method name, &block
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,92 @@
1
+ require_relative "faraday"
2
+ require "faraday/follow_redirects"
3
+ require_relative "utils"
4
+ require "checkerberry/error"
5
+ require "multi_json"
6
+
7
+ module Checkerberry
8
+ class Request
9
+ include Utils
10
+ attr_accessor :endpoint, :verbose
11
+
12
+ def initialize(**args)
13
+ @endpoint = args[:endpoint]
14
+ @verbose = args[:verbose]
15
+ @method = args[:method] || :get
16
+ @names = args[:names]
17
+ @data_sources = args[:data_sources]
18
+ @vernacular_languages = args[:vernacular_languages]
19
+ @with_all_matches = args[:with_all_matches]
20
+ @with_capitalization = args[:with_capitalization]
21
+ @with_species_group = args[:with_species_group]
22
+ @with_uninomial_fuzzy_match = args[:with_uninomial_fuzzy_match]
23
+ @with_stats = args[:with_stats]
24
+ @min_taxon_threshold = args[:min_taxon_threshold]
25
+ @query = args[:query]
26
+ @parent_taxon = args[:parent_taxon]
27
+ @name_string = args[:name_string]
28
+ @genus = args[:genus]
29
+ @species = args[:species]
30
+ @species_any = args[:species_any]
31
+ @infraspecies = args[:infraspecies]
32
+ @author = args[:author]
33
+ @year = args[:year]
34
+ @year_start = args[:year_start]
35
+ @year_end = args[:year_end]
36
+ @with_all_results = args[:with_all_results]
37
+ end
38
+
39
+ def perform
40
+ args = {
41
+ nameStrings: @names,
42
+ dataSources: @data_sources,
43
+ vernaculars: @vernacular_languages,
44
+ withAllMatches: @with_all_matches,
45
+ withCapitalization: @with_capitalization,
46
+ withSpeciesGroup: @with_species_group,
47
+ withUninomialFuzzyMatch: @with_uninomial_fuzzy_match,
48
+ withStats: @with_stats,
49
+ mainTaxonThreshold: @min_taxon_threshold,
50
+ query: @query,
51
+ parentTaxon: @parent_taxon,
52
+ nameString: @name_string,
53
+ genus: @genus,
54
+ species: @species,
55
+ speciesAny: @species_any,
56
+ speciesInfra: @infraspecies,
57
+ author: @author,
58
+ year: @year,
59
+ withAllResults: @with_all_results
60
+ }
61
+ opts = args.delete_if { |_k, v| v.nil? }
62
+
63
+ if @year_start && @year_end
64
+ opts[:yearRange] = { yearStart: @year_start, yearEnd: @year_end }
65
+ end
66
+
67
+ conn = Faraday.new(url: Checkerberry.base_url) do |f|
68
+ f.request :json
69
+ f.response :logger if @verbose
70
+ f.use Faraday::CheckerberryErrors::Middleware
71
+ f.adapter Faraday.default_adapter
72
+ end
73
+
74
+ conn.headers['Accept'] = 'application/json'
75
+ conn.headers['Content-Type'] = 'application/json' if @method == :post
76
+ conn.headers[:user_agent] = make_user_agent
77
+ conn.headers["X-USER-AGENT"] = make_user_agent
78
+
79
+ res = if @method == :post
80
+ conn.post(endpoint, opts.to_json)
81
+ else
82
+ conn.get(endpoint, opts)
83
+ end
84
+
85
+ begin
86
+ MultiJson.load(res.body)
87
+ rescue MultiJson::ParseError
88
+ res.body
89
+ end
90
+ end
91
+ end
92
+ end
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Checkerberry
4
+ module Utils
5
+ def make_user_agent
6
+ requa = "Faraday/v" + Faraday::VERSION
7
+ habua = "Checkerberry/v" + Checkerberry::VERSION
8
+ if Checkerberry.mailto
9
+ mailto = "mailto:" + Checkerberry.mailto
10
+ ua = requa + " " + habua + " " + mailto
11
+ else
12
+ ua = requa + " " + habua
13
+ end
14
+ ua
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Checkerberry
4
+ VERSION = "0.0.1"
5
+ end
@@ -0,0 +1,127 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "erb"
4
+ require_relative "checkerberry/error"
5
+ require_relative "checkerberry/version"
6
+ require_relative "checkerberry/request"
7
+ require "checkerberry/helpers/configuration"
8
+
9
+ module Checkerberry
10
+ extend Configuration
11
+
12
+ define_setting :base_url, "https://verifier.globalnames.org/api/v1"
13
+ define_setting :mailto, ENV["GNVERIFIER_API_EMAIL"]
14
+
15
+ # Verify scientific names
16
+ #
17
+ # @param names [String, Array] A single name or array of names to verify
18
+ # @param data_sources [Array, Integer] The data source IDs to use for verification
19
+ # @param vernacular_languages [String, Array] A single language ISO 639-3 or an array of ISO 639-3 languages for vernacular names
20
+ # @param with_all_matches [Boolean] Show all matches for each name
21
+ # @param with_capitalization [Boolean] Capitalize the first character
22
+ # @param with_species_group [Boolean] Match to species group
23
+ # @param with_uninomial_fuzzy_match [Boolean] Enable uninomial fuzzy matching
24
+ # @param with_stats [Boolean] Include statistics in response
25
+ # @param min_taxon_threshold [Float] The minimum taxon threshold for main taxon assignment
26
+ # @param verbose [Boolean] Print headers to STDOUT
27
+ #
28
+ # @return [Hash] A hash with verification results
29
+ def self.verify(names, data_sources: nil, vernacular_languages: nil,
30
+ with_all_matches: nil, with_capitalization: nil,
31
+ with_species_group: nil, with_uninomial_fuzzy_match: nil,
32
+ with_stats: nil, min_taxon_threshold: nil, verbose: false)
33
+ endpoint = "verifications"
34
+ names_array = names.is_a?(Array) ? names : [names]
35
+ data_sources_array = data_sources.is_a?(Array) ? data_sources : (data_sources.nil? ? nil : [data_sources])
36
+ Request.new(endpoint: endpoint, method: :post, names: names_array,
37
+ data_sources: data_sources_array, vernacular_languages: vernacular_languages,
38
+ with_all_matches: with_all_matches, with_capitalization: with_capitalization,
39
+ with_species_group: with_species_group, with_uninomial_fuzzy_match: with_uninomial_fuzzy_match,
40
+ with_stats: with_stats, min_taxon_threshold: min_taxon_threshold,
41
+ verbose: verbose).perform
42
+ end
43
+
44
+ # Search for scientific names
45
+ #
46
+ # @param query [String] The search query
47
+ # @param data_sources [Array, Integer] The data source IDs to use for verification
48
+ # @param parent_taxon [String] The parent taxon name
49
+ # @param name_string [String] The exact name string to search for
50
+ # @param genus [String] The genus name
51
+ # @param species [String] The species name
52
+ # @param species_any [String] Any part of the species name
53
+ # @param infraspecies [String] The infraspecies name
54
+ # @param author [String] The author name
55
+ # @param year [Integer] The year of publication
56
+ # @param year_start [Integer] The start year for a range search
57
+ # @param year_end [Integer] The end year for a range search
58
+ # @param with_all_results [Boolean] Show all matches for each name
59
+ def self.search(query: nil, data_sources: nil, parent_taxon: nil,
60
+ name_string: nil, genus: nil, species: nil,
61
+ species_any: nil, infraspecies: nil, author: nil,
62
+ year: nil, year_start: nil, year_end: nil,
63
+ with_all_results: nil, verbose: false)
64
+ endpoint = "search"
65
+
66
+ # require year_start and year_end together
67
+ if year_start && !year_end
68
+ raise ArgumentError, "year_end is required when year_start is provided"
69
+ end
70
+ if year_end && !year_start
71
+ raise ArgumentError, "year_start is required when year_end is provided"
72
+ end
73
+
74
+ # require no year if year_start and year_end are provided
75
+ if (year_start || year_end) && year
76
+ raise ArgumentError, "year cannot be provided when year_start and year_end are provided"
77
+ end
78
+
79
+ data_sources_array = data_sources.is_a?(Array) ? data_sources : (data_sources.nil? ? nil : [data_sources])
80
+ Request.new(endpoint: endpoint, method: :post,
81
+ query: query, data_sources: data_sources_array, parent_taxon: parent_taxon,
82
+ name_string: name_string, genus: genus, species: species,
83
+ species_any: species_any, infraspecies: infraspecies,
84
+ author: author, year: year, year_start: year_start,
85
+ year_end: year_end, with_all_results: with_all_results,
86
+ verbose: verbose).perform
87
+ end
88
+
89
+ # Get list of data sources
90
+ #
91
+ # @param verbose [Boolean] Print headers to STDOUT
92
+ #
93
+ # @return [Array] An array of data source information
94
+ def self.data_sources(verbose: false)
95
+ endpoint = "data_sources"
96
+ Request.new(endpoint: endpoint, verbose: verbose).perform
97
+ end
98
+
99
+ # Get a single data source by ID
100
+ #
101
+ # @param source_id [Integer] The data source ID
102
+ # @param verbose [Boolean] Print headers to STDOUT
103
+ #
104
+ # @return [Hash] A hash with data source information
105
+ def self.data_source(source_id, verbose: false)
106
+ endpoint = "data_sources/#{source_id}"
107
+ Request.new(endpoint: endpoint, verbose: verbose).perform
108
+ end
109
+
110
+ # Ping the API (check if the service is alive)
111
+ #
112
+ # @param verbose [Boolean] Print headers to STDOUT
113
+ def self.ping(verbose: false)
114
+ endpoint = "ping"
115
+ Request.new(endpoint: endpoint, verbose: verbose).perform
116
+ end
117
+
118
+ # Get version information
119
+ #
120
+ # @param verbose [Boolean] Print headers to STDOUT
121
+ #
122
+ # @return [Hash] A hash with version information
123
+ def self.version(verbose: false)
124
+ endpoint = "version"
125
+ Request.new(endpoint: endpoint, verbose: verbose).perform
126
+ end
127
+ end
metadata ADDED
@@ -0,0 +1,212 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: checkerberry
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Geoff Ower
8
+ bindir: exe
9
+ cert_chain: []
10
+ date: 1980-01-02 00:00:00.000000000 Z
11
+ dependencies:
12
+ - !ruby/object:Gem::Dependency
13
+ name: bundler
14
+ requirement: !ruby/object:Gem::Requirement
15
+ requirements:
16
+ - - "~>"
17
+ - !ruby/object:Gem::Version
18
+ version: '2.1'
19
+ - - ">="
20
+ - !ruby/object:Gem::Version
21
+ version: 2.1.4
22
+ type: :development
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ requirements:
26
+ - - "~>"
27
+ - !ruby/object:Gem::Version
28
+ version: '2.1'
29
+ - - ">="
30
+ - !ruby/object:Gem::Version
31
+ version: 2.1.4
32
+ - !ruby/object:Gem::Dependency
33
+ name: rake
34
+ requirement: !ruby/object:Gem::Requirement
35
+ requirements:
36
+ - - "~>"
37
+ - !ruby/object:Gem::Version
38
+ version: '13.0'
39
+ - - ">="
40
+ - !ruby/object:Gem::Version
41
+ version: 13.0.1
42
+ type: :development
43
+ prerelease: false
44
+ version_requirements: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - "~>"
47
+ - !ruby/object:Gem::Version
48
+ version: '13.0'
49
+ - - ">="
50
+ - !ruby/object:Gem::Version
51
+ version: 13.0.1
52
+ - !ruby/object:Gem::Dependency
53
+ name: test-unit
54
+ requirement: !ruby/object:Gem::Requirement
55
+ requirements:
56
+ - - "~>"
57
+ - !ruby/object:Gem::Version
58
+ version: '3.3'
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: 3.3.6
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '3.3'
69
+ - - ">="
70
+ - !ruby/object:Gem::Version
71
+ version: 3.3.6
72
+ - !ruby/object:Gem::Dependency
73
+ name: vcr
74
+ requirement: !ruby/object:Gem::Requirement
75
+ requirements:
76
+ - - "~>"
77
+ - !ruby/object:Gem::Version
78
+ version: '6.0'
79
+ type: :development
80
+ prerelease: false
81
+ version_requirements: !ruby/object:Gem::Requirement
82
+ requirements:
83
+ - - "~>"
84
+ - !ruby/object:Gem::Version
85
+ version: '6.0'
86
+ - !ruby/object:Gem::Dependency
87
+ name: webmock
88
+ requirement: !ruby/object:Gem::Requirement
89
+ requirements:
90
+ - - "~>"
91
+ - !ruby/object:Gem::Version
92
+ version: '3.18'
93
+ type: :development
94
+ prerelease: false
95
+ version_requirements: !ruby/object:Gem::Requirement
96
+ requirements:
97
+ - - "~>"
98
+ - !ruby/object:Gem::Version
99
+ version: '3.18'
100
+ - !ruby/object:Gem::Dependency
101
+ name: rexml
102
+ requirement: !ruby/object:Gem::Requirement
103
+ requirements:
104
+ - - "~>"
105
+ - !ruby/object:Gem::Version
106
+ version: '3.3'
107
+ - - ">="
108
+ - !ruby/object:Gem::Version
109
+ version: 3.3.6
110
+ type: :development
111
+ prerelease: false
112
+ version_requirements: !ruby/object:Gem::Requirement
113
+ requirements:
114
+ - - "~>"
115
+ - !ruby/object:Gem::Version
116
+ version: '3.3'
117
+ - - ">="
118
+ - !ruby/object:Gem::Version
119
+ version: 3.3.6
120
+ - !ruby/object:Gem::Dependency
121
+ name: faraday
122
+ requirement: !ruby/object:Gem::Requirement
123
+ requirements:
124
+ - - "~>"
125
+ - !ruby/object:Gem::Version
126
+ version: '2.2'
127
+ type: :runtime
128
+ prerelease: false
129
+ version_requirements: !ruby/object:Gem::Requirement
130
+ requirements:
131
+ - - "~>"
132
+ - !ruby/object:Gem::Version
133
+ version: '2.2'
134
+ - !ruby/object:Gem::Dependency
135
+ name: faraday-follow_redirects
136
+ requirement: !ruby/object:Gem::Requirement
137
+ requirements:
138
+ - - "~>"
139
+ - !ruby/object:Gem::Version
140
+ version: '0.1'
141
+ type: :runtime
142
+ prerelease: false
143
+ version_requirements: !ruby/object:Gem::Requirement
144
+ requirements:
145
+ - - "~>"
146
+ - !ruby/object:Gem::Version
147
+ version: '0.1'
148
+ - !ruby/object:Gem::Dependency
149
+ name: multi_json
150
+ requirement: !ruby/object:Gem::Requirement
151
+ requirements:
152
+ - - "~>"
153
+ - !ruby/object:Gem::Version
154
+ version: '1.15'
155
+ type: :runtime
156
+ prerelease: false
157
+ version_requirements: !ruby/object:Gem::Requirement
158
+ requirements:
159
+ - - "~>"
160
+ - !ruby/object:Gem::Version
161
+ version: '1.15'
162
+ description: checkerberry is a low-level wrapper around the GNverifier API for scientific
163
+ name verification.
164
+ email:
165
+ - gdower@illinois.edu
166
+ executables: []
167
+ extensions: []
168
+ extra_rdoc_files: []
169
+ files:
170
+ - ".github/workflows/main.yaml"
171
+ - ".gitignore"
172
+ - CHANGELOG.md
173
+ - CODE_OF_CONDUCT.md
174
+ - Gemfile
175
+ - LICENSE
176
+ - README.md
177
+ - Rakefile
178
+ - bin/console
179
+ - bin/setup
180
+ - checkerberry.gemspec
181
+ - lib/checkerberry.rb
182
+ - lib/checkerberry/error.rb
183
+ - lib/checkerberry/faraday.rb
184
+ - lib/checkerberry/helpers/configuration.rb
185
+ - lib/checkerberry/request.rb
186
+ - lib/checkerberry/utils.rb
187
+ - lib/checkerberry/version.rb
188
+ homepage: https://github.com/SpeciesFileGroup/checkerberry
189
+ licenses:
190
+ - MIT
191
+ metadata:
192
+ homepage_uri: https://github.com/SpeciesFileGroup/checkerberry
193
+ source_code_uri: https://github.com/SpeciesFileGroup/checkerberry
194
+ changelog_uri: https://github.com/SpeciesFileGroup/checkerberry/releases/tag/v0.0.1
195
+ rdoc_options: []
196
+ require_paths:
197
+ - lib
198
+ required_ruby_version: !ruby/object:Gem::Requirement
199
+ requirements:
200
+ - - ">="
201
+ - !ruby/object:Gem::Version
202
+ version: 2.5.0
203
+ required_rubygems_version: !ruby/object:Gem::Requirement
204
+ requirements:
205
+ - - ">="
206
+ - !ruby/object:Gem::Version
207
+ version: '0'
208
+ requirements: []
209
+ rubygems_version: 3.6.7
210
+ specification_version: 4
211
+ summary: GNverifier API Client
212
+ test_files: []