Module: RelatonBib
- Extended by:
- Config
- Included in:
- Affiliation, BibliographicItem, BibliographicItem::Version, ContributionInfo, Contributor, ContributorRole, CopyrightAssociation, DocumentRelation, EditorialGroup, FullName, LocalityStack, LocalizedString, StructuredIdentifier, StructuredIdentifierCollection
- Defined in:
- lib/relaton_bib/contribution_info.rb,
lib/relaton_bib.rb,
lib/relaton_bib/hit.rb,
lib/relaton_bib/ics.rb,
lib/relaton_bib/util.rb,
lib/relaton_bib/image.rb,
lib/relaton_bib/place.rb,
lib/relaton_bib/config.rb,
lib/relaton_bib/medium.rb,
lib/relaton_bib/person.rb,
lib/relaton_bib/series.rb,
lib/relaton_bib/edition.rb,
lib/relaton_bib/version.rb,
lib/relaton_bib/forename.rb,
lib/relaton_bib/validity.rb,
lib/relaton_bib/full_name.rb,
lib/relaton_bib/typed_uri.rb,
lib/relaton_bib/workgroup.rb,
lib/relaton_bib/xml_parser.rb,
lib/relaton_bib/biblio_note.rb,
lib/relaton_bib/contributor.rb,
lib/relaton_bib/organization.rb,
lib/relaton_bib/workers_pool.rb,
lib/relaton_bib/bibtex_parser.rb,
lib/relaton_bib/bibxml_parser.rb,
lib/relaton_bib/document_type.rb,
lib/relaton_bib/formatted_ref.rb,
lib/relaton_bib/biblio_version.rb,
lib/relaton_bib/classification.rb,
lib/relaton_bib/hash_converter.rb,
lib/relaton_bib/hit_collection.rb,
lib/relaton_bib/document_status.rb,
lib/relaton_bib/editorial_group.rb,
lib/relaton_bib/renderer/bibxml.rb,
lib/relaton_bib/formatted_string.rb,
lib/relaton_bib/localized_string.rb,
lib/relaton_bib/bib_item_locality.rb,
lib/relaton_bib/document_relation.rb,
lib/relaton_bib/bibliographic_date.rb,
lib/relaton_bib/bibliographic_item.rb,
lib/relaton_bib/bibliographic_size.rb,
lib/relaton_bib/typed_title_string.rb,
lib/relaton_bib/document_identifier.rb,
lib/relaton_bib/technical_committee.rb,
lib/relaton_bib/copyright_association.rb,
lib/relaton_bib/structured_identifier.rb,
lib/relaton_bib/renderer/bibtex_builder.rb,
lib/relaton_bib/document_relation_collection.rb
Overview
RelatonBib module
Defined Under Namespace
Modules: BibXMLParser, Config, HashConverter, PersonIdentifierType, Renderer, Util Classes: Address, Affiliation, BibItemLocality, BiblioNote, BiblioNoteCollection, BibliographicDate, BibliographicItem, BibliographicSize, BibtexParser, Classification, Configuration, Contact, ContributionInfo, Contributor, ContributorRole, CopyrightAssociation, DocRelationCollection, DocumentIdentifier, DocumentRelation, DocumentStatus, DocumentType, Edition, EditorialGroup, Error, Forename, FormattedRef, FormattedString, FullName, Hit, HitCollection, ICS, Image, Locality, LocalityStack, LocalizedString, Medium, OrgIdentifier, Organization, Person, PersonIdentifier, Place, RequestError, Series, SourceLocality, SourceLocalityStack, StructuredIdentifier, StructuredIdentifierCollection, TechnicalCommittee, TypedTitleString, TypedTitleStringCollection, TypedUri, Validity, WorkGroup, WorkersPool, XMLParser
Constant Summary collapse
- VERSION =
"1.18.4".freeze
Class Method Summary collapse
- .array(arr) ⇒ Array
-
.format_date(date, format, str, outformat = nil) ⇒ Date, String
Parse date string to Date object and format it.
- .grammar_hash ⇒ Object
-
.parse_date(date, str = true) ⇒ Date, ...
Date.
-
.parse_yaml(yaml, classes = [], symbolize_names: false) ⇒ Hash
Parse yaml content.
Methods included from Config
Class Method Details
.array(arr) ⇒ Array
64 65 66 67 68 69 |
# File 'lib/relaton_bib.rb', line 64 def array(arr) return [] unless arr return [arr] unless arr.is_a?(Array) arr end |
.format_date(date, format, str, outformat = nil) ⇒ Date, String
Parse date string to Date object and format it
57 58 59 60 |
# File 'lib/relaton_bib.rb', line 57 def format_date(date, format, str, outformat = nil) date = Date.strptime(date, format) str ? date.strftime(outformat || format) : date end |
.grammar_hash ⇒ Object
90 91 92 93 94 95 |
# File 'lib/relaton_bib.rb', line 90 def self.grammar_hash # gem_path = File.expand_path "..", __dir__ # grammars_path = File.join gem_path, "grammars", "*" # grammars = Dir[grammars_path].sort.map { |gp| File.read gp }.join Digest::MD5.hexdigest RelatonBib::VERSION # grammars end |
.parse_date(date, str = true) ⇒ Date, ...
Returns date.
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/relaton_bib.rb', line 30 def parse_date(date, str = true) # rubocop:disable Metrics/CyclomaticComplexity,Metrics/MethodLength,Metrics/PerceivedComplexity,Metrics/AbcSize return date if date.is_a?(Date) case date.to_s when /(?<date>\w+\s\d{4})/ # February 2012 format_date $~[:date], "%B %Y", str, "%Y-%m" when /(?<date>\w+\s\d{1,2},\s\d{4})/ # February 11, 2012 format_date $~[:date], "%B %d, %Y", str, "%Y-%m-%d" when /(?<date>\d{4}-\d{1,2}-\d{1,2})/ # 2012-02-03 or 2012-2-3 format_date $~[:date], "%Y-%m-%d", str when /(?<date>\d{4}-\d{1,2})/ # 2012-02 or 2012-2 format_date $~[:date], "%Y-%m", str when /(?<date>\d{4})/ # 2012 format_date $~[:date], "%Y", str end end |
.parse_yaml(yaml, classes = [], symbolize_names: false) ⇒ Hash
Parse yaml content
80 81 82 83 84 85 86 87 |
# File 'lib/relaton_bib.rb', line 80 def parse_yaml(yaml, classes = [], symbolize_names: false) # Newer versions of Psych uses the `permitted_classes:` parameter if YAML.method(:safe_load).parameters.map(&:last).include? :permitted_classes YAML.safe_load(yaml, permitted_classes: classes, symbolize_names: symbolize_names) else YAML.safe_load(yaml, classes, symbolize_names: symbolize_names) end end |