Module: Crawlyflower
- Extended by:
- Configuration
- Defined in:
- lib/crawlyflower.rb,
lib/crawlyflower/error.rb,
lib/crawlyflower/request.rb,
lib/crawlyflower/version.rb
Defined Under Namespace
Classes: BadGateway, BadRequest, Error, GatewayTimeout, InternalServerError, NotFound, Request, ServiceUnavailable
Constant Summary collapse
- FULL_RECORD_FORMATS =
{ jsonld: 'application/ld+json', rdf: 'application/rdf+xml', turtle: 'text/turtle', ntriples: 'application/n-triples' }.freeze
- VERSION =
"0.0.2"
Class Method Summary collapse
-
.aphia_id_by_name(name, marine_only: nil, extant_only: nil, verbose: false) ⇒ Integer?
Get the AphiaID for a given name.
-
.aphia_ids_by_attribute_key(id, offset: nil, verbose: false) ⇒ Array?
Get a list of AphiaIDs (max 50) with attribute tree for a given attribute definition ID.
-
.attribute_keys(id, include_children: nil, verbose: false) ⇒ Array?
Get attribute definitions.
-
.attribute_values_by_category(id, verbose: false) ⇒ Array?
Get list values that are grouped by a CategoryID.
-
.attributes(id, include_inherited: nil, verbose: false) ⇒ Array?
Get a list of attributes for a given AphiaID.
-
.children(id, marine_only: nil, extant_only: nil, offset: nil, verbose: false) ⇒ Array?
Get the direct children (max. 50) for a given AphiaID.
-
.classification(id, verbose: false) ⇒ Hash?
Get the complete classification for one taxon.
-
.distributions(id, verbose: false) ⇒ Array?
Get all distributions for a given AphiaID.
-
.external_id(id, type: nil, verbose: false) ⇒ Array?
Get any external identifier(s) for a given AphiaID.
-
.full_record(id, format: :jsonld, verbose: false) ⇒ Hash, ...
Get the complete AphiaFullRecord (linked open data) for a given AphiaID.
-
.name(id, verbose: false) ⇒ String?
Get the name for a given AphiaID.
-
.record(id, verbose: false) ⇒ Hash?
Get the complete AphiaRecord for a given AphiaID.
-
.record_by_external_id(id, type: nil, verbose: false) ⇒ Hash?
Get the Aphia Record for a given external identifier.
-
.records_by_aphia_ids(ids, verbose: false) ⇒ Array?
Get AphiaRecords for multiple AphiaIDs in one go (max: 50).
-
.records_by_date(startdate:, enddate: nil, marine_only: nil, extant_only: nil, offset: nil, verbose: false) ⇒ Array?
Lists all AphiaRecords that have their last edit action during the specified period.
-
.records_by_match_names(scientificnames:, authorships: nil, marine_only: nil, extant_only: nil, match_authority: nil, verbose: false) ⇒ Array?
Try to find AphiaRecords using the TAXAMATCH fuzzy matching algorithm.
-
.records_by_name(name, like: nil, marine_only: nil, extant_only: nil, offset: nil, verbose: false) ⇒ Array?
Get one or more matching (max. 50) AphiaRecords for a given name.
-
.records_by_names(scientificnames:, like: nil, marine_only: nil, extant_only: nil, verbose: false) ⇒ Array?
For each given scientific name, try to find one or more AphiaRecords (max 500 names).
-
.records_by_taxon_rank_id(id, belongs_to: nil, offset: nil, verbose: false) ⇒ Array?
Get the AphiaRecords for a given taxonRankID (max 50).
-
.records_by_vernacular(name, like: nil, offset: nil, verbose: false) ⇒ Array?
Get one or more Aphia Records (max. 50) for a given vernacular.
-
.sources(id, verbose: false) ⇒ Array?
Get one or more sources/references including links, for one AphiaID.
-
.suggest(name_part, rank_min: nil, rank_max: nil, max_matches: nil, excluded_ids: nil, combine_vernaculars: nil, marine_only: nil, fossil_id: nil, languages: nil, verbose: false) ⇒ Array?
Get taxa suggestions for a given prefix of a taxon name.
-
.synonyms(id, offset: nil, verbose: false) ⇒ Array?
Get all synonyms for a given AphiaID.
-
.taxon_ranks_by_id(id, aphia_id: nil, verbose: false) ⇒ Array?
Get taxonomic ranks by their identifier.
-
.taxon_ranks_by_name(name, aphia_id: nil, verbose: false) ⇒ Array?
Get taxonomic ranks by their name.
-
.vernaculars(id, verbose: false) ⇒ Array?
Get all vernaculars for a given AphiaID.
Methods included from Configuration
Class Method Details
.aphia_id_by_name(name, marine_only: nil, extant_only: nil, verbose: false) ⇒ Integer?
Get the AphiaID for a given name
67 68 69 70 71 |
# File 'lib/crawlyflower.rb', line 67 def self.aphia_id_by_name(name, marine_only: nil, extant_only: nil, verbose: false) endpoint = "AphiaIDByName/#{ERB::Util.url_encode(name)}" opts = { marine_only: marine_only, extant_only: extant_only }.compact Request.new(endpoint: endpoint, verbose: verbose, options: opts).perform end |
.aphia_ids_by_attribute_key(id, offset: nil, verbose: false) ⇒ Array?
Get a list of AphiaIDs (max 50) with attribute tree for a given attribute definition ID
306 307 308 309 310 |
# File 'lib/crawlyflower.rb', line 306 def self.aphia_ids_by_attribute_key(id, offset: nil, verbose: false) endpoint = "AphiaIDsByAttributeKeyID/#{id}" opts = { offset: offset }.compact Request.new(endpoint: endpoint, verbose: verbose, options: opts).perform end |
.attribute_keys(id, include_children: nil, verbose: false) ⇒ Array?
Get attribute definitions
284 285 286 287 288 |
# File 'lib/crawlyflower.rb', line 284 def self.attribute_keys(id, include_children: nil, verbose: false) endpoint = "AphiaAttributeKeysByID/#{id}" opts = { include_children: include_children }.compact Request.new(endpoint: endpoint, verbose: verbose, options: opts).perform end |
.attribute_values_by_category(id, verbose: false) ⇒ Array?
Get list values that are grouped by a CategoryID
295 296 297 298 |
# File 'lib/crawlyflower.rb', line 295 def self.attribute_values_by_category(id, verbose: false) endpoint = "AphiaAttributeValuesByCategoryID/#{id}" Request.new(endpoint: endpoint, verbose: verbose).perform end |
.attributes(id, include_inherited: nil, verbose: false) ⇒ Array?
Get a list of attributes for a given AphiaID
318 319 320 321 322 |
# File 'lib/crawlyflower.rb', line 318 def self.attributes(id, include_inherited: nil, verbose: false) endpoint = "AphiaAttributesByAphiaID/#{id}" opts = { include_inherited: include_inherited }.compact Request.new(endpoint: endpoint, verbose: verbose, options: opts).perform end |
.children(id, marine_only: nil, extant_only: nil, offset: nil, verbose: false) ⇒ Array?
Get the direct children (max. 50) for a given AphiaID
22 23 24 25 26 |
# File 'lib/crawlyflower.rb', line 22 def self.children(id, marine_only: nil, extant_only: nil, offset: nil, verbose: false) endpoint = "AphiaChildrenByAphiaID/#{id}" opts = { marine_only: marine_only, extant_only: extant_only, offset: offset }.compact Request.new(endpoint: endpoint, verbose: verbose, options: opts).perform end |
.classification(id, verbose: false) ⇒ Hash?
Get the complete classification for one taxon
33 34 35 36 |
# File 'lib/crawlyflower.rb', line 33 def self.classification(id, verbose: false) endpoint = "AphiaClassificationByAphiaID/#{id}" Request.new(endpoint: endpoint, verbose: verbose).perform end |
.distributions(id, verbose: false) ⇒ Array?
Get all distributions for a given AphiaID
43 44 45 46 |
# File 'lib/crawlyflower.rb', line 43 def self.distributions(id, verbose: false) endpoint = "AphiaDistributionsByAphiaID/#{id}" Request.new(endpoint: endpoint, verbose: verbose).perform end |
.external_id(id, type: nil, verbose: false) ⇒ Array?
Get any external identifier(s) for a given AphiaID
54 55 56 57 58 |
# File 'lib/crawlyflower.rb', line 54 def self.external_id(id, type: nil, verbose: false) endpoint = "AphiaExternalIDByAphiaID/#{id}" opts = { type: type }.compact Request.new(endpoint: endpoint, verbose: verbose, options: opts).perform end |
.full_record(id, format: :jsonld, verbose: false) ⇒ Hash, ...
Get the complete AphiaFullRecord (linked open data) for a given AphiaID
272 273 274 275 276 |
# File 'lib/crawlyflower.rb', line 272 def self.full_record(id, format: :jsonld, verbose: false) endpoint = "AphiaRecordFullByAphiaID/#{id}" accept = FULL_RECORD_FORMATS[format] || FULL_RECORD_FORMATS[:jsonld] Request.new(endpoint: endpoint, verbose: verbose, accept: accept).perform end |
.name(id, verbose: false) ⇒ String?
Get the name for a given AphiaID
78 79 80 81 |
# File 'lib/crawlyflower.rb', line 78 def self.name(id, verbose: false) endpoint = "AphiaNameByAphiaID/#{id}" Request.new(endpoint: endpoint, verbose: verbose).perform end |
.record(id, verbose: false) ⇒ Hash?
Get the complete AphiaRecord for a given AphiaID
88 89 90 91 |
# File 'lib/crawlyflower.rb', line 88 def self.record(id, verbose: false) endpoint = "AphiaRecordByAphiaID/#{id}" Request.new(endpoint: endpoint, verbose: verbose).perform end |
.record_by_external_id(id, type: nil, verbose: false) ⇒ Hash?
Get the Aphia Record for a given external identifier
110 111 112 113 114 |
# File 'lib/crawlyflower.rb', line 110 def self.record_by_external_id(id, type: nil, verbose: false) endpoint = "AphiaRecordByExternalID/#{ERB::Util.url_encode(id.to_s)}" opts = { type: type }.compact Request.new(endpoint: endpoint, verbose: verbose, options: opts).perform end |
.records_by_aphia_ids(ids, verbose: false) ⇒ Array?
Get AphiaRecords for multiple AphiaIDs in one go (max: 50)
98 99 100 101 102 |
# File 'lib/crawlyflower.rb', line 98 def self.records_by_aphia_ids(ids, verbose: false) endpoint = "AphiaRecordsByAphiaIDs" opts = { "aphiaids[]": Array(ids) } Request.new(endpoint: endpoint, verbose: verbose, options: opts).perform end |
.records_by_date(startdate:, enddate: nil, marine_only: nil, extant_only: nil, offset: nil, verbose: false) ⇒ Array?
Lists all AphiaRecords that have their last edit action during the specified period
125 126 127 128 129 |
# File 'lib/crawlyflower.rb', line 125 def self.records_by_date(startdate:, enddate: nil, marine_only: nil, extant_only: nil, offset: nil, verbose: false) endpoint = "AphiaRecordsByDate" opts = { startdate: startdate, enddate: enddate, marine_only: marine_only, extant_only: extant_only, offset: offset }.compact Request.new(endpoint: endpoint, verbose: verbose, options: opts).perform end |
.records_by_match_names(scientificnames:, authorships: nil, marine_only: nil, extant_only: nil, match_authority: nil, verbose: false) ⇒ Array?
Try to find AphiaRecords using the TAXAMATCH fuzzy matching algorithm
140 141 142 143 144 145 146 |
# File 'lib/crawlyflower.rb', line 140 def self.records_by_match_names(scientificnames:, authorships: nil, marine_only: nil, extant_only: nil, match_authority: nil, verbose: false) endpoint = "AphiaRecordsByMatchNames" opts = { "scientificnames[]": Array(scientificnames), marine_only: marine_only, extant_only: extant_only, match_authority: } opts[:"authorships[]"] = Array() if opts = opts.compact Request.new(endpoint: endpoint, verbose: verbose, options: opts).perform end |
.records_by_name(name, like: nil, marine_only: nil, extant_only: nil, offset: nil, verbose: false) ⇒ Array?
Get one or more matching (max. 50) AphiaRecords for a given name
157 158 159 160 161 |
# File 'lib/crawlyflower.rb', line 157 def self.records_by_name(name, like: nil, marine_only: nil, extant_only: nil, offset: nil, verbose: false) endpoint = "AphiaRecordsByName/#{ERB::Util.url_encode(name)}" opts = { like: like, marine_only: marine_only, extant_only: extant_only, offset: offset }.compact Request.new(endpoint: endpoint, verbose: verbose, options: opts).perform end |
.records_by_names(scientificnames:, like: nil, marine_only: nil, extant_only: nil, verbose: false) ⇒ Array?
For each given scientific name, try to find one or more AphiaRecords (max 500 names)
171 172 173 174 175 |
# File 'lib/crawlyflower.rb', line 171 def self.records_by_names(scientificnames:, like: nil, marine_only: nil, extant_only: nil, verbose: false) endpoint = "AphiaRecordsByNames" opts = { "scientificnames[]": Array(scientificnames), like: like, marine_only: marine_only, extant_only: extant_only }.compact Request.new(endpoint: endpoint, verbose: verbose, options: opts).perform end |
.records_by_taxon_rank_id(id, belongs_to: nil, offset: nil, verbose: false) ⇒ Array?
Get the AphiaRecords for a given taxonRankID (max 50)
253 254 255 256 257 |
# File 'lib/crawlyflower.rb', line 253 def self.records_by_taxon_rank_id(id, belongs_to: nil, offset: nil, verbose: false) endpoint = "AphiaRecordsByTaxonRankID/#{id}" opts = { belongsTo: belongs_to, offset: offset }.compact Request.new(endpoint: endpoint, verbose: verbose, options: opts).perform end |
.records_by_vernacular(name, like: nil, offset: nil, verbose: false) ⇒ Array?
Get one or more Aphia Records (max. 50) for a given vernacular
184 185 186 187 188 |
# File 'lib/crawlyflower.rb', line 184 def self.records_by_vernacular(name, like: nil, offset: nil, verbose: false) endpoint = "AphiaRecordsByVernacular/#{ERB::Util.url_encode(name)}" opts = { like: like, offset: offset }.compact Request.new(endpoint: endpoint, verbose: verbose, options: opts).perform end |
.sources(id, verbose: false) ⇒ Array?
Get one or more sources/references including links, for one AphiaID
217 218 219 220 |
# File 'lib/crawlyflower.rb', line 217 def self.sources(id, verbose: false) endpoint = "AphiaSourcesByAphiaID/#{id}" Request.new(endpoint: endpoint, verbose: verbose).perform end |
.suggest(name_part, rank_min: nil, rank_max: nil, max_matches: nil, excluded_ids: nil, combine_vernaculars: nil, marine_only: nil, fossil_id: nil, languages: nil, verbose: false) ⇒ Array?
Get taxa suggestions for a given prefix of a taxon name
337 338 339 340 341 342 343 344 345 |
# File 'lib/crawlyflower.rb', line 337 def self.suggest(name_part, rank_min: nil, rank_max: nil, max_matches: nil, excluded_ids: nil, combine_vernaculars: nil, marine_only: nil, fossil_id: nil, languages: nil, verbose: false) endpoint = "AjaxAphiaRecordsByNamePart/#{ERB::Util.url_encode(name_part)}" opts = { rank_min: rank_min, rank_max: rank_max, max_matches: max_matches, combine_vernaculars: combine_vernaculars, marine_only: marine_only, fossil_id: fossil_id } opts[:"excluded_ids[]"] = Array(excluded_ids) if excluded_ids opts[:"languages[]"] = Array(languages) if languages opts = opts.compact Request.new(endpoint: endpoint, verbose: verbose, options: opts).perform end |
.synonyms(id, offset: nil, verbose: false) ⇒ Array?
Get all synonyms for a given AphiaID
196 197 198 199 200 |
# File 'lib/crawlyflower.rb', line 196 def self.synonyms(id, offset: nil, verbose: false) endpoint = "AphiaSynonymsByAphiaID/#{id}" opts = { offset: offset }.compact Request.new(endpoint: endpoint, verbose: verbose, options: opts).perform end |
.taxon_ranks_by_id(id, aphia_id: nil, verbose: false) ⇒ Array?
Get taxonomic ranks by their identifier
228 229 230 231 232 |
# File 'lib/crawlyflower.rb', line 228 def self.taxon_ranks_by_id(id, aphia_id: nil, verbose: false) endpoint = "AphiaTaxonRanksByID/#{id}" opts = { AphiaID: aphia_id }.compact Request.new(endpoint: endpoint, verbose: verbose, options: opts).perform end |
.taxon_ranks_by_name(name, aphia_id: nil, verbose: false) ⇒ Array?
Get taxonomic ranks by their name
240 241 242 243 244 |
# File 'lib/crawlyflower.rb', line 240 def self.taxon_ranks_by_name(name, aphia_id: nil, verbose: false) endpoint = "AphiaTaxonRanksByName/#{ERB::Util.url_encode(name)}" opts = { AphiaID: aphia_id }.compact Request.new(endpoint: endpoint, verbose: verbose, options: opts).perform end |