Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug fix for the #filing_version logic #294

Merged
merged 1 commit into from
Feb 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,14 @@

*

*
## 3.8.2

Bug fix for the `#filing_version` logic, which was incorrectly assuming the
first subfield in a field would hold content (e.g., `$a`) and thus failed
when it held a pointer to a linking field (e.g., `$6 245-01`)

```


## 3.8.1

Expand Down
8 changes: 7 additions & 1 deletion lib/traject/macros/marc21_semantics.rb
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,13 @@ def self.filing_version(field, str, spec)
# (b) include the first subfield in the record

subs = spec.subfields
return str unless subs && subs.include?(field.subfields[0].code)

# Get the code for the first alphabetic subfield, which would be
# the one getting characters shifted off

first_alpha_code = field.subfields.first{|sf| sf.code =~ /[a-z]/}.code

return str unless subs && subs.include?(first_alpha_code)

# OK. If we got this far we actually need to strip characters off the string

Expand Down
2 changes: 1 addition & 1 deletion lib/traject/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module Traject
VERSION = "3.8.1"
VERSION = "3.8.2"
end
13 changes: 12 additions & 1 deletion test/indexer/macros/macros_marc21_semantics_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,9 @@

assert_equal ["Business renaissance quarterly [electronic resource]."], output["author_sort"]
assert_equal [""], @indexer.map_record(empty_record)['author_sort']

end


end

describe "marc_sortable_title" do
Expand All @@ -107,6 +108,16 @@

assert_equal ["Business renaissance quarterly"], output["title_sort"]
end

it "respects non-filing when the first subfield isn't alphabetic" do
@record = MARC::Reader.new(support_file_path "the_business_ren.marc").first
@record.fields("245").first.subfields.unshift MARC::Subfield.new("6", "245-03")
output = @indexer.map_record(@record)
assert_equal ["Business renaissance quarterly"], output["title_sort"]


end

it "works with a record with no 245$ab" do
@record = MARC::Reader.new(support_file_path "245_no_ab.marc").to_a.first
output = @indexer.map_record(@record)
Expand Down
Loading