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.
Files changed (113) hide show
  1. checksums.yaml +5 -5
  2. data/.gitignore +5 -0
  3. data/.rspec +2 -0
  4. data/.rubocop.yml +50 -0
  5. data/.travis.yml +23 -0
  6. data/.yardopts +3 -0
  7. data/Appraisals +67 -0
  8. data/CHANGELOG.md +488 -0
  9. data/Gemfile +26 -0
  10. data/Gemfile.lock +95 -0
  11. data/README.md +601 -0
  12. data/Rakefile +27 -0
  13. data/bin/calendariumrom +3 -0
  14. data/calendarium-romanum.gemspec +31 -0
  15. data/config/locales/cs.yml +4 -0
  16. data/config/locales/en.yml +20 -14
  17. data/config/locales/es.yml +94 -0
  18. data/config/locales/fr.yml +6 -0
  19. data/config/locales/it.yml +6 -0
  20. data/config/locales/la.yml +6 -0
  21. data/config/locales/pt.yml +94 -0
  22. data/data/README.md +70 -24
  23. data/data/czech-brno-cs.txt +4 -6
  24. data/data/czech-budejovice-cs.txt +4 -6
  25. data/data/czech-cechy-cs.txt +4 -5
  26. data/data/czech-cs.txt +239 -235
  27. data/data/czech-hradec-cs.txt +3 -5
  28. data/data/czech-litomerice-cs.txt +5 -7
  29. data/data/czech-morava-cs.txt +4 -5
  30. data/data/czech-olomouc-cs.txt +2 -4
  31. data/data/czech-ostrava-cs.txt +3 -5
  32. data/data/czech-plzen-cs.txt +3 -5
  33. data/data/czech-praha-cs.txt +3 -4
  34. data/data/easter_dates.txt +67 -0
  35. data/data/universal-1969-la.txt +234 -0
  36. data/data/universal-en.txt +217 -211
  37. data/data/universal-es.txt +246 -0
  38. data/data/universal-fr.txt +217 -210
  39. data/data/universal-it.txt +217 -211
  40. data/data/universal-la.txt +217 -212
  41. data/data/universal-pt.txt +248 -0
  42. data/doc/data_readme.md +2 -0
  43. data/doc/images/class_diagram.png +0 -0
  44. data/doc/images/class_diagram.puml +44 -0
  45. data/doc/yard_readme.rdoc +76 -0
  46. data/lib/calendarium-romanum.rb +16 -2
  47. data/lib/calendarium-romanum/abstract_date.rb +15 -0
  48. data/lib/calendarium-romanum/calendar.rb +150 -33
  49. data/lib/calendarium-romanum/cli.rb +80 -100
  50. data/lib/calendarium-romanum/cli/comparator.rb +83 -0
  51. data/lib/calendarium-romanum/cli/date_parser.rb +30 -0
  52. data/lib/calendarium-romanum/cli/dumper.rb +68 -0
  53. data/lib/calendarium-romanum/cli/helper.rb +23 -0
  54. data/lib/calendarium-romanum/cli/querier.rb +73 -0
  55. data/lib/calendarium-romanum/cr.rb +16 -0
  56. data/lib/calendarium-romanum/data.rb +40 -8
  57. data/lib/calendarium-romanum/day.rb +187 -32
  58. data/lib/calendarium-romanum/enum.rb +41 -24
  59. data/lib/calendarium-romanum/enums.rb +127 -43
  60. data/lib/calendarium-romanum/errors.rb +1 -1
  61. data/lib/calendarium-romanum/ordinalizer.rb +10 -1
  62. data/lib/calendarium-romanum/perpetual_calendar.rb +58 -7
  63. data/lib/calendarium-romanum/rank.rb +39 -8
  64. data/lib/calendarium-romanum/rank_predicates.rb +43 -0
  65. data/lib/calendarium-romanum/sanctorale.rb +213 -23
  66. data/lib/calendarium-romanum/sanctorale_factory.rb +74 -3
  67. data/lib/calendarium-romanum/sanctorale_loader.rb +180 -0
  68. data/lib/calendarium-romanum/sanctorale_writer.rb +124 -0
  69. data/lib/calendarium-romanum/temporale.rb +222 -42
  70. data/lib/calendarium-romanum/temporale/celebration_factory.rb +68 -9
  71. data/lib/calendarium-romanum/temporale/date_helper.rb +85 -0
  72. data/lib/calendarium-romanum/temporale/dates.rb +52 -59
  73. data/lib/calendarium-romanum/temporale/easter_table.rb +27 -0
  74. data/lib/calendarium-romanum/temporale/extensions.rb +15 -0
  75. data/lib/calendarium-romanum/temporale/extensions/christ_eternal_priest.rb +16 -3
  76. data/lib/calendarium-romanum/temporale/extensions/dedication_before_all_saints.rb +73 -0
  77. data/lib/calendarium-romanum/transfers.rb +84 -24
  78. data/lib/calendarium-romanum/util.rb +21 -23
  79. data/lib/calendarium-romanum/version.rb +3 -2
  80. data/liturgical_law/1969_normae_universales.md +568 -0
  81. data/liturgical_law/1977_decretum_de_celebratione_baptismatis_domini.md +58 -0
  82. data/liturgical_law/1990_decretum_de_variatione_inducenda.md +67 -0
  83. data/liturgical_law/1998_notificatio_de_occurrentia.md +57 -0
  84. data/liturgical_law/2002_normae_universales.md +946 -0
  85. data/liturgical_law/2006_notification.md +37 -0
  86. data/liturgical_law/2012_declarationes.md +38 -0
  87. data/liturgical_law/2020_dubia_de_calendario_2022.md +100 -0
  88. data/liturgical_law/README.md +74 -0
  89. metadata +61 -38
  90. data/lib/calendarium-romanum/sanctoraleloader.rb +0 -122
  91. data/spec/abstract_date_spec.rb +0 -62
  92. data/spec/calendar_spec.rb +0 -559
  93. data/spec/celebration_factory_spec.rb +0 -16
  94. data/spec/celebration_spec.rb +0 -43
  95. data/spec/cli_spec.rb +0 -155
  96. data/spec/colour_spec.rb +0 -17
  97. data/spec/data_spec.rb +0 -23
  98. data/spec/date_parser_spec.rb +0 -68
  99. data/spec/date_spec.rb +0 -61
  100. data/spec/dates_spec.rb +0 -45
  101. data/spec/day_spec.rb +0 -108
  102. data/spec/enum_spec.rb +0 -51
  103. data/spec/i18n_spec.rb +0 -58
  104. data/spec/ordinalizer_spec.rb +0 -36
  105. data/spec/perpetual_calendar_spec.rb +0 -91
  106. data/spec/rank_spec.rb +0 -57
  107. data/spec/readme_spec.rb +0 -56
  108. data/spec/sanctorale_factory_spec.rb +0 -42
  109. data/spec/sanctorale_spec.rb +0 -191
  110. data/spec/sanctoraleloader_spec.rb +0 -176
  111. data/spec/season_spec.rb +0 -17
  112. data/spec/spec_helper.rb +0 -46
  113. data/spec/temporale_spec.rb +0 -572
@@ -1,10 +1,22 @@
1
1
  module CalendariumRomanum
2
2
  class Temporale
3
- # builds temporale Celebrations
3
+ # Provides factory methods building {Celebration}s
4
+ # for temporale feasts
4
5
  class CelebrationFactory
5
6
  class << self
7
+ # @yield [Symbol]
8
+ # @return [void, Enumerator]
9
+ def each
10
+ return to_enum(__method__) unless block_given?
11
+
12
+ celebrations.each do |symbol|
13
+ yield public_send(symbol)
14
+ end
15
+ end
16
+
17
+ # @return [Celebration]
6
18
  def first_advent_sunday
7
- Celebration.new(
19
+ Temporale.create_celebration(
8
20
  I18n.t('temporale.advent.sunday', week: Ordinalizer.ordinal(1)),
9
21
  Ranks::PRIMARY,
10
22
  Colours::VIOLET
@@ -13,36 +25,83 @@ module CalendariumRomanum
13
25
 
14
26
  private
15
27
 
16
- def celebration(symbol, rank, colour = Colours::WHITE)
28
+ def celebrations
29
+ @celebrations ||= [:first_advent_sunday]
30
+ end
31
+
32
+ def celebration(symbol, rank, colour = Colours::WHITE, fixed_date: nil, sunday: nil)
17
33
  define_singleton_method(symbol) do
18
- Celebration.new(
34
+ Temporale.create_celebration(
19
35
  proc { I18n.t("temporale.solemnity.#{symbol}") },
20
36
  rank,
21
37
  colour,
22
- symbol
38
+ symbol: symbol,
39
+ date: fixed_date,
40
+ sunday: sunday
23
41
  )
24
42
  end
43
+
44
+ celebrations << symbol
25
45
  end
26
46
  end
27
47
 
28
- # define factory methods
29
- celebration(:nativity, Ranks::PRIMARY)
48
+ # @return [Celebration]
49
+ # @!scope class
50
+ celebration(:nativity, Ranks::PRIMARY, fixed_date: AbstractDate.new(12, 25))
51
+ # @return [Celebration]
52
+ # @!scope class
30
53
  celebration(:holy_family, Ranks::FEAST_LORD_GENERAL)
31
- celebration(:mother_of_god, Ranks::SOLEMNITY_GENERAL)
54
+ # @return [Celebration]
55
+ # @!scope class
56
+ celebration(:mother_of_god, Ranks::SOLEMNITY_GENERAL, fixed_date: AbstractDate.new(1, 1))
57
+ # @return [Celebration]
58
+ # @!scope class
32
59
  celebration(:epiphany, Ranks::PRIMARY)
60
+ # @return [Celebration]
61
+ # @!scope class
33
62
  celebration(:baptism_of_lord, Ranks::FEAST_LORD_GENERAL)
63
+ # @return [Celebration]
64
+ # @!scope class
34
65
  celebration(:ash_wednesday, Ranks::PRIMARY, Colours::VIOLET)
66
+ # @return [Celebration]
67
+ # @!scope class
35
68
  celebration(:good_friday, Ranks::TRIDUUM, Colours::RED)
69
+ # @return [Celebration]
70
+ # @!scope class
36
71
  celebration(:holy_saturday, Ranks::TRIDUUM, Colours::VIOLET)
37
- celebration(:palm_sunday, Ranks::PRIMARY, Colours::RED)
72
+ # @return [Celebration]
73
+ # @!scope class
74
+ celebration(:palm_sunday, Ranks::PRIMARY, Colours::RED, sunday: true)
75
+ # @return [Celebration]
76
+ # @!scope class
38
77
  celebration(:easter_sunday, Ranks::TRIDUUM)
78
+ # @return [Celebration]
79
+ # @!scope class
39
80
  celebration(:ascension, Ranks::PRIMARY)
81
+ # @return [Celebration]
82
+ # @!scope class
40
83
  celebration(:pentecost, Ranks::PRIMARY, Colours::RED)
84
+ # @return [Celebration]
85
+ # @!scope class
41
86
  celebration(:holy_trinity, Ranks::SOLEMNITY_GENERAL)
87
+ # @return [Celebration]
88
+ # @!scope class
42
89
  celebration(:corpus_christi, Ranks::SOLEMNITY_GENERAL)
90
+ # @return [Celebration]
91
+ # @!scope class
43
92
  celebration(:sacred_heart, Ranks::SOLEMNITY_GENERAL)
93
+ # @return [Celebration]
94
+ # @!scope class
44
95
  celebration(:christ_king, Ranks::SOLEMNITY_GENERAL)
96
+ # @return [Celebration]
97
+ # @!scope class
98
+ celebration(:mother_of_church, Ranks::MEMORIAL_GENERAL)
99
+ # @return [Celebration]
100
+ # @!scope class
45
101
  celebration(:immaculate_heart, Ranks::MEMORIAL_GENERAL)
102
+ # @return [Celebration]
103
+ # @!scope class
104
+ celebration(:saturday_memorial_bvm, Ranks::MEMORIAL_OPTIONAL)
46
105
  end
47
106
  end
48
107
  end
@@ -0,0 +1,85 @@
1
+ module CalendariumRomanum
2
+ class Temporale
3
+ # Provides utility methods for date arithmetics, available
4
+ # both as mixin instance methods and module methods.
5
+ #
6
+ # @since 0.9.0
7
+ module DateHelper
8
+ extend self
9
+
10
+ # @param weekday [Integer]
11
+ # @param date [Date]
12
+ # @return [Date]
13
+ def weekday_before(weekday, date)
14
+ if date.wday == weekday
15
+ date - WEEK
16
+ elsif weekday < date.wday
17
+ date - (date.wday - weekday)
18
+ else
19
+ date - (date.wday + WEEK - weekday)
20
+ end
21
+ end
22
+
23
+ # (see .weekday_before)
24
+ def weekday_after(weekday, date)
25
+ if date.wday == weekday
26
+ date + WEEK
27
+ elsif weekday > date.wday
28
+ date + (weekday - date.wday)
29
+ else
30
+ date + (WEEK - date.wday + weekday)
31
+ end
32
+ end
33
+
34
+ # @param date [Date]
35
+ # @return [Date]
36
+ def octave_of(date)
37
+ date + WEEK
38
+ end
39
+
40
+ # @!method sunday_before(date)
41
+ # @param date [Date]
42
+ # @return [Date]
43
+ # @!method monday_before(date)
44
+ # (see .sunday_before)
45
+ # @!method tuesday_before(date)
46
+ # (see .sunday_before)
47
+ # @!method wednesday_before(date)
48
+ # (see .sunday_before)
49
+ # @!method thursday_before(date)
50
+ # (see .sunday_before)
51
+ # @!method friday_before(date)
52
+ # (see .sunday_before)
53
+ # @!method saturday_before(date)
54
+ # (see .sunday_before)
55
+
56
+ # @!method sunday_after(date)
57
+ # @param date [Date]
58
+ # @return [Date]
59
+ # @!method monday_after(date)
60
+ # (see .sunday_after)
61
+ # @!method tuesday_after(date)
62
+ # (see .sunday_after)
63
+ # @!method wednesday_after(date)
64
+ # (see .sunday_after)
65
+ # @!method thursday_after(date)
66
+ # (see .sunday_after)
67
+ # @!method friday_after(date)
68
+ # (see .sunday_after)
69
+ # @!method saturday_after(date)
70
+ # (see .sunday_after)
71
+
72
+ # @api private
73
+ WEEKDAYS = %w(sunday monday tuesday wednesday thursday friday saturday).freeze
74
+ WEEKDAYS.each_with_index do |weekday, weekday_i|
75
+ define_method "#{weekday}_before" do |date|
76
+ send('weekday_before', weekday_i, date)
77
+ end
78
+
79
+ define_method "#{weekday}_after" do |date|
80
+ send('weekday_after', weekday_i, date)
81
+ end
82
+ end
83
+ end
84
+ end
85
+ end
@@ -1,16 +1,24 @@
1
1
  module CalendariumRomanum
2
2
  class Temporale
3
- # dates of movable feasts
3
+ # Provides methods computing dates of movable feasts
4
+ # and utilities for common computations of relative dates
4
5
  module Dates
5
- def self.first_advent_sunday(year)
6
+ include DateHelper
7
+ extend self
8
+
9
+ # (see #nativity)
10
+ def first_advent_sunday(year)
6
11
  sunday_before(nativity(year)) - 3 * WEEK
7
12
  end
8
13
 
9
- def self.nativity(year)
14
+ # @param year [Integer] liturgical year
15
+ # @return [Date]
16
+ def nativity(year)
10
17
  Date.new(year, 12, 25)
11
18
  end
12
19
 
13
- def self.holy_family(year)
20
+ # (see #nativity)
21
+ def holy_family(year)
14
22
  xmas = nativity(year)
15
23
  if xmas.sunday?
16
24
  return Date.new(year, 12, 30)
@@ -19,11 +27,15 @@ module CalendariumRomanum
19
27
  end
20
28
  end
21
29
 
22
- def self.mother_of_god(year)
30
+ # (see #nativity)
31
+ def mother_of_god(year)
23
32
  octave_of(nativity(year))
24
33
  end
25
34
 
26
- def self.epiphany(year, sunday: false)
35
+ # @param year [Integer] liturgical year
36
+ # @param sunday [Boolean] transfer to Sunday?
37
+ # @return [Date]
38
+ def epiphany(year, sunday: false)
27
39
  if sunday
28
40
  # GNLYC 7 a)
29
41
  return sunday_after(Date.new(year + 1, 1, 1))
@@ -32,20 +44,25 @@ module CalendariumRomanum
32
44
  Date.new(year + 1, 1, 6)
33
45
  end
34
46
 
35
- def self.baptism_of_lord(year, epiphany_on_sunday: false)
47
+ # @param year [Integer] liturgical year
48
+ # @param epiphany_on_sunday [Boolean] was Epiphany transferred to Sunday?
49
+ # @return [Date]
50
+ def baptism_of_lord(year, epiphany_on_sunday: false)
36
51
  e = epiphany(year, sunday: epiphany_on_sunday)
37
- if epiphany_on_sunday
52
+ if e.day > 6
38
53
  e + 1
39
54
  else
40
55
  sunday_after e
41
56
  end
42
57
  end
43
58
 
44
- def self.ash_wednesday(year)
59
+ # (see #nativity)
60
+ def ash_wednesday(year)
45
61
  easter_sunday(year) - (6 * WEEK + 4)
46
62
  end
47
63
 
48
- def self.easter_sunday(year)
64
+ # (see #nativity)
65
+ def easter_sunday(year)
49
66
  year += 1
50
67
 
51
68
  # algorithm below taken from the 'easter' gem:
@@ -71,19 +88,23 @@ module CalendariumRomanum
71
88
  end
72
89
  end
73
90
 
74
- def self.palm_sunday(year)
91
+ # (see #nativity)
92
+ def palm_sunday(year)
75
93
  easter_sunday(year) - 7
76
94
  end
77
95
 
78
- def self.good_friday(year)
96
+ # (see #nativity)
97
+ def good_friday(year)
79
98
  easter_sunday(year) - 2
80
99
  end
81
100
 
82
- def self.holy_saturday(year)
101
+ # (see #nativity)
102
+ def holy_saturday(year)
83
103
  easter_sunday(year) - 1
84
104
  end
85
105
 
86
- def self.ascension(year, sunday: false)
106
+ # (see .epiphany)
107
+ def ascension(year, sunday: false)
87
108
  if sunday
88
109
  # GNLYC 7 b)
89
110
  return easter_sunday(year) + 6 * WEEK
@@ -92,15 +113,18 @@ module CalendariumRomanum
92
113
  pentecost(year) - 10
93
114
  end
94
115
 
95
- def self.pentecost(year)
116
+ # (see #nativity)
117
+ def pentecost(year)
96
118
  easter_sunday(year) + 7 * WEEK
97
119
  end
98
120
 
99
- def self.holy_trinity(year)
121
+ # (see #nativity)
122
+ def holy_trinity(year)
100
123
  octave_of(pentecost(year))
101
124
  end
102
125
 
103
- def self.corpus_christi(year, sunday: false)
126
+ # (see .epiphany)
127
+ def corpus_christi(year, sunday: false)
104
128
  if sunday
105
129
  # GNLYC 7 c)
106
130
  return holy_trinity(year) + WEEK
@@ -109,55 +133,24 @@ module CalendariumRomanum
109
133
  holy_trinity(year) + 4
110
134
  end
111
135
 
112
- def self.sacred_heart(year)
136
+ # (see #nativity)
137
+ def sacred_heart(year)
113
138
  corpus_christi(year) + 8
114
139
  end
115
140
 
116
- def self.immaculate_heart(year)
117
- pentecost(year) + 20
118
- end
119
-
120
- def self.christ_king(year)
121
- first_advent_sunday(year + 1) - 7
122
- end
123
-
124
- # utility methods
125
-
126
- def self.weekday_before(weekday, date)
127
- if date.wday == weekday
128
- date - WEEK
129
- elsif weekday < date.wday
130
- date - (date.wday - weekday)
131
- else
132
- date - (date.wday + WEEK - weekday)
133
- end
134
- end
135
-
136
- def self.weekday_after(weekday, date)
137
- if date.wday == weekday
138
- date + WEEK
139
- elsif weekday > date.wday
140
- date + (weekday - date.wday)
141
- else
142
- date + (WEEK - date.wday + weekday)
143
- end
141
+ # (see #nativity)
142
+ def mother_of_church(year)
143
+ pentecost(year) + 1
144
144
  end
145
145
 
146
- def self.octave_of(date)
147
- date + WEEK
146
+ # (see #nativity)
147
+ def immaculate_heart(year)
148
+ pentecost(year) + 20
148
149
  end
149
150
 
150
- class << self
151
- WEEKDAYS = %w(sunday monday tuesday wednesday thursday friday saturday).freeze
152
- WEEKDAYS.each_with_index do |weekday, weekday_i|
153
- define_method "#{weekday}_before" do |date|
154
- send('weekday_before', weekday_i, date)
155
- end
156
-
157
- define_method "#{weekday}_after" do |date|
158
- send('weekday_after', weekday_i, date)
159
- end
160
- end
151
+ # (see #nativity)
152
+ def christ_king(year)
153
+ first_advent_sunday(year + 1) - 7
161
154
  end
162
155
  end
163
156
  end
@@ -0,0 +1,27 @@
1
+ module CalendariumRomanum
2
+ class Temporale
3
+ # @since 0.8.0
4
+ class EasterTable
5
+ # Loads an Easter table from a String- or IO-like object +src+.
6
+ # +src+ must contain Easter dates, parseable by +Date.parse+, one date per line.
7
+ # Blank lines and bash-like comments are ignored.
8
+ # Returns a +Hash+ mapping (liturgical) year to Easter date.
9
+ #
10
+ # @param src [#each_line]
11
+ # @return [Hash<Integer=>Date>]
12
+ def self.load_from(src)
13
+ r = {}
14
+ src.each_line do |l|
15
+ cleaned = l.sub(/#.*$/, '').strip
16
+ next if cleaned == ''
17
+
18
+ date = Date.parse cleaned
19
+ liturgical_year = date.year - 1
20
+ r[liturgical_year] = date
21
+ end
22
+
23
+ r
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,15 @@
1
+ module CalendariumRomanum
2
+ class Temporale
3
+ module Extensions
4
+ # Returns all Temporale extensions defined by the gem.
5
+ #
6
+ # @return [Array<Module>]
7
+ # @since 0.8.0
8
+ def self.all
9
+ constants
10
+ .collect {|c| const_get(c) }
11
+ .select {|c| c.is_a? Module }
12
+ end
13
+ end
14
+ end
15
+ end
@@ -1,21 +1,34 @@
1
1
  module CalendariumRomanum
2
2
  class Temporale
3
3
  module Extensions
4
- # Temporale extension adding feast of Christ Eternal Priests,
4
+ # {Temporale} extension adding the movable feast
5
+ # of "Christ Eternal Priests",
5
6
  # included in some local calendars
7
+ #
8
+ # @example
9
+ # temporale = Temporale.new(2015, extensions: [
10
+ # Temporale::Extensions::ChristEternalPriest
11
+ # ])
6
12
  module ChristEternalPriest
13
+ # @yield [Symbol, Celebration]
14
+ # @return [void]
7
15
  def self.each_celebration
8
16
  yield(
17
+ # symbol refers to the date-computing method
9
18
  :christ_eternal_priest,
10
19
  Celebration.new(
11
20
  proc { I18n.t('temporale.extension.christ_eternal_priest') },
12
21
  Ranks::FEAST_PROPER,
13
- Colours::WHITE
22
+ Colours::WHITE,
23
+ :christ_eternal_priest
14
24
  )
15
25
  )
16
26
  end
17
27
 
18
- # method computing date
28
+ # Computes the feast's date
29
+ #
30
+ # @param year [Integer] liturgical year
31
+ # @return [Date]
19
32
  def self.christ_eternal_priest(year)
20
33
  Dates.pentecost(year) + 4
21
34
  end