Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
andrew2net committed Mar 5, 2025
1 parent 31563cf commit 7eeb0f1
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 25 deletions.
26 changes: 13 additions & 13 deletions lib/relaton_bib/bibliographic_item.rb
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ def initialize(**args)
a.is_a?(Hash) ? FormattedString.new(**a) : a
end

@copyright = args.fetch(:copyright, []).map do |c|
@copyright = (args[:copyright] || []).map do |c|
c.is_a?(Hash) ? CopyrightAssociation.new(**c) : c
end

Expand All @@ -248,43 +248,43 @@ def initialize(**args)
Edition.new(content: args[:edition].to_s)
when Edition then args[:edition]
end
@version = args.fetch :version, []
@biblionote = args.fetch :biblionote, BiblioNoteCollection.new([])
@language = args.fetch :language, []
@script = args.fetch :script, []
@version = args[:version] || []
@biblionote = args[:biblionote] || BiblioNoteCollection.new([])
@language = args[:language] || []
@script = args[:script] || []
@status = args[:docstatus]
@relation = DocRelationCollection.new(args[:relation] || [])
@link = args.fetch(:link, []).map do |s|
@link = (args[:link] || []).map do |s|
case s
when Hash then TypedUri.new(**s)
when String then TypedUri.new(content: s)
else s
end
end
@series = args.fetch :series, []
@series = args[:series] || []
@medium = args[:medium]
@place = args.fetch(:place, []).map do |pl|
@place = (args[:place] || []).map do |pl|
pl.is_a?(String) ? Place.new(name: pl) : pl
end
@extent = args[:extent] || []
@size = args[:size]
@accesslocation = args.fetch :accesslocation, []
@classification = args.fetch :classification, []
@accesslocation = args[:accesslocation] || []
@classification = args[:classification] || []
@validity = args[:validity]
# we should pass the fetched arg from scrappers
@fetched = args.fetch :fetched, nil
@fetched = args[:fetched]
@keyword = (args[:keyword] || []).map do |kw|
case kw
when Hash then LocalizedString.new(kw[:content], kw[:language], kw[:script])
when String then LocalizedString.new(kw)
else kw
end
end
@license = args.fetch :license, []
@license = args[:license] || []
@doctype = args[:doctype]
@subdoctype = args[:subdoctype]
@editorialgroup = args[:editorialgroup]
@ics = args.fetch :ics, []
@ics = args[:ics] || []
@structuredidentifier = args[:structuredidentifier]
end
# rubocop:enable Metrics/MethodLength, Metrics/AbcSize
Expand Down
2 changes: 1 addition & 1 deletion lib/relaton_bib/contribution_info.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def initialize(**args)
end

@type = args[:type]
@description = args.fetch(:description, []).map do |d|
@description = (args[:description] || []).map do |d|
FormattedString.new content: d, format: nil
end
end
Expand Down
16 changes: 9 additions & 7 deletions lib/relaton_bib/full_name.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,23 +23,25 @@ class FullName
# @param prefix [Array<RelatonBib::LocalizedString>] array of prefixes
# @param completename [RelatonBib::LocalizedString, nil] completename or surname should be present
#
def initialize(**args) # rubocop:disable Metrics/AbcSize
def initialize(**args) # rubocop:disable Metrics/AbcSize,Metrics/CyclomaticComplexity
unless args[:surname] || args[:completename]
raise ArgumentError, "Should be given :surname or :completename"
end

@surname = args[:surname]
@abbreviation = args[:abbreviation]
@forename = args.fetch :forename, []
@forename = args[:forename] || []
@initials = args[:initials].is_a?(String) ? LocalizedString.new(args[:initials]) : args[:initials]
@addition = args.fetch :addition, []
@prefix = args.fetch :prefix, []
@addition = args[:addition] || []
@prefix = args[:prefix] || []
@completename = args[:completename]
end

def ==(other)
surname == other.surname && abbreviation == other.abbreviation && completename == other.completename &&
forename == other.forename && initials == other.initials && addition == other.addition && prefix == other.prefix
def ==(other) # rubocop:disable Metrics/AbcSize,Metrics/CyclomaticComplexity
surname == other.surname && abbreviation == other.abbreviation &&
completename == other.completename && forename == other.forename &&
initials == other.initials && addition == other.addition &&
prefix == other.prefix
end

# @param opts [Hash]
Expand Down
6 changes: 3 additions & 3 deletions lib/relaton_bib/organization.rb
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,10 @@ class Organization < Contributor
# @param identifier [Array<RelatonBib::OrgIdentifier>]
# @param contact [Array<RelatonBib::Address, RelatonBib::Contact>]
# @param logo [RelatonBib::Image, nil]
def initialize(**args) # rubocop:disable Metrics/AbcSize,Metrics/MethodLength
def initialize(**args) # rubocop:disable Metrics/AbcSize,Metrics/MethodLength,Metrics/CyclomaticComplexity,Metrics/PerceivedComplexity
raise ArgumentError, "missing keyword: name" unless args[:name]

super(url: args[:url], contact: args.fetch(:contact, []))
super(url: args[:url], contact: args[:contact] || [])

@name = if args[:name].is_a?(Array)
args[:name].map { |n| localized_string(n) }
Expand All @@ -90,7 +90,7 @@ def initialize(**args) # rubocop:disable Metrics/AbcSize,Metrics/MethodLength
@subdivision = (args[:subdivision] || []).map do |sd|
localized_string sd
end
@identifier = args.fetch(:identifier, [])
@identifier = args[:identifier] || []
@logo = args[:logo]
end

Expand Down
2 changes: 1 addition & 1 deletion lib/relaton_bib/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module RelatonBib
VERSION = "1.20.5".freeze
VERSION = "1.20.6".freeze
end

0 comments on commit 7eeb0f1

Please sign in to comment.