edtf-humanize 1.0.0 → 2.1.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.
Files changed (34) hide show
  1. checksums.yaml +4 -4
  2. data/config/locales/en.edtf.yml +44 -0
  3. data/config/locales/fr.edtf.yml +55 -0
  4. data/config/locales/it.edtf.yml +55 -0
  5. data/lib/edtf/humanize/century.rb +4 -4
  6. data/lib/edtf/humanize/decade.rb +4 -4
  7. data/lib/edtf/humanize/interval.rb +4 -21
  8. data/lib/edtf/humanize/iso_date.rb +4 -4
  9. data/lib/edtf/humanize/language/default/century.rb +20 -0
  10. data/lib/edtf/humanize/language/default/decade.rb +21 -0
  11. data/lib/edtf/humanize/language/default/formats.rb +112 -0
  12. data/lib/edtf/humanize/language/default/interval.rb +132 -0
  13. data/lib/edtf/humanize/language/default/iso_date.rb +21 -0
  14. data/lib/edtf/humanize/language/default/season.rb +30 -0
  15. data/lib/edtf/humanize/language/default/set.rb +78 -0
  16. data/lib/edtf/humanize/language/default/unknown.rb +17 -0
  17. data/lib/edtf/humanize/language/default.rb +17 -0
  18. data/lib/edtf/humanize/language/english.rb +11 -0
  19. data/lib/edtf/humanize/language/french.rb +36 -0
  20. data/lib/edtf/humanize/language/italian.rb +34 -0
  21. data/lib/edtf/humanize/language.rb +13 -0
  22. data/lib/edtf/humanize/season.rb +4 -16
  23. data/lib/edtf/humanize/set.rb +4 -33
  24. data/lib/edtf/humanize/unknown.rb +5 -3
  25. data/lib/edtf/humanize/version.rb +3 -1
  26. data/lib/edtf/humanize.rb +24 -45
  27. data/lib/edtf-humanize.rb +5 -0
  28. data/spec/edtf_humanize_en_spec.rb +102 -0
  29. data/spec/edtf_humanize_fr_spec.rb +110 -0
  30. data/spec/edtf_humanize_it_spec.rb +110 -0
  31. data/spec/spec_helper.rb +2 -0
  32. metadata +70 -20
  33. data/lib/edtf/humanize/formats.rb +0 -73
  34. data/spec/edtf_humanize_spec.rb +0 -65
metadata CHANGED
@@ -1,15 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: edtf-humanize
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 2.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Cory Lown
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-05-28 00:00:00.000000000 Z
11
+ date: 2022-08-04 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: activesupport
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '4'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '4'
13
27
  - !ruby/object:Gem::Dependency
14
28
  name: edtf
15
29
  requirement: !ruby/object:Gem::Requirement
@@ -31,19 +45,19 @@ dependencies:
31
45
  - !ruby/object:Gem::Version
32
46
  version: '4'
33
47
  - !ruby/object:Gem::Dependency
34
- name: activesupport
48
+ name: roman
35
49
  requirement: !ruby/object:Gem::Requirement
36
50
  requirements:
37
- - - ">="
51
+ - - "~>"
38
52
  - !ruby/object:Gem::Version
39
- version: '4'
53
+ version: 0.2.0
40
54
  type: :runtime
41
55
  prerelease: false
42
56
  version_requirements: !ruby/object:Gem::Requirement
43
57
  requirements:
44
- - - ">="
58
+ - - "~>"
45
59
  - !ruby/object:Gem::Version
46
- version: '4'
60
+ version: 0.2.0
47
61
  - !ruby/object:Gem::Dependency
48
62
  name: rake
49
63
  requirement: !ruby/object:Gem::Requirement
@@ -73,19 +87,33 @@ dependencies:
73
87
  - !ruby/object:Gem::Version
74
88
  version: '3.9'
75
89
  - !ruby/object:Gem::Dependency
76
- name: bump
90
+ name: rubocop
77
91
  requirement: !ruby/object:Gem::Requirement
78
92
  requirements:
79
- - - ">="
93
+ - - "~>"
80
94
  - !ruby/object:Gem::Version
81
- version: '0'
95
+ version: '0.87'
82
96
  type: :development
83
97
  prerelease: false
84
98
  version_requirements: !ruby/object:Gem::Requirement
85
99
  requirements:
86
- - - ">="
100
+ - - "~>"
87
101
  - !ruby/object:Gem::Version
88
- version: '0'
102
+ version: '0.87'
103
+ - !ruby/object:Gem::Dependency
104
+ name: rubocop-rspec
105
+ requirement: !ruby/object:Gem::Requirement
106
+ requirements:
107
+ - - "~>"
108
+ - !ruby/object:Gem::Version
109
+ version: '1.39'
110
+ type: :development
111
+ prerelease: false
112
+ version_requirements: !ruby/object:Gem::Requirement
113
+ requirements:
114
+ - - "~>"
115
+ - !ruby/object:Gem::Version
116
+ version: '1.39'
89
117
  description: This gem adds a humanize method to EDTF::Decade, EDTF::Interval, EDTF::Set,
90
118
  EDTF::Season, EDTF::Unknown, and Date (ISO 8601 compliant) objects.
91
119
  email:
@@ -95,24 +123,41 @@ extensions: []
95
123
  extra_rdoc_files: []
96
124
  files:
97
125
  - LICENSE.txt
126
+ - config/locales/en.edtf.yml
127
+ - config/locales/fr.edtf.yml
128
+ - config/locales/it.edtf.yml
98
129
  - lib/edtf-humanize.rb
99
130
  - lib/edtf/humanize.rb
100
131
  - lib/edtf/humanize/century.rb
101
132
  - lib/edtf/humanize/decade.rb
102
- - lib/edtf/humanize/formats.rb
103
133
  - lib/edtf/humanize/interval.rb
104
134
  - lib/edtf/humanize/iso_date.rb
135
+ - lib/edtf/humanize/language.rb
136
+ - lib/edtf/humanize/language/default.rb
137
+ - lib/edtf/humanize/language/default/century.rb
138
+ - lib/edtf/humanize/language/default/decade.rb
139
+ - lib/edtf/humanize/language/default/formats.rb
140
+ - lib/edtf/humanize/language/default/interval.rb
141
+ - lib/edtf/humanize/language/default/iso_date.rb
142
+ - lib/edtf/humanize/language/default/season.rb
143
+ - lib/edtf/humanize/language/default/set.rb
144
+ - lib/edtf/humanize/language/default/unknown.rb
145
+ - lib/edtf/humanize/language/english.rb
146
+ - lib/edtf/humanize/language/french.rb
147
+ - lib/edtf/humanize/language/italian.rb
105
148
  - lib/edtf/humanize/season.rb
106
149
  - lib/edtf/humanize/set.rb
107
150
  - lib/edtf/humanize/unknown.rb
108
151
  - lib/edtf/humanize/version.rb
109
- - spec/edtf_humanize_spec.rb
152
+ - spec/edtf_humanize_en_spec.rb
153
+ - spec/edtf_humanize_fr_spec.rb
154
+ - spec/edtf_humanize_it_spec.rb
110
155
  - spec/spec_helper.rb
111
156
  homepage: https://github.com/duke-libraries/edtf-humanize
112
157
  licenses:
113
158
  - BSD-3-Clause
114
159
  metadata: {}
115
- post_install_message:
160
+ post_install_message:
116
161
  rdoc_options: []
117
162
  require_paths:
118
163
  - lib
@@ -120,17 +165,22 @@ required_ruby_version: !ruby/object:Gem::Requirement
120
165
  requirements:
121
166
  - - ">="
122
167
  - !ruby/object:Gem::Version
123
- version: '0'
168
+ version: '2.4'
169
+ - - "<"
170
+ - !ruby/object:Gem::Version
171
+ version: '4'
124
172
  required_rubygems_version: !ruby/object:Gem::Requirement
125
173
  requirements:
126
174
  - - ">="
127
175
  - !ruby/object:Gem::Version
128
176
  version: '0'
129
177
  requirements: []
130
- rubygems_version: 3.0.6
131
- signing_key:
178
+ rubygems_version: 3.2.32
179
+ signing_key:
132
180
  specification_version: 4
133
181
  summary: This gem adds a humanize method to EDTF dates.
134
182
  test_files:
183
+ - spec/edtf_humanize_en_spec.rb
184
+ - spec/edtf_humanize_fr_spec.rb
185
+ - spec/edtf_humanize_it_spec.rb
135
186
  - spec/spec_helper.rb
136
- - spec/edtf_humanize_spec.rb
@@ -1,73 +0,0 @@
1
- module Edtf
2
- module Humanize
3
- module Formats
4
-
5
- private
6
-
7
- def simple_date_format date
8
- "#{apply_if_unspecified_year(date)}#{apply_if_uncertain(date)}"
9
- end
10
-
11
- def date_precision date
12
- if date.respond_to? :precision
13
- case date.precision
14
- when :day # 2010-10-25
15
- day_precision_format(date)
16
- when :month # 2010-10
17
- month_precision_format(date)
18
- when :year # 2010
19
- year_precision_format(date)
20
- end
21
- else
22
- date
23
- end
24
- end
25
-
26
- # October 5, 1995
27
- def day_precision_format date
28
- I18n.localize(date, format: Edtf::Humanize.configuration.day_precision_strftime_format)
29
- end
30
-
31
- # October 1995
32
- def month_precision_format date
33
- I18n.localize(date, format: Edtf::Humanize.configuration.month_precision_strftime_format)
34
- end
35
-
36
- # 1995
37
- def year_precision_format date
38
- date.strftime(Edtf::Humanize.configuration.year_precision_strftime_format)
39
- end
40
-
41
- # '1990~' => circa 1990
42
- def apply_if_approximate date
43
- if date.respond_to? :approximate?
44
- if date.approximate?
45
- Edtf::Humanize.configuration.approximate_date_prefix
46
- end
47
- end
48
- end
49
-
50
- # '1990?' => 1990?
51
- def apply_if_uncertain date
52
- if date.respond_to? :uncertain?
53
- if date.uncertain?
54
- Edtf::Humanize.configuration.uncertain_date_suffix
55
- end
56
- end
57
- end
58
-
59
- # '198u' => 198x
60
- def apply_if_unspecified_year date
61
- display = date_precision(date)
62
- if date.respond_to? :unspecified?
63
- if date.unspecified? :year
64
- year_substitute = date.year_precision.edtf.gsub(/u/, Edtf::Humanize.configuration.unspecified_digit_substitute)
65
- display.gsub!("#{date.year}", year_substitute)
66
- end
67
- end
68
- display
69
- end
70
-
71
- end
72
- end
73
- end
@@ -1,65 +0,0 @@
1
- require 'edtf-humanize'
2
-
3
- RSpec.describe Edtf::Humanize do
4
-
5
- it { is_expected.to be_a(Module) }
6
-
7
- context 'with a decade' do
8
- it 'should return a humanized decade string' do
9
- expect(Date.edtf('199x').humanize).to eq('1990s')
10
- end
11
- end
12
-
13
- context 'with a centrury' do
14
- it 'should return a humanized century string' do
15
- expect(Date.edtf('19xx').humanize).to eq('1900s')
16
- end
17
- end
18
-
19
- context 'with an interval' do
20
- it 'should return a humanized interval string' do
21
- expect(Date.edtf('1970/1980').humanize).to eq('1970 to 1980')
22
- end
23
- end
24
-
25
- context 'with an appoximate interval'
26
- it 'should return a humanized approximate interval string' do
27
- expect(Date.edtf('1970~/1980~').humanize).to eq('circa 1970 to circa 1980')
28
- end
29
-
30
- context 'with an iso date' do
31
- it 'should return a humanized ISO date string' do
32
- expect(Date.edtf('1975-07-01').humanize).to eq('July 1, 1975')
33
- end
34
- end
35
-
36
- context 'with an uncertain iso date' do
37
- it 'should return a humanized uncertain ISO date string' do
38
- expect(Date.edtf('1975?').humanize).to eq('1975?')
39
- end
40
- end
41
-
42
- context 'with an unspecfic year iso date' do
43
- it 'should return a humanized unspecified year ISO date string' do
44
- expect(Date.edtf('197u').humanize).to eq('197x')
45
- end
46
- end
47
-
48
- context 'with a season' do
49
- it 'should return a humanized season string' do
50
- expect(Date.edtf('1975-22').humanize).to eq('summer 1975')
51
- end
52
- end
53
-
54
- context 'with a set' do
55
- it 'should return a humanized set string' do
56
- expect(Date.edtf('[1980, 1981, 1983]').humanize).to eq('1980, 1981 or 1983')
57
- end
58
- end
59
-
60
- context 'with an unknown value' do
61
- it 'should return a humanized unknown string' do
62
- expect(Date.edtf('uuuu').humanize).to eq('unknown')
63
- end
64
- end
65
- end