stanford-mods 3.0.0 → 3.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,29 +1,5 @@
1
1
  describe "SearchWorks Publication methods" do
2
2
  let(:smods_rec) { Stanford::Mods::Record.new }
3
- RSpec.shared_examples "pub year" do |method_sym, exp_val_position|
4
- context 'searchworks actual data' do
5
- require 'fixtures/searchworks_pub_date_data'
6
- SEARCHWORKS_PUB_DATE_DATA.each_pair.each do |coll_name, coll_data|
7
- coll_data.each_pair do |mods_str, exp_vals|
8
- expected = exp_vals[exp_val_position]
9
- # TODO: pub_year_display_str doesn't cope with date ranges yet
10
- expected = expected.split(' - ')[0] if method_sym == :pub_year_display_str && expected
11
- it "#{expected} for rec in #{coll_name}" do
12
- smods_rec.from_str(mods_str)
13
- expect(smods_rec.send(method_sym)).to eq expected
14
- end
15
- end
16
- end
17
- end
18
- end
19
-
20
- context '#pub_year_int' do
21
- it_behaves_like "pub year", :pub_year_int, 0
22
- end
23
-
24
- context '#pub_year_display_str' do
25
- it_behaves_like "pub year", :pub_year_display_str, 1
26
- end
27
3
 
28
4
  context '#imprint_display' do
29
5
  require 'fixtures/searchworks_imprint_data'
@@ -16,7 +16,7 @@ Gem::Specification.new do |gem|
16
16
  gem.test_files = gem.files.grep(%r{^spec/})
17
17
  gem.require_paths = ["lib"]
18
18
 
19
- gem.add_dependency 'mods', '~> 3.0', '>= 3.0.1'
19
+ gem.add_dependency 'mods', '~> 3.0', '>= 3.0.3'
20
20
  # active_support for .ordinalize, eg. 1 -> 1st, 2 -> 2nd for centuries
21
21
  gem.add_dependency 'activesupport'
22
22
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stanford-mods
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.0
4
+ version: 3.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Naomi Dushay
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2022-02-02 00:00:00.000000000 Z
12
+ date: 2022-08-02 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: mods
@@ -20,7 +20,7 @@ dependencies:
20
20
  version: '3.0'
21
21
  - - ">="
22
22
  - !ruby/object:Gem::Version
23
- version: 3.0.1
23
+ version: 3.0.3
24
24
  type: :runtime
25
25
  prerelease: false
26
26
  version_requirements: !ruby/object:Gem::Requirement
@@ -30,7 +30,7 @@ dependencies:
30
30
  version: '3.0'
31
31
  - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: 3.0.1
33
+ version: 3.0.3
34
34
  - !ruby/object:Gem::Dependency
35
35
  name: activesupport
36
36
  requirement: !ruby/object:Gem::Requirement
@@ -175,14 +175,11 @@ files:
175
175
  - lib/stanford-mods/concerns/searchworks_subjects.rb
176
176
  - lib/stanford-mods/concerns/title.rb
177
177
  - lib/stanford-mods/coordinate.rb
178
- - lib/stanford-mods/date_parsing.rb
179
178
  - lib/stanford-mods/imprint.rb
180
179
  - lib/stanford-mods/record.rb
181
180
  - lib/stanford-mods/version.rb
182
181
  - lib/stanford-mods/vocabularies/searchworks_languages.rb
183
182
  - spec/fixtures/searchworks_imprint_data.rb
184
- - spec/fixtures/searchworks_pub_date_data.rb
185
- - spec/fixtures/spotlight_pub_date_data.rb
186
183
  - spec/geo_spatial_spec.rb
187
184
  - spec/imprint_spec.rb
188
185
  - spec/lib/stanford-mods/coordinate_spec.rb
@@ -217,14 +214,12 @@ required_rubygems_version: !ruby/object:Gem::Requirement
217
214
  - !ruby/object:Gem::Version
218
215
  version: '0'
219
216
  requirements: []
220
- rubygems_version: 3.2.32
217
+ rubygems_version: 3.3.7
221
218
  signing_key:
222
219
  specification_version: 4
223
220
  summary: Stanford specific wrangling of MODS metadata
224
221
  test_files:
225
222
  - spec/fixtures/searchworks_imprint_data.rb
226
- - spec/fixtures/searchworks_pub_date_data.rb
227
- - spec/fixtures/spotlight_pub_date_data.rb
228
223
  - spec/geo_spatial_spec.rb
229
224
  - spec/imprint_spec.rb
230
225
  - spec/lib/stanford-mods/coordinate_spec.rb
@@ -1,70 +0,0 @@
1
- module Stanford
2
- module Mods
3
- class DateParsing
4
- # true if the year is between -9999 and (current year + 1)
5
- # @return [Boolean] true if the year is between -9999 and (current year + 1); false otherwise
6
- def self.year_int_valid?(year)
7
- return false unless year.is_a? Integer
8
-
9
- (year < Date.today.year + 2)
10
- end
11
-
12
- attr_reader :xml
13
-
14
- def initialize(xml)
15
- @xml = xml
16
- end
17
-
18
- # get display value for year, generally an explicit year or "17th century" or "5 B.C." or "1950s" or '845 A.D.'
19
- # @return [String, nil] String value for year if we could parse one, nil otherwise
20
- def date_str_for_display
21
- date = xml&.as_object&.date
22
- date = date.min || date.max if date.is_a?(EDTF::Epoch) || date.is_a?(EDTF::Interval)
23
-
24
- return case xml.as_object.precision
25
- when :century
26
- return "#{(date.to_s[0..1].to_i + 1).ordinalize} century"
27
- when :decade
28
- return "#{date.year}s"
29
- when :unknown
30
- xml.text
31
- else
32
- if !self.class.year_int_valid? date.year
33
- xml.text
34
- elsif date.year < 1
35
- "#{date.year.abs + 1} B.C."
36
- elsif date.year < 1000
37
- "#{date.year} A.D."
38
- else
39
- date.year.to_s
40
- end
41
- end
42
- end
43
-
44
- # get Integer year if we can parse date_str to get a year.
45
- # @return [Integer, nil] Integer year if we could parse one, nil otherwise
46
- def year_int_from_date_str
47
- xml&.as_object&.as_range&.first&.year
48
- end
49
-
50
- # get String sortable value year if we can parse date_str to get a year.
51
- # SearchWorks currently uses a string field for pub date sorting; thus so does Spotlight.
52
- # The values returned must *lexically* sort in chronological order, so the B.C. dates are tricky
53
- # @return [String, nil] String sortable year if we could parse one, nil otherwise
54
- # note that these values must *lexically* sort to create a chronological sort.
55
- def sortable_year_string_from_date_str
56
- return unless xml&.as_object&.date
57
-
58
- date = xml.as_object.date
59
-
60
- if date.is_a?(EDTF::Interval) && date.from.year < 1
61
- (-1 * date.from.year - 1000).to_s
62
- elsif date.is_a?(Date) && date.year < 1
63
- (-1 * date.year - 1000).to_s
64
- else
65
- date.to_s[0..3]&.gsub('X', '-')
66
- end
67
- end
68
- end
69
- end
70
- end