calendarium-romanum 0.5.0 → 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.gitignore +5 -0
- data/.rspec +2 -0
- data/.rubocop.yml +50 -0
- data/.travis.yml +23 -0
- data/.yardopts +3 -0
- data/Appraisals +67 -0
- data/CHANGELOG.md +488 -0
- data/Gemfile +26 -0
- data/Gemfile.lock +95 -0
- data/README.md +601 -0
- data/Rakefile +27 -0
- data/bin/calendariumrom +3 -0
- data/calendarium-romanum.gemspec +31 -0
- data/config/locales/cs.yml +4 -0
- data/config/locales/en.yml +20 -14
- data/config/locales/es.yml +94 -0
- data/config/locales/fr.yml +6 -0
- data/config/locales/it.yml +6 -0
- data/config/locales/la.yml +6 -0
- data/config/locales/pt.yml +94 -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 +239 -235
- 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 +217 -211
- data/data/universal-es.txt +246 -0
- data/data/universal-fr.txt +217 -210
- data/data/universal-it.txt +217 -211
- data/data/universal-la.txt +217 -212
- data/data/universal-pt.txt +248 -0
- 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 +16 -2
- data/lib/calendarium-romanum/abstract_date.rb +15 -0
- data/lib/calendarium-romanum/calendar.rb +150 -33
- data/lib/calendarium-romanum/cli.rb +80 -100
- data/lib/calendarium-romanum/cli/comparator.rb +83 -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 +40 -8
- data/lib/calendarium-romanum/day.rb +187 -32
- data/lib/calendarium-romanum/enum.rb +41 -24
- data/lib/calendarium-romanum/enums.rb +127 -43
- data/lib/calendarium-romanum/errors.rb +1 -1
- data/lib/calendarium-romanum/ordinalizer.rb +10 -1
- data/lib/calendarium-romanum/perpetual_calendar.rb +58 -7
- data/lib/calendarium-romanum/rank.rb +39 -8
- data/lib/calendarium-romanum/rank_predicates.rb +43 -0
- data/lib/calendarium-romanum/sanctorale.rb +213 -23
- 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 +124 -0
- data/lib/calendarium-romanum/temporale.rb +222 -42
- data/lib/calendarium-romanum/temporale/celebration_factory.rb +68 -9
- data/lib/calendarium-romanum/temporale/date_helper.rb +85 -0
- data/lib/calendarium-romanum/temporale/dates.rb +52 -59
- 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 +84 -24
- data/lib/calendarium-romanum/util.rb +21 -23
- data/lib/calendarium-romanum/version.rb +3 -2
- 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/2020_dubia_de_calendario_2022.md +100 -0
- data/liturgical_law/README.md +74 -0
- metadata +61 -38
- data/lib/calendarium-romanum/sanctoraleloader.rb +0 -122
- data/spec/abstract_date_spec.rb +0 -62
- data/spec/calendar_spec.rb +0 -559
- data/spec/celebration_factory_spec.rb +0 -16
- data/spec/celebration_spec.rb +0 -43
- data/spec/cli_spec.rb +0 -155
- data/spec/colour_spec.rb +0 -17
- data/spec/data_spec.rb +0 -23
- data/spec/date_parser_spec.rb +0 -68
- data/spec/date_spec.rb +0 -61
- data/spec/dates_spec.rb +0 -45
- data/spec/day_spec.rb +0 -108
- data/spec/enum_spec.rb +0 -51
- data/spec/i18n_spec.rb +0 -58
- data/spec/ordinalizer_spec.rb +0 -36
- data/spec/perpetual_calendar_spec.rb +0 -91
- data/spec/rank_spec.rb +0 -57
- data/spec/readme_spec.rb +0 -56
- data/spec/sanctorale_factory_spec.rb +0 -42
- data/spec/sanctorale_spec.rb +0 -191
- data/spec/sanctoraleloader_spec.rb +0 -176
- data/spec/season_spec.rb +0 -17
- data/spec/spec_helper.rb +0 -46
- data/spec/temporale_spec.rb +0 -572
data/Gemfile
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
source 'https://rubygems.org'
|
2
|
+
|
3
|
+
gem 'thor'
|
4
|
+
gem 'i18n'
|
5
|
+
gem 'roman-numerals'
|
6
|
+
|
7
|
+
group :development, :test do
|
8
|
+
gem 'rake'
|
9
|
+
end
|
10
|
+
|
11
|
+
group :development do
|
12
|
+
gem 'rubocop'
|
13
|
+
gem 'yard'
|
14
|
+
gem 'appraisal'
|
15
|
+
end
|
16
|
+
|
17
|
+
group :test do
|
18
|
+
gem 'rspec'
|
19
|
+
gem 'aruba'
|
20
|
+
# We don't use cucumber, but it is required by aruba
|
21
|
+
# and cucumber >= 3.0.0 requires ruby >= 2.1,
|
22
|
+
# but we want the tests to pass on ruby 2.0 as earliest target
|
23
|
+
gem 'cucumber', '~> 2.99'
|
24
|
+
gem 'simplecov'
|
25
|
+
gem 'backports', '~> 3.18'
|
26
|
+
end
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,95 @@
|
|
1
|
+
GEM
|
2
|
+
remote: https://rubygems.org/
|
3
|
+
specs:
|
4
|
+
appraisal (2.4.0)
|
5
|
+
bundler
|
6
|
+
rake
|
7
|
+
thor (>= 0.14.0)
|
8
|
+
aruba (0.8.1)
|
9
|
+
childprocess (~> 0.5.6)
|
10
|
+
contracts (~> 0.9)
|
11
|
+
cucumber (>= 1.3.19)
|
12
|
+
rspec-expectations (>= 2.99)
|
13
|
+
ast (2.4.2)
|
14
|
+
backports (3.18.1)
|
15
|
+
builder (3.2.3)
|
16
|
+
childprocess (0.5.9)
|
17
|
+
ffi (~> 1.0, >= 1.0.11)
|
18
|
+
contracts (0.16.0)
|
19
|
+
cucumber (2.99.0)
|
20
|
+
builder (>= 2.1.2)
|
21
|
+
cucumber-core (~> 1.5.0)
|
22
|
+
cucumber-wire (~> 0.0.1)
|
23
|
+
diff-lcs (>= 1.1.3)
|
24
|
+
gherkin (~> 4.0)
|
25
|
+
multi_json (>= 1.7.5, < 2.0)
|
26
|
+
multi_test (>= 0.1.2)
|
27
|
+
cucumber-core (1.5.0)
|
28
|
+
gherkin (~> 4.0)
|
29
|
+
cucumber-wire (0.0.1)
|
30
|
+
diff-lcs (1.3)
|
31
|
+
docile (1.1.5)
|
32
|
+
ffi (1.9.18)
|
33
|
+
gherkin (4.1.3)
|
34
|
+
i18n (0.6.9)
|
35
|
+
jaro_winkler (1.5.4)
|
36
|
+
json (2.0.2)
|
37
|
+
multi_json (1.12.2)
|
38
|
+
multi_test (0.1.2)
|
39
|
+
parallel (1.19.2)
|
40
|
+
parser (3.0.0.0)
|
41
|
+
ast (~> 2.4.1)
|
42
|
+
rainbow (3.0.0)
|
43
|
+
rake (12.0.0)
|
44
|
+
rexml (3.2.4)
|
45
|
+
roman-numerals (0.3.0)
|
46
|
+
rspec (3.7.0)
|
47
|
+
rspec-core (~> 3.7.0)
|
48
|
+
rspec-expectations (~> 3.7.0)
|
49
|
+
rspec-mocks (~> 3.7.0)
|
50
|
+
rspec-core (3.7.0)
|
51
|
+
rspec-support (~> 3.7.0)
|
52
|
+
rspec-expectations (3.7.0)
|
53
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
54
|
+
rspec-support (~> 3.7.0)
|
55
|
+
rspec-mocks (3.7.0)
|
56
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
57
|
+
rspec-support (~> 3.7.0)
|
58
|
+
rspec-support (3.7.0)
|
59
|
+
rubocop (0.81.0)
|
60
|
+
jaro_winkler (~> 1.5.1)
|
61
|
+
parallel (~> 1.10)
|
62
|
+
parser (>= 2.7.0.1)
|
63
|
+
rainbow (>= 2.2.2, < 4.0)
|
64
|
+
rexml
|
65
|
+
ruby-progressbar (~> 1.7)
|
66
|
+
unicode-display_width (>= 1.4.0, < 2.0)
|
67
|
+
ruby-progressbar (1.11.0)
|
68
|
+
simplecov (0.12.0)
|
69
|
+
docile (~> 1.1.0)
|
70
|
+
json (>= 1.8, < 3)
|
71
|
+
simplecov-html (~> 0.10.0)
|
72
|
+
simplecov-html (0.10.0)
|
73
|
+
thor (0.18.1)
|
74
|
+
unicode-display_width (1.7.0)
|
75
|
+
yard (0.9.16)
|
76
|
+
|
77
|
+
PLATFORMS
|
78
|
+
ruby
|
79
|
+
|
80
|
+
DEPENDENCIES
|
81
|
+
appraisal
|
82
|
+
aruba
|
83
|
+
backports (~> 3.18)
|
84
|
+
cucumber (~> 2.99)
|
85
|
+
i18n
|
86
|
+
rake
|
87
|
+
roman-numerals
|
88
|
+
rspec
|
89
|
+
rubocop
|
90
|
+
simplecov
|
91
|
+
thor
|
92
|
+
yard
|
93
|
+
|
94
|
+
BUNDLED WITH
|
95
|
+
1.16.6
|
data/README.md
ADDED
@@ -0,0 +1,601 @@
|
|
1
|
+
# calendarium-romanum
|
2
|
+
|
3
|
+
[![Build Status](https://travis-ci.org/igneus/calendarium-romanum.svg?branch=master)](https://travis-ci.org/igneus/calendarium-romanum)
|
4
|
+
[![Gem Version](https://badge.fury.io/rb/calendarium-romanum.svg)](https://badge.fury.io/rb/calendarium-romanum)
|
5
|
+
|
6
|
+
API documentation:
|
7
|
+
[0.8.0](http://www.rubydoc.info/gems/calendarium-romanum/0.9.0)
|
8
|
+
[0.8.0](http://www.rubydoc.info/gems/calendarium-romanum/0.8.0)
|
9
|
+
[0.7.1](http://www.rubydoc.info/gems/calendarium-romanum/0.7.1)
|
10
|
+
[0.6.0](http://www.rubydoc.info/gems/calendarium-romanum/0.6.0)
|
11
|
+
[0.5.0](http://www.rubydoc.info/gems/calendarium-romanum/0.5.0)
|
12
|
+
[0.4.0](http://www.rubydoc.info/gems/calendarium-romanum/0.4.0)
|
13
|
+
[0.3.0](http://www.rubydoc.info/gems/calendarium-romanum/0.3.0)
|
14
|
+
[0.2.0](http://www.rubydoc.info/gems/calendarium-romanum/0.2.0)
|
15
|
+
|
16
|
+
Ruby gem for
|
17
|
+
calendar computations according to the Roman Catholic liturgical calendar as instituted by
|
18
|
+
[MP Mysterii Paschalis](http://w2.vatican.va/content/paul-vi/en/motu_proprio/documents/hf_p-vi_motu-proprio_19690214_mysterii-paschalis.html)
|
19
|
+
of Paul VI. (AAS 61 (1969), pp. 222-226),
|
20
|
+
defined in *General Norms for the Liturgical Year and the Calendar*
|
21
|
+
([English translation][gnlyc])
|
22
|
+
and subsequent [documents of liturgical legislation][liturgical_law].
|
23
|
+
|
24
|
+
`calendarium-romanum` aspires to become the most complete and most accurate
|
25
|
+
FOSS implementation of this calendar system
|
26
|
+
(see [list of implementations available][awesomecc]).
|
27
|
+
|
28
|
+
## Features
|
29
|
+
|
30
|
+
`calendarium-romanum` is now a **feature-complete** implementation of the abovementioned calendar
|
31
|
+
system, capable of generating a complete and (at least mostly) correct Roman Catholic liturgical
|
32
|
+
calendar for any year according to the most recent calendar rules and data
|
33
|
+
(i.e. today's state of the calendar is used also for years in the past - for historically accurate
|
34
|
+
computations see a [related project][crhistorical]).
|
35
|
+
|
36
|
+
It is **continuously kept up-to-date** with latest developments of the liturgical
|
37
|
+
legislation and newly introduced feasts.
|
38
|
+
|
39
|
+
**Accuracy** is highly valued. Therefore just a very limited set of calendar data
|
40
|
+
is bundled in the library, but with a guarantee that a theologian continuously takes care
|
41
|
+
of them being up-to-date and correct. Users of the library will usually want to prepare
|
42
|
+
and maintain their own data files representing their local calendars.
|
43
|
+
(For ready-to-use calendar data without guarantees of correctness
|
44
|
+
see a [related repository][data-contrib].)
|
45
|
+
|
46
|
+
The project's scope is strictly limited to computing **liturgical calendar in a narrow sense.**
|
47
|
+
It doesn't provide functionality specific for individual liturgical books, unless it is
|
48
|
+
dealt with in general liturgical norms regarding the calendar.
|
49
|
+
(Liturgical colours being an exception from this rule, as it is very common to include
|
50
|
+
them in all kinds of liturgical calendars.)
|
51
|
+
But the library is designed with machine-readability in mind, so that additional layers
|
52
|
+
of functionality, implementing book-specific calculations, can be built upon it.
|
53
|
+
|
54
|
+
Strings are **localized** (using the [i18n][i18n] Ruby gem). Translations to six languages
|
55
|
+
(Latin, English, Spanish, French, Italian, Czech)
|
56
|
+
are provided. The built-in translations can be both replaced and/or supplemented
|
57
|
+
with translations to additional languages without having to modify the gem's code.
|
58
|
+
|
59
|
+
## Credits
|
60
|
+
|
61
|
+
includes computation of the Easter date from the
|
62
|
+
[easter](https://github.com/jrobertson/easter) gem
|
63
|
+
by James Robertson.
|
64
|
+
|
65
|
+
See also changelog for list of contributions and their authors.
|
66
|
+
|
67
|
+
## License
|
68
|
+
|
69
|
+
dual licensed: freely choose between GNU/LGPL 3 and MIT
|
70
|
+
|
71
|
+
## Project status
|
72
|
+
|
73
|
+
The library is currently considered feature-complete for release 1.0.0
|
74
|
+
and it's public API mostly stabilized.
|
75
|
+
Development focuses on reaching higher degree of certainty regarding
|
76
|
+
correctness by means of making the test suite more comprehensive and rigorous.
|
77
|
+
|
78
|
+
## Backward compatibility
|
79
|
+
|
80
|
+
The gem's public interface has now been mostly stabilized, but until v1.0.0 release
|
81
|
+
there is still no guaranteed backward compatibility between minor versions.
|
82
|
+
|
83
|
+
When using the gem in your projects, it is recommended to lock
|
84
|
+
the dependency to a particular minor version.
|
85
|
+
|
86
|
+
In your app's Gemfile
|
87
|
+
|
88
|
+
```
|
89
|
+
gem 'calendarium-romanum', '~>0.9.0'
|
90
|
+
```
|
91
|
+
|
92
|
+
or in gemspec of your gem
|
93
|
+
|
94
|
+
```
|
95
|
+
spec.add_dependency 'calendarium-romanum', '~>0.9.0'
|
96
|
+
```
|
97
|
+
|
98
|
+
## Usage
|
99
|
+
|
100
|
+
All the examples below expect that you first required the gem:
|
101
|
+
|
102
|
+
```ruby
|
103
|
+
require 'calendarium-romanum'
|
104
|
+
```
|
105
|
+
|
106
|
+
### 1. Typical usage
|
107
|
+
|
108
|
+
The easiest way to obtain calendar entry of a liturgical day:
|
109
|
+
|
110
|
+
```ruby
|
111
|
+
I18n.locale = :en # set locale
|
112
|
+
|
113
|
+
# build calendar
|
114
|
+
pcal = CalendariumRomanum::PerpetualCalendar.new(
|
115
|
+
sanctorale: CalendariumRomanum::Data::GENERAL_ROMAN_ENGLISH.load
|
116
|
+
)
|
117
|
+
|
118
|
+
# query
|
119
|
+
day = pcal[Date.new(2000, 1, 1)]
|
120
|
+
```
|
121
|
+
|
122
|
+
For explanation see the detailed steps below.
|
123
|
+
|
124
|
+
### 2. What liturgical day is it today?
|
125
|
+
|
126
|
+
`PerpetualCalendar` used in the example above is a high-level API.
|
127
|
+
In order to understand what's happening under the hood, we will
|
128
|
+
now take a lower-level approach and work on the level of a simple
|
129
|
+
`Calendar`.
|
130
|
+
Each `Calendar` instance describes a particular *liturgical year*.
|
131
|
+
We may not know which liturgical year our day of interest
|
132
|
+
belongs to, but fortunately there is "alternative constructor"
|
133
|
+
`Calendar.for_day()` to rescue:
|
134
|
+
|
135
|
+
```ruby
|
136
|
+
date = Date.new(2016, 8, 19)
|
137
|
+
calendar = CalendariumRomanum::Calendar.for_day(date)
|
138
|
+
day = calendar[date]
|
139
|
+
|
140
|
+
day.season # => #<CalendariumRomanum::Season:0x00000001d4cfa0 @symbol=:ordinary, @colour=#<CalendariumRomanum::Colour:0x00000001d4d928 @symbol=:green, @i18n_key="colour.green">, @i18n_key="temporale.season.ordinary">
|
141
|
+
day.season.equal? CalendariumRomanum::Seasons::ORDINARY # => true
|
142
|
+
|
143
|
+
day.celebrations
|
144
|
+
# => [#<CalendariumRomanum::Celebration:0x00000001c69cc8 @title="Friday, 20th week in Ordinary Time", @rank=#<CalendariumRomanum::Rank:0x00000001d4c708 @priority=3.13, @desc="rank.3_13", @short_desc="rank.short.ferial">, @colour=#<CalendariumRomanum::Colour:0x00000001d4d928 @symbol=:green, @i18n_key="colour.green">, @symbol=nil>]
|
145
|
+
c = day.celebrations.first
|
146
|
+
c.title # => "Friday, 20th week in Ordinary Time"
|
147
|
+
c.rank # => #<CalendariumRomanum::Rank:0x00000001d4c708 @priority=3.13, @desc="rank.3_13", @short_desc="rank.short.ferial">
|
148
|
+
c.rank.equal? CalendariumRomanum::Ranks::FERIAL # => true
|
149
|
+
c.rank < CalendariumRomanum::Ranks::MEMORIAL_PROPER # => true
|
150
|
+
c.colour
|
151
|
+
# => #<CalendariumRomanum::Colour:0x00000001d4d928 @symbol=:green, @i18n_key="colour.green">
|
152
|
+
```
|
153
|
+
|
154
|
+
`Calendar#[]` returns a single `Day`, describing a liturgical day.
|
155
|
+
Each day belongs to some `#season`; every day, we can choose from
|
156
|
+
one or more `#celebrations` to celebrate.
|
157
|
+
(The only case with multiple choices is combination of a ferial
|
158
|
+
with one or more optional memorials; higher-ranking celebrations
|
159
|
+
are always exclusive.)
|
160
|
+
|
161
|
+
Each `Celebration` is described by a `#title`, `#rank` and `#colour`.
|
162
|
+
|
163
|
+
### 3. But does it take feasts of saints in account?
|
164
|
+
|
165
|
+
Actually, no. Not yet. We need to load some calendar data first:
|
166
|
+
|
167
|
+
```ruby
|
168
|
+
CR = CalendariumRomanum
|
169
|
+
loader = CR::SanctoraleLoader.new
|
170
|
+
sanctorale = loader.load_from_file 'data/universal-en.txt' # insert path to your data file
|
171
|
+
date = Date.new(2016, 8, 19)
|
172
|
+
calendar = CR::Calendar.for_day(date, sanctorale)
|
173
|
+
day = calendar[date]
|
174
|
+
day.celebrations # => [#<CalendariumRomanum::Celebration:0x000000027d9590 @title="Friday, 20th week in Ordinary Time", @rank=#<CalendariumRomanum::Rank:0x000000029e1108 @priority=3.13, ... >, @colour=#<CalendariumRomanum::Colour:0x000000029e1f68 @symbol=:green>>, #<CalendariumRomanum::Celebration:0x000000029c96c0 @title="Saint John Eudes, priest", @rank=#<CalendariumRomanum::Rank:0x000000029e1180 @priority=3.12, ... >, @colour=#<CalendariumRomanum::Colour:0x000000029e1f18 @symbol=:white>>]
|
175
|
+
```
|
176
|
+
|
177
|
+
Unless a sanctorale is loaded, `Calendar` only counts with
|
178
|
+
temporale feasts, Sundays and ferials.
|
179
|
+
|
180
|
+
Note how we saved some typing by defining new constant `CR`
|
181
|
+
referencing the `CalendariumRomanum` module.
|
182
|
+
In fact you can save even more typing by replacing
|
183
|
+
`require 'calendarium-romanum'`
|
184
|
+
by
|
185
|
+
`require 'calendarium-romanum/cr'`
|
186
|
+
which loads the gem *and* defines the `CR` shortcut for you.
|
187
|
+
Following examples expect the `CR` constant to be defined
|
188
|
+
and reference the `CalendariumRomanum` module.
|
189
|
+
|
190
|
+
Another possible way of saving some typing (if you don't care about
|
191
|
+
possible name clashes or polluting current namespace)
|
192
|
+
is including `CalendariumRomanum` module in the current module.
|
193
|
+
Then `CalendariumRomanum` classes can be referenced unqualified:
|
194
|
+
|
195
|
+
```ruby
|
196
|
+
include CalendariumRomanum
|
197
|
+
|
198
|
+
loader = SanctoraleLoader.new
|
199
|
+
# etc.
|
200
|
+
```
|
201
|
+
|
202
|
+
### 4. Isn't there an easier way to get sanctorale data?
|
203
|
+
|
204
|
+
Yes! There are a few data files bundled in the gem.
|
205
|
+
You can explore them by iterating over `CalendariumRomanum::Data.all`.
|
206
|
+
Those of general interest are additionally identified by their proper
|
207
|
+
constants, e.g. `CalendariumRomanum::Data::GENERAL_ROMAN_ENGLISH`.
|
208
|
+
Bundled data files can be loaded by a handy shortcut method `#load`:
|
209
|
+
|
210
|
+
```ruby
|
211
|
+
sanctorale = CR::Data::GENERAL_ROMAN_ENGLISH.load # easy loading
|
212
|
+
date = Date.new(2016, 8, 19)
|
213
|
+
calendar = CR::Calendar.for_day(date, sanctorale)
|
214
|
+
day = calendar[date]
|
215
|
+
```
|
216
|
+
|
217
|
+
### 5. I don't want to care about (liturgical) years
|
218
|
+
|
219
|
+
Each Calendar instance is bound to a particular *liturgical* year.
|
220
|
+
Calling `Calendar#[]` with a date out of the year's range
|
221
|
+
results in a `RangeError`:
|
222
|
+
|
223
|
+
```ruby
|
224
|
+
calendar = CR::Calendar.new(2000)
|
225
|
+
begin
|
226
|
+
day = calendar[Date.new(2000, 1, 1)]
|
227
|
+
rescue RangeError
|
228
|
+
STDERR.puts 'ouch' # will happen
|
229
|
+
end
|
230
|
+
```
|
231
|
+
|
232
|
+
The example demonstrates the well known fact,
|
233
|
+
that the **civil and liturgical year don't match:**
|
234
|
+
1st January 2000
|
235
|
+
does not belong to the liturgical year 2000-2001
|
236
|
+
(which will begin on the first Sunday of Advent,
|
237
|
+
i.e. on 3rd December 2000), but to the year 1999-2000.
|
238
|
+
For the sake of simplicity, `calendarium-romanum` denotes
|
239
|
+
liturgical years by the starting year only, so you create
|
240
|
+
a `Calendar` for liturgical year 1999-2000 by calling
|
241
|
+
`Calendar.new(1999)`.
|
242
|
+
|
243
|
+
We have already seen `Calendar.for_day()`, which takes care
|
244
|
+
of finding the liturgical year a particular date belongs to
|
245
|
+
and creating a `Calendar` for this year.
|
246
|
+
But maybe you want to query a calendar without caring about liturgical
|
247
|
+
years altogether, possibly picking days across multiple years.
|
248
|
+
The best tool for such use cases is `PerpetualCalendar`.
|
249
|
+
|
250
|
+
```ruby
|
251
|
+
pcal = CR::PerpetualCalendar.new
|
252
|
+
|
253
|
+
# get days
|
254
|
+
d1 = pcal[Date.new(2000, 1, 1)]
|
255
|
+
d2 = pcal[Date.new(2100, 1, 1)]
|
256
|
+
d3 = pcal[Date.new(1970, 1, 1)]
|
257
|
+
|
258
|
+
# get Calendar instances if you need them
|
259
|
+
calendar = pcal.calendar_for_year(1987)
|
260
|
+
```
|
261
|
+
|
262
|
+
Just like `Calendar` with the default settings (no sanctorale data
|
263
|
+
etc.) is usually of little use, so is a `PerpetualCalendar`
|
264
|
+
creating such `Calendar`s. Of course it is possible to specify
|
265
|
+
configuration which is then applied on the `Calendar`s
|
266
|
+
being created:
|
267
|
+
|
268
|
+
```ruby
|
269
|
+
pcal = CR::PerpetualCalendar.new(
|
270
|
+
# Sanctorale instance
|
271
|
+
sanctorale: CR::Data::GENERAL_ROMAN_ENGLISH.load,
|
272
|
+
# options that will be passed to Temporale.new
|
273
|
+
temporale_options: {
|
274
|
+
transfer_to_sunday: [:epiphany],
|
275
|
+
extensions: [CR::Temporale::Extensions::ChristEternalPriest]
|
276
|
+
}
|
277
|
+
)
|
278
|
+
d = pcal[Date.new(2000, 1, 1)]
|
279
|
+
|
280
|
+
# It is also possible to supply Temporale factory instead of options:
|
281
|
+
pcal = CR::PerpetualCalendar.new(
|
282
|
+
# Proc returning a Temporale instance for the specified year
|
283
|
+
temporale_factory: lambda do |year|
|
284
|
+
CR::Temporale.new(year, transfer_to_sunday: [:ascension])
|
285
|
+
end
|
286
|
+
)
|
287
|
+
pcal[Date.new(2000, 1, 1)]
|
288
|
+
```
|
289
|
+
|
290
|
+
**Memory management note:**
|
291
|
+
Internally, `PerpetualCalendar` builds `Calendar` instances as needed
|
292
|
+
and by default caches them *perpetually.* This is OK in most cases,
|
293
|
+
but it can lead to memory exhaustion if you traverse an excessive
|
294
|
+
amount of liturgical years. In such cases you can supply
|
295
|
+
your own cache (a `Hash` or anything with hash-like interface)
|
296
|
+
and implement some kind of cache size limiting.
|
297
|
+
|
298
|
+
```ruby
|
299
|
+
my_cache = {}
|
300
|
+
pcal = CR::PerpetualCalendar.new(cache: my_cache)
|
301
|
+
```
|
302
|
+
|
303
|
+
## Sanctorale Data
|
304
|
+
|
305
|
+
### Use prepared data or create your own
|
306
|
+
|
307
|
+
The gem expects data files following a custom format -
|
308
|
+
see README in the [data][data] directory for it's description.
|
309
|
+
The same directory contains a bunch of example data files.
|
310
|
+
(All of them are also bundled in the gem and accessible via
|
311
|
+
`CalendariumRomanum::Data`, as described above.)
|
312
|
+
|
313
|
+
`universal-en.txt` and `universal-la.txt` are data of the General
|
314
|
+
Roman Calendar in English and Latin.
|
315
|
+
|
316
|
+
The `czech-*.txt` files, when layered properly, can be used to assemble
|
317
|
+
proper calendar of any diocese in the Czech Republic.
|
318
|
+
|
319
|
+
### Implement custom loading strategy
|
320
|
+
|
321
|
+
In case you already have sanctorale data in another format,
|
322
|
+
it might be better suited for you to implement your own loading
|
323
|
+
routine instead of transforming them to our custom format.
|
324
|
+
`SanctoraleLoader` is the class to look into for inspiration.
|
325
|
+
|
326
|
+
The important bit is that for each celebration you
|
327
|
+
build a `Celebration` instance and push it in a `Sanctorale`
|
328
|
+
instance by a call to `Sanctorale#add`, which receives a month,
|
329
|
+
a day (as integers) and a `Celebration`:
|
330
|
+
|
331
|
+
```ruby
|
332
|
+
sanctorale = CR::Sanctorale.new
|
333
|
+
celebration = CR::Celebration.new('Saint John Eudes, priest', CR::Ranks::MEMORIAL_OPTIONAL, CR::Colours::WHITE)
|
334
|
+
sanctorale.add 8, 19, celebration
|
335
|
+
|
336
|
+
date = Date.new(2016, 8, 19)
|
337
|
+
calendar = CR::Calendar.for_day(date, sanctorale)
|
338
|
+
|
339
|
+
day = calendar[date]
|
340
|
+
day.celebrations # => [#<CalendariumRomanum::Celebration:0x000000010deea8 @title="", @rank=#<struct CalendariumRomanum::Rank priority=3.13, desc="Unprivileged ferials", short_desc="ferial">, @colour=:green>, #<CalendariumRomanum::Celebration:0x000000010fec08 @title="Saint John Eudes, priest", @rank=#<struct CalendariumRomanum::Rank priority=3.12, desc="Optional memorials", short_desc="optional memorial">, @colour=:white>]
|
341
|
+
```
|
342
|
+
|
343
|
+
### Proper calendar of a church
|
344
|
+
|
345
|
+
One common case of preparing custom sanctorale data is
|
346
|
+
implementing proper calendar of a church
|
347
|
+
(cf. *General Norms for the Liturgical Year and the Calendar* par. 52 c).
|
348
|
+
Proper calendar of a church is built by adding to the calendar
|
349
|
+
of the diocese (or religious institute) the church'es proper celebration,
|
350
|
+
which are usually just two solemnities: anniversary of dedication
|
351
|
+
and titular solemnity.
|
352
|
+
|
353
|
+
Let's say you have calendar of your diocese in sanctorale data file
|
354
|
+
`my-diocese.txt`.
|
355
|
+
You could copy the file to a new location and add the two proper solemnities,
|
356
|
+
but your programmer better self won't allow you to do that.
|
357
|
+
What options are left? You can create a new sanctorale file
|
358
|
+
with the two proper celebrations and then load it over the calendar
|
359
|
+
of the diocese, as explained in [data][data].
|
360
|
+
Or, if you need the calendar just for that single little script
|
361
|
+
and don't care about creating data files, you can build the two
|
362
|
+
proper solemnities in code:
|
363
|
+
|
364
|
+
```ruby
|
365
|
+
# here you would load your 'diocese.txt' instead
|
366
|
+
diocese = CR::SanctoraleLoader.new.load_from_file 'data/universal-en.txt'
|
367
|
+
|
368
|
+
dedication = CR::Celebration.new('Anniversary of Dedication of the Parish Church', CR::Ranks::SOLEMNITY_PROPER, CR::Colours::WHITE)
|
369
|
+
titular = CR::Celebration.new('Saint Nicholas, Bishop, Titular Solemnity of the Parish Church', CR::Ranks::SOLEMNITY_PROPER, CR::Colours::WHITE)
|
370
|
+
|
371
|
+
# solution 1 - directly modify the loaded Sanctorale
|
372
|
+
|
373
|
+
diocese.replace(10, 25, [dedication])
|
374
|
+
diocese.replace(12, 6, [titular])
|
375
|
+
|
376
|
+
# solution 2 - create a new Sanctorale with just the two solemnities,
|
377
|
+
# then create a third instance merging contents of the two without modifying them
|
378
|
+
|
379
|
+
proper_solemnities = CR::Sanctorale.new
|
380
|
+
proper_solemnities.replace(10, 25, [dedication])
|
381
|
+
proper_solemnities.replace(12, 6, [titular])
|
382
|
+
|
383
|
+
complete_proper_calendar = CR::SanctoraleFactory.create_layered(diocese, proper_solemnities)
|
384
|
+
```
|
385
|
+
|
386
|
+
## I18n, or, how to fix names of temporale feasts
|
387
|
+
|
388
|
+
One drawback of the current implementation is that names
|
389
|
+
of *temporale* feasts are totally independent of *sanctorale* feast
|
390
|
+
names. They are hardcoded in the gem, as [i18n][]
|
391
|
+
[translation strings][translations].
|
392
|
+
|
393
|
+
When you load *sanctorale* data in your favourite language,
|
394
|
+
the `Calendar` will by default still produce *temporale*
|
395
|
+
feasts with names in English.
|
396
|
+
This can be fixed by changing locale to match your *sanctorale*
|
397
|
+
data.
|
398
|
+
|
399
|
+
`I18n.locale = :la # or :en, :fr, :it, :cs`
|
400
|
+
|
401
|
+
The gem ships with English, Latin, Italian, Spanish, French and Czech translation.
|
402
|
+
Contributed translations to other languages are most welcome.
|
403
|
+
|
404
|
+
## Transfer of solemnities to a Sunday
|
405
|
+
|
406
|
+
As specified in
|
407
|
+
[General Norms for the Liturgical Year and the Calendar][gnlyc] 7,
|
408
|
+
the solemnities of Epiphany, Ascension and Corpus Christi
|
409
|
+
can be transferred to a Sunday.
|
410
|
+
`Temporale` by default preserves the regular dates of these
|
411
|
+
solemnities, but it has an option to enable the transfer:
|
412
|
+
|
413
|
+
```ruby
|
414
|
+
# transfer all three to Sunday
|
415
|
+
temporale = CR::Temporale.new(2016, transfer_to_sunday: [:epiphany, :ascension, :corpus_christi])
|
416
|
+
```
|
417
|
+
|
418
|
+
Usually you don't want to work with `Temporale` alone, but with
|
419
|
+
a `Calendar`. In order to create a `Calendar` with non-default
|
420
|
+
`Temporale` settings, it is necessary to provide a `Temporale`
|
421
|
+
as third argument to the constructor.
|
422
|
+
|
423
|
+
```ruby
|
424
|
+
year = 2000
|
425
|
+
sanctorale = CR::Data::GENERAL_ROMAN_ENGLISH.load
|
426
|
+
temporale = CR::Temporale.new(year, transfer_to_sunday: [:epiphany])
|
427
|
+
|
428
|
+
calendar = CR::Calendar.new(year, sanctorale, temporale)
|
429
|
+
```
|
430
|
+
|
431
|
+
## Custom movable feasts
|
432
|
+
|
433
|
+
Some local calendars may include proper movable feasts.
|
434
|
+
In Czech Republic this has recently been the case with the newly
|
435
|
+
introduced feast of *Christ the Priest* (celebrated on Thursday
|
436
|
+
after Pentecost). Support for this feast, celebrated in several other
|
437
|
+
dioceses and religious institutes, is included in the gem
|
438
|
+
as `Temporale` extension.
|
439
|
+
|
440
|
+
In order to build a complete Czech `Calendar` with proper sanctorale
|
441
|
+
feasts and the additional temporale feast of *Christ the Priest*,
|
442
|
+
it is necessary, apart of loading the sanctorale data,
|
443
|
+
to provide a `Temporale` instance with the extension applied:
|
444
|
+
|
445
|
+
```ruby
|
446
|
+
year = 2016
|
447
|
+
sanctorale = CR::Data::CZECH.load
|
448
|
+
temporale =
|
449
|
+
CR::Temporale.new(
|
450
|
+
year,
|
451
|
+
# the important bit: apply the Temporale extension
|
452
|
+
extensions: [CR::Temporale::Extensions::ChristEternalPriest]
|
453
|
+
)
|
454
|
+
|
455
|
+
calendar = CR::Calendar.new(year, sanctorale, temporale)
|
456
|
+
```
|
457
|
+
|
458
|
+
The feast of *Christ the Priest*, by it's nature, extends the cycle of
|
459
|
+
*Feasts of the Lord in the Ordinary Time* and thus clearly belongs
|
460
|
+
to the *temporale.* Even if your proper movable feast
|
461
|
+
is by it's nature a *sanctorale* feast, just having a movable
|
462
|
+
date, the only way to handle it using this gem is to write
|
463
|
+
a *temporale* extension. There is no support for movable feasts
|
464
|
+
in the `Sanctorale` class. Even the single movable sanctorale
|
465
|
+
feast of the General Roman Calendar,
|
466
|
+
the memorial of *Immaculate Heart of Mary,* is, by a little cheat,
|
467
|
+
currently implemented in the `Temporale`.
|
468
|
+
|
469
|
+
Any object defining method `each_celebration`, which yields
|
470
|
+
pairs of "date computer" and `Celebration`, can be used as
|
471
|
+
temporale extension. Unless you have a good reason to do otherwise,
|
472
|
+
a class or module defining `each_celebration` as class/module method
|
473
|
+
is a convenient choice.
|
474
|
+
|
475
|
+
```ruby
|
476
|
+
module MyExtension
|
477
|
+
# yields celebrations defined by the extension
|
478
|
+
def self.each_celebration
|
479
|
+
yield(
|
480
|
+
:my_feast_date, # name of a method computing date of the feast
|
481
|
+
CR::Celebration.new(
|
482
|
+
'My Feast', # feast title
|
483
|
+
CR::Ranks::FEAST_PROPER, # rank
|
484
|
+
CR::Colours::WHITE # colour
|
485
|
+
)
|
486
|
+
)
|
487
|
+
|
488
|
+
yield(
|
489
|
+
# Proc can be used for date computation instead of a method
|
490
|
+
# referenced by name
|
491
|
+
lambda {|year| CR::Temporale::Dates.easter_sunday(year) + 9 },
|
492
|
+
CR::Celebration.new(
|
493
|
+
# It is possible to use a Proc as feast title if you want it
|
494
|
+
# to be determined at runtime - e.g. because you want to
|
495
|
+
# have the feast title translated and follow changes of `I18n.locale`
|
496
|
+
proc { I18n.t('my_feasts.another_feast') },
|
497
|
+
CR::Ranks::MEMORIAL_PROPER,
|
498
|
+
CR::Colours::WHITE
|
499
|
+
)
|
500
|
+
)
|
501
|
+
end
|
502
|
+
|
503
|
+
# computes date of the feast;
|
504
|
+
# the year passed as argument is year when the liturgical
|
505
|
+
# year in question _began_
|
506
|
+
def self.my_feast_date(year)
|
507
|
+
# the day before Christ the King
|
508
|
+
CR::Temporale::Dates.christ_king(year) - 1
|
509
|
+
end
|
510
|
+
end
|
511
|
+
|
512
|
+
temporale = CR::Temporale.new(2016, extensions: [MyExtension])
|
513
|
+
|
514
|
+
# the feast is there!
|
515
|
+
temporale[Date.new(2017, 11, 25)] # => #<CalendariumRomanum::Celebration:0x0000000246fd78 @title="My Feast", @rank=#<CalendariumRomanum::Rank:0x000000019c27e0 @priority=2.8, ... >, @colour=#<CalendariumRomanum::Colour:0x000000019c31e0 @symbol=:white>>
|
516
|
+
```
|
517
|
+
|
518
|
+
## Internationalization internals
|
519
|
+
|
520
|
+
It was already mentioned earlier in this document that
|
521
|
+
for internationalization of temporale feast names and
|
522
|
+
other "built-in strings"
|
523
|
+
`calendarium-romanum` relies upon the `i18n` gem.
|
524
|
+
Some internal details may be worth a mention:
|
525
|
+
|
526
|
+
On `require 'calendarium-romanum'`, paths of a few translation
|
527
|
+
files bundled in the gem are added to `I18n.config.load_path`.
|
528
|
+
While otherwise we avoid polluting or modifying the environment
|
529
|
+
outside the gem's own scope, in this case we exceptionally
|
530
|
+
modify global configuration in order to make the internationalization
|
531
|
+
easily and conveniently work.
|
532
|
+
If your application requires `calendarium-romanum` to handle
|
533
|
+
languages not bundled in the gem, or if you don't like the default
|
534
|
+
translations, just prepare a [translation file][translations],
|
535
|
+
put it anywhere in your project's tree
|
536
|
+
and add it's path to `I18n.config.load_path`.
|
537
|
+
If, on the other hand, even the officially supported languages
|
538
|
+
don't work for you, check if paths to the gem's translation files
|
539
|
+
are present in `I18n.config.load_path` and possibly search your
|
540
|
+
application (and it's other dependencies) for code which kicked
|
541
|
+
them out.
|
542
|
+
|
543
|
+
## Executable
|
544
|
+
|
545
|
+
This gem provides an executable, `calendariumrom`.
|
546
|
+
It's handful of subcommands can be used to query liturgical calendar
|
547
|
+
from the command line and to check validity of sanctorale data files.
|
548
|
+
|
549
|
+
### 1. Query liturgical calendar from the command line
|
550
|
+
|
551
|
+
- `calendariumrom query` prints calendar entries for today or a specified day, month or year.
|
552
|
+
See `calendariumrom help query` for available options and arguments.
|
553
|
+
- `calendariumrom calendars` lists data files bundled in `calendarium-romanum`.
|
554
|
+
|
555
|
+
Tip: `calendariumrom query` is a rather bare-bones calendar querying
|
556
|
+
tool. Check out the [`calrom`][calrom] gem for a more feature-rich
|
557
|
+
liturgical calendar for your command line.
|
558
|
+
|
559
|
+
### 2. Check sanctorale data files
|
560
|
+
|
561
|
+
- `calendariumrom cmp FILE1 FILE2` loads two data files and prints any differences between them
|
562
|
+
(excepting differences in celebration titles)
|
563
|
+
- `calendariumrom errors FILE1, ...` attempts loading a data file (or several of them),
|
564
|
+
reports eventual errors
|
565
|
+
|
566
|
+
### 3. Help
|
567
|
+
|
568
|
+
- `calendariumrom` lists available subcommands
|
569
|
+
- `calendariumrom help [COMMAND]` outputs a short help for all available subcommands
|
570
|
+
- `calendariumrom version` prints installed version of the gem
|
571
|
+
|
572
|
+
## For Developers
|
573
|
+
|
574
|
+
Get the sources and install development depencencies:
|
575
|
+
|
576
|
+
1. `git clone git@github.com:igneus/calendarium-romanum.git`
|
577
|
+
2. `cd calendarium-romanum`
|
578
|
+
3. `bundle install` or `bundle install --path vendor/bundle`
|
579
|
+
|
580
|
+
### Run from CLI
|
581
|
+
|
582
|
+
`bundle exec ruby -Ilib bin/calendariumrom`
|
583
|
+
|
584
|
+
### Run Tests
|
585
|
+
|
586
|
+
- `bundle exec rake spec` to execute the test suite
|
587
|
+
- `bundle exec rake spec_all_locales` to run the test suite for each of the supported locales
|
588
|
+
- `bundle exec appraisal rake spec` to test compatibility with different versions of dependencies
|
589
|
+
- `bash spec/build/gem_build_test.sh` to test that a valid working Ruby gem can be built from the sources
|
590
|
+
|
591
|
+
[awesomecc]: https://github.com/calendarium-romanum/awesome-church-calendar
|
592
|
+
[gnlyc]: https://www.ewtn.com/catholicism/library/liturgical-year-2193
|
593
|
+
[i18n]: https://github.com/svenfuchs/i18n
|
594
|
+
[translations]: /config/locales
|
595
|
+
[liturgical_law]: /liturgical_law
|
596
|
+
[data]: /data
|
597
|
+
[module-included]: http://ruby-doc.org/core-2.2.2/Module.html#method-i-included
|
598
|
+
[calrom]: https://github.com/calendarium-romanum/calrom
|
599
|
+
[crhistorical]: https://github.com/calendarium-romanum/historical
|
600
|
+
[data-contrib]: https://github.com/calendarium-romanum/data-contrib
|
601
|
+
[i18n]: https://github.com/ruby-i18n/i18n
|