diff --git a/CHANGELOG.md b/CHANGELOG.md index 9879b214..b9b0a71f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,9 @@ This project bumps the version number for any changes (including documentation u ## [Unreleased] - i.e. pushed to main branch but not yet tagged as a release - none +## [4.0.2] - 2022-06-07 +Uses Zeitwerk eager loading (and custom inflection on version.rb to VERSION) to make `rails:zeitwerk` check pass when used with collectionspace-csv-importer. + ## [4.0.1] - 2022-05-23 See [PR 138](https://github.com/collectionspace/collectionspace-mapper/pull/138) for more details on changes. diff --git a/lib/collectionspace/mapper.rb b/lib/collectionspace/mapper.rb index bb3af2ec..a7781df4 100644 --- a/lib/collectionspace/mapper.rb +++ b/lib/collectionspace/mapper.rb @@ -15,11 +15,16 @@ require 'xxhash' require 'zeitwerk' +loader = Zeitwerk::Loader.new +loader.inflector.inflect( + "version" => "VERSION" +) +loader.push_dir("#{__dir__}/mapper", namespace: CollectionSpace::Mapper) +loader.setup +loader.eager_load + module CollectionSpace - ::CS = CollectionSpace module Mapper - - LOGGER = Logger.new(STDERR) THE_BOMB = "\u{1F4A3}" @@ -68,8 +73,4 @@ def merge_default_values(data, batchconfig) data end end - - loader = Zeitwerk::Loader.new - loader.push_dir("#{__dir__}/mapper", namespace: CollectionSpace::Mapper) - loader.setup end diff --git a/lib/collectionspace/mapper/column_mappings.rb b/lib/collectionspace/mapper/column_mappings.rb index 65108db8..20e89188 100644 --- a/lib/collectionspace/mapper/column_mappings.rb +++ b/lib/collectionspace/mapper/column_mappings.rb @@ -49,7 +49,7 @@ def required_columns attr_reader :mapper, :config, :all, :lkup def add_mapping(mapping_hash) - mapobj = CS::Mapper::ColumnMapping.new(mapping_hash, mapper) + mapobj = CollectionSpace::Mapper::ColumnMapping.new(mapping_hash, mapper) all << mapobj lkup[mapobj.datacolumn] = mapobj end diff --git a/lib/collectionspace/mapper/config.rb b/lib/collectionspace/mapper/config.rb index 516d0aac..4c8208b5 100644 --- a/lib/collectionspace/mapper/config.rb +++ b/lib/collectionspace/mapper/config.rb @@ -136,13 +136,13 @@ def has_required_attributes def record_type_extension case record_type when 'media' - CS::Mapper::Media + CollectionSpace::Mapper::Media when 'objecthierarchy' - CS::Mapper::ObjectHierarchy + CollectionSpace::Mapper::ObjectHierarchy when 'authorityhierarchy' - CS::Mapper::AuthorityHierarchy + CollectionSpace::Mapper::AuthorityHierarchy when 'nonhierarchicalrelationship' - CS::Mapper::NonHierarchicalRelationship + CollectionSpace::Mapper::NonHierarchicalRelationship else nil end diff --git a/lib/collectionspace/mapper/data_handler.rb b/lib/collectionspace/mapper/data_handler.rb index 667878cb..c95277bf 100644 --- a/lib/collectionspace/mapper/data_handler.rb +++ b/lib/collectionspace/mapper/data_handler.rb @@ -13,9 +13,9 @@ def initialize(record_mapper:, client:, cache:, csid_cache:, config: {}) @mapper = CollectionSpace::Mapper::RecordMapper.new(mapper: record_mapper, batchconfig: config, csclient: client, termcache: cache, csidcache: csid_cache ) - @validator = CS::Mapper::DataValidator.new(@mapper, @mapper.termcache) - @searcher = CS::Mapper::Searcher.new(client: client, config: mapper.batchconfig) - @date_handler = CS::Mapper::Dates::StructuredDateHandler.new( + @validator = CollectionSpace::Mapper::DataValidator.new(@mapper, @mapper.termcache) + @searcher = CollectionSpace::Mapper::Searcher.new(client: client, config: mapper.batchconfig) + @date_handler = CollectionSpace::Mapper::Dates::StructuredDateHandler.new( client: client, cache: cache, csid_cache: csid_cache, diff --git a/lib/collectionspace/mapper/dates/chronic_parser.rb b/lib/collectionspace/mapper/dates/chronic_parser.rb index 0d40a740..176bd398 100644 --- a/lib/collectionspace/mapper/dates/chronic_parser.rb +++ b/lib/collectionspace/mapper/dates/chronic_parser.rb @@ -6,14 +6,14 @@ module CollectionSpace module Mapper module Dates class ChronicParser - include CS::Mapper::Dates::Mappable + include CollectionSpace::Mapper::Dates::Mappable attr_reader :mappable def initialize(date_string, handler) @date_string = date_string @handler = handler parsed = parse - return CS::Mapper::Dates::ServicesParser.new(date_string, handler) unless parsed + return CollectionSpace::Mapper::Dates::ServicesParser.new(date_string, handler) unless parsed @mappable = map_timestamp(parsed) self diff --git a/lib/collectionspace/mapper/dates/services_parser.rb b/lib/collectionspace/mapper/dates/services_parser.rb index 76efd04e..5d878948 100644 --- a/lib/collectionspace/mapper/dates/services_parser.rb +++ b/lib/collectionspace/mapper/dates/services_parser.rb @@ -4,7 +4,7 @@ module CollectionSpace module Mapper module Dates class ServicesParser - include CS::Mapper::Dates::Mappable + include CollectionSpace::Mapper::Dates::Mappable attr_reader :mappable def initialize(date_string, handler) diff --git a/lib/collectionspace/mapper/dates/structured_date_handler.rb b/lib/collectionspace/mapper/dates/structured_date_handler.rb index 5d446589..dd9e9cce 100644 --- a/lib/collectionspace/mapper/dates/structured_date_handler.rb +++ b/lib/collectionspace/mapper/dates/structured_date_handler.rb @@ -25,21 +25,21 @@ def ce def call(date_string) if date_string == '%NULLVALUE%' - CS::Mapper::Dates::NullDate.new + CollectionSpace::Mapper::Dates::NullDate.new elsif date_string == THE_BOMB - CS::Mapper::Dates::DateBomber.new + CollectionSpace::Mapper::Dates::DateBomber.new elsif date_formats.any?{ |re| date_string.match?(re) } - CS::Mapper::Dates::ChronicParser.new(date_string, self) + CollectionSpace::Mapper::Dates::ChronicParser.new(date_string, self) elsif two_digit_year_date_formats.any?{ |re| date_string.match?(re) } - CS::Mapper::Dates::TwoDigitYearHandler.new(date_string, self) + CollectionSpace::Mapper::Dates::TwoDigitYearHandler.new(date_string, self) elsif service_parseable_month_formats.any?{ |re| date_string.match?(re) } - CS::Mapper::Dates::ServicesParser.new(date_string, self) + CollectionSpace::Mapper::Dates::ServicesParser.new(date_string, self) elsif other_month_formats.any?{ |re| date_string.match?(re) } - CS::Mapper::Dates::YearMonthDateCreator.new(date_string, self) + CollectionSpace::Mapper::Dates::YearMonthDateCreator.new(date_string, self) elsif date_string.match?(/^\d{4}$/) - CS::Mapper::Dates::YearDateCreator.new(date_string, self) + CollectionSpace::Mapper::Dates::YearDateCreator.new(date_string, self) else - CS::Mapper::Dates::ServicesParser.new(date_string, self) + CollectionSpace::Mapper::Dates::ServicesParser.new(date_string, self) end end diff --git a/lib/collectionspace/mapper/dates/two_digit_year_handler.rb b/lib/collectionspace/mapper/dates/two_digit_year_handler.rb index 92378403..63f9d584 100644 --- a/lib/collectionspace/mapper/dates/two_digit_year_handler.rb +++ b/lib/collectionspace/mapper/dates/two_digit_year_handler.rb @@ -4,7 +4,7 @@ module CollectionSpace module Mapper module Dates class TwoDigitYearHandler - include CS::Mapper::Dates::Mappable + include CollectionSpace::Mapper::Dates::Mappable attr_reader :mappable @@ -13,9 +13,9 @@ def initialize(date_string, handler) @year_handling = handler.config.two_digit_year_handling if literal? - @mappable = CS::Mapper::Dates::ServicesParser.new(date_string, handler).mappable + @mappable = CollectionSpace::Mapper::Dates::ServicesParser.new(date_string, handler).mappable elsif coerce? - mappable = CS::Mapper::Dates::ChronicParser.new(coerced_year_date, handler).mappable + mappable = CollectionSpace::Mapper::Dates::ChronicParser.new(coerced_year_date, handler).mappable mappable['dateDisplayDate'] = date_string @mappable = mappable else diff --git a/lib/collectionspace/mapper/dates/year_date_creator.rb b/lib/collectionspace/mapper/dates/year_date_creator.rb index 748928cc..7b284331 100644 --- a/lib/collectionspace/mapper/dates/year_date_creator.rb +++ b/lib/collectionspace/mapper/dates/year_date_creator.rb @@ -4,7 +4,7 @@ module CollectionSpace module Mapper module Dates class YearDateCreator - include CS::Mapper::Dates::Mappable + include CollectionSpace::Mapper::Dates::Mappable attr_reader :mappable diff --git a/lib/collectionspace/mapper/dates/year_month_date_creator.rb b/lib/collectionspace/mapper/dates/year_month_date_creator.rb index b842c879..65f88a32 100644 --- a/lib/collectionspace/mapper/dates/year_month_date_creator.rb +++ b/lib/collectionspace/mapper/dates/year_month_date_creator.rb @@ -4,7 +4,7 @@ module CollectionSpace module Mapper module Dates class YearMonthDateCreator - include CS::Mapper::Dates::Mappable + include CollectionSpace::Mapper::Dates::Mappable attr_reader :mappable diff --git a/lib/collectionspace/mapper/record_mapper.rb b/lib/collectionspace/mapper/record_mapper.rb index f2c0bdcb..f85143f1 100644 --- a/lib/collectionspace/mapper/record_mapper.rb +++ b/lib/collectionspace/mapper/record_mapper.rb @@ -22,7 +22,7 @@ class RecordMapper def initialize(opts) jhash = opts[:mapper].is_a?(Hash) ? opts[:mapper] : JSON.parse(opts[:mapper]) convert(jhash) - @batchconfig = CS::Mapper::Config.new(config: opts[:batchconfig], record_type: record_type) + @batchconfig = CollectionSpace::Mapper::Config.new(config: opts[:batchconfig], record_type: record_type) @csclient = opts[:csclient] @termcache = opts[:termcache] @csidcache = opts[:csidcache] @@ -38,11 +38,11 @@ def record_type def service_type_extension case config.service_type when 'authority' - CS::Mapper::Authority + CollectionSpace::Mapper::Authority when 'relation' - CS::Mapper::Relationship + CollectionSpace::Mapper::Relationship when 'procedure' - CS::Mapper::Media if record_type == 'media' + CollectionSpace::Mapper::Media if record_type == 'media' end end @@ -50,9 +50,9 @@ def service_type_extension def convert(json) hash = symbolize(json) - @config = CS::Mapper::RecordMapperConfig.new(hash[:config]) - @xml_template = CS::Mapper::XmlTemplate.new(hash[:docstructure]) - @mappings = CS::Mapper::ColumnMappings.new(mappings: hash[:mappings], + @config = CollectionSpace::Mapper::RecordMapperConfig.new(hash[:config]) + @xml_template = CollectionSpace::Mapper::XmlTemplate.new(hash[:docstructure]) + @mappings = CollectionSpace::Mapper::ColumnMappings.new(mappings: hash[:mappings], mapper: self) end end diff --git a/lib/collectionspace/mapper/row_data.rb b/lib/collectionspace/mapper/row_data.rb index f1a45567..e25d60bc 100644 --- a/lib/collectionspace/mapper/row_data.rb +++ b/lib/collectionspace/mapper/row_data.rb @@ -10,7 +10,7 @@ class RowData def initialize(datahash, recmapper) @recmapper = recmapper @columns = datahash.map do |column, value| - CS::Mapper::ColumnValue.create(column: column, + CollectionSpace::Mapper::ColumnValue.create(column: column, value: value, recmapper: @recmapper, mapping: @recmapper.mappings.lookup(column)) diff --git a/lib/collectionspace/mapper/searcher.rb b/lib/collectionspace/mapper/searcher.rb index d7464dd7..14064c7b 100644 --- a/lib/collectionspace/mapper/searcher.rb +++ b/lib/collectionspace/mapper/searcher.rb @@ -3,7 +3,7 @@ module CollectionSpace module Mapper class Searcher - def initialize(client:, config: CS::Mapper::Config.new({})) + def initialize(client:, config: CollectionSpace::Mapper::Config.new({})) @client = client @active = config.search_if_not_cached @search_fields = {} diff --git a/lib/collectionspace/mapper/tools/record_status_service_builder.rb b/lib/collectionspace/mapper/tools/record_status_service_builder.rb index 836309bf..6198fa3c 100644 --- a/lib/collectionspace/mapper/tools/record_status_service_builder.rb +++ b/lib/collectionspace/mapper/tools/record_status_service_builder.rb @@ -7,9 +7,9 @@ class RecordStatusServiceBuilder class << self def call(client, mapper) if mapper.batchconfig.status_check_method == 'client' - CS::Mapper::Tools::RecordStatusServiceClient.new(client, mapper) + CollectionSpace::Mapper::Tools::RecordStatusServiceClient.new(client, mapper) else - CS::Mapper::Tools::RecordStatusServiceCache.new(mapper) + CollectionSpace::Mapper::Tools::RecordStatusServiceCache.new(mapper) end end end diff --git a/lib/collectionspace/mapper/tools/record_status_service_cache.rb b/lib/collectionspace/mapper/tools/record_status_service_cache.rb index f2b9e9a3..05a2690e 100644 --- a/lib/collectionspace/mapper/tools/record_status_service_cache.rb +++ b/lib/collectionspace/mapper/tools/record_status_service_cache.rb @@ -6,7 +6,7 @@ module Tools # Returns status of records, based on presence in CSID Cache. # @note This should **only** be used with expert migration tooling with which you can # confidently ensure the CSID Cache is accurately populated with all existing records - class RecordStatusServiceCache < CS::Mapper::Tools::RecordStatusServiceBuilder + class RecordStatusServiceCache < CollectionSpace::Mapper::Tools::RecordStatusServiceBuilder def initialize(mapper) super @refname_cache = mapper.termcache diff --git a/lib/collectionspace/mapper/tools/record_status_service_client.rb b/lib/collectionspace/mapper/tools/record_status_service_client.rb index 559413ff..e6855bb1 100644 --- a/lib/collectionspace/mapper/tools/record_status_service_client.rb +++ b/lib/collectionspace/mapper/tools/record_status_service_client.rb @@ -3,7 +3,7 @@ module CollectionSpace module Mapper module Tools - class RecordStatusServiceClient < CS::Mapper::Tools::RecordStatusServiceBuilder + class RecordStatusServiceClient < CollectionSpace::Mapper::Tools::RecordStatusServiceBuilder def initialize(client, mapper) super @client = client @@ -32,14 +32,14 @@ def get_service subtype: subtype ) rescue KeyError - raise CS::Mapper::NoClientServiceError, + raise CollectionSpace::Mapper::NoClientServiceError, "#{type} > #{subtype}" end else begin client.service(type: type) rescue KeyError - raise CS::Mapper::NoClientServiceError, type + raise CollectionSpace::Mapper::NoClientServiceError, type end end end diff --git a/lib/collectionspace/mapper/unknown_term.rb b/lib/collectionspace/mapper/unknown_term.rb index 68b13abf..bd1c70dc 100644 --- a/lib/collectionspace/mapper/unknown_term.rb +++ b/lib/collectionspace/mapper/unknown_term.rb @@ -4,7 +4,7 @@ module CollectionSpace module Mapper class UnknownTerm - class ReconstituteNilError < CS::Mapper::Error + class ReconstituteNilError < CollectionSpace::Mapper::Error def initialize msg = "Cannot reconstitute from NilValue" super(msg) @@ -27,7 +27,7 @@ def initialize(type:, subtype:, term:) @subtype = subtype @display_name = term @identifier = term - # Named "urn" to be used the same way as CS::Mapper::Tools::RefName + # Named "urn" to be used the same way as CollectionSpace::Mapper::Tools::RefName # This value gets cached and can be reconstituted into an UnknownTerm object @urn = "#{type}|||#{subtype}|||#{term}" end diff --git a/lib/collectionspace/mapper/version.rb b/lib/collectionspace/mapper/version.rb index 517196a2..1c128ce1 100644 --- a/lib/collectionspace/mapper/version.rb +++ b/lib/collectionspace/mapper/version.rb @@ -2,6 +2,6 @@ module CollectionSpace module Mapper - VERSION = '4.0.1' + VERSION = '4.0.2' end end diff --git a/spec/collectionspace/mapper/column_mapping_spec.rb b/spec/collectionspace/mapper/column_mapping_spec.rb index 6c3bf914..ed280eee 100644 --- a/spec/collectionspace/mapper/column_mapping_spec.rb +++ b/spec/collectionspace/mapper/column_mapping_spec.rb @@ -16,7 +16,7 @@ # :opt_list_values=>[], # :datacolumn=>"numberValue", # :required=>"n" - let(:recordmapper){ instance_double('CS::Mapper::RecordMapper') } + let(:recordmapper){ instance_double('CollectionSpace::Mapper::RecordMapper') } let(:mapping){ described_class.new(hash, recordmapper) } describe '#datacolumn' do diff --git a/spec/collectionspace/mapper/column_mappings_spec.rb b/spec/collectionspace/mapper/column_mappings_spec.rb index 0712c76d..9f339bce 100644 --- a/spec/collectionspace/mapper/column_mappings_spec.rb +++ b/spec/collectionspace/mapper/column_mappings_spec.rb @@ -58,8 +58,8 @@ ] end - let(:recordmapper){ instance_double('CS::Mapper::RecordMapper') } - let(:mapperconfig){ instance_double('CS::Mapper::RecordMapperConfig') } + let(:recordmapper){ instance_double('CollectionSpace::Mapper::RecordMapper') } + let(:mapperconfig){ instance_double('CollectionSpace::Mapper::RecordMapperConfig') } let(:mappingsobj){ dc = described_class.new(mappings: mappings, mapper: recordmapper) } @@ -84,7 +84,7 @@ context 'when initialized from authority RecordMapper' do it 'adds shortIdentifier to mappings' do allow(mapperconfig).to receive(:common_namespace).and_return('citations_common') - allow(recordmapper).to receive(:service_type_extension).and_return(CS::Mapper::Authority) + allow(recordmapper).to receive(:service_type_extension).and_return(CollectionSpace::Mapper::Authority) authmappings = described_class.new(mappings: mappings, mapper: recordmapper) expect(authmappings.known_columns.include?('shortidentifier')).to be true @@ -129,7 +129,7 @@ it 'adds mediaFileURI to mappings' do allow(mapperconfig).to receive(:common_namespace).and_return('media_common') - allow(recordmapper).to receive(:service_type_extension).and_return(CS::Mapper::Media) + allow(recordmapper).to receive(:service_type_extension).and_return(CollectionSpace::Mapper::Media) mediamappings = described_class.new(mappings: mappings, mapper: recordmapper) diff --git a/spec/collectionspace/mapper/column_value_spec.rb b/spec/collectionspace/mapper/column_value_spec.rb index 8a8c5830..468471e9 100644 --- a/spec/collectionspace/mapper/column_value_spec.rb +++ b/spec/collectionspace/mapper/column_value_spec.rb @@ -25,7 +25,7 @@ let(:colname){ 'collection' } let(:colvalue){ 'blah' } it 'returns ColumnValue' do - expect(creator).to be_a(CS::Mapper::ColumnValue) + expect(creator).to be_a(CollectionSpace::Mapper::ColumnValue) end end @@ -33,7 +33,7 @@ let(:colname){ 'comment' } let(:colvalue){ 'blah' } it 'returns MultivalColumnValue' do - expect(creator).to be_a(CS::Mapper::MultivalColumnValue) + expect(creator).to be_a(CollectionSpace::Mapper::MultivalColumnValue) end end @@ -41,7 +41,7 @@ let(:colname){ 'title' } let(:colvalue){ 'blah' } it 'returns GroupColumnValue' do - expect(creator).to be_a(CS::Mapper::GroupColumnValue) + expect(creator).to be_a(CollectionSpace::Mapper::GroupColumnValue) end end @@ -50,7 +50,7 @@ let(:colname){ 'fertilizerToBeUsed' } let(:colvalue){ 'blah' } it 'returns GroupMultivalColumnValue' do - expect(creator).to be_a(CS::Mapper::GroupMultivalColumnValue) + expect(creator).to be_a(CollectionSpace::Mapper::GroupMultivalColumnValue) end end @@ -58,7 +58,7 @@ let(:colname){ 'titleTranslation' } let(:colvalue){ 'blah' } it 'returns SubgroupColumnValue' do - expect(creator).to be_a(CS::Mapper::SubgroupColumnValue) + expect(creator).to be_a(CollectionSpace::Mapper::SubgroupColumnValue) end end end diff --git a/spec/collectionspace/mapper/data_quality_checker_spec.rb b/spec/collectionspace/mapper/data_quality_checker_spec.rb index 403f43ac..d813af89 100644 --- a/spec/collectionspace/mapper/data_quality_checker_spec.rb +++ b/spec/collectionspace/mapper/data_quality_checker_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' RSpec.describe CollectionSpace::Mapper::DataQualityChecker do - let(:recordmapper){ instance_double('CS::Mapper::RecordMapper') } + let(:recordmapper){ instance_double('CollectionSpace::Mapper::RecordMapper') } let(:mapping){ CollectionSpace::Mapper::ColumnMapping.new(maphash, recordmapper) } context 'when source_type = optionlist' do diff --git a/spec/collectionspace/mapper/data_splitter_spec.rb b/spec/collectionspace/mapper/data_splitter_spec.rb index e9829753..7ef341c3 100644 --- a/spec/collectionspace/mapper/data_splitter_spec.rb +++ b/spec/collectionspace/mapper/data_splitter_spec.rb @@ -4,7 +4,7 @@ RSpec.describe CollectionSpace::Mapper::SimpleSplitter do before(:all) do - @config = CS::Mapper::Config.new(config: {delimiter: ';', subgroup_delimiter: '^^'}) + @config = CollectionSpace::Mapper::Config.new(config: {delimiter: ';', subgroup_delimiter: '^^'}) end describe '#result' do @@ -49,7 +49,7 @@ RSpec.describe CollectionSpace::Mapper::SubgroupSplitter do before(:all) do - @config = CS::Mapper::Config.new(config: {delimiter: ';', subgroup_delimiter: '^^'}) + @config = CollectionSpace::Mapper::Config.new(config: {delimiter: ';', subgroup_delimiter: '^^'}) end describe '#result' do diff --git a/spec/collectionspace/mapper/data_validator_spec.rb b/spec/collectionspace/mapper/data_validator_spec.rb index 0457ed14..c9e6e7bd 100644 --- a/spec/collectionspace/mapper/data_validator_spec.rb +++ b/spec/collectionspace/mapper/data_validator_spec.rb @@ -9,7 +9,7 @@ let(:csid_cache){ anthro_csid_cache } let(:mapper){ get_json_record_mapper(mapper_path) } let(:recordmapper) do - CS::Mapper::RecordMapper.new( + CollectionSpace::Mapper::RecordMapper.new( mapper: mapper, csclient: client, termcache: cache, @@ -89,7 +89,7 @@ let(:mapper_path){ 'spec/fixtures/files/mappers/release_6_1/core/core_6-1-0_authorityhierarchy.json' } let(:data) do raw = get_datahash(path: 'spec/fixtures/files/datahashes/core/authorityHierarchy1.json') - CS::Mapper.setup_data(raw, recordmapper.batchconfig) + CollectionSpace::Mapper.setup_data(raw, recordmapper.batchconfig) end it 'no required field error returned', services_call: true do diff --git a/spec/collectionspace/mapper/dates/structured_date_handler_spec.rb b/spec/collectionspace/mapper/dates/structured_date_handler_spec.rb index ea143ead..601134e5 100644 --- a/spec/collectionspace/mapper/dates/structured_date_handler_spec.rb +++ b/spec/collectionspace/mapper/dates/structured_date_handler_spec.rb @@ -6,8 +6,8 @@ let(:client){ anthro_client } let(:cache){ anthro_cache } let(:csid_cache){ anthro_csid_cache } - let(:config){ CS::Mapper::Config.new } - let(:searcher) { CS::Mapper::Searcher.new(client: client, config: config) } + let(:config){ CollectionSpace::Mapper::Config.new } + let(:searcher) { CollectionSpace::Mapper::Searcher.new(client: client, config: config) } let(:handler){ described_class.new(client: client, cache: cache, csid_cache: csid_cache, config: config, searcher: searcher) } describe '#ce' do diff --git a/spec/collectionspace/mapper/find_replace_operation_spec.rb b/spec/collectionspace/mapper/find_replace_operation_spec.rb index c0f0995b..04fba4a0 100644 --- a/spec/collectionspace/mapper/find_replace_operation_spec.rb +++ b/spec/collectionspace/mapper/find_replace_operation_spec.rb @@ -11,14 +11,14 @@ context 'given a plain operation' do let(:opspec){ {find: ' ', replace: '-', type: 'plain'} } it 'returns a FindReplaceOperation' do - expect(creator).to be_a(CS::Mapper::FindReplaceOperation) + expect(creator).to be_a(CollectionSpace::Mapper::FindReplaceOperation) end end context 'given a regex operation' do let(:opspec){ {find: '(\d)-A', replace: '\1 A', type: 'regex'} } it 'returns a RegexFindReplaceOperation' do - expect(creator).to be_a(CS::Mapper::RegexFindReplaceOperation) + expect(creator).to be_a(CollectionSpace::Mapper::RegexFindReplaceOperation) end end end diff --git a/spec/collectionspace/mapper/group_column_value_spec.rb b/spec/collectionspace/mapper/group_column_value_spec.rb index 54888525..65059f9f 100644 --- a/spec/collectionspace/mapper/group_column_value_spec.rb +++ b/spec/collectionspace/mapper/group_column_value_spec.rb @@ -6,7 +6,7 @@ let(:mapperpath){ 'spec/fixtures/files/mappers/release_6_1/core/core_6-1-0_collectionobject.json' } let(:config){ {delimiter: '|', subgroup_delimiter: '^^'} } let(:recmapper) do - CS::Mapper::RecordMapper.new(mapper: get_json_record_mapper(mapperpath), + CollectionSpace::Mapper::RecordMapper.new(mapper: get_json_record_mapper(mapperpath), batchconfig: config, termcache: core_cache) end diff --git a/spec/collectionspace/mapper/group_multival_column_value_spec.rb b/spec/collectionspace/mapper/group_multival_column_value_spec.rb index 93b41894..7f250b21 100644 --- a/spec/collectionspace/mapper/group_multival_column_value_spec.rb +++ b/spec/collectionspace/mapper/group_multival_column_value_spec.rb @@ -6,7 +6,7 @@ let(:mapperpath){ 'spec/fixtures/files/mappers/release_6_1/bonsai/bonsai_4-1-1_conservation.json' } let(:config){ {delimiter: '|', subgroup_delimiter: '^^'} } let(:recmapper) do - CS::Mapper::RecordMapper.new(mapper: get_json_record_mapper(mapperpath), + CollectionSpace::Mapper::RecordMapper.new(mapper: get_json_record_mapper(mapperpath), batchconfig: config, termcache: bonsai_cache) end diff --git a/spec/collectionspace/mapper/multival_column_value_spec.rb b/spec/collectionspace/mapper/multival_column_value_spec.rb index 5eb6e631..6cf70f17 100644 --- a/spec/collectionspace/mapper/multival_column_value_spec.rb +++ b/spec/collectionspace/mapper/multival_column_value_spec.rb @@ -6,7 +6,7 @@ let(:mapperpath){ 'spec/fixtures/files/mappers/release_6_1/core/core_6-1-0_collectionobject.json' } let(:config){ {delimiter: '|', subgroup_delimiter: '^^'} } let(:recmapper) do - CS::Mapper::RecordMapper.new(mapper: get_json_record_mapper(mapperpath), + CollectionSpace::Mapper::RecordMapper.new(mapper: get_json_record_mapper(mapperpath), batchconfig: config, termcache: core_cache) end diff --git a/spec/collectionspace/mapper/record_mapper_spec.rb b/spec/collectionspace/mapper/record_mapper_spec.rb index 008f2da1..188df4b4 100644 --- a/spec/collectionspace/mapper/record_mapper_spec.rb +++ b/spec/collectionspace/mapper/record_mapper_spec.rb @@ -17,14 +17,14 @@ context 'when initialized with authority mapper' do let(:path){ 'spec/fixtures/files/mappers/release_6_1/anthro/anthro_4-1-2_citation-local.json' } it 'returns Authority module name' do - expect(mapper.service_type_extension).to eq(CS::Mapper::Authority) + expect(mapper.service_type_extension).to eq(CollectionSpace::Mapper::Authority) end end context 'when initialized with relationship mapper' do let(:path){ 'spec/fixtures/files/mappers/release_6_1/anthro/anthro_4-1-2_authorityhierarchy.json' } it 'returns Relationship module name' do - expect(mapper.service_type_extension).to eq(CS::Mapper::Relationship) + expect(mapper.service_type_extension).to eq(CollectionSpace::Mapper::Relationship) end end diff --git a/spec/collectionspace/mapper/row_data_spec.rb b/spec/collectionspace/mapper/row_data_spec.rb index 8e931f0b..c0fd03a2 100644 --- a/spec/collectionspace/mapper/row_data_spec.rb +++ b/spec/collectionspace/mapper/row_data_spec.rb @@ -21,7 +21,7 @@ expect(row.columns).to be_a(Array) end it 'of ColumnValues' do - expect(row.columns.any?{ |col| !col.is_a?(CS::Mapper::ColumnValue) }).to be false + expect(row.columns.any?{ |col| !col.is_a?(CollectionSpace::Mapper::ColumnValue) }).to be false end it '2 elements long' do expect(row.columns.length).to eq(4) diff --git a/spec/collectionspace/mapper/searcher_spec.rb b/spec/collectionspace/mapper/searcher_spec.rb index b942b999..6b5e7b66 100644 --- a/spec/collectionspace/mapper/searcher_spec.rb +++ b/spec/collectionspace/mapper/searcher_spec.rb @@ -4,7 +4,7 @@ RSpec.describe CollectionSpace::Mapper::Searcher do let(:client){ core_client } - let(:config){ CS::Mapper::Config.new(config: config_hash) } + let(:config){ CollectionSpace::Mapper::Config.new(config: config_hash) } let(:klass){ described_class.new(client: client, config: config) } describe '#.call' do diff --git a/spec/collectionspace/mapper/subgroup_column_value_spec.rb b/spec/collectionspace/mapper/subgroup_column_value_spec.rb index d0efb81e..55edb354 100644 --- a/spec/collectionspace/mapper/subgroup_column_value_spec.rb +++ b/spec/collectionspace/mapper/subgroup_column_value_spec.rb @@ -6,7 +6,7 @@ let(:mapperpath){ 'spec/fixtures/files/mappers/release_6_1/core/core_6-1-0_collectionobject.json' } let(:config){ {delimiter: '|', subgroup_delimiter: '^^'} } let(:recmapper) do - CS::Mapper::RecordMapper.new(mapper: get_json_record_mapper(mapperpath), + CollectionSpace::Mapper::RecordMapper.new(mapper: get_json_record_mapper(mapperpath), batchconfig: config, termcache: core_cache) end diff --git a/spec/collectionspace/mapper/term_handler_spec.rb b/spec/collectionspace/mapper/term_handler_spec.rb index 734d1419..54456c09 100644 --- a/spec/collectionspace/mapper/term_handler_spec.rb +++ b/spec/collectionspace/mapper/term_handler_spec.rb @@ -8,15 +8,15 @@ let(:csidcache){ core_csid_cache } let(:mapperpath){ 'spec/fixtures/files/mappers/release_6_1/core/core_6-1-0_collectionobject.json' } let(:recmapper) do - CS::Mapper::RecordMapper.new(mapper: File.read(mapperpath), + CollectionSpace::Mapper::RecordMapper.new(mapper: File.read(mapperpath), csclient: client, termcache: termcache, csidcache: csidcache) end let(:colmapping){ recmapper.mappings.lookup(colname) } - let(:searcher){ CS::Mapper::Searcher.new(client: client)} + let(:searcher){ CollectionSpace::Mapper::Searcher.new(client: client)} let(:th) do - CS::Mapper::TermHandler.new(mapping: colmapping, + CollectionSpace::Mapper::TermHandler.new(mapping: colmapping, data: data, client: client, mapper: recmapper, @@ -63,14 +63,14 @@ describe '#result' do context 'titletranslationlanguage (vocabulary, field subgroup)' do let(:colname){ 'titleTranslationLanguage' } - let(:data){ [['%NULLVALUE%', 'Swahili'], %w[Klingon Spanish], [CS::Mapper::THE_BOMB]] } + let(:data){ [['%NULLVALUE%', 'Swahili'], %w[Klingon Spanish], [CollectionSpace::Mapper::THE_BOMB]] } it 'result is the transformed value for mapping' do expected = [['', "urn:cspace:c.core.collectionspace.org:vocabularies:name(languages):item:name(swa)'Swahili'"], ['', "urn:cspace:c.core.collectionspace.org:vocabularies:name(languages):item:name(spa)'Spanish'"], - [CS::Mapper::THE_BOMB]] + [CollectionSpace::Mapper::THE_BOMB]] expect(th.result).to eq(expected) end end @@ -98,7 +98,7 @@ let(:terms){ th.terms } context 'titletranslationlanguage (vocabulary, field subgroup)' do let(:colname){ 'titleTranslationLanguage' } - let(:data){ [['%NULLVALUE%', 'Swahili'], %w[Sanza Spanish], [CS::Mapper::THE_BOMB]] } + let(:data){ [['%NULLVALUE%', 'Swahili'], %w[Sanza Spanish], [CollectionSpace::Mapper::THE_BOMB]] } context 'when new term (Sanza) is initially encountered' do it 'returns terms as expected' do @@ -112,7 +112,7 @@ context 'when new term is subsequently encountered' do it 'the term is still treated as not found' do - first_handler = CS::Mapper::TermHandler.new(mapping: colmapping, + first_handler = CollectionSpace::Mapper::TermHandler.new(mapping: colmapping, data: data, client: client, mapper: recmapper, diff --git a/spec/collectionspace/mapper/term_searchable_spec.rb b/spec/collectionspace/mapper/term_searchable_spec.rb index 6f9ec733..017b26cf 100644 --- a/spec/collectionspace/mapper/term_searchable_spec.rb +++ b/spec/collectionspace/mapper/term_searchable_spec.rb @@ -6,7 +6,7 @@ class TermClass attr_reader :cache, :client, :searcher attr_accessor :type, :subtype, :errors - include CS::Mapper::TermSearchable + include CollectionSpace::Mapper::TermSearchable def initialize(cache, csid_cache, client, type, subtype) @cache = cache @@ -15,7 +15,7 @@ def initialize(cache, csid_cache, client, type, subtype) @type = type @subtype = subtype @errors = [] - @searcher = CS::Mapper::Searcher.new(client: client) + @searcher = CollectionSpace::Mapper::Searcher.new(client: client) end end diff --git a/spec/collectionspace/mapper/tools/dates_spec.rb b/spec/collectionspace/mapper/tools/dates_spec.rb index 8a1327c1..977647bc 100644 --- a/spec/collectionspace/mapper/tools/dates_spec.rb +++ b/spec/collectionspace/mapper/tools/dates_spec.rb @@ -6,10 +6,10 @@ let(:client){ anthro_client } let(:cache){ anthro_cache } let(:csid_cache){ anthro_csid_cache } - let(:config){ CS::Mapper::Config.new } - let(:searcher) { CS::Mapper::Searcher.new(client: client, config: config) } + let(:config){ CollectionSpace::Mapper::Config.new } + let(:searcher) { CollectionSpace::Mapper::Searcher.new(client: client, config: config) } let(:handler) do - CS::Mapper::Dates::StructuredDateHandler.new( + CollectionSpace::Mapper::Dates::StructuredDateHandler.new( client: client, cache: cache, csid_cache: csid_cache, @@ -72,7 +72,7 @@ end context 'when date_format in config = day month year' do - let(:config){ CS::Mapper::Config.new(config: {date_format: 'day month year'}) } + let(:config){ CollectionSpace::Mapper::Config.new(config: {date_format: 'day month year'}) } it 'interprets as D/M/Y' do expect(csdate.mappable['dateEarliestScalarValue']).to start_with('2020-02-01') @@ -91,7 +91,7 @@ end context 'when config[:two_digit_year_handling] = literal', services_call: true do - let(:config){ CS::Mapper::Config.new(config: {two_digit_year_handling: 'literal'}) } + let(:config){ CollectionSpace::Mapper::Config.new(config: {two_digit_year_handling: 'literal'}) } it 'Services parses date with uncoerced 2-digit year' do expect(csdate.mappable['dateEarliestSingleYear']).to eq('91') diff --git a/spec/collectionspace/mapper/tools/record_status_service_builder_spec.rb b/spec/collectionspace/mapper/tools/record_status_service_builder_spec.rb index ce78366b..277443e1 100644 --- a/spec/collectionspace/mapper/tools/record_status_service_builder_spec.rb +++ b/spec/collectionspace/mapper/tools/record_status_service_builder_spec.rb @@ -8,7 +8,7 @@ describe '.call' do let(:mapper) do - CS::Mapper::RecordMapper.new(mapper: get_json_record_mapper( + CollectionSpace::Mapper::RecordMapper.new(mapper: get_json_record_mapper( 'spec/fixtures/files/mappers/release_6_1/core/core_6-1-0_group.json' ), termcache: core_cache, csidcache: 'foo', batchconfig: config) end @@ -18,14 +18,14 @@ let(:config){ {status_check_method: 'client'} } it 'raises returns RecordStatusServiceClient' do - expect(result).to be_a(CS::Mapper::Tools::RecordStatusServiceClient) + expect(result).to be_a(CollectionSpace::Mapper::Tools::RecordStatusServiceClient) end end context 'when status_check_method = cache' do let(:config){ {status_check_method: 'cache'} } it 'raises returns RecordStatusServiceCache' do - expect(result).to be_a(CS::Mapper::Tools::RecordStatusServiceCache) + expect(result).to be_a(CollectionSpace::Mapper::Tools::RecordStatusServiceCache) end end end diff --git a/spec/collectionspace/mapper/tools/record_status_service_client_spec.rb b/spec/collectionspace/mapper/tools/record_status_service_client_spec.rb index 459e15bf..65fdfbc2 100644 --- a/spec/collectionspace/mapper/tools/record_status_service_client_spec.rb +++ b/spec/collectionspace/mapper/tools/record_status_service_client_spec.rb @@ -8,15 +8,15 @@ context 'when mapper service_path not handled by collectionspace-client' do let(:mapper) do - CS::Mapper::RecordMapper.new(mapper: get_json_record_mapper( + CollectionSpace::Mapper::RecordMapper.new(mapper: get_json_record_mapper( 'spec/fixtures/files/mappers/core_6-1-0_aardvark.json' ), termcache: core_cache) end it 'raises NoClientServiceError' do expect do - CS::Mapper::Tools::RecordStatusServiceClient.new(client, mapper) - end.to raise_error(CS::Mapper::NoClientServiceError) + CollectionSpace::Mapper::Tools::RecordStatusServiceClient.new(client, mapper) + end.to raise_error(CollectionSpace::Mapper::NoClientServiceError) end end diff --git a/spec/collectionspace/mapper/tools/symbolizable_spec.rb b/spec/collectionspace/mapper/tools/symbolizable_spec.rb index 47b5154d..d806b842 100644 --- a/spec/collectionspace/mapper/tools/symbolizable_spec.rb +++ b/spec/collectionspace/mapper/tools/symbolizable_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe CS::Mapper::Tools::Symbolizable do +RSpec.describe CollectionSpace::Mapper::Tools::Symbolizable do let(:config) do JSON.parse('{ "delimiter": ";", @@ -31,7 +31,7 @@ }') end - let(:symconfig){ CS::Mapper::Tools::Symbolizable.symbolize(config) } + let(:symconfig){ CollectionSpace::Mapper::Tools::Symbolizable.symbolize(config) } describe '#symbolize' do it 'turns hash keys into symbols' do expected = %i[delimiter subgroup_delimiter response_mode force_defaults check_record_status @@ -47,7 +47,7 @@ replacements: [{find: ' ', replace: '-', type: 'plain'}]}} end it 'transforms as expected' do - expect(CS::Mapper::Tools::Symbolizable.symbolize_transforms(transforms)).to eq(expected) + expect(CollectionSpace::Mapper::Tools::Symbolizable.symbolize_transforms(transforms)).to eq(expected) end end end diff --git a/spec/collectionspace/mapper/transformer_spec.rb b/spec/collectionspace/mapper/transformer_spec.rb index 37fc25a8..229fd1e7 100644 --- a/spec/collectionspace/mapper/transformer_spec.rb +++ b/spec/collectionspace/mapper/transformer_spec.rb @@ -7,7 +7,7 @@ let(:cache){ anthro_cache } let(:mapperpath){ 'spec/fixtures/files/mappers/release_6_1/anthro/anthro_4-1-2_collectionobject_transforms.json' } let(:recmapper) do - CS::Mapper::RecordMapper.new(mapper: File.read(mapperpath), + CollectionSpace::Mapper::RecordMapper.new(mapper: File.read(mapperpath), csclient: client, termcache: cache) end @@ -24,7 +24,7 @@ let(:transform){ %w[personauthorities person] } it 'returns an AuthorityTransformer' do - expect(creator).to be_a(CS::Mapper::AuthorityTransformer) + expect(creator).to be_a(CollectionSpace::Mapper::AuthorityTransformer) end end @@ -32,7 +32,7 @@ let(:type){ :vocabulary } let(:transform){ 'behrensmeyer' } it 'returns a VocabularyTransformer' do - expect(creator).to be_a(CS::Mapper::VocabularyTransformer) + expect(creator).to be_a(CollectionSpace::Mapper::VocabularyTransformer) end end @@ -40,8 +40,8 @@ let(:type){ :special } let(:transform){ %w[downcase_value boolean behrensmeyer_translate] } it 'returns array of expected transformers' do - expected = [CS::Mapper::DowncaseTransformer, CS::Mapper::BooleanTransformer, - CS::Mapper::BehrensmeyerTransformer] + expected = [CollectionSpace::Mapper::DowncaseTransformer, CollectionSpace::Mapper::BooleanTransformer, + CollectionSpace::Mapper::BehrensmeyerTransformer] expect(creator.map(&:class)).to eq(expected) end end @@ -50,7 +50,7 @@ let(:type){ :replacements } let(:transform){ [{find: ' ', replace: '-', type: 'plain'}] } it 'returns a FindReplaceTransformer' do - expect(creator).to be_a(CS::Mapper::FindReplaceTransformer) + expect(creator).to be_a(CollectionSpace::Mapper::FindReplaceTransformer) end end end diff --git a/spec/collectionspace/mapper/transformers_spec.rb b/spec/collectionspace/mapper/transformers_spec.rb index c89ecc43..6b848fd6 100644 --- a/spec/collectionspace/mapper/transformers_spec.rb +++ b/spec/collectionspace/mapper/transformers_spec.rb @@ -7,7 +7,7 @@ let(:cache){ anthro_cache } let(:mapperpath){ 'spec/fixtures/files/mappers/release_6_1/anthro/anthro_4-1-2_collectionobject_transforms.json' } let(:recmapper) do - CS::Mapper::RecordMapper.new(mapper: File.read(mapperpath), + CollectionSpace::Mapper::RecordMapper.new(mapper: File.read(mapperpath), csclient: client, termcache: cache) end @@ -22,7 +22,7 @@ context 'when measuredByPerson column' do let(:colname){ 'measuredByPerson' } it 'contains only AuthorityTransformer' do - expect(xforms.queue.map(&:class)).to eq([CS::Mapper::AuthorityTransformer]) + expect(xforms.queue.map(&:class)).to eq([CollectionSpace::Mapper::AuthorityTransformer]) end end @@ -31,7 +31,7 @@ # let(:result) { xforms.queue } let(:result){ xforms.queue.map(&:class) } it 'expected elements are in expected order' do - expect(result).to eq([CS::Mapper::BehrensmeyerTransformer, CS::Mapper::VocabularyTransformer]) + expect(result).to eq([CollectionSpace::Mapper::BehrensmeyerTransformer, CollectionSpace::Mapper::VocabularyTransformer]) end end end diff --git a/spec/collectionspace/mapper/unknown_term_spec.rb b/spec/collectionspace/mapper/unknown_term_spec.rb index a7839896..b113367e 100644 --- a/spec/collectionspace/mapper/unknown_term_spec.rb +++ b/spec/collectionspace/mapper/unknown_term_spec.rb @@ -22,7 +22,7 @@ let(:str){ nil } it 'fails', :aggregate_failures do - expect{ result }.to raise_error(CS::Mapper::UnknownTerm::ReconstituteNilError) + expect{ result }.to raise_error(CollectionSpace::Mapper::UnknownTerm::ReconstituteNilError) end end end diff --git a/spec/collectionspace/mapper/value_transformer_spec.rb b/spec/collectionspace/mapper/value_transformer_spec.rb index 04cc087d..0825f908 100644 --- a/spec/collectionspace/mapper/value_transformer_spec.rb +++ b/spec/collectionspace/mapper/value_transformer_spec.rb @@ -6,7 +6,7 @@ let(:mapper_path){ 'spec/fixtures/files/mappers/release_6_1/anthro/anthro_4-1-2_collectionobject.json' } let(:mapper){ get_json_record_mapper(mapper_path) } let(:handler) do - CS::Mapper::DataHandler.new( + CollectionSpace::Mapper::DataHandler.new( record_mapper: mapper, client: anthro_client, cache: anthro_cache, @@ -14,7 +14,7 @@ config: {} ) end - let(:prepper){ CS::Mapper::DataPrepper.new({}, handler.searcher, handler) } + let(:prepper){ CollectionSpace::Mapper::DataPrepper.new({}, handler.searcher, handler) } let(:transformer){ described_class.new(value, transforms, prepper) } let(:result){ transformer.result } diff --git a/spec/helpers.rb b/spec/helpers.rb index f69cc8a5..1beaadbe 100644 --- a/spec/helpers.rb +++ b/spec/helpers.rb @@ -31,7 +31,7 @@ def get_json_record_mapper(path) end def get_record_mapper_object(path, cache = nil) - CS::Mapper::RecordMapper.new(mapper: File.read(path), termcache: cache) + CollectionSpace::Mapper::RecordMapper.new(mapper: File.read(path), termcache: cache) end def get_datahash(path:)