calendarium-romanum 0.4.0 → 0.8.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (106) hide show
  1. checksums.yaml +5 -5
  2. data/.gitignore +4 -0
  3. data/.rspec +2 -0
  4. data/.rubocop.yml +47 -0
  5. data/.travis.yml +22 -0
  6. data/.yardopts +3 -0
  7. data/CHANGELOG.md +431 -0
  8. data/Gemfile +25 -0
  9. data/Gemfile.lock +86 -0
  10. data/README.md +598 -0
  11. data/Rakefile +16 -0
  12. data/bin/calendariumrom +4 -1
  13. data/calendarium-romanum.gemspec +31 -0
  14. data/config/locales/cs.yml +5 -0
  15. data/config/locales/en.yml +21 -14
  16. data/config/locales/es.yml +94 -0
  17. data/config/locales/fr.yml +7 -0
  18. data/config/locales/it.yml +7 -0
  19. data/config/locales/la.yml +7 -0
  20. data/data/README.md +70 -24
  21. data/data/czech-brno-cs.txt +4 -6
  22. data/data/czech-budejovice-cs.txt +4 -6
  23. data/data/czech-cechy-cs.txt +4 -5
  24. data/data/czech-cs.txt +236 -234
  25. data/data/czech-hradec-cs.txt +3 -5
  26. data/data/czech-litomerice-cs.txt +5 -7
  27. data/data/czech-morava-cs.txt +4 -5
  28. data/data/czech-olomouc-cs.txt +2 -4
  29. data/data/czech-ostrava-cs.txt +3 -5
  30. data/data/czech-plzen-cs.txt +3 -5
  31. data/data/czech-praha-cs.txt +3 -4
  32. data/data/easter_dates.txt +67 -0
  33. data/data/universal-1969-la.txt +234 -0
  34. data/data/universal-en.txt +214 -211
  35. data/data/universal-es.txt +243 -0
  36. data/data/universal-fr.txt +214 -210
  37. data/data/universal-it.txt +214 -211
  38. data/data/universal-la.txt +214 -210
  39. data/doc/data_readme.md +2 -0
  40. data/doc/images/class_diagram.png +0 -0
  41. data/doc/images/class_diagram.puml +44 -0
  42. data/doc/yard_readme.rdoc +76 -0
  43. data/lib/calendarium-romanum.rb +35 -22
  44. data/lib/calendarium-romanum/abstract_date.rb +15 -0
  45. data/lib/calendarium-romanum/calendar.rb +207 -42
  46. data/lib/calendarium-romanum/cli.rb +63 -80
  47. data/lib/calendarium-romanum/cli/comparator.rb +63 -0
  48. data/lib/calendarium-romanum/cli/date_parser.rb +30 -0
  49. data/lib/calendarium-romanum/cli/dumper.rb +68 -0
  50. data/lib/calendarium-romanum/cli/helper.rb +23 -0
  51. data/lib/calendarium-romanum/cli/querier.rb +73 -0
  52. data/lib/calendarium-romanum/cr.rb +16 -0
  53. data/lib/calendarium-romanum/data.rb +50 -20
  54. data/lib/calendarium-romanum/day.rb +208 -32
  55. data/lib/calendarium-romanum/enum.rb +42 -25
  56. data/lib/calendarium-romanum/enums.rb +124 -44
  57. data/lib/calendarium-romanum/errors.rb +4 -0
  58. data/lib/calendarium-romanum/ordinalizer.rb +23 -2
  59. data/lib/calendarium-romanum/perpetual_calendar.rb +58 -7
  60. data/lib/calendarium-romanum/rank.rb +43 -12
  61. data/lib/calendarium-romanum/rank_predicates.rb +43 -0
  62. data/lib/calendarium-romanum/sanctorale.rb +164 -24
  63. data/lib/calendarium-romanum/sanctorale_factory.rb +74 -3
  64. data/lib/calendarium-romanum/sanctorale_loader.rb +180 -0
  65. data/lib/calendarium-romanum/sanctorale_writer.rb +119 -0
  66. data/lib/calendarium-romanum/temporale.rb +226 -94
  67. data/lib/calendarium-romanum/temporale/celebration_factory.rb +107 -0
  68. data/lib/calendarium-romanum/temporale/dates.rb +84 -16
  69. data/lib/calendarium-romanum/temporale/easter_table.rb +27 -0
  70. data/lib/calendarium-romanum/temporale/extensions.rb +15 -0
  71. data/lib/calendarium-romanum/temporale/extensions/christ_eternal_priest.rb +16 -3
  72. data/lib/calendarium-romanum/temporale/extensions/dedication_before_all_saints.rb +73 -0
  73. data/lib/calendarium-romanum/transfers.rb +60 -15
  74. data/lib/calendarium-romanum/util.rb +22 -3
  75. data/lib/calendarium-romanum/version.rb +5 -1
  76. data/liturgical_law/1969_normae_universales.md +568 -0
  77. data/liturgical_law/1977_decretum_de_celebratione_baptismatis_domini.md +58 -0
  78. data/liturgical_law/1990_decretum_de_variatione_inducenda.md +67 -0
  79. data/liturgical_law/1998_notificatio_de_occurrentia.md +57 -0
  80. data/liturgical_law/2002_normae_universales.md +946 -0
  81. data/liturgical_law/2006_notification.md +37 -0
  82. data/liturgical_law/2012_declarationes.md +38 -0
  83. data/liturgical_law/README.md +74 -0
  84. metadata +50 -28
  85. data/lib/calendarium-romanum/sanctoraleloader.rb +0 -115
  86. data/spec/abstract_date_spec.rb +0 -62
  87. data/spec/calendar_spec.rb +0 -330
  88. data/spec/celebration_spec.rb +0 -23
  89. data/spec/cli_spec.rb +0 -26
  90. data/spec/colour_spec.rb +0 -17
  91. data/spec/data_spec.rb +0 -23
  92. data/spec/date_spec.rb +0 -61
  93. data/spec/dates_spec.rb +0 -45
  94. data/spec/day_spec.rb +0 -59
  95. data/spec/enum_spec.rb +0 -51
  96. data/spec/i18n_spec.rb +0 -59
  97. data/spec/ordinalizer_spec.rb +0 -22
  98. data/spec/perpetual_calendar_spec.rb +0 -91
  99. data/spec/rank_spec.rb +0 -57
  100. data/spec/readme_spec.rb +0 -52
  101. data/spec/sanctorale_factory_spec.rb +0 -42
  102. data/spec/sanctorale_spec.rb +0 -191
  103. data/spec/sanctoraleloader_spec.rb +0 -171
  104. data/spec/season_spec.rb +0 -17
  105. data/spec/spec_helper.rb +0 -35
  106. data/spec/temporale_spec.rb +0 -519
@@ -1,330 +0,0 @@
1
- require_relative 'spec_helper'
2
-
3
- describe CR::Calendar do
4
- before :all do
5
- @c = described_class.new(2013).freeze
6
- end
7
-
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/)
13
- end
14
-
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
23
-
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)
27
- end
28
-
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)
31
- end
32
- end
33
-
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
56
- end
57
- end
58
-
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
65
- end
66
-
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
71
- end
72
-
73
- describe 'three Integers' do
74
- it 'returns a Day' do
75
- expect(@c.day(2013, 12, 10)).to be_a CR::Day
76
- end
77
- end
78
-
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)
85
- end
86
- end
87
-
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)
93
- end
94
- end
95
-
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')
102
- end
103
- end
104
-
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')
110
- end
111
- end
112
- end
113
- end
114
- end
115
-
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
121
-
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
126
- end
127
- end
128
-
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
134
- end
135
-
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
141
- end
142
- end
143
-
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
147
- end
148
-
149
- it 'first Sunday starts week 1' do
150
- expect(@c.day(2013, 12, 29).season_week).to eq 1
151
- end
152
- end
153
-
154
- describe 'Lent' do
155
- it 'Ash Wednesday is week 0' do
156
- expect(@c.day(2014, 3, 5).season_week).to eq 0
157
- end
158
- end
159
-
160
- describe 'Easter' do
161
- it 'Easter Sunday opens week 1' do
162
- expect(@c.day(2014, 4, 20).season_week).to eq 1
163
- end
164
- end
165
-
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
169
- end
170
-
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
175
- end
176
-
177
- it '2015' do
178
- c = described_class.new(2014)
179
- expect(c.day(2015, 5, 25).season_week).to eq 8
180
- end
181
-
182
- it '2016' do
183
- c = described_class.new(2015)
184
- expect(c.day(2016, 5, 16).season_week).to eq 7
185
- end
186
-
187
- it '2017' do
188
- c = described_class.new(2016)
189
- expect(c.day(2017, 6, 5).season_week).to eq 9
190
- end
191
-
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
197
- end
198
- end
199
- end
200
-
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
205
- end
206
- end
207
- end
208
-
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
213
- end
214
- end
215
- end
216
-
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
221
- end
222
- end
223
- end
224
- end
225
- end
226
- end
227
- end
228
- end
229
-
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
235
-
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
241
-
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
248
-
249
- it 'optional memorial does not suppress ferial' do
250
- d = @c.day(7, 14)
251
- expect(d.celebrations.size).to eq 2
252
-
253
- expect(d.celebrations[0].rank).to eq CR::Ranks::FERIAL
254
-
255
- expect(d.celebrations[1].rank).to eq CR::Ranks::MEMORIAL_OPTIONAL
256
- expect(d.celebrations[1].title).to include 'Lellis'
257
- end
258
-
259
- it 'obligatory memorial does suppress ferial' do
260
- d = @c.day(1, 17)
261
- expect(d.celebrations.size).to eq 1
262
-
263
- expect(d.celebrations[0].rank).to eq CR::Ranks::MEMORIAL_GENERAL
264
- end
265
-
266
- it 'memorial in Lent becomes mere commemoration' do
267
- d = @c.day(4, 2)
268
- expect(d.celebrations.size).to eq 2
269
-
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
274
-
275
- it 'Sunday suppresses feast' do
276
- san = CR::Sanctorale.new
277
-
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)
281
-
282
- c = described_class.new 2014, san
283
-
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
288
-
289
- it 'suppressed fictive solemnity is transferred' do
290
- san = CR::Sanctorale.new
291
-
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
295
-
296
- c = described_class.new 2014, san
297
-
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'
303
-
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
309
- end
310
-
311
- it 'transfer of suppressed Annunciation (real world example)' do
312
- c = described_class.new 2015, @s
313
-
314
- d = Date.new(2016, 3, 25)
315
-
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'
321
-
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'
327
- end
328
- end
329
- end
330
- end
@@ -1,23 +0,0 @@
1
- require_relative 'spec_helper'
2
-
3
- describe CR::Celebration do
4
- describe '#==' do
5
- let(:c) { described_class.new('title') }
6
-
7
- describe 'same content' do
8
- let(:c2) { described_class.new('title') }
9
-
10
- it 'is equal' do
11
- expect(c).to eq c2
12
- end
13
- end
14
-
15
- describe 'different content' do
16
- let(:c2) { described_class.new('another title') }
17
-
18
- it 'is different' do
19
- expect(c).not_to eq c2
20
- end
21
- end
22
- end
23
- end
@@ -1,26 +0,0 @@
1
- require 'spec_helper'
2
- require 'calendarium-romanum/cli'
3
-
4
- describe CalendariumRomanum::CLI do
5
- let(:path_universal_la) { File.expand_path('../../data/universal-la.txt', __FILE__) }
6
- let(:path_universal_en) { File.expand_path('../../data/universal-en.txt', __FILE__) }
7
- describe 'subcommands' do
8
- describe 'errors' do
9
- it 'raises no exception' do
10
- described_class.start(['errors', path_universal_la])
11
- end
12
-
13
- it 'fails on a non-existent file' do
14
- expect do
15
- described_class.start(['errors', 'does-not-exist.txt'])
16
- end.to raise_exception Errno::ENOENT
17
- end
18
- end
19
-
20
- describe 'cmp' do
21
- it 'raises no exception' do
22
- described_class.start(['cmp', path_universal_la, path_universal_en])
23
- end
24
- end
25
- end
26
- end
@@ -1,17 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe CR::Colour do
4
- CR::Colours.each do |colour|
5
- describe colour do
6
- describe '#name' do
7
- it { expect(colour.name).to have_translation }
8
- end
9
- end
10
- end
11
-
12
- describe 'indexing' do
13
- it 'is indexed by symbol' do
14
- expect(CR::Colours[:red]).to be CR::Colours::RED
15
- end
16
- end
17
- end
@@ -1,23 +0,0 @@
1
- require_relative 'spec_helper'
2
-
3
- describe CalendariumRomanum::Data do
4
- describe 'all available data files are included' do
5
- data_path = File.expand_path '../data', File.dirname(__FILE__)
6
- glob = File.join(data_path, '*.txt')
7
-
8
- Dir[glob].each do |file|
9
- it "#{file} has it's Data entry" do
10
- in_data = described_class.all.find {|f| f.path == file }
11
- expect(in_data).not_to be nil
12
- end
13
- end
14
- end
15
-
16
- describe 'all can be loaded' do
17
- described_class.each do |data|
18
- it data.siglum do
19
- expect { data.load }.not_to raise_exception
20
- end
21
- end
22
- end
23
- end
@@ -1,61 +0,0 @@
1
- require 'spec_helper'
2
-
3
- # expectations concerning the Ruby implementation
4
- describe Date do
5
- describe '#-' do
6
- it 'returns Rational' do
7
- date_diff = Date.new(2013,5,5) - Date.new(2013,5,1)
8
- expect(date_diff).to be_a Rational
9
- expect(date_diff.numerator).to eq 4
10
- end
11
- end
12
-
13
- describe 'range' do
14
- let(:range) { (Date.new(2000,1,1) .. Date.new(2010,1,1)) }
15
-
16
- # please note that the RSpec 'include' matcher cannot
17
- # be used here, because it does't simply test
18
- # if `n.include?(x)` returns true (see it's implementation)
19
- # and it yields misleading results when testing inclusion
20
- # of DateTime in a Date range.
21
- describe 'test Date inclusion' do
22
- it 'includes' do
23
- expect(range.include?(Date.new(2005,3,3))).to be true
24
- end
25
-
26
- it 'excludes' do
27
- expect(range.include?(Date.new(1995,3,3))).to be false
28
- end
29
- end
30
-
31
- describe 'test DateTime inclusion' do
32
- # DateTime without time details is treated just like Date
33
- describe 'without time specified' do
34
- it 'excludes' do
35
- expect(range.include?(DateTime.new(1995,3,3))).to be false
36
- end
37
-
38
- it 'includes' do
39
- expect(range.include?(DateTime.new(2005,3,3))).to be true
40
- end
41
- end
42
-
43
- # treatment of a DateTime with time details is different
44
- describe 'with time specified' do
45
- it 'excludes a DateTime not falling in the range' do
46
- expect(range.include?(DateTime.new(1995,3,3,1,1,1))).to be false
47
- end
48
-
49
- it '... but also one *falling* in the range!' do
50
- expect(range.include?(DateTime.new(2005,3,3,1,1,1))).to be false
51
- end
52
- end
53
- end
54
- end
55
-
56
- describe 'inheritance' do
57
- it 'is inherited by DateTime' do
58
- expect(DateTime.new).to be_a Date
59
- end
60
- end
61
- end