Skip to content

Commit

Permalink
Address feedback on PR.
Browse files Browse the repository at this point in the history
  • Loading branch information
moseshll committed Mar 28, 2023
1 parent 05168ab commit 132496a
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 43 deletions.
13 changes: 0 additions & 13 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,19 +31,6 @@ services:
- solr-sdr-catalog
- mariadb

test-persist:
build: .
volumes:
- .:/usr/src/app
- gem_cache:/gems
command: bash -c "bin/wait-for solr-sdr-catalog:9033 mariadb:3306"
environment:
SOLR_URL: http://solr-sdr-catalog:9033/solr/catalog
RIGHTS_DATABASE_CONNECTION_STRING: "mysql2://ht_rights:ht_rights@mariadb/ht"
depends_on:
- solr-sdr-catalog
- mariadb

solr-sdr-catalog:
image: ghcr.io/hathitrust/catalog-solr-sample
ports:
Expand Down
4 changes: 2 additions & 2 deletions lib/oai_solr/basic_marc_extractor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ def values(rec)
# merge into one set; the ranges we handle separately for efficiency (no sense in
# turning '600'..'699' into an array)
def set_interesting_tags!
@interesting_single_tags = Set.new
@interesting_ranges = Set.new
@interesting_single_tags = ::Set.new
@interesting_ranges = ::Set.new
@single_extractors.map(&:computed_tags).each do |tags|
case tags
when Range
Expand Down
2 changes: 1 addition & 1 deletion lib/oai_solr/basic_marc_single_extractor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ def tag_matcher(tags_to_match)
@computed_tags = tags_to_match
->(t) { @computed_tags.cover?(t) }
else
raise "Illegal argumrnt '#{tags_to_match.inspect}'"
raise "Illegal argument '#{tags_to_match.inspect}'"
end
end

Expand Down
35 changes: 8 additions & 27 deletions lib/oai_solr/dublin_core_crosswalk.rb
Original file line number Diff line number Diff line change
Expand Up @@ -82,31 +82,17 @@ class DublinCoreCrosswalk
# type -- see below
}

# Build the instance that will do the data extraction based on the mappings
# in MAPPINGS.
def initialize
MAPPINGS.each_pair do |key, spec_pairs|
define_singleton_method(key.to_sym, basic_marc_extractor_proc(spec_pairs))
end
MAPPINGS.each do |key, spec_pairs|
bme = BasicMARCExtractor.from_pairs(spec_pairs)
define_method(key.to_sym, ->(rec) { bme.values(rec) })
end

# If it's necessary to add a field that does not have an identically-named
# accessor, or is not in MAPPINGS, some adjustment may be necessary,
def full_map(rec)
{
contributor: contributor(rec),
coverage: coverage(rec),
date: date(rec),
description: description(rec),
format: self.format(rec), # need self to avoid keyword conflict
identifier: identifier(rec),
language: language(rec),
publisher: publisher(rec),
relation: relation(rec),
rights: rights(rec),
source: source(rec),
subject: subject(rec),
title: title(rec),
type: type(rec)
}.reject { |k, v| v.empty? }
fields = MAPPINGS.keys + %i(type date)
Hash[fields.map {|field| [ field, self.send(field, rec)] }]
.reject { |k, v| v.empty? }
end

# Get the best date possible, looking for four digits in the 008, then
Expand Down Expand Up @@ -138,11 +124,6 @@ def type(rec)

private

def basic_marc_extractor_proc(pairs)
bme = BasicMARCExtractor.from_pairs(pairs)
->(rec) { bme.values(rec) }
end

def date_008(rec)
rec["008"].value[7..10]
end
Expand Down

0 comments on commit 132496a

Please sign in to comment.