relaton / loc_mods

LOC MODS in Ruby
0 stars 1 forks source link

Migrate to lutaml-model #16

Closed ronaldtse closed 1 month ago

ronaldtse commented 1 month ago

Fixes #15.

There is an incompatibility with Shale here:

Given this code:

module LocMods
  class OriginInfo < BaseMapper
# ...
    attribute :date_issued, Date, collection: true
# ...

    xml do
      root "originInfo"
# ...
      map_element "dateIssued", to: :date_issued
# ...
    end
  end
end
module LocMods
  class Date < BaseMapper
# ...
    xml do
      root "recordChangeDate"
      namespace "http://www.loc.gov/mods/v3", nil
# ...
    end
  end
end

We get these errors:

  20) LocMods::Collection round-trips NIST MODS record: allrecords-MODS-991000026529708106
      Failure/Error: expect(output).to be_analogous_with(input)

        DIFF 1: expected node: <recordChangeDate encoding="marc">2012</recordChangeDate>
                actual node  : <dateIssued encoding="marc">2012</dateIssued>
                diff from    : recordChangeDate
                diff to      : dateIssued

        DIFF 2: expected node: <recordChangeDate>2012.</recordChangeDate>
                actual node  : <dateIssued>2012.</dateIssued>
                diff from    : recordChangeDate
                diff to      : dateIssued

        DIFF 3: expected node: <nameIdentifier type="oclc">1255596905</nameIdentifier>
                actual node  : <identifier type="oclc">1255596905</identifier>
                diff from    : nameIdentifier
                diff to      : identifier
      # ./spec/loc_mods/collection_spec.rb:83:in `block (3 levels) in <top (required)>'

Because the root tag in the inner element is used instead of the original mapped element tag in the outer element.

This is a lutaml-model bug.