Module: RelatonBib
- 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/place.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/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/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/document_relation_collection.rb
Overview
RelatonBib module
Defined Under Namespace
Modules: BibXMLParser, PersonIdentifierType Classes: Address, Affiliation, BibItemLocality, BiblioNote, BiblioNoteCollection, BibliographicDate, BibliographicItem, BibliographicSize, BibtexParser, Classification, Contact, ContributionInfo, Contributor, ContributorRole, CopyrightAssociation, DocRelationCollection, DocumentIdentifier, DocumentRelation, DocumentStatus, Edition, EditorialGroup, Error, Forename, FormattedRef, FormattedString, FullName, HashConverter, Hit, HitCollection, ICS, 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.13.15".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.
-
.parse_date(date, str = true) ⇒ Date, ...
Date.
-
.parse_yaml(yaml, classes = []) ⇒ Hash
Parse yaml content.
Class Method Details
.array(arr) ⇒ Array
58 59 60 61 62 63 |
# File 'lib/relaton_bib.rb', line 58 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
51 52 53 54 |
# File 'lib/relaton_bib.rb', line 51 def format_date(date, format, str, outformat = nil) date = Date.strptime(date, format) str ? date.strftime(outformat || format) : date end |
.parse_date(date, str = true) ⇒ Date, ...
Returns date.
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/relaton_bib.rb', line 24 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 = []) ⇒ Hash
Parse yaml content
72 73 74 75 76 77 78 79 |
# File 'lib/relaton_bib.rb', line 72 def parse_yaml(yaml, classes = []) # 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) else YAML.safe_load(yaml, classes) end end |