calendarium-romanum 0.3.0 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (38) hide show
  1. checksums.yaml +4 -4
  2. data/config/locales/cs.yml +14 -1
  3. data/config/locales/en.yml +12 -1
  4. data/config/locales/fr.yml +87 -0
  5. data/config/locales/it.yml +15 -2
  6. data/config/locales/la.yml +14 -1
  7. data/data/czech-cs.txt +1 -2
  8. data/data/universal-en.txt +1 -1
  9. data/data/universal-fr.txt +239 -0
  10. data/data/universal-it.txt +1 -1
  11. data/data/universal-la.txt +1 -1
  12. data/lib/calendarium-romanum.rb +1 -0
  13. data/lib/calendarium-romanum/calendar.rb +30 -18
  14. data/lib/calendarium-romanum/cli.rb +8 -4
  15. data/lib/calendarium-romanum/data.rb +1 -0
  16. data/lib/calendarium-romanum/day.rb +15 -0
  17. data/lib/calendarium-romanum/enums.rb +12 -2
  18. data/lib/calendarium-romanum/ordinalizer.rb +7 -4
  19. data/lib/calendarium-romanum/perpetual_calendar.rb +49 -0
  20. data/lib/calendarium-romanum/rank.rb +1 -1
  21. data/lib/calendarium-romanum/sanctorale.rb +8 -1
  22. data/lib/calendarium-romanum/temporale.rb +63 -36
  23. data/lib/calendarium-romanum/temporale/dates.rb +38 -25
  24. data/lib/calendarium-romanum/temporale/extensions/christ_eternal_priest.rb +4 -4
  25. data/lib/calendarium-romanum/version.rb +1 -1
  26. data/spec/calendar_spec.rb +233 -255
  27. data/spec/celebration_spec.rb +23 -0
  28. data/spec/colour_spec.rb +17 -0
  29. data/spec/data_spec.rb +1 -1
  30. data/spec/day_spec.rb +59 -0
  31. data/spec/ordinalizer_spec.rb +22 -0
  32. data/spec/perpetual_calendar_spec.rb +91 -0
  33. data/spec/rank_spec.rb +22 -7
  34. data/spec/sanctorale_spec.rb +84 -60
  35. data/spec/season_spec.rb +17 -0
  36. data/spec/spec_helper.rb +2 -2
  37. data/spec/temporale_spec.rb +62 -43
  38. metadata +12 -3
@@ -3,7 +3,7 @@ module CalendariumRomanum
3
3
  # dates of movable feasts
4
4
  module Dates
5
5
  def self.first_advent_sunday(year)
6
- sunday_before(nativity(year)) - 3 * Temporale::WEEK
6
+ sunday_before(nativity(year)) - 3 * WEEK
7
7
  end
8
8
 
9
9
  def self.nativity(year)
@@ -23,16 +23,26 @@ module CalendariumRomanum
23
23
  octave_of(nativity(year))
24
24
  end
25
25
 
26
- def self.epiphany(year)
26
+ def self.epiphany(year, sunday: false)
27
+ if sunday
28
+ # GNLYC 7 a)
29
+ return sunday_after(Date.new(year + 1, 1, 1))
30
+ end
31
+
27
32
  Date.new(year+1, 1, 6)
28
33
  end
29
34
 
30
- def self.baptism_of_lord(year)
31
- sunday_after epiphany(year)
35
+ def self.baptism_of_lord(year, epiphany_on_sunday: false)
36
+ e = epiphany(year, sunday: epiphany_on_sunday)
37
+ if epiphany_on_sunday
38
+ e + 1
39
+ else
40
+ sunday_after e
41
+ end
32
42
  end
33
43
 
34
44
  def self.ash_wednesday(year)
35
- easter_sunday(year) - (6 * Temporale::WEEK + 4)
45
+ easter_sunday(year) - (6 * WEEK + 4)
36
46
  end
37
47
 
38
48
  def self.easter_sunday(year)
@@ -42,17 +52,10 @@ module CalendariumRomanum
42
52
  # https://github.com/jrobertson/easter
43
53
 
44
54
  golden_number = (year % 19) + 1
45
- if year <= 1752 then
46
- # Julian calendar
47
- dominical_number = (year + (year / 4) + 5) % 7
48
- paschal_full_moon = (3 - (11 * golden_number) - 7) % 30
49
- else
50
- # Gregorian calendar
51
- dominical_number = (year + (year / 4) - (year / 100) + (year / 400)) % 7
52
- solar_correction = (year - 1600) / 100 - (year - 1600) / 400
53
- lunar_correction = (((year - 1400) / 100) * 8) / 25
54
- paschal_full_moon = (3 - 11 * golden_number + solar_correction - lunar_correction) % 30
55
- end
55
+ dominical_number = (year + (year / 4) - (year / 100) + (year / 400)) % 7
56
+ solar_correction = (year - 1600) / 100 - (year - 1600) / 400
57
+ lunar_correction = (((year - 1400) / 100) * 8) / 25
58
+ paschal_full_moon = (3 - 11 * golden_number + solar_correction - lunar_correction) % 30
56
59
  dominical_number += 7 until dominical_number > 0
57
60
  paschal_full_moon += 30 until paschal_full_moon > 0
58
61
  paschal_full_moon -= 1 if paschal_full_moon == 29 or (paschal_full_moon == 28 and golden_number > 11)
@@ -80,24 +83,34 @@ module CalendariumRomanum
80
83
  easter_sunday(year) - 1
81
84
  end
82
85
 
83
- def self.ascension(year)
86
+ def self.ascension(year, sunday: false)
87
+ if sunday
88
+ # GNLYC 7 b)
89
+ return easter_sunday(year) + 6 * WEEK
90
+ end
91
+
84
92
  pentecost(year) - 10
85
93
  end
86
94
 
87
95
  def self.pentecost(year)
88
- easter_sunday(year) + 7 * Temporale::WEEK
96
+ easter_sunday(year) + 7 * WEEK
89
97
  end
90
98
 
91
99
  def self.holy_trinity(year)
92
100
  octave_of(pentecost(year))
93
101
  end
94
102
 
95
- def self.body_blood(year)
103
+ def self.corpus_christi(year, sunday: false)
104
+ if sunday
105
+ # GNLYC 7 c)
106
+ return holy_trinity(year) + WEEK
107
+ end
108
+
96
109
  holy_trinity(year) + 4
97
110
  end
98
111
 
99
112
  def self.sacred_heart(year)
100
- body_blood(year) + 8
113
+ corpus_christi(year) + 8
101
114
  end
102
115
 
103
116
  def self.immaculate_heart(year)
@@ -112,26 +125,26 @@ module CalendariumRomanum
112
125
 
113
126
  def self.weekday_before(weekday, date)
114
127
  if date.wday == weekday then
115
- return date - Temporale::WEEK
128
+ return date - WEEK
116
129
  elsif weekday < date.wday
117
130
  return date - (date.wday - weekday)
118
131
  else
119
- return date - (date.wday + Temporale::WEEK - weekday)
132
+ return date - (date.wday + WEEK - weekday)
120
133
  end
121
134
  end
122
135
 
123
136
  def self.weekday_after(weekday, date)
124
137
  if date.wday == weekday then
125
- return date + Temporale::WEEK
138
+ return date + WEEK
126
139
  elsif weekday > date.wday
127
140
  return date + (weekday - date.wday)
128
141
  else
129
- return date + (Temporale::WEEK - date.wday + weekday)
142
+ return date + (WEEK - date.wday + weekday)
130
143
  end
131
144
  end
132
145
 
133
146
  def self.octave_of(date)
134
- date + Temporale::WEEK
147
+ date + WEEK
135
148
  end
136
149
 
137
150
  class << self
@@ -4,8 +4,8 @@ module CalendariumRomanum
4
4
  # Temporale extension adding feast of Christ Eternal Priests,
5
5
  # included in some local calendars
6
6
  module ChristEternalPriest
7
- def self.included(mod)
8
- mod.add_celebration(
7
+ def self.each_celebration
8
+ yield(
9
9
  :christ_eternal_priest,
10
10
  Celebration.new(
11
11
  proc { I18n.t('temporale.extension.christ_eternal_priest') },
@@ -16,8 +16,8 @@ module CalendariumRomanum
16
16
  end
17
17
 
18
18
  # method computing date
19
- def christ_eternal_priest
20
- pentecost + 4
19
+ def self.christ_eternal_priest(year)
20
+ Dates.pentecost(year) + 4
21
21
  end
22
22
  end
23
23
  end
@@ -1,3 +1,3 @@
1
1
  module CalendariumRomanum
2
- VERSION = '0.3.0'
2
+ VERSION = '0.4.0'
3
3
  end
@@ -1,201 +1,223 @@
1
1
  require_relative 'spec_helper'
2
2
 
3
3
  describe CR::Calendar do
4
+ before :all do
5
+ @c = described_class.new(2013).freeze
6
+ end
4
7
 
5
- describe 'core functions' do
6
- before :all do
7
- @c = described_class.new 2013
8
+ describe '.new' do
9
+ it 'throws RangeError on invalid year' do
10
+ expect do
11
+ described_class.new(1968)
12
+ end.to raise_exception(RangeError, /in use only since 1st January 1970/)
8
13
  end
9
14
 
10
- describe '#==' do
11
- it 'considers calendars with the same year same' do
12
- expect(described_class.new(2014) == described_class.new(2014)).to be true
13
- end
15
+ it 'throws ArgumentError when Temporale year does not match' do
16
+ year = 2000
17
+ temporale = CR::Temporale.new year
18
+ expect do
19
+ CR::Calendar.new(year + 1, nil, temporale)
20
+ end.to raise_exception ArgumentError
21
+ end
22
+ end
14
23
 
15
- it 'considers calendars with different year different' do
16
- expect(described_class.new(2014) == described_class.new(2010)).to be false
17
- end
24
+ describe '.for_day' do
25
+ it 'continues the previous year\'s calendar in summer' do
26
+ expect(described_class.for_day(Date.new(2014, 6, 9))).to eq described_class.new(2013)
18
27
  end
19
28
 
20
- describe '#lectionary' do
21
- it 'detects correctly' do
22
- expect(described_class.new(2014).lectionary).to eq :B
23
- expect(described_class.new(2013).lectionary).to eq :A
24
- expect(described_class.new(2012).lectionary).to eq :C
25
- end
29
+ it 'provides the current year\'s calendar in December' do
30
+ expect(described_class.for_day(Date.new(2014, 12, 20))).to eq described_class.new(2014)
26
31
  end
32
+ end
27
33
 
28
- describe '#ferial_lectionary' do
29
- it 'detects correctly' do
30
- expect(described_class.new(2014).ferial_lectionary).to eq 1
31
- expect(described_class.new(2013).ferial_lectionary).to eq 2
32
- end
34
+ describe '#==' do
35
+ it 'considers calendars with the same year same' do
36
+ expect(described_class.new(2014) == described_class.new(2014)).to be true
37
+ end
38
+
39
+ it 'considers calendars with different year different' do
40
+ expect(described_class.new(2014) == described_class.new(2010)).to be false
41
+ end
42
+ end
43
+
44
+ describe '#lectionary' do
45
+ it 'detects correctly' do
46
+ expect(described_class.new(2014).lectionary).to eq :B
47
+ expect(described_class.new(2013).lectionary).to eq :A
48
+ expect(described_class.new(2012).lectionary).to eq :C
49
+ end
50
+ end
51
+
52
+ describe '#ferial_lectionary' do
53
+ it 'detects correctly' do
54
+ expect(described_class.new(2014).ferial_lectionary).to eq 1
55
+ expect(described_class.new(2013).ferial_lectionary).to eq 2
33
56
  end
57
+ end
34
58
 
35
- describe '.for_day' do
36
- it 'continues the previous year\'s calendar in summer' do
37
- expect(described_class.for_day(Date.new(2014, 6, 9))).to eq described_class.new(2013)
59
+ describe '#day' do
60
+ describe 'received arguments' do
61
+ describe 'Date' do
62
+ it 'returns a Day' do
63
+ expect(@c.day(Date.new(2013, 12, 10))).to be_a CR::Day
64
+ end
38
65
  end
39
66
 
40
- it 'provides the current year\'s calendar in December' do
41
- expect(described_class.for_day(Date.new(2014, 12, 20))).to eq described_class.new(2014)
67
+ describe 'DateTime' do
68
+ it 'returns a Day' do
69
+ expect(@c.day(DateTime.new(2013, 12, 10, 12, 10, 0))).to be_a CR::Day
70
+ end
42
71
  end
43
- end
44
72
 
45
- describe '#day' do
46
- describe 'received arguments' do
47
- describe 'Date' do
48
- it 'returns a Day' do
49
- expect(@c.day(Date.new(2013, 12, 10))).to be_a CR::Day
50
- end
73
+ describe 'three Integers' do
74
+ it 'returns a Day' do
75
+ expect(@c.day(2013, 12, 10)).to be_a CR::Day
51
76
  end
77
+ end
52
78
 
53
- describe 'DateTime' do
54
- it 'returns a Day' do
55
- expect(@c.day(DateTime.new(2013, 12, 10, 12, 10, 0))).to be_a CR::Day
79
+ describe 'two integers' do
80
+ describe 'autumn' do
81
+ it 'supplies year' do
82
+ day = @c.day(12, 10)
83
+ expect(day).to be_a CR::Day
84
+ expect(day.date).to eq Date.new(2013, 12, 10)
56
85
  end
57
86
  end
58
87
 
59
- describe 'three Integers' do
60
- it 'returns a Day' do
61
- expect(@c.day(2013, 12, 10)).to be_a CR::Day
88
+ describe 'spring' do
89
+ it 'supplies year' do
90
+ day = @c.day(4, 10)
91
+ expect(day).to be_a CR::Day
92
+ expect(day.date).to eq Date.new(2014, 4, 10)
62
93
  end
63
94
  end
64
95
 
65
- describe 'two integers' do
66
- describe 'autumn' do
67
- it 'supplies year' do
68
- day = @c.day(12, 10)
69
- expect(day).to be_a CR::Day
70
- expect(day.date).to eq Date.new(2013, 12, 10)
96
+ describe 'invalid' do
97
+ describe 'absolutely' do
98
+ it 'fails' do
99
+ expect do
100
+ day = @c.day(0, 34)
101
+ end.to raise_exception(ArgumentError, 'invalid date')
71
102
  end
72
103
  end
73
104
 
74
- describe 'spring' do
75
- it 'supplies year' do
76
- day = @c.day(4, 10)
77
- expect(day).to be_a CR::Day
78
- expect(day.date).to eq Date.new(2014, 4, 10)
105
+ describe 'for the given year' do
106
+ it 'fails' do
107
+ expect do
108
+ day = @c.day(2, 29)
109
+ end.to raise_exception(ArgumentError, 'invalid date')
79
110
  end
80
111
  end
112
+ end
113
+ end
114
+ end
81
115
 
82
- describe 'invalid' do
83
- describe 'absolutely' do
84
- it 'fails' do
85
- expect do
86
- day = @c.day(0, 34)
87
- end.to raise_exception(ArgumentError, 'invalid date')
88
- end
89
- end
116
+ describe "date not included in the calendar's year" do
117
+ it 'throws RangeError' do
118
+ expect { @c.day(2000, 1, 1) }.to raise_exception RangeError
119
+ end
120
+ end
90
121
 
91
- describe 'for the given year' do
92
- it 'fails' do
93
- expect do
94
- day = @c.day(2, 29)
95
- end.to raise_exception(ArgumentError, 'invalid date')
96
- end
97
- end
98
- end
99
- end
122
+ describe 'date before system effectiveness' do
123
+ it 'throws RangeError' do
124
+ c = described_class.new 1969
125
+ expect { c.day(1969, 12, 20) }.to raise_exception RangeError
100
126
  end
127
+ end
101
128
 
102
- it 'throws RangeError if given date not included in the year' do
103
- expect { @c.day(2000, 1, 1) }.to raise_error RangeError
129
+ describe 'temporale features' do
130
+ describe 'season' do
131
+ it 'detects Advent correctly' do
132
+ expect(@c.day(2013, 12, 10).season).to eq CR::Seasons::ADVENT
133
+ end
104
134
  end
105
135
 
106
- describe 'temporale features' do
107
- describe 'season' do
108
- it 'detects Advent correctly' do
109
- expect(@c.day(2013, 12, 10).season).to eq CR::Seasons::ADVENT
136
+ describe 'week of the season' do
137
+ describe 'Advent' do
138
+ it 'sets Advent week correctly' do
139
+ expect(@c.day(2013, 12, 10).season_week).to eq 2
140
+ expect(@c.day(2013, 12, 15).season_week).to eq 3
110
141
  end
111
142
  end
112
143
 
113
- describe 'week of the season' do
114
- describe 'Advent' do
115
- it 'sets Advent week correctly' do
116
- expect(@c.day(2013, 12, 10).season_week).to eq 2
117
- expect(@c.day(2013, 12, 15).season_week).to eq 3
118
- end
144
+ describe 'Christmas' do
145
+ it 'days before the first Sunday are week 0' do
146
+ expect(@c.day(2013, 12, 25).season_week).to eq 0
119
147
  end
120
148
 
121
- describe 'Christmas' do
122
- it 'days before the first Sunday are week 0' do
123
- expect(@c.day(2013, 12, 25).season_week).to eq 0
124
- end
149
+ it 'first Sunday starts week 1' do
150
+ expect(@c.day(2013, 12, 29).season_week).to eq 1
151
+ end
152
+ end
125
153
 
126
- it 'first Sunday starts week 1' do
127
- expect(@c.day(2013, 12, 29).season_week).to eq 1
128
- end
154
+ describe 'Lent' do
155
+ it 'Ash Wednesday is week 0' do
156
+ expect(@c.day(2014, 3, 5).season_week).to eq 0
129
157
  end
158
+ end
130
159
 
131
- describe 'Lent' do
132
- it 'Ash Wednesday is week 0' do
133
- expect(@c.day(2014, 3, 5).season_week).to eq 0
134
- end
160
+ describe 'Easter' do
161
+ it 'Easter Sunday opens week 1' do
162
+ expect(@c.day(2014, 4, 20).season_week).to eq 1
135
163
  end
164
+ end
136
165
 
137
- describe 'Easter' do
138
- it 'Easter Sunday opens week 1' do
139
- expect(@c.day(2014, 4, 20).season_week).to eq 1
140
- end
166
+ describe 'Ordinary time' do
167
+ it 'Monday after Baptism of the Lord is week 1' do
168
+ expect(@c.day(2014, 1, 13).season_week).to eq 1
141
169
  end
142
170
 
143
- describe 'Ordinary time' do
144
- it 'Monday after Baptism of the Lord is week 1' do
145
- expect(@c.day(2014, 1, 13).season_week).to eq 1
171
+ describe 'after Pentecost' do
172
+ it '2014' do
173
+ c = described_class.new(2013)
174
+ expect(c.day(2014, 6, 9).season_week).to eq 10
146
175
  end
147
176
 
148
- describe 'after Pentecost' do
149
- it '2014' do
150
- c = described_class.new(2013)
151
- expect(c.day(2014, 6, 9).season_week).to eq 10
152
- end
153
-
154
- it '2015' do
155
- c = described_class.new(2014)
156
- expect(c.day(2015, 5, 25).season_week).to eq 8
157
- end
177
+ it '2015' do
178
+ c = described_class.new(2014)
179
+ expect(c.day(2015, 5, 25).season_week).to eq 8
180
+ end
158
181
 
159
- it '2016' do
160
- c = described_class.new(2015)
161
- expect(c.day(2016, 5, 16).season_week).to eq 7
162
- end
182
+ it '2016' do
183
+ c = described_class.new(2015)
184
+ expect(c.day(2016, 5, 16).season_week).to eq 7
185
+ end
163
186
 
164
- it '2017' do
165
- c = described_class.new(2016)
166
- expect(c.day(2017, 6, 5).season_week).to eq 9
167
- end
187
+ it '2017' do
188
+ c = described_class.new(2016)
189
+ expect(c.day(2017, 6, 5).season_week).to eq 9
190
+ end
168
191
 
169
- describe 'works correctly for the whole week' do
170
- describe 'first' do
171
- Date.new(2014, 6, 9).upto(Date.new(2014, 6, 14)) do |date|
172
- it date do
173
- expect(@c.day(date).season_week).to eq 10
174
- end
192
+ describe 'works correctly for the whole week' do
193
+ describe 'first' do
194
+ Date.new(2014, 6, 9).upto(Date.new(2014, 6, 14)) do |date|
195
+ it date do
196
+ expect(@c.day(date).season_week).to eq 10
175
197
  end
176
198
  end
199
+ end
177
200
 
178
- describe 'second' do
179
- Date.new(2014, 6, 15).upto(Date.new(2014, 6, 21)) do |date|
180
- it date do
181
- expect(@c.day(date).season_week).to eq 11
182
- end
201
+ describe 'second' do
202
+ Date.new(2014, 6, 15).upto(Date.new(2014, 6, 21)) do |date|
203
+ it date do
204
+ expect(@c.day(date).season_week).to eq 11
183
205
  end
184
206
  end
207
+ end
185
208
 
186
- describe 'second last' do
187
- Date.new(2014, 11, 16).upto(Date.new(2014, 11, 22)) do |date|
188
- it date do
189
- expect(@c.day(date).season_week).to eq 33
190
- end
209
+ describe 'second last' do
210
+ Date.new(2014, 11, 16).upto(Date.new(2014, 11, 22)) do |date|
211
+ it date do
212
+ expect(@c.day(date).season_week).to eq 33
191
213
  end
192
214
  end
215
+ end
193
216
 
194
- describe 'last' do
195
- Date.new(2014, 11, 23).upto(Date.new(2014, 11, 29)) do |date|
196
- it date do
197
- expect(@c.day(date).season_week).to eq 34
198
- end
217
+ describe 'last' do
218
+ Date.new(2014, 11, 23).upto(Date.new(2014, 11, 29)) do |date|
219
+ it date do
220
+ expect(@c.day(date).season_week).to eq 34
199
221
  end
200
222
  end
201
223
  end
@@ -203,149 +225,105 @@ describe CR::Calendar do
203
225
  end
204
226
  end
205
227
  end
228
+ end
206
229
 
207
- describe 'Temporale x Sanctorale resolution' do
208
- before :all do
209
- @s = CR::Data::GENERAL_ROMAN_ENGLISH.load
210
- @c = described_class.new 2013, @s
211
- end
212
-
213
- it '"empty" day results in a ferial' do
214
- d = @c.day(7, 2)
215
- expect(d.celebrations.size).to eq 1
216
- expect(d.celebrations[0].rank).to eq CR::Ranks::FERIAL
217
- end
218
-
219
- it 'sanctorale feast' do
220
- d = @c.day(7, 3)
221
- expect(d.celebrations.size).to eq 1
222
- expect(d.celebrations[0].rank).to eq CR::Ranks::FEAST_GENERAL
223
- expect(d.celebrations[0].title).to include 'Thomas'
224
- end
225
-
226
- it 'optional memorial does not suppress ferial' do
227
- d = @c.day(7, 14)
228
- expect(d.celebrations.size).to eq 2
229
-
230
- expect(d.celebrations[0].rank).to eq CR::Ranks::FERIAL
231
-
232
- expect(d.celebrations[1].rank).to eq CR::Ranks::MEMORIAL_OPTIONAL
233
- expect(d.celebrations[1].title).to include 'Lellis'
234
- end
235
-
236
- it 'obligatory memorial does suppress ferial' do
237
- d = @c.day(1, 17)
238
- expect(d.celebrations.size).to eq 1
230
+ describe 'Temporale x Sanctorale resolution' do
231
+ before :all do
232
+ @s = CR::Data::GENERAL_ROMAN_ENGLISH.load
233
+ @c = described_class.new(2013, @s).freeze
234
+ end
239
235
 
240
- expect(d.celebrations[0].rank).to eq CR::Ranks::MEMORIAL_GENERAL
241
- end
236
+ it '"empty" day results in a ferial' do
237
+ d = @c.day(7, 2)
238
+ expect(d.celebrations.size).to eq 1
239
+ expect(d.celebrations[0].rank).to eq CR::Ranks::FERIAL
240
+ end
242
241
 
243
- it 'memorial in Lent becomes mere commemoration' do
244
- d = @c.day(4, 2)
245
- expect(d.celebrations.size).to eq 2
242
+ it 'sanctorale feast' do
243
+ d = @c.day(7, 3)
244
+ expect(d.celebrations.size).to eq 1
245
+ expect(d.celebrations[0].rank).to eq CR::Ranks::FEAST_GENERAL
246
+ expect(d.celebrations[0].title).to include 'Thomas'
247
+ end
246
248
 
247
- comm = d.celebrations[1]
248
- expect(comm.rank).to eq CR::Ranks::COMMEMORATION
249
- expect(comm.title).to eq 'Saint Francis of Paola, hermit'
250
- end
249
+ it 'optional memorial does not suppress ferial' do
250
+ d = @c.day(7, 14)
251
+ expect(d.celebrations.size).to eq 2
251
252
 
252
- it 'Sunday suppresses feast' do
253
- san = CR::Sanctorale.new
253
+ expect(d.celebrations[0].rank).to eq CR::Ranks::FERIAL
254
254
 
255
- d = Date.new 2015, 6, 28
256
- expect(d).to be_sunday # ensure
257
- san.add d.month, d.day, CR::Celebration.new('St. None, programmer', CR::Ranks::FEAST_GENERAL)
255
+ expect(d.celebrations[1].rank).to eq CR::Ranks::MEMORIAL_OPTIONAL
256
+ expect(d.celebrations[1].title).to include 'Lellis'
257
+ end
258
258
 
259
- c = described_class.new 2014, san
259
+ it 'obligatory memorial does suppress ferial' do
260
+ d = @c.day(1, 17)
261
+ expect(d.celebrations.size).to eq 1
260
262
 
261
- celebs = c.day(d).celebrations
262
- expect(celebs.size).to eq 1
263
- expect(celebs[0].rank).to eq CR::Ranks::SUNDAY_UNPRIVILEGED
264
- end
263
+ expect(d.celebrations[0].rank).to eq CR::Ranks::MEMORIAL_GENERAL
264
+ end
265
265
 
266
- it 'suppressed fictive solemnity is transferred' do
267
- san = CR::Sanctorale.new
266
+ it 'memorial in Lent becomes mere commemoration' do
267
+ d = @c.day(4, 2)
268
+ expect(d.celebrations.size).to eq 2
268
269
 
269
- d = CR::Temporale.new(2014).good_friday
270
- st_none = CR::Celebration.new('St. None, abbot, founder of the Order of Programmers (OProg)', CR::Ranks::SOLEMNITY_PROPER)
271
- san.add d.month, d.day, st_none
270
+ comm = d.celebrations[1]
271
+ expect(comm.rank).to eq CR::Ranks::COMMEMORATION
272
+ expect(comm.title).to eq 'Saint Francis of Paola, hermit'
273
+ end
272
274
 
273
- c = described_class.new 2014, san
275
+ it 'Sunday suppresses feast' do
276
+ san = CR::Sanctorale.new
274
277
 
275
- # Good Friday suppresses the solemnity
276
- celebs = c.day(d).celebrations
277
- expect(celebs.size).to eq 1
278
- expect(celebs[0].rank).to eq CR::Ranks::TRIDUUM
279
- expect(celebs[0].title).to have_translation 'Friday of the Passion of the Lord'
278
+ d = Date.new 2015, 6, 28
279
+ expect(d).to be_sunday # ensure
280
+ san.add d.month, d.day, CR::Celebration.new('St. None, programmer', CR::Ranks::FEAST_GENERAL)
280
281
 
281
- # it is transferred on a day after the Easter octave
282
- d = c.temporale.easter_sunday + 8
283
- celebs = c.day(d).celebrations
284
- expect(celebs.size).to eq 1
285
- expect(celebs[0]).to eq st_none
286
- end
282
+ c = described_class.new 2014, san
287
283
 
288
- it 'transfer of suppressed Annunciation (real world example)' do
289
- c = described_class.new 2015, @s
284
+ celebs = c.day(d).celebrations
285
+ expect(celebs.size).to eq 1
286
+ expect(celebs[0].rank).to eq CR::Ranks::SUNDAY_UNPRIVILEGED
287
+ end
290
288
 
291
- d = Date.new(2016, 3, 25)
289
+ it 'suppressed fictive solemnity is transferred' do
290
+ san = CR::Sanctorale.new
292
291
 
293
- # Good Friday suppresses the solemnity
294
- celebs = c.day(d).celebrations
295
- expect(celebs.size).to eq 1
296
- expect(celebs[0].rank).to eq CR::Ranks::TRIDUUM
297
- expect(celebs[0].title).to have_translation 'Friday of the Passion of the Lord'
292
+ d = CR::Temporale.new(2014).good_friday
293
+ st_none = CR::Celebration.new('St. None, abbot, founder of the Order of Programmers (OProg)', CR::Ranks::SOLEMNITY_PROPER)
294
+ san.add d.month, d.day, st_none
298
295
 
299
- # it is transferred on a day after the Easter octave
300
- d = c.temporale.easter_sunday + 8
301
- celebs = c.day(d).celebrations
302
- expect(celebs.size).to eq 1
303
- expect(celebs[0].title).to eq 'Annunciation of the Lord'
304
- end
305
- end
306
- end
296
+ c = described_class.new 2014, san
307
297
 
308
- describe '#pred' do
309
- it 'returns a calendar for the previous year' do
310
- new_cal = @c.pred
311
- expect(new_cal.year).to eq(@c.year - 1)
312
- expect(new_cal.sanctorale).to eq (@c.sanctorale)
313
- end
298
+ # Good Friday suppresses the solemnity
299
+ celebs = c.day(d).celebrations
300
+ expect(celebs.size).to eq 1
301
+ expect(celebs[0].rank).to eq CR::Ranks::TRIDUUM
302
+ expect(celebs[0].title).to have_translation 'Friday of the Passion of the Lord'
314
303
 
315
- it 'preserves sanctorale' do
316
- sanctorale = CR::Sanctorale.new
317
- cal = described_class.new(2000, sanctorale)
318
- new_cal = cal.pred
319
- expect(new_cal.sanctorale).to be sanctorale
304
+ # it is transferred on a day after the Easter octave
305
+ d = c.temporale.easter_sunday + 8
306
+ celebs = c.day(d).celebrations
307
+ expect(celebs.size).to eq 1
308
+ expect(celebs[0]).to eq st_none
320
309
  end
321
310
 
322
- it 'preserves temporale class' do
323
- t_class = Class.new(CR::Temporale)
324
- cal = described_class.new(2000, nil, t_class)
325
- new_cal = cal.pred
326
- expect(new_cal.temporale).to be_a t_class
327
- end
328
- end
311
+ it 'transfer of suppressed Annunciation (real world example)' do
312
+ c = described_class.new 2015, @s
329
313
 
330
- describe '#succ' do
331
- it 'returns a calendar for the subsequent year' do
332
- new_cal = @c.succ
333
- expect(new_cal.year).to eq(@c.year + 1)
334
- expect(new_cal.sanctorale).to eq (@c.sanctorale)
335
- end
314
+ d = Date.new(2016, 3, 25)
336
315
 
337
- it 'preserves sanctorale' do
338
- sanctorale = CR::Sanctorale.new
339
- cal = described_class.new(2000, sanctorale)
340
- new_cal = cal.succ
341
- expect(new_cal.sanctorale).to be sanctorale
342
- end
316
+ # Good Friday suppresses the solemnity
317
+ celebs = c.day(d).celebrations
318
+ expect(celebs.size).to eq 1
319
+ expect(celebs[0].rank).to eq CR::Ranks::TRIDUUM
320
+ expect(celebs[0].title).to have_translation 'Friday of the Passion of the Lord'
343
321
 
344
- it 'preserves temporale class' do
345
- t_class = Class.new(CR::Temporale)
346
- cal = described_class.new(2000, nil, t_class)
347
- new_cal = cal.succ
348
- expect(new_cal.temporale).to be_a t_class
322
+ # it is transferred on a day after the Easter octave
323
+ d = c.temporale.easter_sunday + 8
324
+ celebs = c.day(d).celebrations
325
+ expect(celebs.size).to eq 1
326
+ expect(celebs[0].title).to eq 'Annunciation of the Lord'
349
327
  end
350
328
  end
351
329
  end