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.
- checksums.yaml +5 -5
- data/.gitignore +4 -0
- data/.rspec +2 -0
- data/.rubocop.yml +47 -0
- data/.travis.yml +22 -0
- data/.yardopts +3 -0
- data/CHANGELOG.md +431 -0
- data/Gemfile +25 -0
- data/Gemfile.lock +86 -0
- data/README.md +598 -0
- data/Rakefile +16 -0
- data/bin/calendariumrom +4 -1
- data/calendarium-romanum.gemspec +31 -0
- data/config/locales/cs.yml +5 -0
- data/config/locales/en.yml +21 -14
- data/config/locales/es.yml +94 -0
- data/config/locales/fr.yml +7 -0
- data/config/locales/it.yml +7 -0
- data/config/locales/la.yml +7 -0
- data/data/README.md +70 -24
- data/data/czech-brno-cs.txt +4 -6
- data/data/czech-budejovice-cs.txt +4 -6
- data/data/czech-cechy-cs.txt +4 -5
- data/data/czech-cs.txt +236 -234
- data/data/czech-hradec-cs.txt +3 -5
- data/data/czech-litomerice-cs.txt +5 -7
- data/data/czech-morava-cs.txt +4 -5
- data/data/czech-olomouc-cs.txt +2 -4
- data/data/czech-ostrava-cs.txt +3 -5
- data/data/czech-plzen-cs.txt +3 -5
- data/data/czech-praha-cs.txt +3 -4
- data/data/easter_dates.txt +67 -0
- data/data/universal-1969-la.txt +234 -0
- data/data/universal-en.txt +214 -211
- data/data/universal-es.txt +243 -0
- data/data/universal-fr.txt +214 -210
- data/data/universal-it.txt +214 -211
- data/data/universal-la.txt +214 -210
- data/doc/data_readme.md +2 -0
- data/doc/images/class_diagram.png +0 -0
- data/doc/images/class_diagram.puml +44 -0
- data/doc/yard_readme.rdoc +76 -0
- data/lib/calendarium-romanum.rb +35 -22
- data/lib/calendarium-romanum/abstract_date.rb +15 -0
- data/lib/calendarium-romanum/calendar.rb +207 -42
- data/lib/calendarium-romanum/cli.rb +63 -80
- data/lib/calendarium-romanum/cli/comparator.rb +63 -0
- data/lib/calendarium-romanum/cli/date_parser.rb +30 -0
- data/lib/calendarium-romanum/cli/dumper.rb +68 -0
- data/lib/calendarium-romanum/cli/helper.rb +23 -0
- data/lib/calendarium-romanum/cli/querier.rb +73 -0
- data/lib/calendarium-romanum/cr.rb +16 -0
- data/lib/calendarium-romanum/data.rb +50 -20
- data/lib/calendarium-romanum/day.rb +208 -32
- data/lib/calendarium-romanum/enum.rb +42 -25
- data/lib/calendarium-romanum/enums.rb +124 -44
- data/lib/calendarium-romanum/errors.rb +4 -0
- data/lib/calendarium-romanum/ordinalizer.rb +23 -2
- data/lib/calendarium-romanum/perpetual_calendar.rb +58 -7
- data/lib/calendarium-romanum/rank.rb +43 -12
- data/lib/calendarium-romanum/rank_predicates.rb +43 -0
- data/lib/calendarium-romanum/sanctorale.rb +164 -24
- data/lib/calendarium-romanum/sanctorale_factory.rb +74 -3
- data/lib/calendarium-romanum/sanctorale_loader.rb +180 -0
- data/lib/calendarium-romanum/sanctorale_writer.rb +119 -0
- data/lib/calendarium-romanum/temporale.rb +226 -94
- data/lib/calendarium-romanum/temporale/celebration_factory.rb +107 -0
- data/lib/calendarium-romanum/temporale/dates.rb +84 -16
- data/lib/calendarium-romanum/temporale/easter_table.rb +27 -0
- data/lib/calendarium-romanum/temporale/extensions.rb +15 -0
- data/lib/calendarium-romanum/temporale/extensions/christ_eternal_priest.rb +16 -3
- data/lib/calendarium-romanum/temporale/extensions/dedication_before_all_saints.rb +73 -0
- data/lib/calendarium-romanum/transfers.rb +60 -15
- data/lib/calendarium-romanum/util.rb +22 -3
- data/lib/calendarium-romanum/version.rb +5 -1
- data/liturgical_law/1969_normae_universales.md +568 -0
- data/liturgical_law/1977_decretum_de_celebratione_baptismatis_domini.md +58 -0
- data/liturgical_law/1990_decretum_de_variatione_inducenda.md +67 -0
- data/liturgical_law/1998_notificatio_de_occurrentia.md +57 -0
- data/liturgical_law/2002_normae_universales.md +946 -0
- data/liturgical_law/2006_notification.md +37 -0
- data/liturgical_law/2012_declarationes.md +38 -0
- data/liturgical_law/README.md +74 -0
- metadata +50 -28
- data/lib/calendarium-romanum/sanctoraleloader.rb +0 -115
- data/spec/abstract_date_spec.rb +0 -62
- data/spec/calendar_spec.rb +0 -330
- data/spec/celebration_spec.rb +0 -23
- data/spec/cli_spec.rb +0 -26
- data/spec/colour_spec.rb +0 -17
- data/spec/data_spec.rb +0 -23
- data/spec/date_spec.rb +0 -61
- data/spec/dates_spec.rb +0 -45
- data/spec/day_spec.rb +0 -59
- data/spec/enum_spec.rb +0 -51
- data/spec/i18n_spec.rb +0 -59
- data/spec/ordinalizer_spec.rb +0 -22
- data/spec/perpetual_calendar_spec.rb +0 -91
- data/spec/rank_spec.rb +0 -57
- data/spec/readme_spec.rb +0 -52
- data/spec/sanctorale_factory_spec.rb +0 -42
- data/spec/sanctorale_spec.rb +0 -191
- data/spec/sanctoraleloader_spec.rb +0 -171
- data/spec/season_spec.rb +0 -17
- data/spec/spec_helper.rb +0 -35
- data/spec/temporale_spec.rb +0 -519
@@ -0,0 +1,37 @@
|
|
1
|
+
---
|
2
|
+
source: Notitiae 475-476/2006, p. 96 http://www.cultodivino.va/content/dam/cultodivino/notitiae/2006/475-476%20DEF.pdf#page=34
|
3
|
+
note: |
|
4
|
+
Not an act of liturgical legislation in a proper sense, but an authoritative example
|
5
|
+
of correct application of the law in force.
|
6
|
+
---
|
7
|
+
|
8
|
+
CONGREGATIO DE CULTU DIVINO ET DISCIPLINA SACRAMENTORUM
|
9
|
+
|
10
|
+
NOTIFICAZIONE
|
11
|
+
|
12
|
+
La Congregazione per il Culto Divino e la Disciplina dei Sacramenti si fa premura
|
13
|
+
di attirare l’attenzione sulla occorrenza di alcune celebrazioni che ricorreranno
|
14
|
+
nell’anno 2008. In particolare, si fa presente che la solennità di San Giuseppe (19 marzo)
|
15
|
+
ricorre il mercoledì della Settimana Santa e la solennità dell’Annunciazione del Signore
|
16
|
+
(25 marzo) il martedì fra l’Ottava di Pasqua.
|
17
|
+
|
18
|
+
Secondo la normativa vigente contenuta nelle Normae Universales de Anno Liturgico
|
19
|
+
et de Calendario, le summenzionate solennità devono essere trasferite in tal modo:
|
20
|
+
« Sollemnitas S. Ioseph, ubi est de praecepto servanda, si cum Dominica
|
21
|
+
in Palmis de Passione Domini occurrit, anticipatur sabbato praecedenti, die 18 martii.
|
22
|
+
Ubi vero non est de praecepto servanda, a Conferentia Episcoporum ad alium diem
|
23
|
+
extra Quadragesimam transferri potest » (n. 56 f);
|
24
|
+
« Sollemnitas vero Annuntiationis Domini, quotiescumque occurrit aliquo die Hebdomadae
|
25
|
+
Sanctae, semper ad feriam II post dominicam II Paschae erit transferenda » (n. 60).
|
26
|
+
|
27
|
+
Pertanto, è stabilito che nell’anno 2008 la solennità di San Giuseppe sarà celebrata
|
28
|
+
il 15 marzo, ovvero il sabato precedente la Domenica delle Palme, mentre la solennità
|
29
|
+
dell’Annunciazione del Signore sarà celebrata il 31 marzo, ovvero il lunedì dopo
|
30
|
+
la II Domenica di Pasqua.
|
31
|
+
|
32
|
+
```ruby
|
33
|
+
calendar = CR::PerpetualCalendar.new(sanctorale: CR::Data::GENERAL_ROMAN_LATIN.load)
|
34
|
+
|
35
|
+
expect(calendar[Date.new(2008, 3, 15)].celebrations[0].symbol).to be :joseph
|
36
|
+
expect(calendar[Date.new(2008, 3, 31)].celebrations[0].symbol).to be :annunciation
|
37
|
+
```
|
@@ -0,0 +1,38 @@
|
|
1
|
+
---
|
2
|
+
source: Notitiae 549-550/2012, p. 269; http://www.cultodivino.va/content/dam/cultodivino/notitiae/2012/549-550 DEF.pdf#page=80
|
3
|
+
note: |
|
4
|
+
Not an act of liturgical legislation in a proper sense, but an authoritative example
|
5
|
+
of correct application of the law in force.
|
6
|
+
---
|
7
|
+
|
8
|
+
# Declaratio circa Sollemnitatem Annuntiationis Domini anno 2013 celebrandam
|
9
|
+
|
10
|
+
Cum anno 2013, die 25 martii incidat feria II Hebdomadae
|
11
|
+
Sanctae, iuxta Tabulam dierum liturgicorum secundum ordinem
|
12
|
+
praecedentiae dispositam et secundum n. 60 Normarum de Anno
|
13
|
+
liturgico et de Calendario, sollemnitas Annuntiationis Domini
|
14
|
+
celebrabitur die 8 aprilis, scilicet feria II post Dominicam II Paschae, sicut
|
15
|
+
ex editione typica tertia Missalis Romani patet.
|
16
|
+
|
17
|
+
```ruby
|
18
|
+
calendar = CR::Calendar.new(2012, CR::Data::GENERAL_ROMAN_LATIN.load)
|
19
|
+
|
20
|
+
day = calendar[Date.new(2013, 4, 8)]
|
21
|
+
expect(day.celebrations.first.symbol).to be :annunciation
|
22
|
+
```
|
23
|
+
|
24
|
+
# Declaratio circa sollemnitatem Immaculatae Conceptionis Beatae Mariae Virginis a. 2013 in Dominica II Adventus incidentem
|
25
|
+
|
26
|
+
Cum anno 2013, die 8 decembris incidat Dominica II Adventus,
|
27
|
+
iuxta Tabulam dierum liturgicorum secundum ordinem praecedentiae
|
28
|
+
dispositam et secundum nn. 5 et 60 Normarum de Anno liturgico
|
29
|
+
et de Calendario, sollemnitas Immaculatae Conceptionis Beatae
|
30
|
+
Mariae Virginis celebrabitur die 9 decembris, feria II post Dominica
|
31
|
+
II Adventus.
|
32
|
+
|
33
|
+
```ruby
|
34
|
+
calendar = CR::Calendar.new(2013, CR::Data::GENERAL_ROMAN_LATIN.load)
|
35
|
+
|
36
|
+
day = calendar[Date.new(2013, 12, 9)]
|
37
|
+
expect(day.celebrations.first.symbol).to be :bvm_immaculate
|
38
|
+
```
|
@@ -0,0 +1,74 @@
|
|
1
|
+
# Liturgical Law
|
2
|
+
|
3
|
+
This directory contains documents of liturgical legislation
|
4
|
+
implemented by the library. Each document is reproduced in Latin,
|
5
|
+
in a form of a Markdown file.
|
6
|
+
|
7
|
+
## Main documents, development overview
|
8
|
+
|
9
|
+
Fundamental outline of the calendar system is contained in the document
|
10
|
+
*Normae universales de anno liturgico et de calendario*, first published in 1969.
|
11
|
+
Most of the 1969 text is in force without a substantial change up to this day,
|
12
|
+
but during the years some important parts were changed, a particularly hot matter
|
13
|
+
being the rules concerning transfer of impeded solemnities.
|
14
|
+
Apart of updates of the *Normae* themselves, a few additional rules were added
|
15
|
+
to the calendar system by separate documents (the more formal ones being CDW decrees,
|
16
|
+
the less formal ones notifications).
|
17
|
+
|
18
|
+
* **1969 Normae universales de anno liturgico et de calendario**
|
19
|
+
initial outline of the calendar system
|
20
|
+
* **1970 Missale Romanum, editio typica**
|
21
|
+
[updated](http://www.cultodivino.va/content/dam/cultodivino/notitiae/1970/54 1.pdf#page=49)
|
22
|
+
paragraphs 13, 56, 59 and 60 of the *Normae*
|
23
|
+
* **1975 Missale Romanum, editio typica altera**
|
24
|
+
[updated](http://www.cultodivino.va/content/dam/cultodivino/notitiae/1975/111-112.pdf#page=27)
|
25
|
+
paragraphs 14, 47 and 59 of the *Normae* (mostly mere terminological changes;
|
26
|
+
the change of paragraph 59 dropped a few categories from the *Table of Liturgical Days*)
|
27
|
+
* **1977 Decree about the feast of Baptism of the Lord**
|
28
|
+
with an improved rule of computing it's date for places where Epiphany is celebrated
|
29
|
+
on a Sunday
|
30
|
+
* **1990 Decree updating Normae, n. 5**
|
31
|
+
(transfer rule for a solemnity impeded by a privileged Sunday)
|
32
|
+
* **1998 Notification concerning occurrence of the memorial of the Immaculate Heart of Mary**
|
33
|
+
|
34
|
+
## Code examples
|
35
|
+
|
36
|
+
The Markdown files, in addition to the text of documents of liturgical
|
37
|
+
legislation, contain also blocks of Ruby code, each proving
|
38
|
+
that the immediately preceding part of the document is implemented
|
39
|
+
by the library. The documents illustrated with code blocks thus constitute
|
40
|
+
sort of a test suite in the [literate programming](https://en.wikipedia.org/wiki/Literate_programming)
|
41
|
+
style. This test suite is integrated in the project's main test suite
|
42
|
+
(see `spec/liturgical_law_spec.rb`)
|
43
|
+
|
44
|
+
Utilities commonly used in the code blocks:
|
45
|
+
|
46
|
+
```ruby
|
47
|
+
# RSpec expectations are available in the code blocks
|
48
|
+
expect(1).to be_truthy
|
49
|
+
|
50
|
+
# method `year` returns a random year (which is a valid liturgical years
|
51
|
+
# for calendarium-romanum) and should be used in all examples which need
|
52
|
+
# a single year and don't require a particular one
|
53
|
+
expect(year).to be_a Integer
|
54
|
+
expect(year).to be >= 1970
|
55
|
+
# year is the same for the whole example, even if called multiple times
|
56
|
+
a = year; b = year
|
57
|
+
expect(a).to be b
|
58
|
+
|
59
|
+
# method `years` returns a representative Enumerable of (valid liturgical)
|
60
|
+
# years and should be used in all examples which test across several years
|
61
|
+
# and don't require particular ones
|
62
|
+
expect(years).to be_a Enumerable
|
63
|
+
yrs = years.to_a
|
64
|
+
expect(yrs[0]).to be_a Integer
|
65
|
+
|
66
|
+
# method `years_with` returns an array of years (which are valid liturgical years
|
67
|
+
# for calendarium-romanum) matching the specified condition
|
68
|
+
yrs = years_with {|y| true }
|
69
|
+
expect(yrs).to be_an Array
|
70
|
+
expect(yrs[0]).to be_an Integer
|
71
|
+
# if no matching year is found an exception is raised
|
72
|
+
expect { years_with {|y| false } }
|
73
|
+
.to raise_exception(RuntimeError, /no matching year/)
|
74
|
+
```
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: calendarium-romanum
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.8.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jakub Pavlík
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-11-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|
@@ -81,16 +81,30 @@ dependencies:
|
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '3.5'
|
83
83
|
description: calendar computations according to the Roman Catholic liturgical calendar
|
84
|
-
as instituted by MP Mysterii Paschalis of Paul VI (1969)
|
84
|
+
as instituted by MP Mysterii Paschalis of Paul VI (1969) and defined in General
|
85
|
+
Norms for the Liturgical Year and the Calendar and other documents of liturgical
|
86
|
+
legislation.
|
85
87
|
email: jkb.pavlik@gmail.com
|
86
88
|
executables:
|
87
89
|
- calendariumrom
|
88
90
|
extensions: []
|
89
91
|
extra_rdoc_files: []
|
90
92
|
files:
|
93
|
+
- ".gitignore"
|
94
|
+
- ".rspec"
|
95
|
+
- ".rubocop.yml"
|
96
|
+
- ".travis.yml"
|
97
|
+
- ".yardopts"
|
98
|
+
- CHANGELOG.md
|
99
|
+
- Gemfile
|
100
|
+
- Gemfile.lock
|
101
|
+
- README.md
|
102
|
+
- Rakefile
|
91
103
|
- bin/calendariumrom
|
104
|
+
- calendarium-romanum.gemspec
|
92
105
|
- config/locales/cs.yml
|
93
106
|
- config/locales/en.yml
|
107
|
+
- config/locales/es.yml
|
94
108
|
- config/locales/fr.yml
|
95
109
|
- config/locales/it.yml
|
96
110
|
- config/locales/la.yml
|
@@ -106,57 +120,65 @@ files:
|
|
106
120
|
- data/czech-ostrava-cs.txt
|
107
121
|
- data/czech-plzen-cs.txt
|
108
122
|
- data/czech-praha-cs.txt
|
123
|
+
- data/easter_dates.txt
|
124
|
+
- data/universal-1969-la.txt
|
109
125
|
- data/universal-en.txt
|
126
|
+
- data/universal-es.txt
|
110
127
|
- data/universal-fr.txt
|
111
128
|
- data/universal-it.txt
|
112
129
|
- data/universal-la.txt
|
130
|
+
- doc/data_readme.md
|
131
|
+
- doc/images/class_diagram.png
|
132
|
+
- doc/images/class_diagram.puml
|
133
|
+
- doc/yard_readme.rdoc
|
113
134
|
- lib/calendarium-romanum.rb
|
114
135
|
- lib/calendarium-romanum/abstract_date.rb
|
115
136
|
- lib/calendarium-romanum/calendar.rb
|
116
137
|
- lib/calendarium-romanum/cli.rb
|
138
|
+
- lib/calendarium-romanum/cli/comparator.rb
|
139
|
+
- lib/calendarium-romanum/cli/date_parser.rb
|
140
|
+
- lib/calendarium-romanum/cli/dumper.rb
|
141
|
+
- lib/calendarium-romanum/cli/helper.rb
|
142
|
+
- lib/calendarium-romanum/cli/querier.rb
|
143
|
+
- lib/calendarium-romanum/cr.rb
|
117
144
|
- lib/calendarium-romanum/data.rb
|
118
145
|
- lib/calendarium-romanum/day.rb
|
119
146
|
- lib/calendarium-romanum/enum.rb
|
120
147
|
- lib/calendarium-romanum/enums.rb
|
148
|
+
- lib/calendarium-romanum/errors.rb
|
121
149
|
- lib/calendarium-romanum/i18n_setup.rb
|
122
150
|
- lib/calendarium-romanum/ordinalizer.rb
|
123
151
|
- lib/calendarium-romanum/perpetual_calendar.rb
|
124
152
|
- lib/calendarium-romanum/rank.rb
|
153
|
+
- lib/calendarium-romanum/rank_predicates.rb
|
125
154
|
- lib/calendarium-romanum/sanctorale.rb
|
126
155
|
- lib/calendarium-romanum/sanctorale_factory.rb
|
127
|
-
- lib/calendarium-romanum/
|
156
|
+
- lib/calendarium-romanum/sanctorale_loader.rb
|
157
|
+
- lib/calendarium-romanum/sanctorale_writer.rb
|
128
158
|
- lib/calendarium-romanum/temporale.rb
|
159
|
+
- lib/calendarium-romanum/temporale/celebration_factory.rb
|
129
160
|
- lib/calendarium-romanum/temporale/dates.rb
|
161
|
+
- lib/calendarium-romanum/temporale/easter_table.rb
|
162
|
+
- lib/calendarium-romanum/temporale/extensions.rb
|
130
163
|
- lib/calendarium-romanum/temporale/extensions/christ_eternal_priest.rb
|
164
|
+
- lib/calendarium-romanum/temporale/extensions/dedication_before_all_saints.rb
|
131
165
|
- lib/calendarium-romanum/transfers.rb
|
132
166
|
- lib/calendarium-romanum/util.rb
|
133
167
|
- lib/calendarium-romanum/version.rb
|
134
|
-
-
|
135
|
-
-
|
136
|
-
-
|
137
|
-
-
|
138
|
-
-
|
139
|
-
-
|
140
|
-
-
|
141
|
-
-
|
142
|
-
- spec/day_spec.rb
|
143
|
-
- spec/enum_spec.rb
|
144
|
-
- spec/i18n_spec.rb
|
145
|
-
- spec/ordinalizer_spec.rb
|
146
|
-
- spec/perpetual_calendar_spec.rb
|
147
|
-
- spec/rank_spec.rb
|
148
|
-
- spec/readme_spec.rb
|
149
|
-
- spec/sanctorale_factory_spec.rb
|
150
|
-
- spec/sanctorale_spec.rb
|
151
|
-
- spec/sanctoraleloader_spec.rb
|
152
|
-
- spec/season_spec.rb
|
153
|
-
- spec/spec_helper.rb
|
154
|
-
- spec/temporale_spec.rb
|
168
|
+
- liturgical_law/1969_normae_universales.md
|
169
|
+
- liturgical_law/1977_decretum_de_celebratione_baptismatis_domini.md
|
170
|
+
- liturgical_law/1990_decretum_de_variatione_inducenda.md
|
171
|
+
- liturgical_law/1998_notificatio_de_occurrentia.md
|
172
|
+
- liturgical_law/2002_normae_universales.md
|
173
|
+
- liturgical_law/2006_notification.md
|
174
|
+
- liturgical_law/2012_declarationes.md
|
175
|
+
- liturgical_law/README.md
|
155
176
|
homepage: http://github.com/igneus/calendarium-romanum
|
156
177
|
licenses:
|
157
178
|
- LGPL-3.0
|
158
179
|
- MIT
|
159
|
-
metadata:
|
180
|
+
metadata:
|
181
|
+
documentation_uri: https://www.rubydoc.info/gems/calendarium-romanum/
|
160
182
|
post_install_message:
|
161
183
|
rdoc_options: []
|
162
184
|
require_paths:
|
@@ -165,7 +187,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
165
187
|
requirements:
|
166
188
|
- - ">="
|
167
189
|
- !ruby/object:Gem::Version
|
168
|
-
version: '0'
|
190
|
+
version: '2.0'
|
169
191
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
170
192
|
requirements:
|
171
193
|
- - ">="
|
@@ -173,7 +195,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
173
195
|
version: '0'
|
174
196
|
requirements: []
|
175
197
|
rubyforge_project:
|
176
|
-
rubygems_version: 2.
|
198
|
+
rubygems_version: 2.7.6
|
177
199
|
signing_key:
|
178
200
|
specification_version: 4
|
179
201
|
summary: Roman Catholic liturgical calendar computations
|
@@ -1,115 +0,0 @@
|
|
1
|
-
module CalendariumRomanum
|
2
|
-
|
3
|
-
# understands a plaintext calendar format
|
4
|
-
# and knows how to transform it to Celebrations
|
5
|
-
# and fill them in a Sanctorale
|
6
|
-
#
|
7
|
-
# Format of the file:
|
8
|
-
# 1/31 m : S. Ioannis Bosco, presbyteri
|
9
|
-
#
|
10
|
-
# <month>/<day> <rank shortcut> : <title>
|
11
|
-
# rank shortcut is optional, default value is optional memorial
|
12
|
-
class SanctoraleLoader
|
13
|
-
|
14
|
-
RANK_CODES = {
|
15
|
-
nil => Ranks::MEMORIAL_OPTIONAL,
|
16
|
-
'm' => Ranks::MEMORIAL_GENERAL,
|
17
|
-
'f' => Ranks::FEAST_GENERAL,
|
18
|
-
's' => Ranks::SOLEMNITY_GENERAL
|
19
|
-
}
|
20
|
-
COLOUR_CODES = {
|
21
|
-
nil => Colours::WHITE,
|
22
|
-
'w' => Colours::WHITE,
|
23
|
-
'v' => Colours::VIOLET,
|
24
|
-
'g' => Colours::GREEN,
|
25
|
-
'r' => Colours::RED
|
26
|
-
}
|
27
|
-
|
28
|
-
# dest should be a Sanctorale,
|
29
|
-
# src anything with #each_line
|
30
|
-
def load(src, dest=nil)
|
31
|
-
dest ||= Sanctorale.new
|
32
|
-
|
33
|
-
in_front_matter = false
|
34
|
-
month_section = nil
|
35
|
-
src.each_line.with_index(1) do |l, line_num|
|
36
|
-
# skip YAML front matter
|
37
|
-
if line_num == 1 && l.start_with?('---')
|
38
|
-
in_front_matter = true
|
39
|
-
next
|
40
|
-
elsif in_front_matter
|
41
|
-
if l.start_with?('---')
|
42
|
-
in_front_matter = false
|
43
|
-
end
|
44
|
-
|
45
|
-
next
|
46
|
-
end
|
47
|
-
|
48
|
-
# strip whitespace and comments
|
49
|
-
l.sub!(/#.*/, '')
|
50
|
-
l.strip!
|
51
|
-
next if l.empty?
|
52
|
-
|
53
|
-
# month section heading
|
54
|
-
n = l.match /^=\s*(\d+)\s*$/
|
55
|
-
unless n.nil?
|
56
|
-
month_section = n[1].to_i
|
57
|
-
unless month_section >= 1 && month_section <= 12
|
58
|
-
raise error("Invalid month #{month_section}", line_num)
|
59
|
-
end
|
60
|
-
next
|
61
|
-
end
|
62
|
-
|
63
|
-
# celebration record
|
64
|
-
m = l.match /^((\d+)\/)?(\d+)\s*(([mfs])?(\d\.\d{1,2})?)?\s*([WVRG])?\s*:(.*)$/i
|
65
|
-
if m.nil?
|
66
|
-
raise error("Syntax error, line skipped '#{l}'", line_num)
|
67
|
-
next
|
68
|
-
end
|
69
|
-
|
70
|
-
month, day, rank_char, rank_num, colour, title = m.values_at(2, 3, 5, 6, 7, 8)
|
71
|
-
month ||= month_section
|
72
|
-
day = day.to_i
|
73
|
-
month = month.to_i
|
74
|
-
|
75
|
-
rank = RANK_CODES[rank_char && rank_char.downcase]
|
76
|
-
if rank.nil?
|
77
|
-
raise error("Invalid celebration rank code #{rank_char}", line_num)
|
78
|
-
end
|
79
|
-
|
80
|
-
if rank_num
|
81
|
-
rank_num = rank_num.to_f
|
82
|
-
rank_by_num = Ranks[rank_num]
|
83
|
-
|
84
|
-
if rank_by_num.nil?
|
85
|
-
raise error("Invalid celebration rank code #{rank_num}", line_num)
|
86
|
-
elsif rank_char && (rank.priority.to_i != rank_by_num.priority.to_i)
|
87
|
-
raise error("Invalid combination of rank letter #{rank_char.inspect} and number #{rank_num}.", line_num)
|
88
|
-
end
|
89
|
-
|
90
|
-
rank = rank_by_num
|
91
|
-
end
|
92
|
-
|
93
|
-
dest.add month, day, Celebration.new(
|
94
|
-
title.strip,
|
95
|
-
rank,
|
96
|
-
COLOUR_CODES[colour && colour.downcase]
|
97
|
-
)
|
98
|
-
end
|
99
|
-
|
100
|
-
dest
|
101
|
-
end
|
102
|
-
|
103
|
-
alias_method :load_from_string, :load
|
104
|
-
|
105
|
-
def load_from_file(filename, dest=nil, encoding='utf-8')
|
106
|
-
self.load File.open(filename, 'r', encoding: encoding), dest
|
107
|
-
end
|
108
|
-
|
109
|
-
private
|
110
|
-
|
111
|
-
def error(message, line_number)
|
112
|
-
RuntimeError.new("L#{line_number}: #{message}")
|
113
|
-
end
|
114
|
-
end
|
115
|
-
end
|
data/spec/abstract_date_spec.rb
DELETED
@@ -1,62 +0,0 @@
|
|
1
|
-
require_relative 'spec_helper'
|
2
|
-
|
3
|
-
describe CR::AbstractDate do
|
4
|
-
AD = CR::AbstractDate
|
5
|
-
|
6
|
-
describe '.new' do
|
7
|
-
describe 'fails on invalid' do
|
8
|
-
it 'month' do
|
9
|
-
expect do
|
10
|
-
AD.new(13, 1)
|
11
|
-
end.to raise_exception /Invalid month/
|
12
|
-
end
|
13
|
-
|
14
|
-
it 'day' do
|
15
|
-
expect do
|
16
|
-
AD.new(1, 32)
|
17
|
-
end.to raise_exception /Invalid day/
|
18
|
-
end
|
19
|
-
|
20
|
-
it 'day of month' do
|
21
|
-
expect do
|
22
|
-
AD.new(2, 30)
|
23
|
-
end.to raise_exception /Invalid day/
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
# test .new through .from_date on a complete leap year
|
29
|
-
describe '.from_date' do
|
30
|
-
YEAR = 2000
|
31
|
-
|
32
|
-
it 'the test year is leap' do
|
33
|
-
expect(Date.new(YEAR)).to be_leap
|
34
|
-
end
|
35
|
-
|
36
|
-
CR::Util::Year.new(YEAR).each do |date|
|
37
|
-
it date.to_s do
|
38
|
-
expect do
|
39
|
-
AD.from_date date
|
40
|
-
end.not_to raise_exception
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
describe '#<' do
|
46
|
-
it { expect(AD.new(1, 1)).to be < AD.new(1, 2) }
|
47
|
-
it { expect(AD.new(1, 1)).to be < AD.new(2, 1) }
|
48
|
-
it { expect(AD.new(1, 1)).not_to be < AD.new(1, 1) }
|
49
|
-
end
|
50
|
-
|
51
|
-
describe '#==' do
|
52
|
-
it { expect(AD.new(1, 1)).to be == AD.new(1, 1) }
|
53
|
-
it { expect(AD.new(1, 1)).not_to be == AD.new(1, 2) }
|
54
|
-
end
|
55
|
-
|
56
|
-
describe 'as a Hash key' do
|
57
|
-
it 'different objects with the same values are considered same key' do
|
58
|
-
h = {AD.new(1, 1) => 1}
|
59
|
-
expect(h).to have_key AD.new(1, 1)
|
60
|
-
end
|
61
|
-
end
|
62
|
-
end
|