From 902e01e101ead82db7ad9ebbfe619d4a6fcd7249 Mon Sep 17 00:00:00 2001 From: Naomi Dushay Date: Wed, 8 Dec 2021 14:33:16 -0800 Subject: [PATCH 1/8] physical_description: treat dimensions as a proper attribute of physical_description model --- .../rdf2model/mappers/physical_description_fields.rb | 11 +++++------ .../mappers/physical_description_fields_spec.rb | 4 ---- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/lib/rdf2marc/rdf2model/mappers/physical_description_fields.rb b/lib/rdf2marc/rdf2model/mappers/physical_description_fields.rb index 61a7a0e..1cf49e6 100644 --- a/lib/rdf2marc/rdf2model/mappers/physical_description_fields.rb +++ b/lib/rdf2marc/rdf2model/mappers/physical_description_fields.rb @@ -26,14 +26,13 @@ def physical_descriptions RDF::RDFS.label], subject_term: extent_term) } end - dimensions = { - dimensions: item.instance.query.path_all_literal([BF.dimensions]).sort - } - if extent_physical_description.length == 1 && dimensions[:dimensions].length == 1 - return [extent_physical_description.first.merge(dimensions)] + dimensions = item.instance.query.path_all_literal([BF.dimensions]).sort + if extent_physical_description.length == 1 && dimensions.length == 1 + return [extent_physical_description.first.merge(dimensions: dimensions)] end - extent_physical_description + [dimensions] + extent_physical_description << { dimensions: dimensions } if dimensions.present? + extent_physical_description end def media_types diff --git a/spec/rdf2marc/rdf2model/mappers/physical_description_fields_spec.rb b/spec/rdf2marc/rdf2model/mappers/physical_description_fields_spec.rb index 5d4d049..ad0383a 100644 --- a/spec/rdf2marc/rdf2model/mappers/physical_description_fields_spec.rb +++ b/spec/rdf2marc/rdf2model/mappers/physical_description_fields_spec.rb @@ -8,7 +8,6 @@ let(:model) do { - physical_descriptions: [{}] } end @@ -89,7 +88,6 @@ let(:model) do { - physical_descriptions: [{}], media_types: [ { authority_control_number_uri: 'http://id.loc.gov/vocabulary/mediaTypes/h', @@ -120,7 +118,6 @@ let(:model) do { - physical_descriptions: [{}], carrier_types: [ { authority_control_number_uri: 'http://id.loc.gov/vocabulary/carriers/nc', @@ -151,7 +148,6 @@ let(:model) do { - physical_descriptions: [{}], content_types: [ { authority_control_number_uri: 'http://id.loc.gov/vocabulary/contentTypes/sti', From ff554a1b85aef831ca6e19c1315d1dd08f2c874b Mon Sep 17 00:00:00 2001 From: Naomi Dushay Date: Wed, 8 Dec 2021 14:34:11 -0800 Subject: [PATCH 2/8] rdf2model/mappers/physical_description_fields_spec: fix ttl alignment --- .../rdf2model/mappers/physical_description_fields_spec.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/spec/rdf2marc/rdf2model/mappers/physical_description_fields_spec.rb b/spec/rdf2marc/rdf2model/mappers/physical_description_fields_spec.rb index ad0383a..d0f8d0a 100644 --- a/spec/rdf2marc/rdf2model/mappers/physical_description_fields_spec.rb +++ b/spec/rdf2marc/rdf2model/mappers/physical_description_fields_spec.rb @@ -18,7 +18,7 @@ context 'with multiple extents' do let(:ttl) do <<~TTL - <#{instance_term}> _:b38. + <#{instance_term}> _:b38. _:b38 a ; "149 pages"@eng, "1 score (16 p.)"@eng; _:b39. @@ -79,7 +79,7 @@ describe 'media types' do let(:ttl) do <<~TTL - <#{instance_term}> . + <#{instance_term}> . "unmediated". <#{instance_term}> . "microform". @@ -109,7 +109,7 @@ describe 'carrier types' do let(:ttl) do <<~TTL - <#{instance_term}> . + <#{instance_term}> . "volume". <#{instance_term}> . "audio cartridge". @@ -139,7 +139,7 @@ describe 'content types' do let(:ttl) do <<~TTL - <#{work_term}> . + <#{work_term}> . "text". <#{work_term}> . "still image". From 2e51559b2743af8b93c726d75ae140b4ed4502c9 Mon Sep 17 00:00:00 2001 From: Naomi Dushay Date: Wed, 8 Dec 2021 15:57:26 -0800 Subject: [PATCH 3/8] rdf2model physical_description_fields_spec: add spec for single extent and multiple dimensions --- .../physical_description_fields_spec.rb | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/spec/rdf2marc/rdf2model/mappers/physical_description_fields_spec.rb b/spec/rdf2marc/rdf2model/mappers/physical_description_fields_spec.rb index d0f8d0a..dba83c2 100644 --- a/spec/rdf2marc/rdf2model/mappers/physical_description_fields_spec.rb +++ b/spec/rdf2marc/rdf2model/mappers/physical_description_fields_spec.rb @@ -51,6 +51,34 @@ include_examples 'mapper', described_class end + context 'with a single extent and multiple dimensions' do + let(:ttl) do + <<~TTL + <#{instance_term}> _:b40. + _:b40 a ; + "1 sound disc (20 min.)"@eng. + <#{instance_term}> "10 x 27 cm"@eng ; + "7 1/4 x 3 1/2 in."@eng ; + "1/4 in. tape"@eng. + TTL + end + + let(:model) do + { + physical_descriptions: [ + { + extents: ['1 sound disc (20 min.)'] + }, + { + dimensions: ['1/4 in. tape', '10 x 27 cm', '7 1/4 x 3 1/2 in.'] + } + ] + } + end + + include_examples 'mapper', described_class + end + context 'with a single extent and a single dimension' do let(:ttl) do <<~TTL From d5a03d98287648cd7a7c522a81c2c0d329f00966 Mon Sep 17 00:00:00 2001 From: Naomi Dushay Date: Wed, 8 Dec 2021 15:47:10 -0800 Subject: [PATCH 4/8] add spec for model2marc field_300_spec --- spec/rdf2marc/model2marc/field_300_spec.rb | 78 ++++++++++++++++------ 1 file changed, 57 insertions(+), 21 deletions(-) diff --git a/spec/rdf2marc/model2marc/field_300_spec.rb b/spec/rdf2marc/model2marc/field_300_spec.rb index 724d784..dd465dc 100644 --- a/spec/rdf2marc/model2marc/field_300_spec.rb +++ b/spec/rdf2marc/model2marc/field_300_spec.rb @@ -1,29 +1,65 @@ # frozen_string_literal: true RSpec.describe Rdf2marc::Model2marc::Field300 do - let(:model) do - { - physical_description_fields: { - physical_descriptions: [ - { - extents: %w[extent1 extent2], - dimensions: %w[dimension1 dimension2], - materials_specified: 'materials_specified1' - }, - { - materials_specified: 'materials_specified2' - } - ] + context 'with multiple extents and dimensions in single physical description' do + let(:model) do + { + physical_description_fields: { + physical_descriptions: [ + { + extents: %w[extent1 extent2], + dimensions: %w[dimension1 dimension2], + materials_specified: 'materials_specified1' + }, + { + materials_specified: 'materials_specified2' + } + ] + } } - } - end + end + + let(:expected_fields) do + [ + '300 $a extent1 $a extent2 $c dimension1 $c dimension2 $3 materials_specified1', + '300 $3 materials_specified2' + ] + end - let(:expected_fields) do - [ - '300 $a extent1 $a extent2 $c dimension1 $c dimension2 $3 materials_specified1', - '300 $3 materials_specified2' - ] + include_examples 'fields', '300' end - include_examples 'fields', '300' + context 'with single extents and dimensions in multiple physical descriptions' do + let(:model) do + { + physical_description_fields: { + physical_descriptions: [ + { + extents: %w[extent1], + dimensions: %w[dimension1 dimensionA], + materials_specified: 'materials_specified1' + }, + { + extents: %w[extent2 extent3], + dimensions: %w[dimension2], + materials_specified: 'materials_specified1' + }, + { + materials_specified: 'materials_specified2' + } + ] + } + } + end + + let(:expected_fields) do + [ + '300 $a extent1 $c dimension1 $c dimensionA $3 materials_specified1', + '300 $a extent2 $a extent3 $c dimension2 $3 materials_specified1', + '300 $3 materials_specified2' + ] + end + + include_examples 'fields', '300' + end end From d15fda527a8d0b9f9b6acfb90097b2d5510779e7 Mon Sep 17 00:00:00 2001 From: Naomi Dushay Date: Wed, 8 Dec 2021 14:38:19 -0800 Subject: [PATCH 5/8] physical_description model gets other_physical_details attrib (mapped from BF.illustrativeContent) --- .../physical_description.rb | 1 + .../mappers/physical_description_fields.rb | 20 ++- .../maps_to_model.yml | 119 ++++++++++++++++++ .../physical_description_fields_spec.rb | 26 +++- 4 files changed, 159 insertions(+), 7 deletions(-) create mode 100644 spec/cassettes/Rdf2marc_Rdf2model_Mappers_PhysicalDescriptionFields/physical_descriptions/with_a_single_extent_and_illustrativeContent/maps_to_model.yml diff --git a/lib/rdf2marc/models/physical_description_field/physical_description.rb b/lib/rdf2marc/models/physical_description_field/physical_description.rb index 3226052..410dd2f 100644 --- a/lib/rdf2marc/models/physical_description_field/physical_description.rb +++ b/lib/rdf2marc/models/physical_description_field/physical_description.rb @@ -6,6 +6,7 @@ module PhysicalDescriptionField # Model for 300 - Physical Description. class PhysicalDescription < Struct attribute? :extents, Types::Array.of(Types::String) + attribute? :other_physical_details, Types::String attribute? :dimensions, Types::Array.of(Types::String) attribute? :materials_specified, Types::String end diff --git a/lib/rdf2marc/rdf2model/mappers/physical_description_fields.rb b/lib/rdf2marc/rdf2model/mappers/physical_description_fields.rb index 1cf49e6..f0eacc6 100644 --- a/lib/rdf2marc/rdf2model/mappers/physical_description_fields.rb +++ b/lib/rdf2marc/rdf2model/mappers/physical_description_fields.rb @@ -18,21 +18,29 @@ def generate def physical_descriptions extent_terms = item.instance.query.path_all([[BF.extent, BF.Extent]]) - extent_physical_description = extent_terms.sort.map do |extent_term| + + # can have multiple illustrativeContent, but only using one + illustrative_content_uri = item.instance.query.path_first_uri([BF.illustrativeContent]) || + item.work.query.path_first_uri([BF.illustrativeContent]) + if illustrative_content_uri + other_physical_details = LiteralOrRemoteResolver.resolve_label(term: illustrative_content_uri, item: item) + end + extent_physical_descriptions = extent_terms.sort.map do |extent_term| { extents: item.instance.query.path_all_literal([RDF::RDFS.label], subject_term: extent_term).sort, # Can be multiple notes, but only using one. materials_specified: item.instance.query.path_first_literal([[BF.note, BF.Note], - RDF::RDFS.label], subject_term: extent_term) + RDF::RDFS.label], subject_term: extent_term), + other_physical_details: other_physical_details } end dimensions = item.instance.query.path_all_literal([BF.dimensions]).sort - if extent_physical_description.length == 1 && dimensions.length == 1 - return [extent_physical_description.first.merge(dimensions: dimensions)] + if extent_physical_descriptions.length == 1 && dimensions.length == 1 + return [extent_physical_descriptions.first.merge(dimensions: dimensions)] end - extent_physical_description << { dimensions: dimensions } if dimensions.present? - extent_physical_description + extent_physical_descriptions << { dimensions: dimensions } if dimensions.present? + extent_physical_descriptions end def media_types diff --git a/spec/cassettes/Rdf2marc_Rdf2model_Mappers_PhysicalDescriptionFields/physical_descriptions/with_a_single_extent_and_illustrativeContent/maps_to_model.yml b/spec/cassettes/Rdf2marc_Rdf2model_Mappers_PhysicalDescriptionFields/physical_descriptions/with_a_single_extent_and_illustrativeContent/maps_to_model.yml new file mode 100644 index 0000000..b43a72a --- /dev/null +++ b/spec/cassettes/Rdf2marc_Rdf2model_Mappers_PhysicalDescriptionFields/physical_descriptions/with_a_single_extent_and_illustrativeContent/maps_to_model.yml @@ -0,0 +1,119 @@ +--- +http_interactions: +- request: + method: get + uri: http://id.loc.gov/vocabulary/millus/ill.skos.nt + body: + encoding: US-ASCII + string: '' + headers: + User-Agent: + - Ruby RDF.rb/3.1.15 + Accept: + - text/turtle, text/rdf+turtle, application/turtle;q=0.2, application/x-turtle;q=0.2, + application/ld+json, application/x-ld+json, application/rdf+xml, application/n-triples, + text/plain;q=0.2, application/n-quads, text/x-nquads;q=0.2, */*;q=0.1 + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + response: + status: + code: 301 + message: Moved Permanently + headers: + Date: + - Wed, 08 Dec 2021 23:32:52 GMT + Transfer-Encoding: + - chunked + Connection: + - keep-alive + Cache-Control: + - max-age=3600 + Expires: + - Thu, 09 Dec 2021 00:32:52 GMT + Location: + - https://id.loc.gov/vocabulary/millus/ill.skos.nt + Vary: + - Accept-Encoding + Server: + - cloudflare + Cf-Ray: + - 6ba9cba6eb75711b-SJC + body: + encoding: UTF-8 + string: '' + recorded_at: Wed, 08 Dec 2021 23:32:52 GMT +- request: + method: get + uri: https://id.loc.gov/vocabulary/millus/ill.skos.nt + body: + encoding: US-ASCII + string: '' + headers: + User-Agent: + - Ruby RDF.rb/3.1.15 + Accept: + - text/turtle, text/rdf+turtle, application/turtle;q=0.2, application/x-turtle;q=0.2, + application/ld+json, application/x-ld+json, application/rdf+xml, application/n-triples, + text/plain;q=0.2, application/n-quads, text/x-nquads;q=0.2, */*;q=0.1 + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + response: + status: + code: 200 + message: OK + headers: + Date: + - Wed, 08 Dec 2021 23:32:53 GMT + Content-Type: + - text/plain; charset=UTF-8 + Transfer-Encoding: + - chunked + Connection: + - keep-alive + X-Frame-Options: + - DENY + X-Xss-Protection: + - '1' + X-Content-Type-Options: + - nosniff + Access-Control-Allow-Origin: + - "*" + Access-Control-Allow-Method: + - HEAD, POST, GET, OPTIONS + Access-Control-Allow-Headers: + - Content-Type, Access-Control-Allow-Headers, Authorization, X-Requested-With + Access-Control-Expose-Headers: + - Content-Type, Cache-Control, X-URI, X-PrefLabel + Strict-Transport-Security: + - max-age=31536000 + X-Preflabel: + - Illustrations + X-Uri: + - http://id.loc.gov/vocabulary/millus/ill + Cache-Control: + - public, max-age=2419200 + X-Varnish: + - 378161244 367752864 + Age: + - '1409632' + Via: + - 1.1 varnish (Varnish/6.0) + Cf-Cache-Status: + - DYNAMIC + Expect-Ct: + - max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct" + Server: + - cloudflare + Cf-Ray: + - 6ba9cba72bc9ed6b-SJC + body: + encoding: ASCII-8BIT + string: |- + . + "Illustrations" . + "Resource contains illustrations, type unspecified"@en . + "008BK/18-21 - a"@en . + "ill" . + . + recorded_at: Wed, 08 Dec 2021 23:32:53 GMT +recorded_with: VCR 6.0.0 diff --git a/spec/rdf2marc/rdf2model/mappers/physical_description_fields_spec.rb b/spec/rdf2marc/rdf2model/mappers/physical_description_fields_spec.rb index dba83c2..75bb449 100644 --- a/spec/rdf2marc/rdf2model/mappers/physical_description_fields_spec.rb +++ b/spec/rdf2marc/rdf2model/mappers/physical_description_fields_spec.rb @@ -2,7 +2,7 @@ require 'rdf2marc/rdf2model/mappers/mappers_shared_examples' -RSpec.describe Rdf2marc::Rdf2model::Mappers::PhysicalDescriptionFields do +RSpec.describe Rdf2marc::Rdf2model::Mappers::PhysicalDescriptionFields, :vcr do context 'with minimal graph' do let(:ttl) { '' } @@ -102,6 +102,30 @@ include_examples 'mapper', described_class end + + context 'with a single extent and illustrativeContent' do + let(:ttl) do + <<~TTL + <#{instance_term}> _:b38. + _:b38 a ; + "1 folded sheet (5 pages)"@eng. + <#{work_term}> . + TTL + end + + let(:model) do + { + physical_descriptions: [ + { + extents: ['1 folded sheet (5 pages)'], + other_physical_details: 'Illustrations' + } + ] + } + end + + include_examples 'mapper', described_class + end end describe 'media types' do From ffebf3b81574c89008436d132821d2d9a6f33f63 Mon Sep 17 00:00:00 2001 From: Naomi Dushay Date: Wed, 8 Dec 2021 16:09:01 -0800 Subject: [PATCH 6/8] map physical_description other_physical_details to Marc 300b --- lib/rdf2marc/model2marc/field_300.rb | 1 + spec/rdf2marc/model2marc/field_300_spec.rb | 24 ++++++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/lib/rdf2marc/model2marc/field_300.rb b/lib/rdf2marc/model2marc/field_300.rb index d89be57..64125c1 100644 --- a/lib/rdf2marc/model2marc/field_300.rb +++ b/lib/rdf2marc/model2marc/field_300.rb @@ -10,6 +10,7 @@ def initialize(marc_record, model) def build append_repeatable('a', model.extents) + append('b', model.other_physical_details) append_repeatable('c', model.dimensions) append('3', model.materials_specified) end diff --git a/spec/rdf2marc/model2marc/field_300_spec.rb b/spec/rdf2marc/model2marc/field_300_spec.rb index dd465dc..ece2a85 100644 --- a/spec/rdf2marc/model2marc/field_300_spec.rb +++ b/spec/rdf2marc/model2marc/field_300_spec.rb @@ -62,4 +62,28 @@ include_examples 'fields', '300' end + + context 'with other_physical_details physical descriptions' do + let(:model) do + { + physical_description_fields: { + physical_descriptions: [ + { + extents: %w[extent1], + other_physical_details: 'Illustrations', + dimensions: %w[dimension1] + } + ] + } + } + end + + let(:expected_fields) do + [ + '300 $a extent1 $b Illustrations $c dimension1' + ] + end + + include_examples 'fields', '300' + end end From ee41f412b222084e7a697755fbb327d5b7b2685f Mon Sep 17 00:00:00 2001 From: Naomi Dushay Date: Wed, 8 Dec 2021 16:27:45 -0800 Subject: [PATCH 7/8] map RDF illustrativeContent to model control_field general_info --- .../models/control_field/general_info.rb | 1 + .../rdf2model/mappers/control_fields.rb | 11 +- .../maps_to_model.yml | 119 ++++++++++++++++++ .../model2marc/control_field_008_spec.rb | 23 ++++ .../rdf2model/mappers/control_fields_spec.rb | 25 +++- 5 files changed, 175 insertions(+), 4 deletions(-) create mode 100644 spec/cassettes/Rdf2marc_Rdf2model_Mappers_ControlFields/general_info_book_illustrative_content/maps_to_model.yml diff --git a/lib/rdf2marc/models/control_field/general_info.rb b/lib/rdf2marc/models/control_field/general_info.rb index 8bef438..c77d514 100644 --- a/lib/rdf2marc/models/control_field/general_info.rb +++ b/lib/rdf2marc/models/control_field/general_info.rb @@ -9,6 +9,7 @@ class GeneralInfo < Struct attribute? :date1, Types::String attribute? :place, Types::String.default('xx').constrained(min_size: 2, max_size: 3) attribute? :language, Types::String + attribute? :book_illustrative_content, Types::String end end end diff --git a/lib/rdf2marc/rdf2model/mappers/control_fields.rb b/lib/rdf2marc/rdf2model/mappers/control_fields.rb index 71cda53..8676330 100644 --- a/lib/rdf2marc/rdf2model/mappers/control_fields.rb +++ b/lib/rdf2marc/rdf2model/mappers/control_fields.rb @@ -12,7 +12,8 @@ def generate place: place, date_entered: date_entered, date1: item.instance.query.path_first_literal([[BF.provisionActivity, BF.Publication], [BF.date]]), - language: language + language: language, + book_illustrative_content: book_illustrative_content } } end @@ -51,6 +52,14 @@ def language language_uri.sub(%r{^https?://id.loc.gov/vocabulary/languages/}, '') end + + def book_illustrative_content + illustrative_content_uri = item.instance.query.path_first_uri([BF.illustrativeContent]) || + item.work.query.path_first_uri([BF.illustrativeContent]) + return nil if illustrative_content_uri.blank? + + LiteralOrRemoteResolver.resolve_label(term: illustrative_content_uri, item: item) + end end end end diff --git a/spec/cassettes/Rdf2marc_Rdf2model_Mappers_ControlFields/general_info_book_illustrative_content/maps_to_model.yml b/spec/cassettes/Rdf2marc_Rdf2model_Mappers_ControlFields/general_info_book_illustrative_content/maps_to_model.yml new file mode 100644 index 0000000..92865d4 --- /dev/null +++ b/spec/cassettes/Rdf2marc_Rdf2model_Mappers_ControlFields/general_info_book_illustrative_content/maps_to_model.yml @@ -0,0 +1,119 @@ +--- +http_interactions: +- request: + method: get + uri: http://id.loc.gov/vocabulary/millus/ill.skos.nt + body: + encoding: US-ASCII + string: '' + headers: + User-Agent: + - Ruby RDF.rb/3.1.15 + Accept: + - text/turtle, text/rdf+turtle, application/turtle;q=0.2, application/x-turtle;q=0.2, + application/ld+json, application/x-ld+json, application/rdf+xml, application/n-triples, + text/plain;q=0.2, application/n-quads, text/x-nquads;q=0.2, */*;q=0.1 + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + response: + status: + code: 301 + message: Moved Permanently + headers: + Date: + - Thu, 09 Dec 2021 00:26:24 GMT + Transfer-Encoding: + - chunked + Connection: + - keep-alive + Cache-Control: + - max-age=3600 + Expires: + - Thu, 09 Dec 2021 01:26:24 GMT + Location: + - https://id.loc.gov/vocabulary/millus/ill.skos.nt + Vary: + - Accept-Encoding + Server: + - cloudflare + Cf-Ray: + - 6baa1a111e3d3b34-SJC + body: + encoding: UTF-8 + string: '' + recorded_at: Thu, 09 Dec 2021 00:26:24 GMT +- request: + method: get + uri: https://id.loc.gov/vocabulary/millus/ill.skos.nt + body: + encoding: US-ASCII + string: '' + headers: + User-Agent: + - Ruby RDF.rb/3.1.15 + Accept: + - text/turtle, text/rdf+turtle, application/turtle;q=0.2, application/x-turtle;q=0.2, + application/ld+json, application/x-ld+json, application/rdf+xml, application/n-triples, + text/plain;q=0.2, application/n-quads, text/x-nquads;q=0.2, */*;q=0.1 + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + response: + status: + code: 200 + message: OK + headers: + Date: + - Thu, 09 Dec 2021 00:26:25 GMT + Content-Type: + - text/plain; charset=UTF-8 + Transfer-Encoding: + - chunked + Connection: + - keep-alive + X-Frame-Options: + - DENY + X-Xss-Protection: + - '1' + X-Content-Type-Options: + - nosniff + Access-Control-Allow-Origin: + - "*" + Access-Control-Allow-Method: + - HEAD, POST, GET, OPTIONS + Access-Control-Allow-Headers: + - Content-Type, Access-Control-Allow-Headers, Authorization, X-Requested-With + Access-Control-Expose-Headers: + - Content-Type, Cache-Control, X-URI, X-PrefLabel + Strict-Transport-Security: + - max-age=31536000 + X-Preflabel: + - Illustrations + X-Uri: + - http://id.loc.gov/vocabulary/millus/ill + Cache-Control: + - public, max-age=2419200 + X-Varnish: + - 376457851 367752864 + Age: + - '1412844' + Via: + - 1.1 varnish (Varnish/6.0) + Cf-Cache-Status: + - DYNAMIC + Expect-Ct: + - max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct" + Server: + - cloudflare + Cf-Ray: + - 6baa1a115b43711a-SJC + body: + encoding: ASCII-8BIT + string: |- + . + "Illustrations" . + "Resource contains illustrations, type unspecified"@en . + "008BK/18-21 - a"@en . + "ill" . + . + recorded_at: Thu, 09 Dec 2021 00:26:25 GMT +recorded_with: VCR 6.0.0 diff --git a/spec/rdf2marc/model2marc/control_field_008_spec.rb b/spec/rdf2marc/model2marc/control_field_008_spec.rb index bec2b7e..097d7d7 100644 --- a/spec/rdf2marc/model2marc/control_field_008_spec.rb +++ b/spec/rdf2marc/model2marc/control_field_008_spec.rb @@ -41,4 +41,27 @@ include_examples 'fields', '008' end + + context 'with model with illustrative_content' do + let(:model) do + { + control_fields: { + general_info: { + date_entered: Date.new(2020, 10, 15), + date1: '202x', + place: 'gau', + language: 'ace' + } + } + } + end + + let(:expected_fields) { ['008 201015s202u gaua ace||'] } + + before do + allow(Date).to receive(:today).and_return(Date.new(2020, 10, 1)) + end + + include_examples 'fields', '008' + end end diff --git a/spec/rdf2marc/rdf2model/mappers/control_fields_spec.rb b/spec/rdf2marc/rdf2model/mappers/control_fields_spec.rb index 1507f07..4737920 100644 --- a/spec/rdf2marc/rdf2model/mappers/control_fields_spec.rb +++ b/spec/rdf2marc/rdf2model/mappers/control_fields_spec.rb @@ -39,7 +39,7 @@ describe 'general info place' do let(:ttl) do <<~TTL - <#{instance_term}> _:b9. + <#{instance_term}> _:b9. _:b9 a ; . "Palo Alto (Miss.)". @@ -79,7 +79,7 @@ describe 'general info date1' do let(:ttl) do <<~TTL - <#{instance_term}> _:b10. + <#{instance_term}> _:b10. _:b10 a ; "2020-10-12"@eng. TTL @@ -100,7 +100,7 @@ describe 'general info language' do let(:ttl) do <<~TTL - <#{work_term}> . + <#{work_term}> . "Achinese". <> . "Bugis". @@ -118,4 +118,23 @@ include_examples 'mapper', described_class end + + describe 'general info book illustrative content' do + let(:ttl) do + <<~TTL + <#{work_term}> . + TTL + end + + let(:model) do + { + general_info: { + book_illustrative_content: 'Illustrations', + place: 'xx' + } + } + end + + include_examples 'mapper', described_class + end end From a9bd1751d54285fef8523bc96756c3686a8a37b5 Mon Sep 17 00:00:00 2001 From: Naomi Dushay Date: Wed, 8 Dec 2021 16:33:12 -0800 Subject: [PATCH 8/8] map model control_field general_info.book_illustrative_content to MARC 008/18 --- lib/rdf2marc/model2marc/control_field_008.rb | 2 ++ spec/rdf2marc/model2marc/control_field_008_spec.rb | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/rdf2marc/model2marc/control_field_008.rb b/lib/rdf2marc/model2marc/control_field_008.rb index 84436a5..cac73e9 100644 --- a/lib/rdf2marc/model2marc/control_field_008.rb +++ b/lib/rdf2marc/model2marc/control_field_008.rb @@ -19,6 +19,8 @@ def value field_value[6..14] = '|||||||||' end field_value[15..17] = model.place + # Book Illustrative Context + field_value[18] = 'a' if model.book_illustrative_content.present? # Language field_value[35..37] = model.language[0..2] if model.language # Modified record diff --git a/spec/rdf2marc/model2marc/control_field_008_spec.rb b/spec/rdf2marc/model2marc/control_field_008_spec.rb index 097d7d7..d125afb 100644 --- a/spec/rdf2marc/model2marc/control_field_008_spec.rb +++ b/spec/rdf2marc/model2marc/control_field_008_spec.rb @@ -50,7 +50,8 @@ date_entered: Date.new(2020, 10, 15), date1: '202x', place: 'gau', - language: 'ace' + language: 'ace', + book_illustrative_content: 'Illustrations' } } }