stanford-mods 3.3.0 → 3.3.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c9c63c6699eef72da80bbf9e15d892248dfc21a7550588aac09843ef26d1869f
4
- data.tar.gz: f820451452017ec653c4eabd48d19cb23a36fcfafbad814272dd26c9cc9b9d42
3
+ metadata.gz: f4b93a6a17a1d2d60d82a661d02d6ba4a74f6c9958597a9895650506b4f4c4b1
4
+ data.tar.gz: a63b8a8a5bd2c6b638082936e5ee908613cb981447b016e6b8d3beed8c2637b8
5
5
  SHA512:
6
- metadata.gz: '0817296bebb438d882509919ff0b6fb2ec0e1accd71b379209f3b3b5f4cbd684d8208d8aab7ff3ce5f745860c4331af9098afadb5d066bd406016625c63d3701'
7
- data.tar.gz: 4ed8b47a3186c3f241d2b543358138c71bea5f7128fc483e1d78117af1224b75db1fb4524763c726b011f414524b7d732a54096dd07d38a909c13a05116cc3ca
6
+ metadata.gz: b61ce90be97c3b7b314f5b2a199f18bbb8843c8de704703a71a55540241ee4aa3307b1683b0c6b60de170de781d08cb702233cef1626a69af09bd78dc8590253
7
+ data.tar.gz: 1fcc5a1238cab589e41ee281dad172c24adea68b718401a643bcc71e138b0623a8d54717fb89204cf708e014b0dfc638a5fb307dd2bf5716e6fb74bfb84087f1
@@ -16,8 +16,8 @@ module Stanford
16
16
  # @param [Boolean] ignore_approximate true if approximate dates (per qualifier attribute) should be ignored; false if approximate dates should be included
17
17
  # @return [Integer] publication year as an Integer
18
18
  # @note for sorting: 5 BCE => -5; 666 BCE => -666
19
- def pub_year_int(ignore_approximate: false)
20
- date = earliest_preferred_date(ignore_approximate: ignore_approximate)
19
+ def pub_year_int(fields = [:dateIssued, :dateCreated, :dateCaptured], ignore_approximate: false)
20
+ date = earliest_preferred_date(fields: fields, ignore_approximate: ignore_approximate)
21
21
 
22
22
  return unless date
23
23
 
@@ -41,8 +41,8 @@ module Stanford
41
41
  # @return [String] single String containing publication year for lexical sorting
42
42
  # @note for string sorting 5 BCE = -5 => -995; 6 BCE => -994, so 6 BCE sorts before 5 BCE
43
43
  # @deprecated use pub_year_int
44
- def pub_year_sort_str(ignore_approximate: false)
45
- earliest_preferred_date(ignore_approximate: ignore_approximate)&.sort_key
44
+ def pub_year_sort_str(fields = [:dateIssued, :dateCreated, :dateCaptured], ignore_approximate: false)
45
+ earliest_preferred_date(fields: fields, ignore_approximate: ignore_approximate)&.sort_key
46
46
  end
47
47
 
48
48
  # return a single string intended for display of pub year (or year range)
@@ -50,8 +50,8 @@ module Stanford
50
50
  # @param [Array<Symbol>] fields array of field types to use to look for dates.
51
51
  # @param [Boolean] ignore_approximate true if approximate dates (per qualifier attribute)
52
52
  # should be ignored; false if approximate dates should be included
53
- def pub_year_display_str(ignore_approximate: false)
54
- earliest_preferred_date(ignore_approximate: ignore_approximate)&.decoded_value(allowed_precisions: [:year, :decade, :century], ignore_unparseable: true, display_original_text: false)
53
+ def pub_year_display_str(fields = [:dateIssued, :dateCreated, :dateCaptured], ignore_approximate: false)
54
+ earliest_preferred_date(fields: fields, ignore_approximate: ignore_approximate)&.decoded_value(allowed_precisions: [:year, :decade, :century], ignore_unparseable: true, display_original_text: false)
55
55
  end
56
56
 
57
57
  # @return [Array<Stanford::Mods::Imprint>] array of imprint objects
@@ -1,6 +1,6 @@
1
1
  module Stanford
2
2
  module Mods
3
3
  # this is the Ruby Gem version
4
- VERSION = '3.3.0'.freeze
4
+ VERSION = '3.3.1'.freeze
5
5
  end
6
6
  end
@@ -100,6 +100,12 @@ describe "computations from /originInfo field" do
100
100
  it 'returns the year from the preferred field type regardless of the keyDate' do
101
101
  expect(record.pub_year_display_str).to eq '1800'
102
102
  end
103
+
104
+ context 'with field filters' do
105
+ it 'returns the year from the requested field' do
106
+ expect(record.pub_year_display_str([:dateCreated])).to eq '1900'
107
+ end
108
+ end
103
109
  end
104
110
 
105
111
  context 'when it has multiple dates' do
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.3.0
4
+ version: 3.3.1
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-08-02 00:00:00.000000000 Z
12
+ date: 2022-08-03 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: mods