edtf-humanize 2.1.0 → 2.3.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: 1d37dd3663889a9bcaa2a00392525eca76c61691705591c6c50f0ee8eacf9d8f
4
+ data.tar.gz: de92c0782ba2cfa57b62d55a214ede47c8a6fa152cc14b7d38f6bde0c4bfc66b
5
5
  SHA512:
6
- metadata.gz: e7d3799ba863355aefa8afd5fdd09f20bc796cea31609d2015979b36f175ccff9a998019b62901c71d0873ca48dc03c0405f47fce7dd049d2ac801fc763d74f3
7
- data.tar.gz: 6233da61c4a069e473336c229cd117e479ce1037d10d789506a32565ff4abed04740ce9fa59df1f8be772aaaa62447e58e9b422f6d72ed8778c9e2a6416e0035
6
+ metadata.gz: 47f4afa9029965ed3a620067218a4594559717f6eeae2ae42c5fe4ba985c6eae9d6be81fd06a150deabf8997c9d5fb10564d4915c0f725c3e0743c636df407cd
7
+ data.tar.gz: 3180b6b54cc2b9011cfdef70259a4196721cc6894d0eab0258962020b0918e8bcfa2dc8b6744b6ba6f2f90f3f6a065039f214e39075490700597a70a6f3d372d
@@ -0,0 +1,61 @@
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_day: " - "
29
+ interval_connector_month: " - "
30
+ interval_connector_year: " - "
31
+ interval_unspecified_suffix: ""
32
+ open_start_interval_with_day: "bis %{date}"
33
+ open_start_interval_with_month: "bis %{date}"
34
+ open_start_interval_with_year: "bis %{date}"
35
+ open_end_interval_with_day: "%{date} - "
36
+ open_end_interval_with_month: "%{date} - "
37
+ open_end_interval_with_year: "%{date} - "
38
+ set_dates_connector_exclusive: ", "
39
+ set_dates_connector_inclusive: ", "
40
+ set_earlier_prefix_exclusive: "vor "
41
+ set_earlier_prefix_inclusive: "vor "
42
+ set_last_date_connector_exclusive: " oder "
43
+ set_last_date_connector_inclusive: " und "
44
+ set_later_prefix_exclusive: "nach "
45
+ set_later_prefix_inclusive: "nach "
46
+ set_two_dates_connector_exclusive: " oder "
47
+ set_two_dates_connector_inclusive: " eund "
48
+ uncertain_date_prefix: ""
49
+ uncertain_date_suffix: " ?"
50
+ unknown: "Datum unbekannt"
51
+ unknown_start_interval_with_day: "unbekanntes Datum bis %{date}"
52
+ unknown_start_interval_with_month: "unbekanntes Datum bis %{date}"
53
+ unknown_start_interval_with_year: "unbekanntes Datum bis %{date}"
54
+ unknown_end_interval_with_day: "%{date} bis unbekanntes Datum"
55
+ unknown_end_interval_with_month: "%{date} bis unbekanntes Datum"
56
+ unknown_end_interval_with_year: "%{date} bis unbekanntes Datum"
57
+ unspecified_digit_substitute: "x"
58
+ formats:
59
+ day_precision_strftime_format: "%-d. %B %Y"
60
+ month_precision_strftime_format: "%B %Y"
61
+ year_precision_strftime_format: "%Y"
@@ -15,7 +15,6 @@ en:
15
15
  interval_prefix_year: ""
16
16
  interval_connector_approximate: " to "
17
17
  interval_connector_day: " to "
18
- interval_connector_open: " to "
19
18
  interval_connector_month: " to "
20
19
  interval_connector_year: " to "
21
20
  interval_unspecified_suffix: "s"
@@ -35,8 +34,15 @@ en:
35
34
  set_later_prefix_inclusive: 'on and after '
36
35
  set_two_dates_connector_exclusive: " or "
37
36
  set_two_dates_connector_inclusive: " and "
37
+ uncertain_date_prefix: ""
38
38
  uncertain_date_suffix: "?"
39
39
  unknown: 'unknown'
40
+ unknown_start_interval_with_day: "unknown date to %{date}"
41
+ unknown_start_interval_with_month: "unknown date to %{date}"
42
+ unknown_start_interval_with_year: "unknown date to %{date}"
43
+ unknown_end_interval_with_day: "%{date} to unknown date"
44
+ unknown_end_interval_with_month: "%{date} to unknown date"
45
+ unknown_end_interval_with_year: "%{date} to unknown date"
40
46
  unspecified_digit_substitute: "x"
41
47
  formats:
42
48
  day_precision_strftime_format: "%B %-d, %Y"
@@ -25,7 +25,6 @@ fr:
25
25
  interval_prefix_month: "De "
26
26
  interval_prefix_year: "De "
27
27
  interval_connector_approximate: " à "
28
- interval_connector_open: " à "
29
28
  interval_connector_day: " au "
30
29
  interval_connector_month: " à "
31
30
  interval_connector_year: " à "
@@ -46,8 +45,15 @@ fr:
46
45
  set_later_prefix_inclusive: 'Le et après '
47
46
  set_two_dates_connector_exclusive: " ou "
48
47
  set_two_dates_connector_inclusive: " et "
48
+ uncertain_date_prefix: ""
49
49
  uncertain_date_suffix: "?"
50
50
  unknown: 'Inconnue'
51
+ unknown_start_interval_with_day: "date inconnue au %{date}"
52
+ unknown_start_interval_with_month: "date inconnue jusqu'en %{date}"
53
+ unknown_start_interval_with_year: "date inconnue jusqu'en %{date}"
54
+ unknown_end_interval_with_day: "%{date} à date inconnue"
55
+ unknown_end_interval_with_month: "%{date} à date inconnue"
56
+ unknown_end_interval_with_year: "%{date} à date inconnue"
51
57
  unspecified_digit_substitute: "x"
52
58
  formats:
53
59
  day_precision_strftime_format: "%-d %B %Y"
@@ -25,7 +25,6 @@ it:
25
25
  interval_prefix_month: ""
26
26
  interval_prefix_year: ""
27
27
  interval_connector_approximate: " - "
28
- interval_connector_open: " - "
29
28
  interval_connector_day: " - "
30
29
  interval_connector_month: " - "
31
30
  interval_connector_year: " - "
@@ -46,8 +45,15 @@ it:
46
45
  set_later_prefix_inclusive: "dopo "
47
46
  set_two_dates_connector_exclusive: " o "
48
47
  set_two_dates_connector_inclusive: " e "
48
+ uncertain_date_prefix: ""
49
49
  uncertain_date_suffix: " ?"
50
50
  unknown: "data sconosciuta"
51
+ unknown_start_interval_with_day: "data sconosciuta a %{date}"
52
+ unknown_start_interval_with_month: "data sconosciuta a %{date}"
53
+ unknown_start_interval_with_year: "data sconosciuta a %{date}"
54
+ unknown_end_interval_with_day: "%{date} a data sconosciuta"
55
+ unknown_end_interval_with_month: "%{date} a data sconosciuta"
56
+ unknown_end_interval_with_year: "%{date} a data sconosciuta"
51
57
  unspecified_digit_substitute: "x"
52
58
  formats:
53
59
  day_precision_strftime_format: "%-d %B %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
@@ -10,7 +10,7 @@ module Edtf
10
10
  private
11
11
 
12
12
  def date_format(date)
13
- "#{apply_if_unspecified_year(date)}#{apply_if_uncertain(date)}"
13
+ "#{apply_prefix_if_uncertain(date)}#{apply_if_unspecified_year(date)}#{apply_suffix_if_uncertain(date)}"
14
14
  end
15
15
 
16
16
  def date_precision(date)
@@ -85,19 +85,26 @@ module Edtf
85
85
  end
86
86
 
87
87
  # '1990?' => 1990?
88
- def apply_if_uncertain(date)
88
+ def apply_suffix_if_uncertain(date)
89
89
  return '' unless date.respond_to?(:uncertain?) && date.uncertain?
90
90
 
91
91
  I18n.t('edtf.terms.uncertain_date_suffix', default: '?')
92
92
  end
93
93
 
94
+ # '1990?' => ?1990
95
+ def apply_prefix_if_uncertain(date)
96
+ return '' unless date.respond_to?(:uncertain?) && date.uncertain?
97
+
98
+ I18n.t('edtf.terms.uncertain_date_prefix', default: '')
99
+ end
100
+
94
101
  # '198u' => 198x
95
102
  def apply_if_unspecified_year(date)
96
103
  display = date_precision(date)
97
- if date.respond_to?(:unspecified?) && date.unspecified?(:year)
104
+ if date.respond_to?(:unspecified?) && (date.unspecified? :year)
98
105
  year_substitute =
99
106
  date.year_precision.edtf.gsub(
100
- /u/,
107
+ 'u',
101
108
  I18n.t('edtf.terms.unspecified_digit_substitute',
102
109
  default: 'x')
103
110
  )
@@ -12,11 +12,13 @@ module Edtf
12
12
  def humanizer(date)
13
13
  if date.from == :open || date.to == :open
14
14
  open_interval(date)
15
+ elsif date.from == :unknown || date.to == :unknown
16
+ unknown_interval(date)
15
17
  else
16
18
  "#{interval_prefix(date)}" \
17
- "#{formatted_date(date.from)}" \
18
- "#{interval_connector(date)}" \
19
- "#{formatted_date(date.to)}"
19
+ "#{formatted_date(date.from)}" \
20
+ "#{interval_connector(date)}" \
21
+ "#{formatted_date(date.to)}"
20
22
  end
21
23
  end
22
24
 
@@ -68,10 +70,56 @@ module Edtf
68
70
  end
69
71
  end
70
72
 
73
+ def unknown_interval(date)
74
+ if date.from == :unknown
75
+ unknown_start_interval(formatted_date: formatted_date(date.to),
76
+ precision: date.to.precision)
77
+ elsif date.to == :unknown
78
+ unknown_end_interval(formatted_date: formatted_date(date.from),
79
+ precision: date.from.precision)
80
+ end
81
+ end
82
+
83
+ # unknown/1980 => unknown year to 1980
84
+ def unknown_start_interval(formatted_date:, precision:)
85
+ case precision
86
+ when :year
87
+ I18n.t('edtf.terms.unknown_start_interval_with_year',
88
+ date: formatted_date,
89
+ default: "unknown date to #{formatted_date}")
90
+ when :month
91
+ I18n.t('edtf.terms.unknown_start_interval_with_month',
92
+ date: formatted_date,
93
+ default: "unknown date to #{formatted_date}")
94
+ when :day
95
+ I18n.t('edtf.terms.unknown_start_interval_with_day',
96
+ date: formatted_date,
97
+ default: "unknown date to #{formatted_date}")
98
+ end
99
+ end
100
+
101
+ # 1980/unknown => 1980 to unknown year
102
+ def unknown_end_interval(formatted_date:, precision:)
103
+ case precision
104
+ when :year
105
+ I18n.t('edtf.terms.unknown_end_interval_with_year',
106
+ date: formatted_date,
107
+ default: "#{formatted_date} to unknown date")
108
+ when :month
109
+ I18n.t('edtf.terms.unknown_end_interval_with_month',
110
+ date: formatted_date,
111
+ default: "#{formatted_date} to unknown date")
112
+ when :day
113
+ I18n.t('edtf.terms.unknown_end_interval_with_day',
114
+ date: formatted_date,
115
+ default: "#{formatted_date} to unknown date")
116
+ end
117
+ end
118
+
71
119
  def formatted_date(date)
72
120
  "#{apply_prefix_if_approximate(date)}" \
73
- "#{date_format(date)}" \
74
- "#{apply_suffix_if_approximate(date)}"
121
+ "#{date_format(date)}" \
122
+ "#{apply_suffix_if_approximate(date)}"
75
123
  end
76
124
 
77
125
  def interval_prefix(date)
@@ -86,8 +134,6 @@ module Edtf
86
134
  end
87
135
 
88
136
  def interval_connector(date)
89
- return interval_connector_open if date.to == :open
90
-
91
137
  return interval_connector_approx if date.to.approximate.day ||
92
138
  date.to.approximate.month ||
93
139
  date.to.approximate.year
@@ -95,10 +141,6 @@ module Edtf
95
141
  interval_connector_other(date)
96
142
  end
97
143
 
98
- def interval_connector_open
99
- I18n.t('edtf.terms.interval_connector_open')
100
- end
101
-
102
144
  def interval_connector_approx
103
145
  I18n.t('edtf.terms.interval_connector_approximate',
104
146
  default: ' to ')
@@ -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,11 @@ 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_uncertain(date)}" \
14
+ "#{apply_prefix_if_approximate(date)}" \
15
+ "#{translate_season(date.season)} #{date.year}" \
16
+ "#{apply_suffix_if_approximate(date)}" \
17
+ "#{apply_suffix_if_uncertain(date)}"
17
18
  end
18
19
 
19
20
  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.3.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.3.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-12-17 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.4.19
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