Module: Salad

Defined in:
lib/salad.rb,
lib/salad/console.rb,
lib/salad/version.rb,
lib/salad/gem_help.rb,
lib/salad/catalogue_of_life.rb

Defined Under Namespace

Classes: CatalogueOfLife

Constant Summary collapse

GEMS =
%w[
  bananomia
  bell_pepper
  bok_choy
  checkerberry
  colrapi
  crawlyflower
  hookkaido
  nasturtium
  plazucchini
  syconium
  wikimelon
].freeze
SERVICES =
{
  bels:               'bell_pepper',
  bhlnames:           'bok_choy',
  bionomia:           'bananomia',
  catalogue_of_life:  'colrapi',
  checklistbank:      'colrapi',
  clb:                'colrapi',
  col:                'colrapi',
  gnverifier:         'checkerberry',
  inaturalist:        'nasturtium',
  owl:                'hookkaido',
  openalex:           'syconium',
  plazi:              'plazucchini',
  wikidata:           'wikimelon',
  worms:              'crawlyflower'
}.freeze
COMPLETABLE_PREFIX_MIN =

Regex matching any non-empty prefix of length >= 3 of any completable name. Built by enumerating prefixes and joining with ‘|`. Each prefix is escaped so weird characters in a name can’t change the regex’s meaning. The 3-char minimum keeps short ambiguous input (‘s`, `c`) falling through to Pry’s default completion.

3
COL_SCOPED_SERVICES =
%i[catalogue_of_life col].freeze
HINTS =
[
  "TAB completes service and gem names: `Salad.nas<TAB>` → Salad.nasturtium",
  "TAB inside parens shows endpoint parameters: `Salad.inaturalist.observations(<TAB>`",
  "Results render in `less`, press `q` to exit paged API results",
  "Results render in `less`, press `/` to search within paged API results (n/N for next/previous match)",
  "Results render in `less`, use vim-style navigation (j/k, gg/G, h/l) — `man less` is worth a read",
  "See full endpoint docs: `help Salad.nasturtium.observations`",
  "List all services: `help`",
  "Service and gem names are interchangeable: `Salad.inaturalist` == `Salad.nasturtium`",
  "`Salad.catalogue_of_life.*` and `Salad.col.*` auto-scope to the latest COL release (3LR)",
  "Override the COL dataset: `Salad.col.nameusage_search(q: 'Aedes', dataset_id: 'COL25')`",
  "`Salad.clb` and `Salad.checklistbank` search across ALL ChecklistBank datasets, not just COL",
  "Type `hints` any time to see all tips"
].freeze
VERSION =
'0.0.1'
GEM_HELP =
{
  :bananomia => {
    description: "Wrapper for Bionomia API - access specimen and collection records",
    api: "https://bionomia.net",
    endpoints: {
      :parse => {
        description: "Parse human names",
        params: {
          :names => "Human name(s) separated by \\r\\n",
          :verbose => "Print headers to STDOUT",
        },
        examples: [
          "Bananomia.parse('Henry Robert Nicollon des Abbayes; Groom Q\\r\\nMrs. John Errol Chandos Aberdeen')",
          "Date.parse(search_date)",
          "Date.parse(r['item']['birthDate'])",
        ],
      },
      :person => {
        description: "Get a person's profile by ID or specimens",
        params: {
          :id => "An ORCID or WikiData identifier",
          :specimens => "Get the person's specimens",
          :csv => "For specimens, whether to return a csv",
          :page => "Pagination for the results list",
          :verbose => "Print headers to STDOUT",
        },
        examples: [
          "Bananomia.person('0000-0001-7618-5230')",
          "Bananomia.person('0000-0001-7618-5230', specimens: true)",
          "Bananomia.person('0000-0001-7618-5230', specimens: true, csv: true)",
        ],
      },
      :occurrence => {
        description: "Get and occurrence record",
        params: {
          :id => "An occurence ID from Global Biodiversity Information Facility",
          :verbose => "Print headers to STDOUT",
        },
        examples: [
          "Bananomia.occurrence('477976412')",
        ],
      },
      :search_people => {
        description: "Search human names",
        params: {
          :q => "A single human name",
          :families_collected => "Comma-separated list of taxonomic families collected",
          :families_identified => "Comma-separated list of taxonomic families identified",
          :date => "Filters to alive during date (format: YYYY-MM-DD, YYYY-MM, or YYYY)   e.g., Captain John Smith was alive from 1580-01-01 through 1631-06-21, so setting date to any value between         their birth/death date will include Captain John in the search results   Warning: Setting exactly equal to a person's birthdate, excludes them from search!",
          :strict => "Must include vs should include on families_identified, families_collected, date",
          :callback => "A string to produce a JSONP response instead of a JSON-LD response",
          :page => "Pagination for the results list",
          :verbose => "Print headers to STDOUT",
        },
        examples: [
          "Bananomia.search_people('smith', families_collected: 'scarabaeidae', strict: true)",
          "Bananomia.search_people('Thomas McElrath', families_collected: 'Acholeplasmataceae', strict: true)",
          "Bananomia.search_people('Thomas McElrath', families_identified: 'Acholeplasmataceae', strict: true)",
        ],
      },
      :search_occurrences => {
        description: "Search occurrences",
        params: {
          :dataset_id => "a registered dataset UUID provided by the Global Biodiversity Information Facility",
          :occurrence_id => "identifier from the data provider",
          :callback => "A string to produce a JSONP response instead of a JSON-LD response",
          :page => "Pagination for the results list",
          :verbose => "Print headers to STDOUT",
        },
        examples: [],
      },
      :suggest => {
        description: "Suggest human names (autocomplete widget)",
        params: {
          :q => "Part of a human name",
          :is_public => "Filters results to public profiles",
          :has_occurrences => "Filters results to profiles with occurrences",
          :limit => "The number of results to return",
          :verbose => "Print headers to STDOUT",
        },
        examples: [
          "Bananomia.suggest('anning')",
        ],
      },
    },
  },
  :bell_pepper => {
    description: "Wrapper for BELS API - georeference locality descriptions via the Biodiversity Enhanced Location Services",
    api: "https://bels.geo-vocab.org/",
    endpoints: {
      :bestgeoref => {
        description: "Get a georeference",
        params: {
          :id => "an optional identifier that will be returned with the result",
          :city => "The city",
          :continent => "The name of the continent in which the Location occurs",
          :county => "The full, unabbreviated name of the next smaller administrative region than stateProvince (county, shire, department, etc.) in which the Location occurs",
          :country => "The name of the country or major administrative unit in which the Location occurs",
          :country_code => "The ISO 3166-1-alpha-2 code for the country in which the Location occurs",
          :give_me => "The type of georeference match (BEST_GEOREF)",
          :locality => "The specific description of the place",
          :state_province => "The name of the next smaller administrative region than country (state, province, canton, department, region, etc.) in which the Location occurs",
        },
        examples: [],
      },
    },
  },
  :bok_choy => {
    description: "Wrapper for BHL API - access biodiversity heritage library data",
    api: "https://www.biodiversitylibrary.org/api",
    endpoints: {
      :name_refs => {
        description: "Finds BHL references for a name",
        params: {
          :name => "A canonical scientific name (e.g., Pardosa moesta)",
          :author => "An author string (e.g., Banks)",
          :year => "A year string (e.g., 1892)",
          :reference => "A reference string (e.g., Docums Mycol. 34(nos 135-136))",
          :nomen_event => "If true, tries to find nomenclatural event reference (default: true)",
          :json => "An optional JSON hash of name and reference data (overrides all other parameters)",
          :verbose => "Print headers to STDOUT",
        },
        examples: [
          "Choy.name_refs(name: 'Cyphoderris strepitans', nomen_event: true)",
        ],
      },
      :cached_refs => {
        description: "Finds a nomenclatural event in BHL by an external ID from a data source",
        params: {
          :id => "An external ID from a data source",
          :verbose => "Print headers to STDOUT",
        },
        examples: [
          "Choy.cached_refs('6C8Q2')",
        ],
      },
      :items_page_nums => {
        description: "Get a page by item ID and page number",
        params: {
          :item_id => "A BHL item ID",
          :page_num => "A BHL page number",
          :verbose => "Print headers to STDOUT",
        },
        examples: [
          "Choy.items_page_nums(item_id: 15402, page_num: 183)",
        ],
      },
      :items => {
        description: "Get metadata and taxonomic statistics for a BHL item",
        params: {
          :id => "A BHL item ID",
          :verbose => "Print headers to STDOUT",
        },
        examples: [
          "Choy.items(73397)",
          "items(taxon_name: 'Lepidoptera')",
        ],
      },
      :page => {
        description: "Get BHL reference metadata by page ID",
        params: {
          :id => "A page ID from BHL",
          :verbose => "Print headers to STDOUT",
        },
        examples: [
          "Choy.page(6589171)",
        ],
      },
      :taxon_items => {
        description: "Finds BHL items in which a given higher taxon is prevalent",
        params: {
          :taxon_name => "A taxonomic name (e.g., Lepidoptera)",
          :verbose => "Print headers to STDOUT",
        },
        examples: [
          "Choy.taxon_items(taxon_name: 'Lepidoptera')",
        ],
      },
      :references => {
        description: "Gets BHL reference metadata by page ID",
        params: {
          :id => "A page ID from BHL",
          :verbose => "Print headers to STDOUT",
        },
        examples: [
          "Choy.references(6589171)",
        ],
      },
      :ping => {
        description: "Check the API status",
        params: {
          :verbose => "Print headers to STDOUT",
        },
        examples: [],
      },
      :version => {
        description: "Check the API version",
        params: {
          :verbose => "Print headers to STDOUT",
        },
        examples: [],
      },
    },
  },
  :checkerberry => {
    description: "Wrapper for GNverifier API - verify and search scientific names across curated databases",
    api: "https://verifier.globalnames.org",
    endpoints: {
      :verify => {
        description: "Verify scientific names",
        params: {
          :names => "A single name or array of names to verify",
          :data_sources => "The data source IDs to use for verification",
          :vernacular_languages => "A single language ISO 639-3 or an array of ISO 639-3 languages for vernacular names",
          :with_all_matches => "Show all matches for each name",
          :with_capitalization => "Capitalize the first character",
          :with_species_group => "Match to species group",
          :with_uninomial_fuzzy_match => "Enable uninomial fuzzy matching",
          :with_stats => "Include statistics in response",
          :min_taxon_threshold => "The minimum taxon threshold for main taxon assignment",
          :verbose => "Print headers to STDOUT",
        },
        examples: [
          "Checkerberry.verify('Homo sapiens')",
          "Checkerberry.verify(['Homo sapiens', 'Mus musculus'])",
          "Checkerberry.verify('Homo sapiens', data_sources: 1)",
        ],
      },
      :search => {
        description: "Search for scientific names",
        params: {
          :query => "The search query",
          :data_sources => "The data source IDs to use for verification",
          :parent_taxon => "The parent taxon name",
          :name_string => "The exact name string to search for",
          :genus => "The genus name",
          :species => "The species name",
          :species_any => "Any part of the species name",
          :infraspecies => "The infraspecies name",
          :author => "The author name",
          :year => "The year of publication",
          :year_start => "The start year for a range search",
          :year_end => "The end year for a range search",
          :with_all_results => "Show all matches for each name",
        },
        examples: [
          "Checkerberry.search(name_string: \"Homo sapiens\", genus: 'Homo', species: 'sapiens')",
          "Checkerberry.search(parent_taxon: \"Plantae\", genus: 'Homo', species: 'sapiens')",
          "Checkerberry.search(parent_taxon: \"Animalia\", genus: 'Homo', species: 'sapiens')",
        ],
      },
      :data_sources => {
        description: "Get list of data sources",
        params: {
          :verbose => "Print headers to STDOUT",
        },
        examples: [],
      },
      :data_source => {
        description: "Get a single data source by ID",
        params: {
          :source_id => "The data source ID",
          :verbose => "Print headers to STDOUT",
        },
        examples: [
          "Checkerberry.data_source(1)",
        ],
      },
      :ping => {
        description: "Ping the API (check if the service is alive)",
        params: {
          :verbose => "Print headers to STDOUT",
        },
        examples: [],
      },
      :version => {
        description: "Get version information",
        params: {
          :verbose => "Print headers to STDOUT",
        },
        examples: [],
      },
    },
  },
  :colrapi => {
    description: "Wrapper for Catalogue of Life (ChecklistBank) API - access global taxonomic checklists and name data",
    api: "https://www.checklistbank.org/api",
    endpoints: {
      :assembly => {
        description: "Get assembly status",
        params: {
          :dataset_id => "The dataset id",
        },
        examples: [
          "Colrapi.assembly('3')",
        ],
      },
      :archive => {
        description: "Get a dataset's original archive",
        params: {
          :dataset_id => "The dataset id",
          :attempt => "Returns archive for a past import attempt number",
        },
        examples: [
          "Colrapi.archive('36223', attempt: 71)",
        ],
      },
      :dataset => {
        description: "Get dataset metadata",
        params: {},
        examples: [
          "Colrapi.dataset(dataset_id: @dataset_id)",
          "Colrapi.dataset(dataset_id: '1027', attempt: 100)",
          "Colrapi.dataset(offset: 2848, limit: 6)",
        ],
      },
      :decision => {
        description: "Get project decisions",
        params: {
          :dataset_id => "The dataset id",
          :decision_id => "The decision id",
          :name => "The scientific name to match",
          :rank => "The rank of the scientific name",
          :modified_by => "Filter by a user id  on last modified by",
          :broken => "Whether the decision is broken or not",
          :subject_dataset_id => "The source dataset id",
          :mode => "The type of decision (block, reviewed, update, update_recursive, ignore)",
          :subject => "TODO: what does this do? All decisions with subject=true are bare names, so maybe it checks if the subject taxon exists?",
          :offset => "Offset for pagination",
          :limit => "Limit for pagination",
          :verbose => "Print headers to STDOUT",
        },
        examples: [
          "Colrapi.decision(@dataset_id)",
          "Colrapi.decision(@dataset_id, offset: 5, limit: 3)",
          "Colrapi.decision(@dataset_id, rank: 'family')",
        ],
      },
      :duplicate => {
        description: "Get duplicate names",
        params: {
          :dataset_id => "The dataset id",
          :offset => "Offset for pagination",
          :limit => "Limit for pagination",
          :verbose => "Print headers to STDOUT",
        },
        examples: [
          "Colrapi.duplicate(@dataset_id)",
        ],
      },
      :diff => {
        description: "Get names diff between 2 datasets",
        params: {
          :dataset_id => "The first dataset id",
          :dataset2_id => "The second dataset id",
          :root_id => "The root taxon for the first dataset",
          :root2_id => "The root taxon for the second dataset",
          :min_rank => "The minimum taxonomic rank",
          :authorship => "Include authorship",
          :include_synonyms => "Include synonyms",
          :include_parent => "Include parent",
          :parent_rank => "Filter by parent rank",
          :token => "An authentication token from Colrapi.user_login()",
          :offset => "Offset for pagination",
          :limit => "Limit for pagination",
          :verbose => "Print headers to STDOUT",
        },
        examples: [
          "Colrapi.diff(@dataset1_id, @dataset2_id, token: @token)",
        ],
      },
      :editor => {
        description: "Get editor info",
        params: {
          :dataset_id => "The dataset id",
          :token => "The authentication token from retrieved with Colrapi.user_login(user, password) # @return [Array, Hash, Boolean] An array of hashes",
        },
        examples: [
          "Colrapi.editor(@dataset_id, 'a.b.c')",
          "Colrapi.editor(@dataset_id, @token)",
        ],
      },
      :estimate => {
        description: "Get estimates",
        params: {
          :dataset_id => "The dataset id",
          :estimate_id => "The estimate ID",
          :name => "The scientific name",
          :rank => "taxonomic rank",
          :modified_by => "Filter by a user id  on last modified by",
          :broken => "Whether the estimate is broken or not",
          :min => "Filter by the minimum estimate",
          :max => "Filter by the maximum estimate",
          :offset => "Offset for pagination",
          :limit => "Limit for pagination",
          :verbose => "Print headers to STDOUT",
        },
        examples: [
          "Colrapi.estimate(@dataset_id)",
          "Colrapi.estimate(@dataset_id, offset: 7, limit: 3)",
          "Colrapi.estimate(@dataset_id, estimate_id: 68)",
        ],
      },
      :export => {
        description: "TODO: /dataset/{key}/export is covered, but /export and /export/{id} are not",
        params: {
          :dataset_id => "The dataset id",
          :show_id => "TODO: not implemented because it doesn't seem to do anything?",
          :verbose => "Print headers to STDOUT",
        },
        examples: [
          "Colrapi.export('36223')",
        ],
      },
      :issues => {
        description: "Get data quality issues",
        params: {
          :dataset_id => "The dataset id",
          :issue => "Filter by data quality issue (e.g., ACCEPTED_NAME_MISSING, DUPLICATE_NAME, URL_INVALID)",
          :mode => "Verbatim (default) or interpreted",
          :offset => "Offset for pagination",
          :limit => "Limit for pagination",
          :verbose => "Print headers to STDOUT",
        },
        examples: [
          "Colrapi.issues(@dataset_id)",
          "Colrapi.issues(@dataset_id, issue: 'duplicate name')",
          "Colrapi.issues(@dataset_id, issue: 'duplicate name', mode: 'interpreted')",
        ],
      },
      :importer => {
        description: "Get importer status",
        params: {
          :dataset_id => "Calls the dataset_id endpoint /importer/{dataset_id}",
          :dataset_id_filter => "Filters the importer queue by dataset_id",
          :state => "The import status (e.g., waiting, preparing, downloading, processing, inserting, ...)",
          :running => "Filter by actively importing datasets",
          :offset => "Offset for pagination",
          :limit => "Limit for pagination",
          :verbose => "Print headers to STDOUT",
        },
        examples: [
          "Colrapi.importer()",
          "Colrapi.importer(dataset_id: '1148')",
          "Colrapi.importer(running: false)",
        ],
      },
      :logo => {
        description: "Get a dataset's logo",
        params: {
          :dataset_id => "The dataset id",
          :size => "The size of the logo (original, large, medium, small)",
        },
        examples: [
          "Colrapi.logo('9837')",
          "Colrapi.logo('9837', size: 'original')",
          "Colrapi.logo('9837', size: 'medium')",
        ],
      },
      :metrics => {
        description: "Get metrics for the *last successful* import of a dataset or a specific import_attempt",
        params: {
          :dataset_id => "The dataset id",
          :import_attempt => "The import attempt",
        },
        examples: [
          "Colrapi.metrics('9837')",
          "Colrapi.metrics('49590')",
          "Colrapi.metrics(dataset_id)",
        ],
      },
      :name => {
        description: "Get names or a name from a dataset",
        params: {
          :dataset_id => "The dataset id",
          :name_id => "The name id",
          :subresource => "The name subresource endpoint (relations, synonyms, types, or orphans)",
          :offset => "Offset for pagination",
          :limit => "Limit for pagination",
          :verbose => "Print headers to STDOUT",
        },
        examples: [
          "Colrapi.name(@dataset_id, name_id: @name_id)",
          "Colrapi.name(@dataset_id, offset: 13383, limit: 1)",
          "Colrapi.name(@dataset_id, name_id: '00000fe0-d4e6-4a74-8c99-b4ad127e7e64')",
        ],
      },
      :name_list => {
        description: "Get a text list of names for a dataset",
        params: {
          :dataset_id => "The dataset id",
          :import_attempt => "The import attempt number",
        },
        examples: [
          "Colrapi.name_list(@dataset_id, import_attempt: @import_attempt)",
        ],
      },
      :name_tree => {
        description: "Get a text tree of names for a dataset",
        params: {
          :dataset_id => "The dataset id",
          :import_attempt => "The import attempt number",
        },
        examples: [
          "Colrapi.name_tree(@dataset_id, import_attempt: @import_attempt)",
        ],
      },
      :nameusage => {
        description: "Get name usages or a nameusage from a dataset",
        params: {
          :dataset_id => "The dataset id",
          :nameusage_id => "The nameusage id",
          :q => "The scientific name or authorship search query",
          :rank => "The rank of the taxon in the search query q",
          :nidx_id => "The name index id",
          :subresource => "The name subresource endpoint (relations, synonyms, types, or orphans)",
          :offset => "Offset for pagination",
          :limit => "Limit for pagination",
          :verbose => "Print headers to STDOUT",
        },
        examples: [
          "Colrapi.nameusage(@dataset_id)",
          "Colrapi.nameusage(@dataset_id, nameusage_id: '32', subresource: 'related')",
          "Colrapi.nameusage(@dataset_id, nameusage_id: '32', subresource: 'source')",
        ],
      },
      :matching => {
        description: "Get names or a name from a dataset",
        params: {
          :dataset_id => "The dataset id",
          :name => "The scientific name to match",
          :authorship => "The authorship string for the scientific name",
          :code => "The nomenclatural code (bacterial, botanical, cultivars, phytosociological, virus, zoological)",
          :rank => "The rank of the scientific name",
          :within_superkingdom => "Restricts query to within a superkingdom",
          :within_kingdom => "Restricts query to within a kingdom",
          :within_subkingdom => "Restricts query to within a subkingdom",
          :within_superphylum => "Restricts query to within a superphylum",
          :within_phylum => "Restricts query to within a phylum",
          :within_subphylum => "Restricts query to within a subphylum",
          :within_superclass => "Restricts query to within a superclass",
          :within_class => "Restricts query to within a class",
          :within_subclass => "Restricts query to within a subclass",
          :within_superorder => "Restricts query to within a superorder",
          :within_order => "Restricts query to within a order",
          :within_suborder => "Restricts query to within a suborder",
          :within_superfamily => "Restricts query to within a superfamily",
          :within_family => "Restricts query to within a family",
          :within_subfamily => "Restricts query to within a subfamily",
          :within_tribe => "Restricts query to within a tribe",
          :within_subtribe => "Restricts query to within a subtribe",
          :within_genus => "Restricts query to within a genus",
          :within_subgenus => "Restricts query to within a subgenus",
          :within_section => "Restricts query to within a section",
          :within_species => "Restricts query to within a species",
          :verbose => "Print headers to STDOUT",
        },
        examples: [
          "Colrapi.matching(@dataset_id, name: @name)",
          "Colrapi.matching(@dataset_id, name: @homonym)",
          "Colrapi.matching(@dataset_id, name: @homonym, within_kingdom: 'Plantae')",
        ],
      },
      :nameusage_pattern => {
        description: "Search for a name usage with a regex pattern",
        params: {
          :dataset_id => "restricts name usage pattern search within a dataset",
          :regexp => "The regular expression pattern",
          :status => "The taxonomic status (accepted, provisionally_accepted, synonym, ambiguous_synonym, misapplied, bare_name)",
          :rank => "The taxonomic rank",
          :project_id => "Filter to names from project_id, required if decision_mode used",
          :decision_mode => "The type of decision (block, reviewed, update, update_recursive, ignore)",
          :offset => "Offset for pagination",
          :limit => "Limit for pagination",
          :verbose => "Print headers to STDOUT",
        },
        examples: [
          "Colrapi.nameusage_pattern(@col_ac22, '[A-Z]rnithorhynchus anatinus')",
          "Colrapi.nameusage_pattern(@col_ac22, '[A-Z]rnithorhynchus anatinus', rank: 'species')",
          "Colrapi.nameusage_pattern(@col_ac22, '[A-Z]rnithorhynchus anatinus', rank: 'family')",
        ],
      },
      :nameusage_search => {
        description: "Search the nameusage route, which uses Elastic Search",
        params: {
          :authorship => "filters by authorship",
          :authorship_year => "filters by authorship year",
          :content => "restrict search to SCIENTIFIC_NAME, or AUTHORSHIP",
          :dataset_id => "restricts name usage search within a dataset",
          :endpoint => "some endpoints have nested options",
          :environment => "filter by environment (MARINE, TERRESTRIAL, FRESHWATER, BRACKISH)",
          :extinct => "filter by extinct status (0, 1)",
          :facet => "the search facet",
          :field => "filter by name field (see: http://api.checklistbank.org/vocab/namefield)",
          :highest_taxon_id => "Filter by highest taxon ID",
          :issue => "the data quality issue",
          :max_rank => "maximum taxonomic rank of name usages",
          :min_rank => "minimum taxonomic rank of name usages",
          :name_type => "filter by name type (hybrid formula, informal, no name, otu, placeholder, scientific, virus)",
          :nomenclatural_code => "filter by nomenclatural code (botanical, zoological, bacterial, viral, phytosociological, cultivars)",
          :nomenclatural_status => "filter by nomenclatural status (acceptable, conserved, doubtful, established, manuscript, not established, rejected, unacceptable)",
          :origin => "filter by origin of the name usage (see: http://api.checklistbank.org/vocab/origin)",
          :q => "A query string",
          :rank => "taxonomic rank of name usages",
          :secondary_source => "filter by secondary source (authorship, basionym, extinct, holotype, parent, published in, rank, temporal range)",
          :sector_dataset_id => "filter by the sector source dataset ID",
          :sector_mode => "filter by the sector mode (attach, merge, union)",
          :status => "filter by taxonomic status (accepted, ambiguous synonym, misapplied, provisionally accepted, synonym)",
          :taxonomic_group => "filter by taxonomic group (see: http://api.checklistbank.org/vocab/taxgroup)",
          :type => "sets the type of search to PREFIX, WHOLE_WORDS, or EXACT",
          :usage_id => "Filter by usage ID",
          :sort_by => "sort results by NAME, TAXONOMIC, INDEX_NAME_ID, NATIVE, or RELEVANCE",
          :reverse => "sort in reverse order",
          :offset => "Offset for pagination",
          :limit => "Limit for pagination",
          :verbose => "Print headers to STDOUT",
        },
        examples: [
          "Colrapi.nameusage_search(q: @name)",
          "Colrapi.nameusage_search(q: @name, offset: 2, limit: 1)",
          "Colrapi.nameusage_search(q: 'Atta', rank: 'genus')",
        ],
      },
      :nameusage_suggest => {
        description: "Get a name usage suggestion",
        params: {
          :dataset_id => "restricts name usage search within a dataset",
          :q => "A suggestion search query",
          :fuzzy => "Whether to include fuzzy matches for misspellings (TODO: might not actually work?)",
          :min_rank => "The minimum rank to suggest",
          :max_rank => "The maximum rank to suggest",
          :sort_by => "The sorting order (name, taxonomic, index_name_id, native, relevance)",
          :reverse => "Sort in opposite order",
          :accepted => "Suggest only accepted names",
          :verbose => "Print headers to STDOUT",
        },
        examples: [
          "Colrapi.nameusage_suggest(@col_ac22, 'Alces alc', max_rank: 'subspecies', limit: 1)",
        ],
      },
      :nidx => {
        description: "Get names index info",
        params: {
          :nidx_id => "a names index ID",
          :subresource => "the subresource (group)",
        },
        examples: [
          "Colrapi.nidx(1)",
          "Colrapi.nidx(1, subresource: 'group')",
        ],
      },
      :nidx_match => {
        description: "Get names index matches",
        params: {
          :q => "A match query",
          :authorship => "An authorship string",
          :rank => "The taxonomic rank",
          :code => "The nomenclatural code",
          :verbose => "Print headers to STDOUT",
        },
        examples: [
          "Colrapi.nidx_match('Alces alces')",
        ],
      },
      :parser => {
        description: "Parse a {subresource}",
        params: {
          :subresource => "the type of parser to use",
          :q => "a query string or array of query strings to parse",
        },
        examples: [
          "Colrapi.parser(subresource: 'boolean', q: 'TRUE')",
          "Colrapi.parser(subresource: 'country',\n                           q: %w[Canada DEU Mexico])",
          "Colrapi.parser(subresource: 'datasettype', q: 'taxonomic')",
        ],
      },
      :parser_idconverter => {
        description: "Encode or decode identifiers to different formats (e.g., proquints are used as stable identifiers in ChecklistBank)",
        params: {
          :mode => "encode or decode",
          :id => "the identifier to convert",
          :format => "the format (proquint, hex, latin29, latin32, latin36, base64)",
          :verbose => "Print headers to STDOUT",
        },
        examples: [
          "Colrapi.parser_idconverter('encode', @int, 'proquint')",
          "Colrapi.parser_idconverter('decode', @proquint, 'integer')",
        ],
      },
      :parser_metadata => {
        description: "Parse metadata",
        params: {
          :url => "The url to a metadata file",
          :format => "The format of the metadata (yaml, json, eml, datacite, zenodo)",
          :verbose => "Print headers to STDOUT",
        },
        examples: [
          "Colrapi.parser_metadata('https://api.checklistbank.org/dataset/1027.yaml', format: 'yaml')",
        ],
      },
      :parser_name => {
        description: "Parse a scientific name",
        params: {
          :name => "The scientific name to parse",
          :authorship => "The authorship string for the scientific name",
          :rank => "The rank of the scientific name to parse",
          :code => "The nomenclatural code (bacterial, botanical, cultivars, phytosociological, virus, zoological)",
        },
        examples: [
          "Colrapi.parser_name('Acalypha macrostachya Jacq.')",
          "Colrapi.parser_name()",
          "Colrapi.parser_name(name)",
        ],
      },
      :patch => {
        description: "Get metadata patch",
        params: {
          :dataset_id => "The dataset id",
          :token => "The authentication token from retrieved with Colrapi.user_login(user, password)",
        },
        examples: [
          "Colrapi.patch(@dataset_id)",
          "Colrapi.patch(@dataset_id, patch_id: @patch_id)",
        ],
      },
      :preview => {
        description: "Get the latest preview release metadata (or points to the project draft dataset after the preview is released?)",
        params: {
          :project_id => "The project id",
          :token => "The authentication token from retrieved with Colrapi.user_login(user, password)",
          :verbose => "Print headers to STDOUT",
        },
        examples: [
          "Colrapi.preview(@project_id, @token)",
        ],
      },
      :reference => {
        description: "Get a reference with @reference_id from dataset @dataset_id via the reference route",
        params: {
          :dataset_id => "The dataset id",
          :reference_id => "The reference id",
          :subresource => "The reference subresource endpoint (orphans)",
          :issue => "The data quality issue (https://api.checklistbank.org/vocab/issue)",
          :offset => "Offset for pagination",
          :limit => "Limit for pagination",
          :verbose => "Print headers to STDOUT",
        },
        examples: [
          "Colrapi.reference(@dataset_id)",
          "Colrapi.reference(@dataset_id, offset: 3838, limit: 2)",
          "Colrapi.reference(@dataset_id, reference_id: @reference_id)",
        ],
      },
      :reviewer => {
        description: "Get reviewer info",
        params: {
          :dataset_id => "The dataset id",
          :token => "The authentication token from retrieved with Colrapi.user_login(user, password) # @return [Array, Hash, Boolean] An array of hashes",
        },
        examples: [],
      },
      :sector => {
        description: "Get sector metadata, which allows importing datasets into project subtrees",
        params: {
          :dataset_id => "The dataset id",
          :sector_id => "The sector id",
          :name => "The scientific name to query",
          :rank => "The rank of the scientific name",
          :modified_by => "Filter by a user id  on last modified by",
          :broken => "Whether the decision is broken or not",
          :subject_dataset_id => "The source dataset id",
          :last_synced_before => "Filter by sectors synced before this date",
          :mode => "Filter by type of sector (attach, union, merge)",
          :subject => "TODO: what does this do? All decisions with subject=true are bare names, so maybe it checks if the subject taxon exists?",
          :min_size => "The minimum number of records in the sector",
          :without_data => "Filters to empty sectors with no data synced into the project yet",
          :offset => "Offset for pagination",
          :limit => "Limit for pagination",
          :verbose => "Print headers to STDOUT",
        },
        examples: [
          "Colrapi.sector(@dataset_id)",
          "Colrapi.sector(@dataset_id, offset: 11, limit: 5)",
          "Colrapi.sector(@dataset_id, sector_id: 1756)",
        ],
      },
      :sector_sync => {
        description: "Get sector sync info",
        params: {
          :dataset_id => "The dataset id",
          :sector_id => "The sector id",
          :state => "The sector sync state (e.g., waiting, processing, inserting, indexing, finished, etc.)",
          :running => "Filter to sector syncs that are only running",
          :attempt => "The sync attempt number for sector_id",
          :subresource => "The subresource for attempt (names or tree)",
          :offset => "Offset for pagination",
          :limit => "Limit for pagination",
          :verbose => "Print headers to STDOUT",
        },
        examples: [
          "Colrapi.sector_sync(@col_draft)",
          "Colrapi.sector_sync(@col_draft, sector_id: res['result'][0]['sectorKey'])",
          "Colrapi.sector_sync(@col_draft, sector_id: sector_id, attempt: attempt, subresource: 'names')",
        ],
      },
      :source => {
        description: "Get source metadata for datasets assembled into a project dataset",
        params: {
          :dataset_id => "The project dataset id",
          :source_id => "The source dataset id",
          :not_current_only => "Return only not current sources",
          :original => "TODO: what does this do?",
        },
        examples: [
          "Colrapi.source('9837')",
          "Colrapi.source('9837', not_current_only: true)",
          "Colrapi.source('9837', source_id: '1027')",
        ],
      },
      :settings => {
        description: "Get the dataset settings",
        params: {
          :dataset_id => "The dataset id",
        },
        examples: [
          "Colrapi.settings('1021')",
        ],
      },
      :synonym => {
        description: "Get a synonym with @synonym_id from dataset @dataset_id via the synonym route",
        params: {
          :dataset_id => "The dataset id",
          :synonym_id => "The synonym id",
          :subresource => "The synonym subresource endpoint (source)",
          :offset => "Offset for pagination",
          :limit => "Limit for pagination",
          :verbose => "Print headers to STDOUT",
        },
        examples: [
          "Colrapi.synonym(@dataset_id)",
          "Colrapi.synonym(@dataset_id, offset: 3893, limit: 4)",
          "Colrapi.synonym(@dataset_id, synonym_id: @synonym_id)",
        ],
      },
      :taxon_ids => {
        description: "Get the full list of taxon IDs for a dataset (returns 1 ID string per line, not JSON)",
        params: {
          :dataset_id => "The dataset id",
        },
        examples: [
          "Colrapi.taxon_ids(@dataset_id)",
        ],
      },
      :taxon => {
        description: "Get a taxon with @id from dataset @dataset_id via the taxon route",
        params: {
          :dataset_id => "The dataset id",
          :taxon_id => "The taxon id",
          :subresource => "The taxon subresource endpoint (classification, distribution, info, interaction, media,   relation, source, synonyms, treatment, or vernacular)",
          :format => "The format of the treatment (plain_text, markdown, xml, html, tax_pub, taxon_x, rdf)",
          :offset => "Offset for pagination",
          :limit => "Limit for pagination",
          :verbose => "Print headers to STDOUT",
        },
        examples: [
          "Colrapi.taxon(@dataset_id, taxon_id: @taxon_id)",
          "Colrapi.taxon(@dataset_id, offset: 3483, limit: 1)",
          "Colrapi.taxon(@dataset_id, taxon_id: @taxon_id, subresource: 'classification')",
        ],
      },
      :tree => {
        description: "Get the root taxa",
        params: {
          :dataset_id => "The dataset id",
          :taxon_id => "The taxon id",
          :children => "Display the children of taxon_id",
          :offset => "Offset for pagination",
          :limit => "Limit for pagination",
          :verbose => "Print headers to STDOUT",
        },
        examples: [
          "tree(@dataset_id, import_attempt: @import_attempt)",
          "Colrapi.tree(@dataset_id)",
          "Colrapi.tree(@dataset_id, taxon_id: 'N', children: true, offset: 3, limit: 5)",
        ],
      },
      :user => {
        description: "Get user data",
        params: {
          :user_id => "The user id",
          :q => "The search query",
          :role => "The user role (admin, editor, or reviewer)",
          :offset => "Offset for pagination",
          :limit => "Limit for pagination",
          :token => "The authentication token from retrieved with Colrapi.user_login(user, password)",
          :verbose => "Print headers to STDOUT",
        },
        examples: [
          "Colrapi.user(q: @user, token: @token)",
          "Colrapi.user(user_id: @user_id)",
        ],
      },
      :user_dataset => {
        description: "Get datasets user can access",
        params: {
          :token => "The access token from Colrapi.user_login()",
          :dataset_id => "A dataset id to check",
          :origin => "Filter by the origin of a dataset (external, project, release, xrelease)",
        },
        examples: [],
      },
      :user_login => {
        description: "Authenticate user and get authentication token",
        params: {},
        examples: [
          "Colrapi.user_login(@user, @password)",
        ],
      },
      :user_me => {
        description: "Get the authenticated user",
        params: {
          :token => "The authentication token from retrieved with Colrapi.user_login(user, password)",
          :verbose => "Print headers to STDOUT",
        },
        examples: [
          "Colrapi.user_me(@token)",
        ],
      },
      :verbatim => {
        description: "Get verbatim data",
        params: {
          :dataset_id => "The dataset id",
          :verbatim_id => "The verbatim id",
          :q => "The search query string",
          :issue => "Filter by data quality issue (e.g., ACCEPTED_NAME_MISSING, DUPLICATE_NAME, URL_INVALID)",
          :type => "The file type (e.g., acef:AcceptedSpecies, col:Taxon, dwc:Taxon) TODO: May not work yet: https://github.com/CatalogueOfLife/backend/issues/1201   @param term [Array, String] Filter by term (http://api.checklistbank.org/vocab/term)   @param term_operator [String] The operator to use with term ('and' or 'or')",
          :offset => "Offset for pagination",
          :limit => "Limit for pagination",
          :verbose => "Print headers to STDOUT",
        },
        examples: [
          "Colrapi.verbatim(@dataset_id)",
          "Colrapi.verbatim(@dataset_id, offset: 5, limit: 2)",
          "Colrapi.verbatim(@dataset_id, verbatim_id: '4')",
        ],
      },
      :vernacular => {
        description: "Get vernacular names",
        params: {
          :dataset_id => "The dataset id",
          :q => "A vernacular name search query",
          :language => "The language of the vernacular name (see: http://api.checklistbank.org/vocab/language)",
          :offset => "Offset for pagination",
          :limit => "Limit for pagination",
          :verbose => "Print headers to STDOUT",
        },
        examples: [
          "Colrapi.vernacular(offset: 5, limit: 4)",
          "Colrapi.vernacular(dataset_id: @col_ac22)",
          "Colrapi.vernacular(dataset_id: @col_ac22, offset: 8, limit: 6)",
        ],
      },
      :version => {
        description: "Get backend version",
        params: {},
        examples: [],
      },
      :vocab => {
        description: "Get vocab",
        params: {
          :term => "The vocab term",
          :subresource => "The subresource which is usually the id, code, or name",
          :children => "Returns the geotime's children if true",
          :verbose => "Print headers to STDOUT",
        },
        examples: [
          "Colrapi.vocab(term: 'issue')",
          "Colrapi.vocab(term: 'geotime')",
          "Colrapi.vocab(term: 'geotime', subresource: 'Jurassic')",
        ],
      },
    },
  },
  :crawlyflower => {
    description: "Wrapper for WoRMS API - access World Register of Marine Species data",
    api: "https://www.marinespecies.org/rest/",
    endpoints: {
      :children => {
        description: "Get the direct children (max. 50) for a given AphiaID",
        params: {
          :id => "The AphiaID to search for",
          :marine_only => "Limit to marine taxa. Default: true",
          :extant_only => "Limit to extant taxa. Default: true",
          :offset => "Starting record number. Default: 1",
        },
        examples: [
          "Crawlyflower.children(126132)",
        ],
      },
      :classification => {
        description: "Get the complete classification for one taxon",
        params: {
          :id => "The AphiaID to search for",
        },
        examples: [
          "Crawlyflower.classification(127160)",
        ],
      },
      :distributions => {
        description: "Get all distributions for a given AphiaID",
        params: {
          :id => "The AphiaID to search for",
        },
        examples: [
          "Crawlyflower.distributions(127160)",
        ],
      },
      :external_id => {
        description: "Get any external identifier(s) for a given AphiaID",
        params: {
          :id => "The AphiaID to search for",
          :type => "Type of external identifier (algaebase, bold, dyntaxa, fishbase, iucn, lsid, ncbi, tsn, gisd)",
        },
        examples: [
          "Crawlyflower.external_id(127160, type: \"tsn\")",
          "external_id(\"173002\", type: \"tsn\")",
        ],
      },
      :aphia_id_by_name => {
        description: "Get the AphiaID for a given name",
        params: {
          :name => "Name to search for",
          :marine_only => "Limit to marine taxa. Default: true",
          :extant_only => "Limit to extant taxa. Default: true",
        },
        examples: [
          "Crawlyflower.aphia_id_by_name(\"Solea solea\")",
        ],
      },
      :name => {
        description: "Get the name for a given AphiaID",
        params: {
          :id => "The AphiaID to search for",
        },
        examples: [
          "name(\"Species\")",
          "Crawlyflower.name(127160)",
          "name(\"Solea solea\")",
        ],
      },
      :record => {
        description: "Get the complete AphiaRecord for a given AphiaID",
        params: {
          :id => "The AphiaID to search for",
        },
        examples: [
          "Crawlyflower.record(127160)",
          "record(127160)",
          "record(127160, format: :turtle)",
        ],
      },
      :records_by_aphia_ids => {
        description: "Get AphiaRecords for multiple AphiaIDs in one go (max: 50)",
        params: {
          :ids => "The AphiaIDs to search for",
        },
        examples: [
          "Crawlyflower.records_by_aphia_ids([127160, 126436])",
        ],
      },
      :record_by_external_id => {
        description: "Get the Aphia Record for a given external identifier",
        params: {
          :id => "The external identifier to search for",
          :type => "Type of external identifier (algaebase, bold, dyntaxa, fishbase, iucn, lsid, ncbi, tsn, gisd)",
        },
        examples: [
          "Crawlyflower.record_by_external_id(\"173002\", type: \"tsn\")",
        ],
      },
      :records_by_date => {
        description: "Lists all AphiaRecords that have their last edit action during the specified period",
        params: {
          :startdate => "ISO 8601 formatted start date(time)",
          :enddate => "ISO 8601 formatted end date(time)",
          :marine_only => "Limit to marine taxa",
          :extant_only => "Limit to extant taxa",
          :offset => "Starting record number. Default: 1",
        },
        examples: [],
      },
      :records_by_match_names => {
        description: "Try to find AphiaRecords using the TAXAMATCH fuzzy matching algorithm",
        params: {
          :scientificnames => "Names to search for",
          :authorships => "The authorities of the given names",
          :marine_only => "Limit to marine taxa",
          :extant_only => "Limit to extant taxa",
          :match_authority => "Use the authority in the matching process",
        },
        examples: [
          "Crawlyflower.records_by_match_names(scientificnames: [\"Solea solea\"])",
        ],
      },
      :records_by_name => {
        description: "Get one or more matching (max. 50) AphiaRecords for a given name",
        params: {
          :name => "Name to search for",
          :like => "Add a '%'-sign after the ScientificName. Default: true",
          :marine_only => "Limit to marine taxa",
          :extant_only => "Limit to extant taxa",
          :offset => "Starting record number. Default: 1",
        },
        examples: [
          "Crawlyflower.records_by_name(\"Solea solea\")",
        ],
      },
      :records_by_names => {
        description: "For each given scientific name, try to find one or more AphiaRecords (max 500 names)",
        params: {
          :scientificnames => "Names to search for",
          :like => "Add a '%'-sign after the ScientificName. Default: false",
          :marine_only => "Limit to marine taxa",
          :extant_only => "Limit to extant taxa",
        },
        examples: [
          "Crawlyflower.records_by_names(scientificnames: [\"Solea solea\", \"Gadus morhua\"])",
        ],
      },
      :records_by_vernacular => {
        description: "Get one or more Aphia Records (max. 50) for a given vernacular",
        params: {
          :name => "The vernacular to find records for",
          :like => "Add a '%'-sign before and after the input. Default: false",
          :offset => "Starting record number. Default: 1",
        },
        examples: [
          "Crawlyflower.records_by_vernacular(\"common sole\")",
        ],
      },
      :synonyms => {
        description: "Get all synonyms for a given AphiaID",
        params: {
          :id => "The AphiaID to search for",
          :offset => "Starting record number. Default: 1",
        },
        examples: [
          "Crawlyflower.synonyms(127160)",
        ],
      },
      :vernaculars => {
        description: "Get all vernaculars for a given AphiaID",
        params: {
          :id => "The AphiaID to search for",
        },
        examples: [
          "Crawlyflower.vernaculars(127160)",
        ],
      },
      :sources => {
        description: "Get one or more sources/references including links, for one AphiaID",
        params: {
          :id => "The AphiaID to search for",
        },
        examples: [
          "Crawlyflower.sources(127160)",
        ],
      },
      :taxon_ranks_by_id => {
        description: "Get taxonomic ranks by their identifier",
        params: {
          :id => "A taxonomic rank identifier. Default: -1",
          :aphia_id => "The AphiaID of the kingdom",
        },
        examples: [
          "Crawlyflower.taxon_ranks_by_id(-1)",
        ],
      },
      :taxon_ranks_by_name => {
        description: "Get taxonomic ranks by their name",
        params: {
          :name => "A taxonomic rank name",
          :aphia_id => "The AphiaID of the kingdom",
        },
        examples: [
          "Crawlyflower.taxon_ranks_by_name(\"Species\")",
        ],
      },
      :records_by_taxon_rank_id => {
        description: "Get the AphiaRecords for a given taxonRankID (max 50)",
        params: {
          :id => "A taxonomic rank identifier",
          :belongs_to => "Limit the results to descendants of the given AphiaID",
          :offset => "Starting record number. Default: 1",
        },
        examples: [
          "Crawlyflower.records_by_taxon_rank_id(220, belongs_to: 126132)",
        ],
      },
      :full_record => {
        description: "Get the complete AphiaFullRecord (linked open data) for a given AphiaID",
        params: {
          :id => "The AphiaID to search for",
          :format => "Response format: :jsonld (default), :rdf, :turtle, :ntriples",
        },
        examples: [
          "Crawlyflower.full_record(127160)",
          "Crawlyflower.full_record(127160, format: :turtle)",
          "Crawlyflower.full_record(127160, format: :rdf)",
        ],
      },
      :attribute_keys => {
        description: "Get attribute definitions",
        params: {
          :id => "The attribute definition id to search for. Use 0 for root items",
          :include_children => "Include the tree of children. Default: true",
        },
        examples: [
          "Crawlyflower.attribute_keys(0)",
        ],
      },
      :attribute_values_by_category => {
        description: "Get list values that are grouped by a CategoryID",
        params: {
          :id => "The CategoryID to search for",
        },
        examples: [],
      },
      :aphia_ids_by_attribute_key => {
        description: "Get a list of AphiaIDs (max 50) with attribute tree for a given attribute definition ID",
        params: {
          :id => "The attribute definition id to search for",
          :offset => "Starting record number. Default: 1",
        },
        examples: [],
      },
      :attributes => {
        description: "Get a list of attributes for a given AphiaID",
        params: {
          :id => "The AphiaID to search for",
          :include_inherited => "Include attributes inherited from parent(s). Default: false",
        },
        examples: [
          "Crawlyflower.attributes(127160)",
        ],
      },
      :suggest => {
        description: "Get taxa suggestions for a given prefix of a taxon name",
        params: {
          :name_part => "The prefix to use to search for taxa",
          :rank_min => "The minimum rank of the returned suggestion. Default: 10",
          :rank_max => "The maximum rank of the returned suggestion. Default: 280",
          :max_matches => "The maximum number of suggestions to return. Default: 20, Max: 50",
          :excluded_ids => "AphiaIDs to exclude from the result set",
          :combine_vernaculars => "When true the name can also match vernaculars. Default: false",
          :marine_only => "Limit to marine taxa. Default: true",
          :fossil_id => "Determines the search behavior for fossil taxa. Default: 0",
          :languages => "List of ISO 639-3 language codes to filter search results",
        },
        examples: [
          "Crawlyflower.suggest(\"Solea\")",
        ],
      },
    },
  },
  :hookkaido => {
    description: "Wrapper for OWL Ontology API - access biodiversity ontology data",
    api: "https://www.ontobee.org",
    endpoints: {
      :ontologies => {
        description: "List available ontology IDs (lowercased)",
        params: {},
        examples: [],
      },
      :search => {
        description: "Search OLS for terms in specific ontologies matching a user-provided term.",
        params: {},
        examples: [],
      },
    },
  },
  :nasturtium => {
    description: "Wrapper for iNaturalist API - access species observations and biodiversity data",
    api: "https://api.inaturalist.org/v1",
    endpoints: {
      :controlled_terms => {
        description: "Get controlled vocabulary terms",
        params: {
          :taxon_id => "If set returns controlled terms for the taxon",
          :page => "The results page number",
          :per_page => "The results limit",
          :verbose => "Print headers to STDOUT",
        },
        examples: [
          "Nasturtium.controlled_terms(per_page: @per_page)",
          "Nasturtium.controlled_terms(taxon_id: 1, per_page: @per_page)",
        ],
      },
      :identifications => {
        description: "Get identifications",
        params: {
          :id => "An array of identification IDs",
          :current_taxon => "The identification taxon is the same as its observation's taxon",
          :own_observation => "The identification was added by th observer",
          :is_change => "The identification was created as a result of a taxon change",
          :taxon_active => "The identification's taxon is currently an active taxon",
          :observation_taxon_active => "The observation's taxon is currently an active taxon",
          :rank => "Filter by a comma-separated list of taxonomic ranks on the identification",
          :observation_rank => "Filter by a comma-separated list of taxonomic ranks on the observation",
          :user_id => "Filter by a comma-separated list of user IDs",
          :user_login => "Filter by a comma-separated list of user logins",
          :current => "The most recent identification on an observation by a user",
          :category => "The type of identification (improving, supporting, leading)",
          :place_id => "Filter by a comma-separated list of place IDs",
          :quality_grade => "Filter by a comma-separated list of quality grades (casual, needs_id, research)",
          :taxon_id => "Filter by a comma-separated list of taxon IDs on the identification",
          :observation_taxon_id => "Filter by a comma-separated list of taxon IDs on the observation",
          :iconic_taxon_id => "Filter by a comma-separated list of iconic taxon IDs on the identification",
          :observation_iconic_taxon_id => "Filter by a comma-separated list of iconic taxon IDs on the observation",
          :rank_lowest => "The identification's taxon must have this rank or higher",
          :rank_highest => "The identification's taxon must have this rank or lower",
          :observation_rank_lowest => "The observation's taxon must have this rank or higher",
          :observation_rank_highest => "The observation's taxon must have this rank or lower",
          :without_taxon_id => "Exclude this comma-separated list of identification taxon IDs and their descendants",
          :without_observation_taxon_id => "Exclude this comma-separated list of observation taxon IDs and their descendants",
          :before => "Identified before this time (d2)",
          :after => "Identified after this time (d1)",
          :observation_created_before => "Observation record was created before this time (observation_created_d2)",
          :observation_created_after => "Observation record was created after this time (observation_created_d1)",
          :observed_before => "Observed before this time (observed_d2)",
          :observed_after => "Observed after this time (observed_d1)",
          :id_below => "The identification ID must be below the provided value",
          :id_above => "The identification ID must be above the provided value",
          :only_id => "Only return record IDs",
          :order => "Ascending or descending sort order (asc, desc)",
          :order_by => "The parameter to sort by (created_at, id)",
          :page => "The results page number",
          :per_page => "The results limit",
          :verbose => "Print headers to STDOUT",
        },
        examples: [
          "Nasturtium.identifications(id: 342040114, per_page: @per_page)",
          "Nasturtium.identifications(current_taxon: true, per_page: @per_page)",
          "Nasturtium.identifications(current_taxon: false, per_page: @per_page)",
        ],
      },
      :mapping => {
        description: "Get map tiling assets for observations",
        params: {},
        examples: [],
      },
      :places_id => {
        description: "Get places",
        params: {
          :id => "A comma-separated list of place IDs",
          :admin_level => "A comma-separated list of admin levels (-10: continent, 0: country, 10: state, 20: county, 30: town, 100: park)",
        },
        examples: [
          "Nasturtium.places_id(1000)",
          "Nasturtium.places_id(1000, admin_level: 100)",
          "Nasturtium.places_id(r['place_id'])",
        ],
      },
      :places_autocomplete => {
        description: "Suggest places",
        params: {
          :q => "A place name must start with this query",
          :order_by => "The parameter to sort by (area)  # TODO: iNaturalist bug? doesn't seem to affect sorting in the API?",
          :per_page => "The results limit",
          :verbose => "Print headers to STDOUT",
        },
        examples: [
          "Nasturtium.places_autocomplete('Kickapoo Rail Trail')",
          "Nasturtium.places_autocomplete('The')",
        ],
      },
      :places_nearby => {
        description: "https://api.inaturalist.org/v1/places/nearby?nelat=40.346036&nelng=-87.951568&swlat=39.935393&swlng=-88.628846",
        params: {
          :ne_latitude => "Get nearby places within provided (nelat) bounding box (ne_latitude, ne_longitude, sw_latitude, sw_longitude)",
          :ne_longitude => "Get nearby places within provided (nelng) bounding box (ne_latitude, ne_longitude, sw_latitude, sw_longitude)",
          :sw_latitude => "Get nearby places within provided (swlat) bounding box (ne_latitude, ne_longitude, sw_latitude, sw_longitude)",
          :sw_longitude => "Get nearby places within provided (swlng) bounding box (ne_latitude, ne_longitude, sw_latitude, sw_longitude)",
          :name => "Place name must match this value  # TODO: iNaturalist bug? you can't provide the last word of a name (e.g., River Bend Forest works, but River Bend Forest Preserve doesn't work)",
          :per_page => "The results limit",
          :verbose => "Print headers to STDOUT",
        },
        examples: [
          "Nasturtium.places_nearby(@ne_lat, @ne_lng, @sw_lat, @sw_lng)",
          "Nasturtium.places_nearby(@ne_lat, @ne_lng, @sw_lat, @sw_lng, name: \"Meadowbrook\")",
        ],
      },
      :posts => {
        description: "Get journal posts",
        params: {
          :login => "Filter by user login",
          :project_id => "Filter by project ID",
          :parent_id => "Filter by parent ID",
          :page => "",
          :per_page => "",
          :verbose => "Print headers to STDOUT",
        },
        examples: [
          "Nasturtium.posts(login: 'loarie', per_page: @per_page)",
          "Nasturtium.posts(parent_id: 1)",
          "Nasturtium.posts(project_id: 42768)",
        ],
      },
      :projects => {
        description: "TODO: Add tests",
        params: {
          :q => "Project name must begin with query string",
          :autocomplete => "Returns projects that start with the search q",
          :id => "Project must have this ID",
          :not_id => "Project must not have this ID",
          :latitude => "Filter by projects within a {radius} kilometer circle around the provided latitude coordinate (lat)",
          :longitude => "Filter by projects within a {radius} kilometer circle around the provided longitude coordinate (lng)",
          :radius => "Filter by projects within the provided radius in kilometers",
          :place_id => "Filter by a comma-separated list of place_ids",
          :featured => "Filter by marked featured for the relevant site",
          :noteworthy => "Filter by marked noteworthy for the relevant site",
          :site_id => "The site ID that applies to featured and noteworthy, defaults to site of the authenticated user or the main iNaturalist site",
          :rule_details => "Return more details about the project rules",
          :type => "Filter by project type [collection, umbrella]",
          :member_id => "Filter by projects that include a user ID",
          :has_params => "Must have search parameter requirements",
          :has_posts => "Project must have posts",
          :page => "The results page number",
          :per_page => "The results limit",
          :order_by => "The parameter to sort by (observed_on, species_guess, votes, id, created_at)",
          :verbose => "Print headers to STDOUT",
        },
        examples: [
          "Nasturtium.projects(id: '67047', per_page: @per_page)",
          "Nasturtium.projects(latitude: 41.295233, longitude: -89.024618, radius: 1, per_page: @per_page)",
          "Nasturtium.projects(place_id: 35, per_page: @per_page)",
        ],
      },
      :project_members => {
        description: "Get project members",
        params: {
          :id => "The project ID",
          :page => "The results page number",
          :per_page => "The results limit",
          :verbose => "Print headers to STDOUT",
        },
        examples: [
          "Nasturtium.project_members(733, page: 1, per_page: @per_page)",
        ],
      },
      :search => {
        description: "Search places, projects, taxa, users",
        params: {
          :q => "A search query",
          :sources => "Type of record to search (places, projects, taxa, users)",
          :place_id => "Filter to an array of place_ids (TODO: place_id is an array in the documentation but doesn't seem to work even with their example?)",
          :preferred_place_id => "Place of preference for regional taxon common names",
          :locale => "Locale preference for taxon common names (e.g., en-US)",
          :page => "The results page number",
          :per_page => "The results limit",
          :verbose => "Print headers to STDOUT",
        },
        examples: [
          "Nasturtium.search(q: 'oak', sources: 'taxa')",
          "Nasturtium.search(q: 'oak', place_id: '35')",
          "Nasturtium.search(q: 'Danaus plexippus', preferred_place_id: 6903)",
        ],
      },
      :user => {
        description: "Get user",
        params: {
          :id => "The user ID",
          :verbose => "Print headers to STDOUT",
        },
        examples: [
          "Nasturtium.user(@id)",
        ],
      },
      :user_me => {
        description: "Get logged in user",
        params: {
          :id => "The user ID",
          :verbose => "Print headers to STDOUT",
        },
        examples: [
          "Nasturtium.user_me()",
        ],
      },
      :user_projects => {
        description: "Get user's projects",
        params: {
          :id => "The user ID",
          :rule_details => "Return more details about project rules",
          :project_type => "Filter by project type (collection, contest, traditional, umbrella)",
          :page => "The results page number",
          :per_page => "The results limit",
          :verbose => "Print headers to STDOUT",
        },
        examples: [
          "Nasturtium.user_projects(@id)",
          "Nasturtium.user_projects(@id, project_type: 'collection')",
          "Nasturtium.user_projects(@id, per_page: 1, page: 2)",
        ],
      },
      :user_autocomplete => {
        description: "Get user suggestions",
        params: {
          :q => "The username must begin with this query",
          :project_id => "Only show members of this project ID",
          :per_page => "The results limit",
          :verbose => "Print headers to STDOUT",
        },
        examples: [
          "Nasturtium.user_autocomplete('debpau')",
          "Nasturtium.user_autocomplete('ab', per_page: 1)",
        ],
      },
      :observations => {
        description: "Get observations",
        params: {
          :subresource => "Access a subresource endpoint of observations (histogram, identifiers, observers, popular_field_values, species_counts)",
          :q => "An observation properties search query",
          :search_on => "Observation properties to search on (names, tags, description, place)",
          :id => "A comma-separated list of observation IDs",
          :not_id => "A comma-separated list of observation IDs that must not be included",
          :acc => "Filter by whether the positional accuracy/coordinate uncertainty was specified",
          :captive => "Filter on whether it was captive/cultivated observations",
          :endemic => "Filter on whether observations were of taxa endemic to their location",
          :geo => "Filter to only georeferenced observations",
          :identified => "Filter to only observations with community identifications",
          :introduced => "Filter to observations of taxa that were introduced to their location",
          :mappable => "Filter to only observations that show on map tiles",
          :native => "Filter to only observations of taxa native tot heir location",
          :out_of_range => "Filter to only observations made in locations outside the taxon's known ranges",
          :pcid => "Filter to observations identified by a curator of a project",
          :photos => "Filter to observations with photos",
          :popular => "Filter to only observations that have been favorited by at least 1 user",
          :sounds => "Filter to observations with sounds",
          :taxon_is_active => "Filter to observations of active taxon concepts",
          :threatened => "Filter to observations of taxa that are threatened at their location",
          :verifiable => "Filter by observations with a quality_grade=needs_id,research",
          :licensed => "Filter by observations with a license",
          :photo_licensed => "License attribute of at least one photo in an observation must not be nil",
          :license => "Filter by a comma-separated list of licenses (cc-by,cc-by-nc,cc-by-nd,cc-by-sa,cc-by-nc-nd,cc-by-nc-sa,cc0)",
          :photo_license => "Filter by a comma-separated list of photo licenses (cc-by,cc-by-nc,cc-by-nd,cc-by-sa,cc-by-nc-nd,cc-by-nc-sa,cc0)",
          :sound_license => "Filter by a comma-separated list of sound licenses (cc-by,cc-by-nc,cc-by-nd,cc-by-sa,cc-by-nc-nd,cc-by-nc-sa,cc0)",
          :ofv_datatype => "Filter by a comma-separated list of datatypes that the observation must include  # TODO: does it take arrays?",
          :place_id => "Filter by a comma-separated list of place_ids",
          :project_id => "Filter by a comma-separated list of project_ids",
          :rank => "Filter by an array of taxon ranks",
          :site_id => "Filter by a comma-separated list of site_ids",
          :taxon_id => "Filter by a comma-separated list of taxon_ids and their descendants",
          :without_taxon_id => "Exclude a comma-separated list of taxon_ids and their descendants",
          :taxon_name => "Filter by a comma-separated list of scientific or common names",
          :user_id => "Filter by observations made by a comma-separated list of user_ids",
          :user_login => "Filter by a comma-separated list of user_logins",
          :ident_user_id => "Filter by observations identified by a particular user_id",
          :day => "Filter on a comma-separated list of days",
          :month => "Filter on a comma-separated list of months",
          :year => "Filter on a comma-separated list of years",
          :term_id => "Filter on a comma-separated list of term_ids",
          :without_term_id => "String, Integer, nil] Exclude on a comma-separated list of term_ids",
          :term_value_id => "Filter on annotations made with this controlled value ID; must be used with term_id",
          :without_term_value_id => "Exclude on annotations made with this controlled value ID",
          :acc_above => "Positional accuracy must be above value",
          :acc_below => "Positional accuracy must be below value",
          :acc_below_or_unknown => "Positional accuracy must be below value or unknown",
          :before => "Must have been observed on or before this date (d2)",
          :after => "Must have been observed on or after this date (d1)",
          :observed_on => "Must have been observed on this date",
          :created_before => "Must have been created on or before this date (created_d2)",
          :created_on => "Must have been created on this date",
          :created_after => "Must have been created on or before this date (created_d1)",
          :unobserved_by_user_id => "Taxon must be unobserved by the provided user_id",
          :apply_project_rules_for => "Must match rules of the provided project_id",
          :conservation_status => "Taxon must have this conservation status (cs) code, use with place_id to make location-specific",
          :conservation_status_authority => "Taxon must have the conservation status from the provided authority (csa), use with place_id to make location-specific",
          :conservation_status_iucn => "Taxon must have the provided conservation status from the IUCN, use with place_id to make location-specific",
          :geoprivacy => "Filter by a comma-separated list of geoprivacy settings (obscured, obscured_private, open)",
          :taxon_geoprivacy => "Filter by a comma-separated list of geoprivacy settings (obscured, obscured_private, open) of the most conservative geoprivacy associated with one of the taxa proposed in the current identifications",
          :rank_lowest => "Taxon rank must be less than or equal to provided rank",
          :rank_highest => "Taxon rank must be greater than or equal to provided rank",
          :iconic_taxa => "Filter by taxa with the provided iconic taxon (Actinopterygii, Animalia, Amphibia, Arachnida, Aves, Chromista, Fungi, Insecta, Mammalia, Mollusca, Repitilia, Plantae, Protozoa, unknown)",
          :id_below => "Most have an observation ID below the provided value",
          :id_above => "Most have an observation ID above the provided value",
          :identifications => "Filter by identifications status (most_agree, some_agree, most_disagree)",
          :latitude => "Filter by observations within a {radius} kilometer circle around the provided latitude coordinate (lat)",
          :longitude => "Filter by observations within a {radius} kilometer circle around the provided longitude coordinate (lng)",
          :radius => "Filter by observations within the provided radius in kilometers",
          :ne_latitude => "Filter by observations within provided (nelat) bounding box (ne_latitude, ne_longitude, sw_latitude, sw_longitude)",
          :ne_longitude => "Filter by observations within provided (nelng) bounding box (ne_latitude, ne_longitude, sw_latitude, sw_longitude)",
          :sw_latitude => "Filter by observations within provided (swlat) bounding box (ne_latitude, ne_longitude, sw_latitude, sw_longitude)",
          :sw_longitude => "Filter by observations within provided (swlng) bounding box (ne_latitude, ne_longitude, sw_latitude, sw_longitude)",
          :list_id => "Taxon must bin the list with the provided ID",
          :not_in_project => "Observation must not be in the provided project_id or slug",
          :not_matching_project_rules_for => "Must not match the rules of the provided project_id or slug",
          :quality_grade => "Filter by observation quality grade (casual, needs_id, research)",
          :updated_since => "Filter by observations updated since the provided time",
          :reviewed => "Observations have been reviewed by viewer_id",
          :viewer_id => "Use with reviewed boolean to filter by observations reviewed by the provided viewer_id",
          :locale => "Locale preference for taxon common names (e.g., en-US)",
          :preferred_place_id => "Place of preference for regional taxon common names",
          :ttl => "Set the Cache-Control HTTP header with a max-age value to cache the request on iNaturalist serers and within the client",
          :only_id => "Only return record IDs",
          :order => "Ascending or descending sort order (asc, desc)",
          :order_by => "The parameter to sort by (observed_on, species_guess, votes, id, created_at)",
          :page => "The results page number",
          :per_page => "The results limit",
          :headers => "Return headers instead of body",
          :verbose => "Print headers to STDOUT",
        },
        examples: [
          "Nasturtium.observations(id: '150842485')",
          "Nasturtium.observations(id_above: 1000, id_below: 2000, only_id: true)",
          "Nasturtium.observations(id_above: 1000, id_below: 2000, not_id: not_ids, only_id: true)",
        ],
      },
      :taxa => {
        description: "Taxon search",
        params: {
          :id => "A taxon ID or comma-separated array of taxon IDs",
          :q => "A search query",
          :is_active => "Filter to taxa with active taxon concepts",
          :taxon_id => "Filter by a comma-separated array of taxon_ids",
          :parent_id => "Filter by a taxon parent_id",
          :rank => "Filter by an array of taxon ranks",
          :rank_level => "Filter by taxon rank level (e.g., 70 for kingdom)",
          :id_above => "ID must be greater than value",
          :id_below => "ID must be below value",
          :preferred_place_id => "Place of preference for regional taxon common names",
          :locale => "Locale preference for taxon common names (e.g., en-US)",
          :only_id => "Only return record IDs",
          :all_names => "Include all taxon names in the response",
          :order => "Ascending or descending sort order (asc, desc)",
          :order_by => "The parameter to sort by",
          :page => "The results page number",
          :per_page => "The results limit",
          :verbose => "Print headers to STDOUT",
        },
        examples: [
          "Nasturtium.taxa(only_id: true, per_page: @per_page)",
          "Nasturtium.taxa(id: 1)",
          "Nasturtium.taxa(parent_id: 1)",
        ],
      },
      :taxa_autocomplete => {
        description: "Taxon suggest",
        params: {
          :q => "A suggest query",
          :is_active => "Suggest only taxa with active taxon concepts",
          :taxon_id => "Filter by comma-separated taxon IDs",
          :rank => "Filter by an array of taxon ranks",
          :rank_level => "Filter by taxon rank level (e.g., 70 for kingdom)",
          :locale => "Locale preference for taxon common names (e.g., en-US)",
          :preferred_place_id => "Place of preference for regional taxon common names",
          :all_names => "Include all taxon names in the response",
          :per_page => "The results limit",
          :verbose => "Print headers to STDOUT",
        },
        examples: [
          "Nasturtium.taxa_autocomplete(q: 'Ladona ')",
          "Nasturtium.taxa_autocomplete(q: 'Sinapis', is_active: true, rank: 'species')",
          "Nasturtium.taxa_autocomplete(q: 'Sinapis', is_active: false, rank: 'species')",
        ],
      },
    },
  },
  :plazucchini => {
    description: "Wrapper for Plazi TreatmentBank API - access taxonomic treatments and species data",
    api: "https://api.plazi.org",
    endpoints: {
      :authors_described_species => {
        description: "Authors Described Species",
        params: {
          :author => "The author (default: \"Agosti, D\")",
          :limit => "The optional result limit",
          :order_mode => "The optional sort order (ASC, DESC, nil)",
          :verbose => "Print headers to STDOUT",
        },
        examples: [
          "Plazucchini.authors_described_species(author: 'Mockford, Edward L.', limit: 1)",
        ],
      },
      :authors_material_type_citations => {
        description: "Authors Material Type Citations",
        params: {
          :genus_epithet => "The genus epithet (default: \"Tyrannosaurus\")",
          :species_epithet => "The species epithet (default: \"rex\")",
          :limit => "The optional result limit",
          :order_mode => "The optional sort order (ASC, DESC, nil)",
          :verbose => "Print headers to STDOUT",
        },
        examples: [],
      },
      :authors_new_species => {
        description: "Authors New Species",
        params: {
          :author => "The author (required, default: \"Malabarba\")",
          :status => "The taxonomic status (default: \"sp. nov.\")",
          :limit => "The optional result limit",
          :order_mode => "The optional sort order (ASC, DESC, nil)",
          :verbose => "Print headers to STDOUT",
        },
        examples: [
          "Plazucchini.authors_new_species(author: 'Mockford', status: 'sp. nov.', limit: 1)",
        ],
      },
      :authors_publication_dates => {
        description: "Authors Publication Dates",
        params: {
          :author => "The author (default: \"Agosti, D\")",
          :limit => "The optional result limit",
          :order_mode => "The optional sort order (ASC, DESC, nil)",
          :verbose => "Print headers to STDOUT",
        },
        examples: [
          "Plazucchini.authors_publication_dates(author: 'Mockford', limit: 1)",
        ],
      },
      :authors_publication_journals => {
        description: "Authors Publication Journals",
        params: {
          :author => "The author (default: \"Agosti, D\")",
          :limit => "The optional result limit",
          :order_mode => "The optional sort order (ASC, DESC, nil)",
          :verbose => "Print headers to STDOUT",
        },
        examples: [
          "Plazucchini.authors_publication_journals(author: 'Mockford', limit: 1)",
        ],
      },
      :authors_publication_partners => {
        description: "Authors Publication Partners (Co-Authors)",
        params: {
          :author => "The author (default: \"Agosti, D\")",
          :limit => "The optional result limit",
          :order_mode => "The optional sort order (ASC, DESC, nil)",
          :verbose => "Print headers to STDOUT",
        },
        examples: [
          "Plazucchini.authors_publication_partners(author: 'Mockford', limit: 1)",
        ],
      },
      :authors_specimen_locations => {
        description: "Authors Specimen Locations",
        params: {
          :collector => "The collector (default: \"Agosti\")",
          :limit => "The optional result limit",
          :order_mode => "The optional sort order (ASC, DESC, nil)",
          :verbose => "Print headers to STDOUT",
        },
        examples: [
          "Plazucchini.authors_specimen_locations(collector: 'Mockford', limit: 1)",
        ],
      },
      :authors_treatment_count => {
        description: "Authors Treatment Count",
        params: {
          :author => "The author (required, default: \"Linnaeus\")",
          :limit => "The optional result limit",
          :order_mode => "The optional sort order (ASC, DESC, nil)",
          :verbose => "Print headers to STDOUT",
        },
        examples: [
          "Plazucchini.authors_treatment_count(author: 'Mockford', limit: 1)",
        ],
      },
      :contributors_material_citations => {
        description: "Contributors Liberated Material Citations",
        params: {
          :user => "The user that made the contribution (default: \"tatiana\")",
          :limit => "The optional result limit",
          :order_mode => "The optional sort order (ASC, DESC, nil)",
          :verbose => "Print headers to STDOUT",
        },
        examples: [
          "Plazucchini.contributors_material_citations(user: 'admin', limit: 1)",
        ],
      },
      :contributors_pages => {
        description: "Contributors Liberated Pages",
        params: {
          :user => "The user that made the contribution (default: \"tatiana\")",
          :limit => "The optional result limit",
          :order_mode => "The optional sort order (ASC, DESC, nil)",
          :verbose => "Print headers to STDOUT",
        },
        examples: [
          "Plazucchini.contributors_pages(user: 'admin', limit: 1)",
        ],
      },
      :contributors_publications => {
        description: "Contributors Liberated Publications",
        params: {
          :user => "The user that made the contribution (default: \"tatiana\")",
          :limit => "The optional result limit",
          :order_mode => "The optional sort order (ASC, DESC, nil)",
          :verbose => "Print headers to STDOUT",
        },
        examples: [
          "Plazucchini.contributors_publications(user: 'admin', limit: 1)",
        ],
      },
      :contributors_treatments => {
        description: "Contributors Liberated Treatments",
        params: {
          :user => "The user that made the contribution (default: \"tatiana\")",
          :limit => "The optional result limit",
          :order_mode => "The optional sort order (ASC, DESC, nil)",
          :verbose => "Print headers to STDOUT",
        },
        examples: [
          "Plazucchini.contributors_treatments(user: 'admin', limit: 1)",
        ],
      },
      :institutions_cited_materials => {
        description: "Institutions Cited Materials",
        params: {
          :collection_code => "The collection code (default: \"MNHN\")",
          :limit => "The optional result limit",
          :order_mode => "The optional sort order (ASC, DESC, nil)",
          :verbose => "Print headers to STDOUT",
        },
        examples: [
          "Plazucchini.institutions_cited_materials(collection_code: 'INHS', limit: 1)",
        ],
      },
      :institutions_distribution_range => {
        description: "Institutions Distribution Range",
        params: {
          :collection_code => "The collection code (default: \"MNHN\")",
          :limit => "The optional result limit",
          :order_mode => "The optional sort order (ASC, DESC, nil)",
          :verbose => "Print headers to STDOUT",
        },
        examples: [
          "Plazucchini.institutions_distribution_range(collection_code: 'INHS', limit: 1)",
        ],
      },
      :institutions_journal_occurrences => {
        description: "Institutions Journal Occurrences",
        params: {
          :collection_code => "The collection code (default: \"MNHN\")",
          :limit => "The optional result limit",
          :order_mode => "The optional sort order (ASC, DESC, nil)",
          :verbose => "Print headers to STDOUT",
        },
        examples: [
          "Plazucchini.institutions_journal_occurrences(collection_code: 'INHS', limit: 1)",
        ],
      },
      :institutions_specimens_stored => {
        description: "Institutions Specimens Stored",
        params: {
          :collection_code => "The collection code (default: MNHN)",
          :limit => "The optional result limit",
          :order_mode => "The optional sort order (ASC, DESC, nil)",
          :verbose => "Print headers to STDOUT",
        },
        examples: [
          "Plazucchini.institutions_specimens_stored(collection_code: 'INHS', limit: 1)",
        ],
      },
      :institutions_stored_types => {
        description: "Institutions Stored Types",
        params: {
          :collection_code => "The collection code (default: MNHN)",
          :limit => "The optional result limit",
          :order_mode => "The optional sort order (ASC, DESC, nil)",
          :verbose => "Print headers to STDOUT",
        },
        examples: [
          "Plazucchini.institutions_stored_types(collection_code: 'INHS', limit: 1)",
        ],
      },
      :journals_cited_collections => {
        description: "Journals Cited Collections",
        params: {
          :journal => "The journal name (default: Phytotaxa)",
          :limit => "The optional result limit",
          :order_mode => "The optional sort order (ASC, DESC, nil)",
          :verbose => "Print headers to STDOUT",
        },
        examples: [
          "Plazucchini.journals_cited_collections(journal: 'Zootaxa', limit: 1)",
        ],
      },
      :journals_published_figures_count => {
        description: "Journals Published Figures Count",
        params: {
          :journal => "The journal name (default: Zootaxa)",
          :limit => "The optional result limit",
          :order_mode => "The optional sort order (ASC, DESC, nil)",
          :verbose => "Print headers to STDOUT",
        },
        examples: [
          "Plazucchini.journals_published_figures_count(journal: 'Acarologia', limit: 1)",
        ],
      },
      :journals_published_material_distribution => {
        description: "Journals Published Material Distribution",
        params: {
          :journal => "The journal name (default: Phytotaxa)",
          :limit => "The optional result limit",
          :order_mode => "The optional sort order (ASC, DESC, nil)",
          :verbose => "Print headers to STDOUT",
        },
        examples: [
          "Plazucchini.journals_published_material_distribution(journal: 'Acarologia', limit: 1)",
        ],
      },
      :journals_published_new_species_count => {
        description: "Journals Published New Species Count",
        params: {
          :journal => "The journal name",
          :limit => "The optional result limit",
          :order_mode => "The optional sort order (ASC, DESC, nil)",
          :verbose => "Print headers to STDOUT",
        },
        examples: [
          "Plazucchini.journals_published_new_species_count(journal: 'Acarologia')",
        ],
      },
      :journals_published_page_count => {
        description: "Journals Published Page Count",
        params: {
          :journal => "The journal name (default: )",
          :limit => "The optional result limit",
          :order_mode => "The optional sort order (ASC, DESC, nil)",
          :verbose => "Print headers to STDOUT",
        },
        examples: [
          "Plazucchini.journals_published_page_count(journal: 'Acarologia')",
        ],
      },
      :journals_published_synonyms => {
        description: "Journals Published Synonyms Count",
        params: {
          :journal => "The journal name",
          :limit => "The optional result limit",
          :order_mode => "The optional sort order (ASC, DESC, nil)",
          :verbose => "Print headers to STDOUT",
        },
        examples: [
          "Plazucchini.journals_published_synonyms(journal: 'Acarologia')",
        ],
      },
      :journals_published_tables => {
        description: "Journals Published Tables Count",
        params: {
          :journal => "The journal name",
          :limit => "The optional result limit",
          :order_mode => "The optional sort order (ASC, DESC, nil)",
          :verbose => "Print headers to STDOUT",
        },
        examples: [
          "Plazucchini.journals_published_tables(journal: 'Acarologia')",
        ],
      },
      :journals_published_treatment_count => {
        description: "Journals Published Treatment Count",
        params: {
          :journal => "The journal name",
          :limit => "The optional result limit",
          :order_mode => "The optional sort order (ASC, DESC, nil)",
          :verbose => "Print headers to STDOUT",
        },
        examples: [
          "Plazucchini.journals_published_treatment_count(journal: 'Acarologia')",
        ],
      },
      :metrics_journal_data_count => {
        description: "Metrics Journal Data Count",
        params: {
          :limit => "The optional result limit",
          :order_mode => "The optional sort order (ASC, DESC, nil)",
          :verbose => "Print headers to STDOUT",
        },
        examples: [
          "Plazucchini.metrics_journal_data_count(limit: 1)",
        ],
      },
      :metrics_user_contribution_count => {
        description: "Metrics User Contribution Count",
        params: {
          :limit => "The optional result limit",
          :order_mode => "The optional sort order (ASC, DESC, nil)",
          :verbose => "Print headers to STDOUT",
        },
        examples: [
          "Plazucchini.metrics_user_contribution_count(limit: 1)",
        ],
      },
      :specimens_with_genes => {
        description: "Specimens With Genes",
        params: {
          :genus_epithet => "The genus (required, default: \"Exobasidium\")",
          :limit => "The optional result limit",
          :order_mode => "The optional sort order (ASC, DESC, nil)",
          :verbose => "Print headers to STDOUT",
        },
        examples: [
          "Plazucchini.specimens_with_genes(genus_epithet: 'Alces', limit: 1)",
        ],
      },
      :taxon_materials_citations => {
        description: "Taxon Materials Citations",
        params: {
          :genus_epithet => "The genus of the treatment",
          :species_epithet => "The species of the treatment",
          :limit => "The optional result limit",
          :order_mode => "The optional sort order (ASC, DESC, nil)",
          :verbose => "Print headers to STDOUT",
        },
        examples: [
          "Plazucchini.taxon_materials_citations(genus_epithet: 'Alces', species_epithet: 'alces', limit: 1)",
        ],
      },
      :taxon_occurrence_by_materials_citation => {
        description: "Taxon Occurrence By Material Citation",
        params: {
          :limit => "The optional result limit",
          :order_mode => "The optional sort order (ASC, DESC, nil)",
          :verbose => "Print headers to STDOUT",
        },
        examples: [
          "Plazucchini.taxon_occurrence_by_materials_citation(limit: 1)",
        ],
      },
      :taxon_specimens_in_collections => {
        description: "Taxon Specimens In Collections",
        params: {
          :genus_epithet => "The genus of the treatment",
          :limit => "The optional result limit",
          :order_mode => "The optional sort order (ASC, DESC, nil)",
          :verbose => "Print headers to STDOUT",
        },
        examples: [
          "Plazucchini.taxon_specimens_in_collections(genus_epithet: 'Allium', limit: 1)",
        ],
      },
      :taxon_treatments_for_taxon => {
        description: "Taxon Treatments for taxon",
        params: {
          :genus_epithet => "The genus of the treatment",
          :species_epithet => "The species of the treatment",
          :limit => "The optional result limit",
          :order_mode => "The optional sort order (ASC, DESC, nil)",
          :verbose => "Print headers to STDOUT",
        },
        examples: [],
      },
      :taxon_treatments_with_keys => {
        description: "Taxon Treatments With Keys",
        params: {
          :genus_epithet => "The genus of the treatment",
          :limit => "The optional result limit",
          :order_mode => "The optional sort order (ASC, DESC, nil)",
          :verbose => "Print headers to STDOUT",
        },
        examples: [
          "Plazucchini.taxon_treatments_with_keys(genus_epithet: 'Allium', limit: 1)",
        ],
      },
      :treatments_fetch => {
        description: "Treatments Fetch",
        params: {
          :uuid => "The UUID of the treatment to fetch (required)",
          :verbose => "Print headers to STDOUT",
        },
        examples: [
          "Plazucchini.treatments_fetch(uuid: 'D51587EFFFEC9A37F0C01851F8E4F99F')",
        ],
      },
      :treatments_search => {
        description: "Search treatments",
        params: {
          :kingdom_epithet => "The kingdom to search (optional)",
          :phylum_epithet => "The phylum to search (optional)",
          :class_epithet => "The class to search (optional)",
          :order_epithet => "The order to search (optional)",
          :family_epithet => "The family to search (optional)",
          :genus_epithet => "The genus to search (optional)",
          :species_epithet => "The species to search (optional)",
          :limit => "The search result limit (optional)",
          :order_mode => "The optional sort order (ASC, DESC, nil)",
          :verbose => "Print headers to STDOUT",
        },
        examples: [
          "Plazucchini.treatments_search(limit: 1)",
          "Plazucchini.treatments_search(kingdom_epithet: 'Animalia', limit: 1)",
          "Plazucchini.treatments_search(phylum_epithet: 'Arthropoda', limit: 1)",
        ],
      },
      :treatments_search_by_doi => {
        description: "Search treatments by DOI",
        params: {
          :doi => "The DOI to search for (required)",
          :verbose => "Print headers to STDOUT",
        },
        examples: [
          "Plazucchini.treatments_search_by_doi(doi: '10.5281/zenodo.8117062')",
        ],
      },
      :treatments_summary => {
        description: "Get a treatment summary",
        params: {
          :uuid => "The UUID of the treatment (required)",
          :verbose => "Print headers to STDOUT",
        },
        examples: [
          "Plazucchini.treatments_summary(uuid: 'D51587EFFFEC9A37F0C01851F8E4F99F')",
        ],
      },
      :ping => {
        description: "Ping the API (check if the service is alive)",
        params: {
          :verbose => "Print headers to STDOUT",
        },
        examples: [],
      },
    },
  },
  :syconium => {
    description: "Wrapper for OpenAlex API - access research publications and academic data",
    api: "https://api.openalex.org",
    endpoints: {
    },
  },
  :wikimelon => {
    description: "Wrapper for Wikidata API - access linked open knowledge data",
    api: "https://www.wikidata.org/w/api.php",
    endpoints: {
      :query => {
        description: "Run a Wikidata SPARQL query",
        params: {
          :query => "a Wikidata query",
          :verbose => "Print headers to STDOUT",
        },
        examples: [
          "Wikimelon.query('SELECT * WHERE { ?s ?p ?o } LIMIT 1')",
          "Wikimelon.query(query)",
        ],
      },
      :entity => {
        description: "Get Wikidata entity data",
        params: {
          :entity_id => "a Wikidata entity ID",
          :revision_id => "a revision ID",
          :verbose => "Print headers to STDOUT",
        },
        examples: [
          "Wikimelon.entity('Q13')",
          "Wikimelon.entity('Q13', revision_id: 109)",
        ],
      },
    },
  },
}.freeze

Class Method Summary collapse

Class Method Details

.build_prefix_regex(names, prefix: '') ⇒ Object



88
89
90
91
# File 'lib/salad.rb', line 88

def build_prefix_regex(names, prefix: '')
  prefixes = names.flat_map { |n| (COMPLETABLE_PREFIX_MIN..n.length).map { |i| n[0...i] } }
  Regexp.new("\\A#{prefix}(?:#{prefixes.map { |p| Regexp.escape(p) }.join('|')})\\z", Regexp::IGNORECASE)
end

.completable_namesObject

Top-level constants Salad will offer for case-insensitive tab-completion in the REPL.



52
53
54
# File 'lib/salad.rb', line 52

def completable_names
  @completable_names ||= (['Salad'] + GEMS.map { |g| gem_module(g).to_s }).freeze
end

.completable_prefix_regexObject



63
64
65
# File 'lib/salad.rb', line 63

def completable_prefix_regex
  @completable_prefix_regex ||= build_prefix_regex(completable_names)
end

.consoleObject



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
# File 'lib/salad/console.rb', line 23

def self.console
  # Disable Readline's automatic space appending to completions
  # Salad completions should be chainable without spaces
  require 'readline'
  Readline.completion_append_character = ""

  Pry.config.prompt = Pry::Prompt.new(
    'salad',
    'Salad REPL prompt',
    [->(*) { 'salad> ' }, ->(*) { 'salad* ' }]
  )

  # Case-insensitive prefix completion for top-level constants:
  # `sala<TAB>` -> `Salad.`, `nast<TAB>` -> `Nasturtium.`, etc.
  # The regex is tight (only matches strings that are actual prefixes of a
  # known name) so unrelated lowercase input like `put<TAB>` falls through
  # to Pry's default object/method completion.
  Bond::M.complete(:on => Salad.completable_prefix_regex, :search => false, :action => lambda { |input|
    prefix = input.line.downcase
    Salad.completable_names
      .select { |n| n.downcase.start_with?(prefix) }
      .map { |n| "#{n}." }
  })

  # Help-prefixed variant: `help sal<TAB>` -> `help Salad`,
  # `help nast<TAB>` -> `help nasturtium`. Completes to topics the help
  # command actually recognizes (gem/service names and the literal 'Salad'),
  # with no trailing dot so pressing Enter shows the help.
  Bond::M.complete(:on => Salad.help_completable_prefix_regex, :search => false, :action => lambda { |input|
    prefix = input.line.sub(/\Ahelp\s+/i, '').downcase
    Salad.help_completable_names.select { |n| n.downcase.start_with?(prefix) }
  })

  # Configure Bond completion for Salad services and gems
  # Don't match if there's already a dot (that's handled by endpoint completion)
  salad_gem_pattern = /^(help\s+)?Salad\.(\w*)$/
  Bond::M.complete(:on => salad_gem_pattern, :action => lambda { |input|
    match = input.line.match(salad_gem_pattern)
    if match
      prefix = match[2]
      completions = (Salad::SERVICES.keys.map(&:to_s) + Salad::GEMS)
        .select { |g| g.start_with?(prefix) }

      if input.line.start_with?('help ')
        # No trailing dot: `help Salad.nasturtium` matches the help command's
        # regex; `help Salad.nasturtium.` would fall through to "no help".
        completions.map { |g| "Salad.#{g}" }
      else
        # Trailing dot for chaining: after `Salad.nast<TAB>`, the user almost
        # always wants to type a method next, so put the cursor past the dot.
        completions.map { |g| "Salad.#{g}." }
      end
    else
      []
    end
  })

  # Completion for endpoint/method names: "Salad.gem.method" or "Salad.gem .method" (with optional space)
  # Handles cases where Pry adds a space after the gem name completion or around the dot
  salad_endpoint_pattern = /^(help\s+)?Salad\.(\w+)\s*\.\s*(\w*)$/
  Bond::M.complete(:on => salad_endpoint_pattern, :action => lambda { |input|
    match = input.line.match(salad_endpoint_pattern)
    if match
      is_help = !match[1].nil?
      gem_name = match[2]
      method_prefix = match[3]

      actual_gem_name = if Salad::SERVICES.key?(gem_name.to_sym)
                          Salad::SERVICES[gem_name.to_sym]
                        elsif Salad::GEMS.include?(gem_name)
                          gem_name
                        else
                          nil
                        end

      if actual_gem_name
        begin
          mod = Salad.gem_module(actual_gem_name)
          gem_sym = actual_gem_name.to_sym

          if is_help
            help_data = Salad::GEM_HELP[gem_sym]
            if help_data&.[](:endpoints)
              help_data[:endpoints].keys
                .select { |e| e.to_s.start_with?(method_prefix) }
                .map { |e| "Salad.#{gem_name}.#{e}" }
            else
              []
            end
          else
            help_data = Salad::GEM_HELP[gem_sym]
            endpoints = help_data&.[](:endpoints)&.keys&.map(&:to_s) || []

            begin
              public_methods = mod.methods(false).map(&:to_s)
            rescue
              public_methods = []
            end

            all_methods = (endpoints + public_methods).uniq
              .select { |m| m.start_with?(method_prefix) }
              .sort

            all_methods.map { |m| "Salad.#{gem_name}.#{m}" }
          end
        rescue NameError
          []
        end
      else
        []
      end
    else
      []
    end
  })

  # Completion for raw module access: "Nasturtium.method" or "help Nasturtium.method".
  # Pry's BondCompleter override disables default object-introspection completion,
  # so we explicitly handle the SFG wrapper modules here.
  module_to_gem = Salad::GEMS.each_with_object({}) do |g, h|
    h[g.split('_').map(&:capitalize).join] = g
  end
  module_endpoint_pattern = /^(help\s+)?([A-Z]\w*)\s*\.\s*(\w*)$/
  Bond::M.complete(:on => module_endpoint_pattern, :action => lambda { |input|
    match = input.line.match(module_endpoint_pattern)
    if match
      is_help = !match[1].nil?
      module_name = match[2]
      method_prefix = match[3]
      gem_name = module_to_gem[module_name]

      if gem_name
        help_data = Salad::GEM_HELP[gem_name.to_sym]
        endpoints = help_data&.[](:endpoints)&.keys&.map(&:to_s) || []

        if is_help
          endpoints
            .select { |e| e.start_with?(method_prefix) }
            .sort
            .map { |e| "#{module_name}.#{e}" }
        else
          public_methods = begin
            Object.const_get(module_name).methods(false).map(&:to_s)
          rescue NameError
            []
          end

          (endpoints + public_methods).uniq
            .select { |m| m.start_with?(method_prefix) }
            .sort
            .map { |m| "#{module_name}.#{m}" }
        end
      else
        []
      end
    else
      []
    end
  })

  # Completion for keyword arguments inside a method call:
  # "Salad.gem.method(" or "Salad.gem.method(prior: 1, partial"
  # Shows only the params documented for that specific endpoint in GEM_HELP,
  # and hides params already supplied in the current call.
  # :search => false disables Bond's normal_search filter, which would otherwise
  # require candidates to start with the full line (e.g. "Salad.inaturalist.observations(").
  # We return short candidates ("taxon_id: ") so Readline replaces only the word
  # after the "(" break-char instead of doubling the whole prefix.
  salad_kwarg_pattern = /^Salad\.(\w+)\s*\.\s*(\w+)\s*\(([^)]*)$/
  Bond::M.complete(:on => salad_kwarg_pattern, :search => false, :action => lambda { |input|
    match = input.line.match(salad_kwarg_pattern)
    if match
      gem_name = match[1]
      method_name = match[2]
      inside_parens = match[3]

      partial = inside_parens[/(\w*)\z/] || ''
      prefix_in_parens = inside_parens[0...(inside_parens.length - partial.length)]

      actual_gem_name = if Salad::SERVICES.key?(gem_name.to_sym)
                          Salad::SERVICES[gem_name.to_sym]
                        elsif Salad::GEMS.include?(gem_name)
                          gem_name
                        end

      if actual_gem_name
        help_data = Salad::GEM_HELP[actual_gem_name.to_sym]
        endpoint = help_data && help_data[:endpoints] && help_data[:endpoints][method_name.to_sym]

        if endpoint && endpoint[:params]
          params = endpoint[:params].keys.map(&:to_s)
          used = prefix_in_parens.scan(/(\w+)\s*:/).flatten
          # Return only the param + ": " — Readline treats "(" as a word break,
          # so the "word" being completed starts after the last "(" (or space),
          # not at the beginning of the line. Returning a full-line candidate
          # would cause Readline to insert it after the "(", doubling the prefix.
          (params - used)
            .select { |p| p.start_with?(partial) }
            .sort
            .map { |p| "#{p}: " }
        else
          []
        end
      else
        []
      end
    else
      []
    end
  })

  # Same keyword-arg completion for raw module form: "Nasturtium.observations(...".
  # Only documented params for the specific endpoint are returned, hiding ones
  # already supplied in the current call.
  module_kwarg_pattern = /^([A-Z]\w*)\s*\.\s*(\w+)\s*\(([^)]*)$/
  Bond::M.complete(:on => module_kwarg_pattern, :search => false, :action => lambda { |input|
    match = input.line.match(module_kwarg_pattern)
    if match
      module_name = match[1]
      method_name = match[2]
      inside_parens = match[3]
      gem_name = module_to_gem[module_name]

      if gem_name
        partial = inside_parens[/(\w*)\z/] || ''
        prefix_in_parens = inside_parens[0...(inside_parens.length - partial.length)]

        help_data = Salad::GEM_HELP[gem_name.to_sym]
        endpoint = help_data && help_data[:endpoints] && help_data[:endpoints][method_name.to_sym]

        if endpoint && endpoint[:params]
          params = endpoint[:params].keys.map(&:to_s)
          used = prefix_in_parens.scan(/(\w+)\s*:/).flatten
          (params - used)
            .select { |p| p.start_with?(partial) }
            .sort
            .map { |p| "#{p}: " }
        else
          []
        end
      else
        []
      end
    else
      []
    end
  })

  Pry.config.commands.create_command('help', 'Show Salad services and gem documentation') do
    def process(*args)
      topic = args.join(' ')
      if args.empty? || topic == 'Salad'
        show_salad_services_help
      elsif !show_service_help(topic)
        puts "\nNo Salad help available for `#{topic}`."
        puts "Try `help` (no args) to list services, or Pry's `show-doc #{topic}` / `ls #{topic}` for object docs."
      end
    end

    private

    def show_salad_services_help
      puts "\n=== Salad Services ==="
      puts "Access bundled biodiversity informatics API wrappers by service name or gem name:\n"
      service_width = Salad::SERVICES.keys.map { |s| s.to_s.length }.max
      gem_width = Salad::SERVICES.values.map(&:length).max
      Salad::SERVICES.sort.each do |service, gem_name|
        mod = begin
          Salad.gem_module(gem_name).to_s
        rescue NameError
          '(not loaded)'
        end
        printf "  Salad.%-#{service_width}s  Salad.%-#{gem_width}s  ->  %s\n", service, gem_name, mod
      end
      puts "\nUsage Examples:"
      puts "  help Salad.checkerberry              # Show all endpoints (try: help Salad.check<TAB>)"
      puts "  help Salad.checkerberry.verify       # Show specific endpoint (try: help Salad.checkerberry.v<TAB>)"
      puts "  help gnverifier                      # Also works with service or gem name"
      puts "\nAPI Examples:"
      puts "  Salad.worms.record(127160)"
      puts "  Crawlyflower.record(127160)          # Same as above"
      puts "  Salad.inaturalist.observations(id: 1234)"
      puts "\nTab-completion is powered by Bond and shows only Salad endpoints.\n\n"
    end

    def show_service_help(topic)
      begin
        # Try to match endpoint pattern: "Salad.gem_name.endpoint_name"
        if topic =~ /^Salad\.([\w_]+)\.([\w_]+)$/
          gem_name = Regexp.last_match(1)
          endpoint_name = Regexp.last_match(2)
          return show_endpoint_help(gem_name, endpoint_name)
        end

        # Try to match Salad service pattern: "Salad.service_name" or "Salad.gem_name"
        if topic =~ /^Salad\.([\w_]+)$/
          name = Regexp.last_match(1)
          # Check if it's a service name, and convert to gem name
          gem_name = Salad::SERVICES[name.to_sym] || name
          show_gem_methods(gem_name)
          return true
        end

        # Try matching just service or gem name: "inaturalist" or "nasturtium"
        if Salad::SERVICES.key?(topic.to_sym)
          gem_name = Salad::SERVICES[topic.to_sym]
          show_gem_methods(gem_name)
          return true
        elsif Salad::GEMS.include?(topic)
          show_gem_methods(topic)
          return true
        end

        # CamelCase module form: "Nasturtium" or "Nasturtium.endpoint"
        if topic =~ /^([A-Z]\w*)(?:\.([\w_]+))?$/
          module_name = Regexp.last_match(1)
          endpoint_name = Regexp.last_match(2)
          gem_name = Salad.gem_for_module(module_name)
          if gem_name
            return show_endpoint_help(gem_name, endpoint_name) if endpoint_name
            show_gem_methods(gem_name)
            return true
          end
        end

        false
      rescue => e
        puts "\nError loading help: #{e.class}: #{e.message}"
        false
      end
    end

    def show_gem_methods(service_or_gem)
      mod = begin
        Salad.gem_module(service_or_gem)
      rescue NameError
        puts "Service/gem '#{service_or_gem}' not found."
        return
      end

      puts "\n=== #{mod.to_s} ==="

      # Check for detailed help documentation
      gem_sym = service_or_gem.to_sym
      if Salad::GEM_HELP[gem_sym]
        show_detailed_gem_help(gem_sym, mod, service_or_gem)
      else
        show_generic_gem_help(mod, service_or_gem)
      end
    end

    def show_endpoint_help(gem_name, endpoint_name)
      # Convert service name to gem name if needed
      actual_gem_name = if Salad::SERVICES.key?(gem_name.to_sym)
                          Salad::SERVICES[gem_name.to_sym]
                        else
                          gem_name
                        end
      gem_sym = actual_gem_name.to_sym

      # Check if gem has documented help
      unless Salad::GEM_HELP[gem_sym]
        puts "\nNo detailed documentation available for #{gem_name}.#{endpoint_name}"
        return true
      end

      help = Salad::GEM_HELP[gem_sym]
      endpoints = help[:endpoints]

      unless endpoints
        puts "\nNo endpoints documented for #{gem_name}"
        return true
      end

      endpoint_sym = endpoint_name.to_sym
      endpoint_info = endpoints[endpoint_sym]

      unless endpoint_info
        puts "\nEndpoint '#{endpoint_name}' not found in #{gem_name}."
        puts "\nAvailable endpoints: #{endpoints.keys.join(', ')}"
        return true
      end

      mod = begin
        Salad.gem_module(actual_gem_name)
      rescue NameError
        nil
      end

      module_name = mod ? mod.to_s : actual_gem_name.camelize
      puts "\n=== #{module_name}.#{endpoint_name} ==="
      puts "\n#{endpoint_info[:description]}"

      if endpoint_info[:params]
        puts "\nParameters:"
        endpoint_info[:params].each do |param_name, param_desc|
          puts "  #{param_name.to_s.ljust(20)}#{param_desc}"
        end
      end

      if endpoint_info[:examples]
        puts "\nExamples:"
        endpoint_info[:examples].each { |ex| puts "  #{ex}" }
      end

      puts "\n"
      true
    end

    def show_detailed_gem_help(gem_sym, mod, gem_name)
      help = Salad::GEM_HELP[gem_sym]

      puts "\n#{help[:description]}"
      puts "API: #{help[:api]}"

      if help[:endpoints]
        puts "\n--- Available Endpoints ---"
        help[:endpoints].each do |endpoint_name, endpoint_info|
          begin
            puts "\n#{endpoint_name}"
            puts "  #{endpoint_info[:description]}"

            if endpoint_info[:examples]
              puts "  Example: #{endpoint_info[:examples].first}"
            end

            puts "  ↳ help Salad.#{gem_name}.#{endpoint_name}  # Full documentation"
          rescue => e
            puts "\n#{endpoint_name}"
            puts "  (Documentation temporarily unavailable)"
          end
        end
      end

      puts "\n"
    end

    def show_generic_gem_help(mod, service_or_gem)
      # Show module methods
      public_methods = mod.methods(false).sort
      if public_methods.any?
        puts "\nPublic methods:"
        public_methods.each { |m| puts "  #{m}" }
      end

      # Show constants (often contain useful classes)
      constants = mod.constants(false).sort
      if constants.any?
        puts "\nAvailable classes/constants:"
        module_name = mod.to_s
        constants.each { |c| puts "  #{module_name}::#{c}" }
      end

      puts "\nUsage examples:"
      gem_name = service_or_gem.include?('_') ? service_or_gem :
                 (Salad::SERVICES.find { |_, v| v == service_or_gem }&.last || service_or_gem)
      module_name = mod.to_s
      if mod.respond_to?(:help)
        puts "  #{module_name}.help          # Gem documentation"
      end
      puts "  Salad.#{gem_name}.observations(...)    # Call available methods"
      puts "  #{module_name}.observations(...)         # Or use the gem name directly"
      puts "\n\n"
    end
  end

  Pry.config.commands.create_command('hints', 'Show tips for using the Salad console') do
    def process
      puts "\n=== Salad Tips ==="
      Salad::HINTS.each_with_index do |hint, i|
        puts "  #{(i + 1).to_s.rjust(2)}. #{hint}"
      end
      puts "\n"
    end
  end

  puts "salad v#{Salad::VERSION} — type `help` to list services, `hints` for tips."
  puts "Tip: #{Salad::HINTS.sample}"
  Pry.start
end

.gem_for_module(module_name) ⇒ Object

Reverse lookup: ‘Nasturtium’ -> ‘nasturtium’, ‘BellPepper’ -> ‘bell_pepper’. Returns nil for unknown module names.



77
78
79
80
81
82
# File 'lib/salad.rb', line 77

def gem_for_module(module_name)
  @gem_for_module ||= GEMS.each_with_object({}) do |g, h|
    h[gem_module(g).to_s] = g
  end.freeze
  @gem_for_module[module_name]
end

.gem_module(gem_name) ⇒ Object



39
40
41
42
43
44
# File 'lib/salad.rb', line 39

def gem_module(gem_name)
  name = gem_name.split('_').map(&:capitalize).join
  Object.const_get(name)
rescue NameError
  raise NameError, "Cannot find top-level module for gem #{gem_name.inspect} (expected #{name})"
end

.helpObject



93
94
95
96
97
98
99
100
101
102
103
104
105
106
# File 'lib/salad.rb', line 93

def help
  puts 'Salad services — access by service name or gem name:'
  service_width = SERVICES.keys.map { |s| s.to_s.length }.max
  gem_width = SERVICES.values.map(&:length).max
  SERVICES.sort.each do |service, gem_name|
    mod = begin
      gem_module(gem_name).to_s
    rescue NameError
      '(not loaded)'
    end
    printf "  Salad.%-#{service_width}s  Salad.%-#{gem_width}s  ->  %s\n", service, gem_name, mod
  end
  nil
end

.help_completable_namesObject

Names offered as completions after ‘help `. Uses CamelCase module names for the bundled gems (so `help nast<TAB>` -> `help Nasturtium`) plus the lowercase service aliases (so `help inat<TAB>` -> `help inaturalist`). `Salad` itself is the literal services-listing topic.



71
72
73
# File 'lib/salad.rb', line 71

def help_completable_names
  @help_completable_names ||= (completable_names + SERVICES.keys.map(&:to_s)).uniq.freeze
end

.help_completable_prefix_regexObject



84
85
86
# File 'lib/salad.rb', line 84

def help_completable_prefix_regex
  @help_completable_prefix_regex ||= build_prefix_regex(help_completable_names, prefix: 'help\\s+')
end

.servicesObject



46
47
48
# File 'lib/salad.rb', line 46

def services
  SERVICES
end