Module: Pubid::Doi
- Extended by:
- PrefixesSupport
- Defined in:
- lib/pubid/doi.rb,
lib/pubid/doi/parser.rb,
lib/pubid/doi/builder.rb,
lib/pubid/doi/renderer.rb,
lib/pubid/doi/identifier.rb,
lib/pubid/doi/identifiers.rb,
lib/pubid/doi/identifiers/resource.rb
Overview
DOI (Digital Object Identifier) flavor.
Parses the canonical DOI per ISO 26324:
doi:10.{REGISTRAR}/{SUFFIX}
The optional URL form https://doi.org/10.X/Y is accepted; the resolver
host is stripped before parsing.
Defined Under Namespace
Modules: Identifiers Classes: Builder, Identifier, Parser, Renderer
Constant Summary collapse
- PREFIXES =
Leading tokens a DOI string can start with. The bare "10." form is the canonical prefix per ISO 26324 ยง4.1.
%w[doi: DOI: 10.].freeze
Class Method Summary collapse
- .all_typed_stages ⇒ Object
- .identifier_types ⇒ Object
- .locate_stage(abbr) ⇒ Object
- .locate_type(code) ⇒ Object
- .parse(identifier) ⇒ Object
Methods included from PrefixesSupport
Class Method Details
.all_typed_stages ⇒ Object
38 39 40 41 42 |
# File 'lib/pubid/doi.rb', line 38 def self.all_typed_stages @all_typed_stages ||= identifier_types.flat_map do |klass| klass.const_defined?(:TYPED_STAGES) ? klass.const_get(:TYPED_STAGES) : [] end end |
.identifier_types ⇒ Object
31 32 33 34 35 36 |
# File 'lib/pubid/doi.rb', line 31 def self.identifier_types @identifier_types ||= Identifiers.constants .filter_map { |c| begin; Identifiers.const_get(c); rescue NameError; nil; end } .select { |c| c.is_a?(Class) && c.singleton_methods(false).include?(:type) } .select { |c| c.type.is_a?(Hash) } end |
.locate_stage(abbr) ⇒ Object
48 49 50 51 |
# File 'lib/pubid/doi.rb', line 48 def self.locate_stage(abbr) abbr_str = abbr.to_s.upcase all_typed_stages.find { |s| s.abbr.any? { |a| a.to_s.upcase == abbr_str } } end |
.locate_type(code) ⇒ Object
44 45 46 |
# File 'lib/pubid/doi.rb', line 44 def self.locate_type(code) identifier_types.find { |t| t.type[:key].to_s == code.to_s } end |
.parse(identifier) ⇒ Object
24 25 26 |
# File 'lib/pubid/doi.rb', line 24 def self.parse(identifier) Identifier.parse(identifier) end |