edtf-humanize 2.1.0 → 2.2.0

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: 4d1b42abe59756665b608da4635e8766f78fb44ac2e658e14365141bf919eae9
4
- data.tar.gz: f7a583e56c886eee461568fd2deacbd4769221b48b1f5e6b6f9b2ed68b08420c
3
+ metadata.gz: d0bdc76c57a55ce4f9ec22d75d2247609840b769d52662c252d7dc43dc0926ac
4
+ data.tar.gz: a4c90eeb17b1e05335498c6aa7bb58b8696fb1238feb5700ba4f6098ab498f97
5
5
  SHA512:
6
- metadata.gz: e7d3799ba863355aefa8afd5fdd09f20bc796cea31609d2015979b36f175ccff9a998019b62901c71d0873ca48dc03c0405f47fce7dd049d2ac801fc763d74f3
7
- data.tar.gz: 6233da61c4a069e473336c229cd117e479ce1037d10d789506a32565ff4abed04740ce9fa59df1f8be772aaaa62447e58e9b422f6d72ed8778c9e2a6416e0035
6
+ metadata.gz: fee2ccf6b710d1f52e1e842b837052fe9efe8c274ddf2fe33a494462c801b6220dd878269a9befc8b719cad2baa3f46f7ea239923d8ca091b542368bd5c5176b
7
+ data.tar.gz: 92f100dd9dd8865c7ee2e42dd711787b05a00adc959287afb394f3ac67a182a9142a4d5f1af43bf0e402eb7047935c7a64425e92501b8d1df3ac88c795842424
@@ -0,0 +1,55 @@
1
+ de:
2
+ date:
3
+ day_names: [Sonntag, Montag, Dienstag, Mittwoch, Donnerstag, Freitag, Samstag]
4
+ abbr_day_names: [So, Mo, Di, Mi, Do, Fr, Sa]
5
+ # Don't forget the nil at the beginning; there's no such thing as a 0th month
6
+ month_names: [~, Januar, Februar, März, April, Mai, Juni, Juli, August, September, Oktober, November, Dezember]
7
+ abbr_month_names: [~, Jan, Feb, Mar, Apr, Mai, Jun, Jul, Aug, Sept, Okt, Nov, Dez]
8
+ seasons:
9
+ spring: "Frühling"
10
+ summer: "Sommer"
11
+ autumn: "Herbst"
12
+ winter: "Winter"
13
+ edtf:
14
+ terms:
15
+ approximate_date_prefix_day: "circa "
16
+ approximate_date_prefix_month: "circa "
17
+ approximate_date_prefix_year: "circa "
18
+ approximate_date_suffix_day: ""
19
+ approximate_date_suffix_month: ""
20
+ approximate_date_suffix_year: ""
21
+ decade_prefix: ""
22
+ decade_suffix: "er Jahre"
23
+ century_suffix: ""
24
+ interval_prefix_day: ""
25
+ interval_prefix_month: ""
26
+ interval_prefix_year: ""
27
+ interval_connector_approximate: " - "
28
+ interval_connector_open: " - "
29
+ interval_connector_day: " - "
30
+ interval_connector_month: " - "
31
+ interval_connector_year: " - "
32
+ interval_unspecified_suffix: ""
33
+ open_start_interval_with_day: "bis %{date}"
34
+ open_start_interval_with_month: "bis %{date}"
35
+ open_start_interval_with_year: "bis %{date}"
36
+ open_end_interval_with_day: "%{date} - "
37
+ open_end_interval_with_month: "%{date} - "
38
+ open_end_interval_with_year: "%{date} - "
39
+ set_dates_connector_exclusive: ", "
40
+ set_dates_connector_inclusive: ", "
41
+ set_earlier_prefix_exclusive: "vor "
42
+ set_earlier_prefix_inclusive: "vor "
43
+ set_last_date_connector_exclusive: " oder "
44
+ set_last_date_connector_inclusive: " und "
45
+ set_later_prefix_exclusive: "nach "
46
+ set_later_prefix_inclusive: "nach "
47
+ set_two_dates_connector_exclusive: " oder "
48
+ set_two_dates_connector_inclusive: " eund "
49
+ uncertain_date_suffix: " ?"
50
+ unknown: "Datum unbekannt"
51
+ unspecified_digit_substitute: "x"
52
+ formats:
53
+ day_precision_strftime_format: "%-d. %B %Y"
54
+ month_precision_strftime_format: "%B %Y"
55
+ year_precision_strftime_format: "%Y"
@@ -11,7 +11,7 @@ module Edtf
11
11
 
12
12
  def humanizer(date)
13
13
  "#{date.begin.year}" \
14
- "#{I18n.t('edtf.terms.century_suffix', default: 's')}"
14
+ "#{I18n.t('edtf.terms.century_suffix', default: 's')}"
15
15
  end
16
16
  end
17
17
  end
@@ -11,8 +11,8 @@ module Edtf
11
11
 
12
12
  def humanizer(date)
13
13
  "#{I18n.t('edtf.terms.decade_prefix', default: '')}" \
14
- "#{date.begin.year}" \
15
- "#{I18n.t('edtf.terms.decade_suffix', default: 's')}"
14
+ "#{date.begin.year}" \
15
+ "#{I18n.t('edtf.terms.decade_suffix', default: 's')}"
16
16
  end
17
17
  end
18
18
  end
@@ -94,10 +94,10 @@ module Edtf
94
94
  # '198u' => 198x
95
95
  def apply_if_unspecified_year(date)
96
96
  display = date_precision(date)
97
- if date.respond_to?(:unspecified?) && date.unspecified?(:year)
97
+ if date.respond_to?(:unspecified?) && (date.unspecified? :year)
98
98
  year_substitute =
99
99
  date.year_precision.edtf.gsub(
100
- /u/,
100
+ 'u',
101
101
  I18n.t('edtf.terms.unspecified_digit_substitute',
102
102
  default: 'x')
103
103
  )
@@ -14,9 +14,9 @@ module Edtf
14
14
  open_interval(date)
15
15
  else
16
16
  "#{interval_prefix(date)}" \
17
- "#{formatted_date(date.from)}" \
18
- "#{interval_connector(date)}" \
19
- "#{formatted_date(date.to)}"
17
+ "#{formatted_date(date.from)}" \
18
+ "#{interval_connector(date)}" \
19
+ "#{formatted_date(date.to)}"
20
20
  end
21
21
  end
22
22
 
@@ -70,8 +70,8 @@ module Edtf
70
70
 
71
71
  def formatted_date(date)
72
72
  "#{apply_prefix_if_approximate(date)}" \
73
- "#{date_format(date)}" \
74
- "#{apply_suffix_if_approximate(date)}"
73
+ "#{date_format(date)}" \
74
+ "#{apply_suffix_if_approximate(date)}"
75
75
  end
76
76
 
77
77
  def interval_prefix(date)
@@ -11,8 +11,8 @@ module Edtf
11
11
 
12
12
  def humanizer(date)
13
13
  "#{apply_prefix_if_approximate(date)}" \
14
- "#{date_format(date)}" \
15
- "#{apply_suffix_if_approximate(date)}"
14
+ "#{date_format(date)}" \
15
+ "#{apply_suffix_if_approximate(date)}"
16
16
  end
17
17
  end
18
18
  end
@@ -10,10 +10,10 @@ module Edtf
10
10
  extend self
11
11
 
12
12
  def humanizer(date)
13
- "#{apply_prefix_if_approximate(date)}"\
14
- "#{translate_season(date.season)} #{date.year}"\
15
- "#{apply_suffix_if_approximate(date)}"\
16
- "#{apply_if_uncertain(date)}"
13
+ "#{apply_prefix_if_approximate(date)}" \
14
+ "#{translate_season(date.season)} #{date.year}" \
15
+ "#{apply_suffix_if_approximate(date)}" \
16
+ "#{apply_if_uncertain(date)}"
17
17
  end
18
18
 
19
19
  private
@@ -31,17 +31,17 @@ module Edtf
31
31
 
32
32
  def format_set_entries(dates)
33
33
  dates.entries.map.with_index do |date, index|
34
- "#{apply_if_earlier(dates, index)}"\
35
- "#{apply_if_later(dates, index)}"\
36
- "#{apply_prefix_if_approximate(date)}"\
37
- "#{date_format(date)}"\
38
- "#{apply_suffix_if_approximate(date)}"\
34
+ "#{apply_if_earlier(dates, index)}" \
35
+ "#{apply_if_later(dates, index)}" \
36
+ "#{apply_prefix_if_approximate(date)}" \
37
+ "#{date_format(date)}" \
38
+ "#{apply_suffix_if_approximate(date)}" \
39
39
  end
40
40
  end
41
41
 
42
42
  # '[..1760-12-03]' => on or before December 3, 1760
43
43
  def apply_if_earlier(dates, index)
44
- return earlier_prefix(dates) if dates.earlier? && index.zero?
44
+ earlier_prefix(dates) if dates.earlier? && index.zero?
45
45
  end
46
46
 
47
47
  def earlier_prefix(dates)
@@ -55,8 +55,8 @@ module Edtf
55
55
 
56
56
  # '[1760-12..]' => on or after December 1760
57
57
  def apply_if_later(dates, index)
58
- return later_prefix(dates) if dates.later? &&
59
- (index + 1) == dates.size
58
+ later_prefix(dates) if dates.later? &&
59
+ (index + 1) == dates.size
60
60
  end
61
61
 
62
62
  def later_prefix(dates)
@@ -11,9 +11,9 @@ module Edtf
11
11
 
12
12
  def humanizer(date)
13
13
  require 'roman'
14
- "#{(date.year.abs / 100 + 1).to_roman}" \
15
- "#{century_number_suffix(date)}" \
16
- "#{century_sign_suffix(date)}"
14
+ "#{((date.year.abs / 100) + 1).to_roman}" \
15
+ "#{century_number_suffix(date)}" \
16
+ "#{century_sign_suffix(date)}"
17
17
  end
18
18
 
19
19
  private
@@ -0,0 +1,32 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Edtf
4
+ module Humanize
5
+ module Language
6
+ module German
7
+ include Default
8
+
9
+ module Century
10
+ extend self
11
+
12
+ def humanizer(date)
13
+ "#{(date.year.abs / 100) + 1}." \
14
+ "#{century_number_suffix}"
15
+ end
16
+
17
+ private
18
+
19
+ def century_number_suffix
20
+ ' Jahrhundert'
21
+ end
22
+
23
+ def century_sign_suffix(date)
24
+ return ' v. Chr.' if date.year.negative?
25
+
26
+ ''
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
32
+ end
@@ -11,9 +11,9 @@ module Edtf
11
11
 
12
12
  def humanizer(date)
13
13
  require 'roman'
14
- "#{(date.year.abs / 100 + 1).to_roman}" \
15
- "#{century_number_suffix}" \
16
- "#{century_sign_suffix(date)}"
14
+ "#{((date.year.abs / 100) + 1).to_roman}" \
15
+ "#{century_number_suffix}" \
16
+ "#{century_sign_suffix(date)}"
17
17
  end
18
18
 
19
19
  private
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Edtf
4
4
  module Humanize
5
- VERSION = '2.1.0'
5
+ VERSION = '2.2.0'
6
6
  end
7
7
  end
data/lib/edtf/humanize.rb CHANGED
@@ -24,6 +24,7 @@ module Edtf
24
24
  require 'edtf/humanize/language/english'
25
25
  require 'edtf/humanize/language/french'
26
26
  require 'edtf/humanize/language/italian'
27
+ require 'edtf/humanize/language/german'
27
28
 
28
29
  EDTF::Decade.include Edtf::Humanize::Decade
29
30
  EDTF::Century.include Edtf::Humanize::Century
@@ -51,7 +52,8 @@ module Edtf
51
52
  default: Edtf::Humanize::Language::Default,
52
53
  en: Edtf::Humanize::Language::English,
53
54
  fr: Edtf::Humanize::Language::French,
54
- it: Edtf::Humanize::Language::Italian
55
+ it: Edtf::Humanize::Language::Italian,
56
+ de: Edtf::Humanize::Language::German
55
57
  }
56
58
  end
57
59
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: edtf-humanize
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.0
4
+ version: 2.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Cory Lown
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-08-04 00:00:00.000000000 Z
11
+ date: 2024-03-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -58,71 +58,16 @@ dependencies:
58
58
  - - "~>"
59
59
  - !ruby/object:Gem::Version
60
60
  version: 0.2.0
61
- - !ruby/object:Gem::Dependency
62
- name: rake
63
- requirement: !ruby/object:Gem::Requirement
64
- requirements:
65
- - - "~>"
66
- - !ruby/object:Gem::Version
67
- version: '13.0'
68
- type: :development
69
- prerelease: false
70
- version_requirements: !ruby/object:Gem::Requirement
71
- requirements:
72
- - - "~>"
73
- - !ruby/object:Gem::Version
74
- version: '13.0'
75
- - !ruby/object:Gem::Dependency
76
- name: rspec
77
- requirement: !ruby/object:Gem::Requirement
78
- requirements:
79
- - - "~>"
80
- - !ruby/object:Gem::Version
81
- version: '3.9'
82
- type: :development
83
- prerelease: false
84
- version_requirements: !ruby/object:Gem::Requirement
85
- requirements:
86
- - - "~>"
87
- - !ruby/object:Gem::Version
88
- version: '3.9'
89
- - !ruby/object:Gem::Dependency
90
- name: rubocop
91
- requirement: !ruby/object:Gem::Requirement
92
- requirements:
93
- - - "~>"
94
- - !ruby/object:Gem::Version
95
- version: '0.87'
96
- type: :development
97
- prerelease: false
98
- version_requirements: !ruby/object:Gem::Requirement
99
- requirements:
100
- - - "~>"
101
- - !ruby/object:Gem::Version
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'
117
61
  description: This gem adds a humanize method to EDTF::Decade, EDTF::Interval, EDTF::Set,
118
62
  EDTF::Season, EDTF::Unknown, and Date (ISO 8601 compliant) objects.
119
63
  email:
120
- - cory.lown@duke.edu
64
+ - corylown@stanford.edu
121
65
  executables: []
122
66
  extensions: []
123
67
  extra_rdoc_files: []
124
68
  files:
125
69
  - LICENSE.txt
70
+ - config/locales/de.edtf.yml
126
71
  - config/locales/en.edtf.yml
127
72
  - config/locales/fr.edtf.yml
128
73
  - config/locales/it.edtf.yml
@@ -144,19 +89,17 @@ files:
144
89
  - lib/edtf/humanize/language/default/unknown.rb
145
90
  - lib/edtf/humanize/language/english.rb
146
91
  - lib/edtf/humanize/language/french.rb
92
+ - lib/edtf/humanize/language/german.rb
147
93
  - lib/edtf/humanize/language/italian.rb
148
94
  - lib/edtf/humanize/season.rb
149
95
  - lib/edtf/humanize/set.rb
150
96
  - lib/edtf/humanize/unknown.rb
151
97
  - lib/edtf/humanize/version.rb
152
- - spec/edtf_humanize_en_spec.rb
153
- - spec/edtf_humanize_fr_spec.rb
154
- - spec/edtf_humanize_it_spec.rb
155
- - spec/spec_helper.rb
156
- homepage: https://github.com/duke-libraries/edtf-humanize
98
+ homepage: https://github.com/corylown/edtf-humanize
157
99
  licenses:
158
100
  - BSD-3-Clause
159
- metadata: {}
101
+ metadata:
102
+ rubygems_mfa_required: 'true'
160
103
  post_install_message:
161
104
  rdoc_options: []
162
105
  require_paths:
@@ -175,12 +118,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
175
118
  - !ruby/object:Gem::Version
176
119
  version: '0'
177
120
  requirements: []
178
- rubygems_version: 3.2.32
121
+ rubygems_version: 3.5.6
179
122
  signing_key:
180
123
  specification_version: 4
181
124
  summary: This gem adds a humanize method to EDTF dates.
182
- test_files:
183
- - spec/edtf_humanize_en_spec.rb
184
- - spec/edtf_humanize_fr_spec.rb
185
- - spec/edtf_humanize_it_spec.rb
186
- - spec/spec_helper.rb
125
+ test_files: []
@@ -1,102 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'edtf-humanize'
4
-
5
- RSpec.describe Edtf::Humanize do
6
- before do
7
- I18n.locale = :en
8
- end
9
-
10
- it { is_expected.to be_a(Module) }
11
-
12
- context 'with a decade' do
13
- it 'returns a humanized decade string' do
14
- expect(Date.edtf('199x').humanize).to eq('1990s')
15
- end
16
- end
17
-
18
- context 'with a century' do
19
- it 'returns a humanized century string' do
20
- expect(Date.edtf('19xx').humanize).to eq('1900s')
21
- end
22
- end
23
-
24
- context 'with an interval' do
25
- it 'returns a humanized interval string' do
26
- expect(Date.edtf('1970/1980').humanize).to eq('1970 to 1980')
27
- end
28
- end
29
-
30
- context 'with an open interval' do
31
- it 'returns a humanized interval string' do
32
- expect(Date.edtf('1970/open').humanize).to eq('since 1970')
33
- end
34
- end
35
-
36
- context 'with an approximate interval'
37
- it 'returns a humanized approximate interval string' do
38
- expect(Date.edtf('1970~/1980~').humanize).to(
39
- eq('circa 1970 to circa 1980')
40
- )
41
- end
42
-
43
- context 'with an iso date' do
44
- it 'returns a humanized ISO date string' do
45
- expect(Date.edtf('1975-07-01').humanize).to eq('July 1, 1975')
46
- end
47
- end
48
-
49
- context 'with an uncertain iso date' do
50
- it 'returns a humanized uncertain ISO date string' do
51
- expect(Date.edtf('1975?').humanize).to eq('1975?')
52
- end
53
- end
54
-
55
- context 'with an unspecified year iso date' do
56
- it 'returns a humanized unspecified year ISO date string' do
57
- expect(Date.edtf('197u').humanize).to eq('197X')
58
- end
59
- end
60
-
61
- context 'with a season' do
62
- it 'returns a humanized season string' do
63
- expect(Date.edtf('1975-22').humanize).to eq('summer 1975')
64
- end
65
- end
66
-
67
- context 'with a set' do
68
- it 'returns a humanized exclusive set string' do
69
- expect(Date.edtf('[1980, 1981, 1983]').humanize).to(
70
- eq('1980, 1981 or 1983')
71
- )
72
- end
73
-
74
- it 'returns a humanized inclusive set string' do
75
- expect(Date.edtf('{1980, 1981, 1983}').humanize).to(
76
- eq('1980, 1981 and 1983')
77
- )
78
- end
79
-
80
- it 'returns a humanized open (before) exclusive set string' do
81
- expect(Date.edtf('[..1980]').humanize).to eq('on or before 1980')
82
- end
83
-
84
- it 'returns a humanized open (after) exclusive set string' do
85
- expect(Date.edtf('[1980..]').humanize).to eq('on or after 1980')
86
- end
87
-
88
- it 'returns a humanized open (before) inclusive set string' do
89
- expect(Date.edtf('{..1980}').humanize).to eq('on and before 1980')
90
- end
91
-
92
- it 'returns a humanized open (after) inclusive set string' do
93
- expect(Date.edtf('{1980..}').humanize).to eq('on and after 1980')
94
- end
95
- end
96
-
97
- context 'with an unknown value' do
98
- it 'returns a humanized unknown string' do
99
- expect(Date.edtf('uuuu').humanize).to eq('unknown')
100
- end
101
- end
102
- end
@@ -1,110 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'edtf-humanize'
4
-
5
- RSpec.describe Edtf::Humanize do
6
- before do
7
- I18n.locale = :fr
8
- end
9
-
10
- it { is_expected.to be_a(Module) }
11
-
12
- context 'with a decade' do
13
- it 'returns a humanized decade string' do
14
- expect(Date.edtf('199x').humanize).to eq('Les années 1990')
15
- end
16
- end
17
-
18
- context 'with a century' do
19
- it 'returns a humanized century string' do
20
- expect(Date.edtf('19xx').humanize).to eq('XXe siècle')
21
- end
22
- end
23
-
24
- context 'with an interval' do
25
- it 'returns a humanized interval string' do
26
- expect(Date.edtf('1970/1980').humanize).to eq('De 1970 à 1980')
27
- end
28
- end
29
-
30
- context 'with an open interval' do
31
- it 'returns a humanized interval string' do
32
- expect(Date.edtf('1970/open').humanize).to eq('Depuis 1970')
33
- end
34
- end
35
-
36
- context 'with an approximate interval'
37
- it 'returns a humanized approximate interval string' do
38
- expect(Date.edtf('1970~/1980~').humanize).to(
39
- eq('De 1970 environ à 1980 environ')
40
- )
41
- end
42
-
43
- context 'with an iso date' do
44
- it 'returns a humanized ISO date string' do
45
- expect(Date.edtf('1975-07-01').humanize).to eq('1 Juillet 1975')
46
- end
47
- end
48
-
49
- context 'with an uncertain iso date' do
50
- it 'returns a humanized uncertain ISO date string' do
51
- expect(Date.edtf('1975?').humanize).to eq('1975?')
52
- end
53
- end
54
-
55
- context 'with an unspecified year iso date' do
56
- it 'returns a humanized unspecified year ISO date string' do
57
- expect(Date.edtf('197u').humanize).to eq('197X')
58
- end
59
- end
60
-
61
- context 'with a season' do
62
- it 'returns a humanized season string' do
63
- expect(Date.edtf('1975-22').humanize).to eq('été 1975')
64
- end
65
- end
66
-
67
- context 'with a set' do
68
- it 'returns a humanized exclusive set string' do
69
- expect(Date.edtf('[1980, 1981, 1983]').humanize).to(
70
- eq('1980, 1981 ou 1983')
71
- )
72
- end
73
-
74
- it 'returns a humanized inclusive set string' do
75
- expect(Date.edtf('{1980, 1981, 1983}').humanize).to(
76
- eq('1980, 1981 et 1983')
77
- )
78
- end
79
-
80
- it 'returns a humanized open (before) exclusive set string' do
81
- expect(Date.edtf('[..1980]').humanize).to(
82
- eq('Le ou avant 1980')
83
- )
84
- end
85
-
86
- it 'returns a humanized open (after) exclusive set string' do
87
- expect(Date.edtf('[1980..]').humanize).to(
88
- eq('Le ou après 1980')
89
- )
90
- end
91
-
92
- it 'returns a humanized open (before) inclusive set string' do
93
- expect(Date.edtf('{..1980}').humanize).to(
94
- eq('Le et avant 1980')
95
- )
96
- end
97
-
98
- it 'returns a humanized open (after) inclusive set string' do
99
- expect(Date.edtf('{1980..}').humanize).to(
100
- eq('Le et après 1980')
101
- )
102
- end
103
- end
104
-
105
- context 'with an unknown value' do
106
- it 'returns a humanized unknown string' do
107
- expect(Date.edtf('uuuu').humanize).to eq('Inconnue')
108
- end
109
- end
110
- end
@@ -1,110 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'edtf-humanize'
4
-
5
- RSpec.describe Edtf::Humanize do
6
- before do
7
- I18n.locale = :it
8
- end
9
-
10
- it { is_expected.to be_a(Module) }
11
-
12
- context 'with a decade' do
13
- it 'returns a humanized decade string' do
14
- expect(Date.edtf('199x').humanize).to eq('anni 1990')
15
- end
16
- end
17
-
18
- context 'with a century' do
19
- it 'returns a humanized century string' do
20
- expect(Date.edtf('19xx').humanize).to eq('XX secolo')
21
- end
22
- end
23
-
24
- context 'with an interval' do
25
- it 'returns a humanized interval string' do
26
- expect(Date.edtf('1970/1980').humanize).to eq('1970 - 1980')
27
- end
28
- end
29
-
30
- context 'with an open interval' do
31
- it 'returns a humanized interval string' do
32
- expect(Date.edtf('1970/open').humanize).to eq('1970 - ')
33
- end
34
- end
35
-
36
- context 'with an approximate interval'
37
- it 'returns a humanized approximate interval string' do
38
- expect(Date.edtf('1970~/1980~').humanize).to(
39
- eq('circa 1970 - circa 1980')
40
- )
41
- end
42
-
43
- context 'with an iso date' do
44
- it 'returns a humanized ISO date string' do
45
- expect(Date.edtf('1975-07-01').humanize).to eq('1 luglio 1975')
46
- end
47
- end
48
-
49
- context 'with an uncertain iso date' do
50
- it 'returns a humanized uncertain ISO date string' do
51
- expect(Date.edtf('1975?').humanize).to eq('1975 ?')
52
- end
53
- end
54
-
55
- context 'with an unspecified year iso date' do
56
- it 'returns a humanized unspecified year ISO date string' do
57
- expect(Date.edtf('197u').humanize).to eq('197X')
58
- end
59
- end
60
-
61
- context 'with a season' do
62
- it 'returns a humanized season string' do
63
- expect(Date.edtf('1975-22').humanize).to eq('estate 1975')
64
- end
65
- end
66
-
67
- context 'with a set' do
68
- it 'returns a humanized exclusive set string' do
69
- expect(Date.edtf('[1980, 1981, 1983]').humanize).to(
70
- eq('1980, 1981 o 1983')
71
- )
72
- end
73
-
74
- it 'returns a humanized inclusive set string' do
75
- expect(Date.edtf('{1980, 1981, 1983}').humanize).to(
76
- eq('1980, 1981 e 1983')
77
- )
78
- end
79
-
80
- it 'returns a humanized open (before) exclusive set string' do
81
- expect(Date.edtf('[..1980]').humanize).to(
82
- eq('prima di 1980')
83
- )
84
- end
85
-
86
- it 'returns a humanized open (after) exclusive set string' do
87
- expect(Date.edtf('[1980..]').humanize).to(
88
- eq('dopo 1980')
89
- )
90
- end
91
-
92
- it 'returns a humanized open (before) inclusive set string' do
93
- expect(Date.edtf('{..1980}').humanize).to(
94
- eq('prima di 1980')
95
- )
96
- end
97
-
98
- it 'returns a humanized open (after) inclusive set string' do
99
- expect(Date.edtf('{1980..}').humanize).to(
100
- eq('dopo 1980')
101
- )
102
- end
103
- end
104
-
105
- context 'with an unknown value' do
106
- it 'returns a humanized unknown string' do
107
- expect(Date.edtf('uuuu').humanize).to eq('data sconosciuta')
108
- end
109
- end
110
- end
data/spec/spec_helper.rb DELETED
@@ -1,103 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # This file was generated by the `rspec --init` command. Conventionally, all
4
- # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
5
- # The generated `.rspec` file contains `--require spec_helper` which will cause
6
- # this file to always be loaded, without a need to explicitly require it in any
7
- # files.
8
- #
9
- # Given that it is always loaded, you are encouraged to keep this file as
10
- # light-weight as possible. Requiring heavyweight dependencies from this file
11
- # will add to the boot time of your test suite on EVERY test run, even for an
12
- # individual file that may not need all of that loaded. Instead, consider making
13
- # a separate helper file that requires the additional dependencies and performs
14
- # the additional setup, and require it from the spec files that actually need
15
- # it.
16
- #
17
- # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
18
- #
19
- RSpec.configure do |config|
20
- # rspec-expectations config goes here. You can use an alternate
21
- # assertion/expectation library such as wrong or the stdlib/minitest
22
- # assertions if you prefer.
23
- config.expect_with :rspec do |expectations|
24
- # This option will default to `true` in RSpec 4. It makes the `description`
25
- # and `failure_message` of custom matchers include text for helper methods
26
- # defined using `chain`, e.g.:
27
- # be_bigger_than(2).and_smaller_than(4).description
28
- # # => "be bigger than 2 and smaller than 4"
29
- # ...rather than:
30
- # # => "be bigger than 2"
31
- expectations.include_chain_clauses_in_custom_matcher_descriptions = true
32
- end
33
-
34
- # rspec-mocks config goes here. You can use an alternate test double
35
- # library (such as bogus or mocha) by changing the `mock_with` option here.
36
- config.mock_with :rspec do |mocks|
37
- # Prevents you from mocking or stubbing a method that does not exist on
38
- # a real object. This is generally recommended, and will default to
39
- # `true` in RSpec 4.
40
- mocks.verify_partial_doubles = true
41
- end
42
-
43
- # This option will default to `:apply_to_host_groups` in RSpec 4 (and will
44
- # have no way to turn it off -- the option exists only for backwards
45
- # compatibility in RSpec 3). It causes shared context metadata to be
46
- # inherited by the metadata hash of host groups and examples, rather than
47
- # triggering implicit auto-inclusion in groups with matching metadata.
48
- config.shared_context_metadata_behavior = :apply_to_host_groups
49
-
50
- # The settings below are suggested to provide a good initial experience
51
- # with RSpec, but feel free to customize to your heart's content.
52
- =begin
53
- # This allows you to limit a spec run to individual examples or groups
54
- # you care about by tagging them with `:focus` metadata. When nothing
55
- # is tagged with `:focus`, all examples get run. RSpec also provides
56
- # aliases for `it`, `describe`, and `context` that include `:focus`
57
- # metadata: `fit`, `fdescribe` and `fcontext`, respectively.
58
- config.filter_run_when_matching :focus
59
-
60
- # Allows RSpec to persist some state between runs in order to support
61
- # the `--only-failures` and `--next-failure` CLI options. We recommend
62
- # you configure your source control system to ignore this file.
63
- config.example_status_persistence_file_path = "spec/examples.txt"
64
-
65
- # Limits the available syntax to the non-monkey patched syntax that is
66
- # recommended. For more details, see:
67
- # - http://rspec.info/blog/2012/06/rspecs-new-expectation-syntax/
68
- # - http://www.teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
69
- # - http://rspec.info/blog/2014/05/notable-changes-in-rspec-3/#zero-monkey-patching-mode
70
- config.disable_monkey_patching!
71
-
72
- # This setting enables warnings. It's recommended, but in some cases may
73
- # be too noisy due to issues in dependencies.
74
- config.warnings = true
75
-
76
- # Many RSpec users commonly either run the entire suite or an individual
77
- # file, and it's useful to allow more verbose output when running an
78
- # individual spec file.
79
- if config.files_to_run.one?
80
- # Use the documentation formatter for detailed output,
81
- # unless a formatter has already been configured
82
- # (e.g. via a command-line flag).
83
- config.default_formatter = "doc"
84
- end
85
-
86
- # Print the 10 slowest examples and example groups at the
87
- # end of the spec run, to help surface which specs are running
88
- # particularly slow.
89
- config.profile_examples = 10
90
-
91
- # Run specs in random order to surface order dependencies. If you find an
92
- # order dependency and want to debug it, you can fix the order by providing
93
- # the seed, which is printed after each run.
94
- # --seed 1234
95
- config.order = :random
96
-
97
- # Seed global randomization in this process using the `--seed` CLI option.
98
- # Setting this allows you to use `--seed` to deterministically reproduce
99
- # test failures related to randomization by passing the same `--seed` value
100
- # as the one that triggered the failure.
101
- Kernel.srand config.seed
102
- =end
103
- end