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

All <unitdates> now display #1486

Merged
merged 3 commits into from
Dec 15, 2023
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
15 changes: 5 additions & 10 deletions lib/arclight/normalized_date.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,11 @@ def year_range(date_array)

# @see http://www2.archivists.org/standards/DACS/part_I/chapter_2/4_date for rules
def normalize
if inclusive.present?
result = inclusive.to_s
result << ", bulk #{bulk}" if bulk.present?
elsif other.present?
result = other.to_s
else
result = nil
end

result&.strip
result = []
result << inclusive if inclusive.present?
result << other if other.present?
result << "bulk #{bulk}" if bulk.present?
result.compact.map(&:strip).join(', ')
end
end
end
3 changes: 2 additions & 1 deletion spec/fixtures/ead/nlm/alphaomegaalpha.xml
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,8 @@
</origination>
<unittitle>"A brief account of the origin of the Alpha Omega Alpha Honorary Fraternity"
- William W. Root,</unittitle>
<unitdate>n.d.</unitdate>
<unitdate>ca. 1967</unitdate>
<unitdate type="inclusive">n.d.</unitdate>
<container id="aspace_d258aae2bcdc020db8152ebcd05b648f" label="Mixed Materials"
type="box">1</container>
<container id="aspace_8a0450988fafd6cee4c334fe4811c392"
Expand Down
20 changes: 11 additions & 9 deletions spec/lib/arclight/normalized_date_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,18 @@

let(:date_inclusive) { ['1990-2000'] }
let(:date_bulk) { '1999-2005' }
let(:date_other) { nil }
let(:date_other) { 'Undated' }

context 'under normal conditions' do
it 'joins dates' do
expect(normalized_date).to eq '1990-2000, bulk 1999-2005'
expect(normalized_date).to eq '1990-2000, Undated, bulk 1999-2005'
end

context 'multiple normalized dates' do
let(:date_inclusive) { %w[1990 1992] }

it 'are joined w/ a comma' do
expect(normalized_date).to eq '1990, 1992, bulk 1999-2005'
expect(normalized_date).to eq '1990, 1992, Undated, bulk 1999-2005'
end
end
end
Expand All @@ -31,28 +31,29 @@
let(:date_bulk) { '1990-2004' }

it 'uses compressed joined years' do
expect(normalized_date).to eq '1990-2002, 2004, bulk 1990-2004'
expect(normalized_date).to eq '1990-2002, 2004, Undated, bulk 1990-2004'
end
end

context 'undated' do
let(:date_bulk) { 'n.d.' }

it 'do not normalized term "undated"' do
expect(normalized_date).to eq '1990-2000, bulk n.d.'
expect(normalized_date).to eq '1990-2000, Undated, bulk n.d.'
end
end

context 'circa' do
let(:date_bulk) { 'c.1995' }

it 'do not normalized term "circa"' do
expect(normalized_date).to eq '1990-2000, bulk c.1995'
expect(normalized_date).to eq '1990-2000, Undated, bulk c.1995'
end
end

context 'no bulk' do
let(:date_bulk) { nil }
let(:date_other) { nil }

it 'uses inclusive date only' do
expect(normalized_date).to eq '1990-2000'
Expand All @@ -72,17 +73,18 @@
context 'no inclusive but bulk' do
let(:date_inclusive) { nil }

it 'does not know what to do' do
expect(normalized_date).to be_nil
it 'uses other and bulk' do
expect(normalized_date).to eq 'Undated, bulk 1999-2005'
end
end

context 'no information' do
let(:date_inclusive) { nil }
let(:date_bulk) { nil }
let(:date_other) { nil }

it 'does not know what to do' do
expect(normalized_date).to be_nil
expect(normalized_date).to eq ''
end
end
end
Expand Down