calendarium-romanum 0.7.1 → 0.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +15 -13
- data/.yardopts +1 -1
- data/CHANGELOG.md +91 -0
- data/README.md +128 -45
- data/Rakefile +7 -0
- data/calendarium-romanum.gemspec +6 -1
- data/config/locales/cs.yml +2 -0
- data/config/locales/en.yml +4 -0
- data/config/locales/es.yml +4 -0
- data/config/locales/fr.yml +4 -0
- data/config/locales/it.yml +4 -0
- data/config/locales/la.yml +4 -0
- data/data/README.md +27 -23
- data/data/czech-cs.txt +13 -15
- data/data/easter_dates.txt +67 -0
- data/data/universal-1969-la.txt +234 -0
- data/data/universal-en.txt +4 -4
- data/data/universal-es.txt +4 -4
- data/data/universal-fr.txt +4 -4
- data/data/universal-it.txt +4 -4
- data/data/universal-la.txt +4 -4
- data/lib/calendarium-romanum.rb +5 -0
- data/lib/calendarium-romanum/abstract_date.rb +6 -3
- data/lib/calendarium-romanum/calendar.rb +37 -15
- data/lib/calendarium-romanum/cli.rb +49 -111
- 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/data.rb +4 -1
- data/lib/calendarium-romanum/day.rb +49 -40
- data/lib/calendarium-romanum/enum.rb +37 -39
- data/lib/calendarium-romanum/enums.rb +28 -4
- data/lib/calendarium-romanum/ordinalizer.rb +2 -2
- data/lib/calendarium-romanum/perpetual_calendar.rb +6 -3
- data/lib/calendarium-romanum/rank.rb +16 -22
- data/lib/calendarium-romanum/rank_predicates.rb +43 -0
- data/lib/calendarium-romanum/sanctorale.rb +9 -8
- data/lib/calendarium-romanum/sanctorale_loader.rb +7 -3
- data/lib/calendarium-romanum/sanctorale_writer.rb +119 -0
- data/lib/calendarium-romanum/temporale.rb +44 -17
- data/lib/calendarium-romanum/temporale/celebration_factory.rb +4 -3
- data/lib/calendarium-romanum/temporale/dates.rb +5 -5
- 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 +3 -2
- data/lib/calendarium-romanum/temporale/extensions/dedication_before_all_saints.rb +73 -0
- data/lib/calendarium-romanum/transfers.rb +44 -18
- data/lib/calendarium-romanum/util.rb +10 -24
- data/lib/calendarium-romanum/version.rb +2 -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/README.md +74 -0
- metadata +28 -5
@@ -33,7 +33,9 @@ module CalendariumRomanum
|
|
33
33
|
end
|
34
34
|
|
35
35
|
# Standard set of liturgical colours
|
36
|
-
|
36
|
+
module Colours
|
37
|
+
extend Enum
|
38
|
+
|
37
39
|
GREEN = Colour.new(:green)
|
38
40
|
VIOLET = Colour.new(:violet)
|
39
41
|
WHITE = Colour.new(:white)
|
@@ -67,15 +69,20 @@ module CalendariumRomanum
|
|
67
69
|
|
68
70
|
# Liturgical colour of the season's Sundays and ferials
|
69
71
|
#
|
70
|
-
#
|
72
|
+
# May be +nil+ if there is no single colour.
|
73
|
+
#
|
74
|
+
# @return [Colour, nil]
|
71
75
|
attr_reader :colour
|
72
76
|
end
|
73
77
|
|
74
78
|
# Standard set of liturgical seasons
|
75
|
-
|
79
|
+
module Seasons
|
80
|
+
extend Enum
|
81
|
+
|
76
82
|
ADVENT = Season.new(:advent, Colours::VIOLET)
|
77
83
|
CHRISTMAS = Season.new(:christmas, Colours::WHITE)
|
78
84
|
LENT = Season.new(:lent, Colours::VIOLET)
|
85
|
+
TRIDUUM = Season.new(:triduum, nil)
|
79
86
|
EASTER = Season.new(:easter, Colours::WHITE)
|
80
87
|
ORDINARY = Season.new(:ordinary, Colours::GREEN)
|
81
88
|
|
@@ -84,6 +91,7 @@ module CalendariumRomanum
|
|
84
91
|
ADVENT,
|
85
92
|
CHRISTMAS,
|
86
93
|
LENT,
|
94
|
+
TRIDUUM,
|
87
95
|
EASTER,
|
88
96
|
ORDINARY,
|
89
97
|
]
|
@@ -95,7 +103,9 @@ module CalendariumRomanum
|
|
95
103
|
LECTIONARY_CYCLES = [:A, :B, :C].freeze
|
96
104
|
|
97
105
|
# Celebration ranks as specified in the Table of Liturgical Days
|
98
|
-
|
106
|
+
module Ranks
|
107
|
+
extend Enum
|
108
|
+
|
99
109
|
TRIDUUM = Rank.new(1.1, 'rank.1_1')
|
100
110
|
PRIMARY = Rank.new(1.2, 'rank.1_2') # description may not be exact
|
101
111
|
SOLEMNITY_GENERAL = Rank.new(1.3, 'rank.1_3', 'rank.short.solemnity') # description may not be exact
|
@@ -140,4 +150,18 @@ module CalendariumRomanum
|
|
140
150
|
]
|
141
151
|
end
|
142
152
|
end
|
153
|
+
|
154
|
+
# Convenience module containing all the colour, season and rank constants
|
155
|
+
# for easy including
|
156
|
+
#
|
157
|
+
# @example
|
158
|
+
# include CalendariumRomanum::Constants
|
159
|
+
# RED # now all the constants are available in current module
|
160
|
+
#
|
161
|
+
# @since 0.8.0
|
162
|
+
module Constants
|
163
|
+
include Colours
|
164
|
+
include Seasons
|
165
|
+
include Ranks
|
166
|
+
end
|
143
167
|
end
|
@@ -6,11 +6,11 @@ module CalendariumRomanum
|
|
6
6
|
# Used by {Temporale} for building names of Sundays and ferials.
|
7
7
|
class Ordinalizer
|
8
8
|
class << self
|
9
|
-
# @param number [
|
9
|
+
# @param number [Integer] number to build ordinal for
|
10
10
|
# @param locale [Symbol,nil]
|
11
11
|
# locale; +I18n.locale+ (i.e. the `i18n` gem's current locale)
|
12
12
|
# is used if not provided
|
13
|
-
# @return [String,
|
13
|
+
# @return [String, Integer]
|
14
14
|
# ordinal, or unchanged +number+ if +Ordinalizer+ cannot
|
15
15
|
# build ordinals for the given locale
|
16
16
|
def ordinal(number, locale: nil)
|
@@ -18,6 +18,8 @@ module CalendariumRomanum
|
|
18
18
|
# +Hash+ of arguments for {Temporale#initialize}.
|
19
19
|
# +temporale_factory+ and +temporale_options+ are mutually
|
20
20
|
# exclusive - pass either (or none) of them, never both.
|
21
|
+
# @param vespers [Boolean]
|
22
|
+
# See argument of the same name to {Calendar#initialize}
|
21
23
|
# @param cache [Hash]
|
22
24
|
# object to be used as internal cache of {Calendar} instances -
|
23
25
|
# anything exposing +#[]=+ and +#[]+ and "behaving mostly like
|
@@ -29,13 +31,14 @@ module CalendariumRomanum
|
|
29
31
|
# by huge amount of cached {Calendar} instances.
|
30
32
|
# (By default, once a {Calendar} for a certain year is built,
|
31
33
|
# it is cached for the +PerpetualCalendar+ instances' lifetime.)
|
32
|
-
def initialize(sanctorale: nil, temporale_factory: nil, temporale_options: nil, cache: {})
|
34
|
+
def initialize(sanctorale: nil, temporale_factory: nil, temporale_options: nil, vespers: false, cache: {})
|
33
35
|
if temporale_factory && temporale_options
|
34
36
|
raise ArgumentError.new('Specify either temporale_factory or temporale_options, not both')
|
35
37
|
end
|
36
38
|
|
37
39
|
@sanctorale = sanctorale
|
38
40
|
@temporale_factory = temporale_factory || build_temporale_factory(temporale_options)
|
41
|
+
@vespers = vespers
|
39
42
|
|
40
43
|
@cache = cache
|
41
44
|
end
|
@@ -73,7 +76,7 @@ module CalendariumRomanum
|
|
73
76
|
|
74
77
|
# Returns a Calendar instance for the specified liturgical year
|
75
78
|
#
|
76
|
-
# @param year [
|
79
|
+
# @param year [Integer]
|
77
80
|
# @return [Calendar]
|
78
81
|
def calendar_for_year(year)
|
79
82
|
calendar_instance year
|
@@ -90,7 +93,7 @@ module CalendariumRomanum
|
|
90
93
|
if @cache.has_key? year
|
91
94
|
@cache[year]
|
92
95
|
else
|
93
|
-
@cache[year] = Calendar.new(year, @sanctorale, @temporale_factory.call(year))
|
96
|
+
@cache[year] = Calendar.new(year, @sanctorale, @temporale_factory.call(year), vespers: @vespers)
|
94
97
|
end
|
95
98
|
end
|
96
99
|
end
|
@@ -1,6 +1,7 @@
|
|
1
1
|
module CalendariumRomanum
|
2
2
|
# Celebration rank
|
3
3
|
class Rank
|
4
|
+
include RankPredicates
|
4
5
|
include Comparable
|
5
6
|
|
6
7
|
# @param priority [Float, nil] number in the Table of Liturgical Days
|
@@ -46,32 +47,25 @@ module CalendariumRomanum
|
|
46
47
|
other.priority <=> priority
|
47
48
|
end
|
48
49
|
|
49
|
-
#
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
# @
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
50
|
+
# Returns the next higher rank.
|
51
|
+
#
|
52
|
+
# Allows constructing ranges of ranks.
|
53
|
+
#
|
54
|
+
# @return [Rank]
|
55
|
+
# @since 0.8.0
|
56
|
+
def succ
|
57
|
+
all = CR::Ranks.all
|
58
|
+
index = all.index(self)
|
59
|
+
raise StopIteration.new if index == 0
|
59
60
|
|
60
|
-
|
61
|
-
def feast?
|
62
|
-
priority.to_i == 2
|
61
|
+
all[index - 1]
|
63
62
|
end
|
64
63
|
|
65
|
-
|
66
|
-
def memorial?
|
67
|
-
priority.to_i == 3 && priority <= 3.12
|
68
|
-
end
|
64
|
+
private
|
69
65
|
|
70
|
-
#
|
71
|
-
|
72
|
-
|
73
|
-
self == Ranks::FERIAL ||
|
74
|
-
self == Ranks::FERIAL_PRIVILEGED
|
66
|
+
# Required by the {RankPredicates} mixin
|
67
|
+
def rank
|
68
|
+
self
|
75
69
|
end
|
76
70
|
end
|
77
71
|
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
module CalendariumRomanum
|
2
|
+
# Mixin providing rank-describing predicates.
|
3
|
+
# Expects the including class to have instance method +#rank+ returning a {Rank}.
|
4
|
+
module RankPredicates
|
5
|
+
# @return [Boolean]
|
6
|
+
def solemnity?
|
7
|
+
rank.priority.to_i == 1
|
8
|
+
end
|
9
|
+
|
10
|
+
# @return [Boolean]
|
11
|
+
# @since 0.6.0
|
12
|
+
def sunday?
|
13
|
+
rank == Ranks::SUNDAY_UNPRIVILEGED
|
14
|
+
end
|
15
|
+
|
16
|
+
# @return [Boolean]
|
17
|
+
def feast?
|
18
|
+
rank.priority.to_i == 2
|
19
|
+
end
|
20
|
+
|
21
|
+
# @return [Boolean]
|
22
|
+
def memorial?
|
23
|
+
rank.priority.to_i == 3 && rank.priority <= 3.12
|
24
|
+
end
|
25
|
+
|
26
|
+
# @return [Boolean]
|
27
|
+
def optional_memorial?
|
28
|
+
rank == Ranks::MEMORIAL_OPTIONAL
|
29
|
+
end
|
30
|
+
|
31
|
+
# @return [Boolean]
|
32
|
+
def obligatory_memorial?
|
33
|
+
memorial? && !optional_memorial?
|
34
|
+
end
|
35
|
+
|
36
|
+
# @return [Boolean]
|
37
|
+
# @since 0.6.0
|
38
|
+
def ferial?
|
39
|
+
rank == Ranks::FERIAL ||
|
40
|
+
rank == Ranks::FERIAL_PRIVILEGED
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -45,8 +45,8 @@ module CalendariumRomanum
|
|
45
45
|
|
46
46
|
# Adds a new {Celebration}
|
47
47
|
#
|
48
|
-
# @param month [
|
49
|
-
# @param day [
|
48
|
+
# @param month [Integer]
|
49
|
+
# @param day [Integer]
|
50
50
|
# @param celebration [Celebration]
|
51
51
|
# @return [void]
|
52
52
|
# @raise [ArgumentError]
|
@@ -84,8 +84,8 @@ module CalendariumRomanum
|
|
84
84
|
|
85
85
|
# Replaces content of the given day by given {Celebration}s
|
86
86
|
#
|
87
|
-
# @param month [
|
88
|
-
# @param day [
|
87
|
+
# @param month [Integer]
|
88
|
+
# @param day [Integer]
|
89
89
|
# @param celebrations [Array<Celebration>]
|
90
90
|
# @param symbol_uniqueness [true|false]
|
91
91
|
# allows disabling symbol uniqueness check.
|
@@ -150,8 +150,8 @@ module CalendariumRomanum
|
|
150
150
|
# @overload get(date)
|
151
151
|
# @param date[AbstractDate, Date]
|
152
152
|
# @overload get(month, day)
|
153
|
-
# @param month [
|
154
|
-
# @param day [
|
153
|
+
# @param month [Integer]
|
154
|
+
# @param day [Integer]
|
155
155
|
# @return (see #[])
|
156
156
|
def get(*args)
|
157
157
|
if args.size == 1 && args[0].is_a?(Date)
|
@@ -179,7 +179,7 @@ module CalendariumRomanum
|
|
179
179
|
|
180
180
|
# Returns count of _days_ with {Celebration}s filled
|
181
181
|
#
|
182
|
-
# @return [
|
182
|
+
# @return [Integer]
|
183
183
|
def size
|
184
184
|
@days.size
|
185
185
|
end
|
@@ -219,7 +219,8 @@ module CalendariumRomanum
|
|
219
219
|
@days.each_pair do |date,celebrations|
|
220
220
|
celebrations.each do |celebration|
|
221
221
|
if @symbols.include?(celebration.symbol) &&
|
222
|
-
!duplicates.include?(celebration.symbol)
|
222
|
+
!duplicates.include?(celebration.symbol) &&
|
223
|
+
!celebration.symbol.nil?
|
223
224
|
duplicates << celebration.symbol
|
224
225
|
end
|
225
226
|
|
@@ -15,8 +15,12 @@ module CalendariumRomanum
|
|
15
15
|
RANK_CODES = {
|
16
16
|
nil => Ranks::MEMORIAL_OPTIONAL, # default
|
17
17
|
'm' => Ranks::MEMORIAL_GENERAL,
|
18
|
+
'mp' => Ranks::MEMORIAL_PROPER,
|
18
19
|
'f' => Ranks::FEAST_GENERAL,
|
19
|
-
'
|
20
|
+
'fl' => Ranks::FEAST_LORD_GENERAL,
|
21
|
+
'fp' => Ranks::FEAST_PROPER,
|
22
|
+
's' => Ranks::SOLEMNITY_GENERAL,
|
23
|
+
'sp' => Ranks::SOLEMNITY_PROPER,
|
20
24
|
}.freeze
|
21
25
|
|
22
26
|
# @api private
|
@@ -109,12 +113,12 @@ module CalendariumRomanum
|
|
109
113
|
def line_regexp
|
110
114
|
@line_regexp ||=
|
111
115
|
begin
|
112
|
-
rank_letters = RANK_CODES.keys.compact.join('')
|
116
|
+
rank_letters = RANK_CODES.keys.compact.join('|')
|
113
117
|
colour_letters = COLOUR_CODES.keys.compact.join('')
|
114
118
|
|
115
119
|
Regexp.new(
|
116
120
|
'^((?<month>\d+)\/)?(?<day>\d+)' + # date
|
117
|
-
'(\s+(?<rank_char>
|
121
|
+
'(\s+(?<rank_char>' + rank_letters + ')?(?<rank_num>\d\.\d{1,2})?)?' + # rank (optional)
|
118
122
|
'(\s+(?<colour>[' + colour_letters + ']))?' + # colour (optional)
|
119
123
|
'(\s+(?<symbol>[\w]{2,}))?' + # symbol (optional)
|
120
124
|
'\s*:(?<title>.*)$', # title
|
@@ -0,0 +1,119 @@
|
|
1
|
+
require 'yaml'
|
2
|
+
|
3
|
+
module CalendariumRomanum
|
4
|
+
|
5
|
+
# Understands a custom plaintext calendar format
|
6
|
+
# and knows how to transform the {Celebration}s in a
|
7
|
+
# {Sanctorale} to this format.
|
8
|
+
#
|
9
|
+
# For specification of the data format see {file:data/README.md}
|
10
|
+
# of the data directory, For a complete example see e.g.
|
11
|
+
# {file:universal-en.txt the file describing General Roman Calendar}.
|
12
|
+
#
|
13
|
+
# @since 0.8.0
|
14
|
+
class SanctoraleWriter
|
15
|
+
|
16
|
+
# @api private
|
17
|
+
RANK_CODES = {
|
18
|
+
Ranks::TRIDUUM => 's1.1',
|
19
|
+
Ranks::PRIMARY => 's1.2',
|
20
|
+
Ranks::SOLEMNITY_GENERAL => 's',
|
21
|
+
Ranks::SOLEMNITY_PROPER => 's1.4',
|
22
|
+
|
23
|
+
Ranks::FEAST_LORD_GENERAL => 'f2.5',
|
24
|
+
Ranks::SUNDAY_UNPRIVILEGED => 'f2.6',
|
25
|
+
Ranks::FEAST_GENERAL => 'f',
|
26
|
+
Ranks::FEAST_PROPER => 'f2.8',
|
27
|
+
Ranks::FERIAL_PRIVILEGED => 'f2.9',
|
28
|
+
|
29
|
+
Ranks::MEMORIAL_GENERAL => 'm',
|
30
|
+
Ranks::MEMORIAL_PROPER => 'm3.11',
|
31
|
+
Ranks::MEMORIAL_OPTIONAL => 'm3.12',
|
32
|
+
Ranks::FERIAL => 'm3.13',
|
33
|
+
|
34
|
+
Ranks::COMMEMORATION => '4.0'
|
35
|
+
}.freeze
|
36
|
+
|
37
|
+
# @api private
|
38
|
+
COLOUR_CODES = {
|
39
|
+
Colours::WHITE => 'W',
|
40
|
+
Colours::VIOLET => 'V',
|
41
|
+
Colours::GREEN => 'G',
|
42
|
+
Colours::RED => 'R'
|
43
|
+
}.freeze
|
44
|
+
|
45
|
+
# Write to an object which understands +#<<+
|
46
|
+
#
|
47
|
+
# @param src [Sanctorale]
|
48
|
+
# source of the loaded data
|
49
|
+
# @param dest [String, File, #<<]
|
50
|
+
# object to populate. If not provided, a new {String}
|
51
|
+
# instance will be created and returned
|
52
|
+
# @return [String]
|
53
|
+
def write(src, dest = nil)
|
54
|
+
dest ||= String.new
|
55
|
+
|
56
|
+
# Write metadata to YAML if present
|
57
|
+
unless src.metadata.nil? || src.metadata.empty?
|
58
|
+
dest << src.metadata.to_yaml
|
59
|
+
dest << "---\n"
|
60
|
+
end
|
61
|
+
|
62
|
+
# Write each celebration, grouped by month with headings
|
63
|
+
current_month = 0
|
64
|
+
src.each_day.sort_by{ |date, _| date }.each do |date, celebrations|
|
65
|
+
if date.month > current_month
|
66
|
+
current_month = date.month
|
67
|
+
dest << "\n= #{current_month}\n"
|
68
|
+
end
|
69
|
+
|
70
|
+
celebrations.each do |c|
|
71
|
+
dest << celebration_line(date, c)
|
72
|
+
dest << "\n"
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
dest
|
77
|
+
end
|
78
|
+
|
79
|
+
alias write_to_string write
|
80
|
+
|
81
|
+
# Write to a filesystem path
|
82
|
+
#
|
83
|
+
# @param sanctorale [Sanctorale]
|
84
|
+
# @param filename [String]
|
85
|
+
# @param encoding [String]
|
86
|
+
# @return [void]
|
87
|
+
def write_to_file(sanctorale, filename, encoding = 'utf-8')
|
88
|
+
File.open(filename, 'w', encoding: encoding) do |f|
|
89
|
+
write(sanctorale, f)
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
private
|
94
|
+
|
95
|
+
# Convert a {Celebration} to a {String} for writing
|
96
|
+
def celebration_line(date, celebration)
|
97
|
+
line = "#{date.day} "
|
98
|
+
|
99
|
+
unless celebration.rank == Ranks::MEMORIAL_OPTIONAL
|
100
|
+
code = RANK_CODES[celebration.rank]
|
101
|
+
line << "#{code} "
|
102
|
+
end
|
103
|
+
|
104
|
+
unless celebration.colour == Colours::WHITE
|
105
|
+
code = COLOUR_CODES[celebration.colour]
|
106
|
+
line << "#{code} "
|
107
|
+
end
|
108
|
+
|
109
|
+
unless celebration.symbol.nil?
|
110
|
+
line << "#{celebration.symbol} "
|
111
|
+
end
|
112
|
+
|
113
|
+
line << ': '
|
114
|
+
line << celebration.title
|
115
|
+
|
116
|
+
line
|
117
|
+
end
|
118
|
+
end
|
119
|
+
end
|
@@ -14,7 +14,7 @@ module CalendariumRomanum
|
|
14
14
|
SUNDAY_TRANSFERABLE_SOLEMNITIES =
|
15
15
|
%i(epiphany ascension corpus_christi).freeze
|
16
16
|
|
17
|
-
# @param year [
|
17
|
+
# @param year [Integer]
|
18
18
|
# the civil year when the liturgical year _begins_
|
19
19
|
# @param extensions [Array<#each_celebration>]
|
20
20
|
# extensions implementing custom temporale celebrations
|
@@ -32,14 +32,14 @@ module CalendariumRomanum
|
|
32
32
|
prepare_solemnities
|
33
33
|
end
|
34
34
|
|
35
|
-
# @return [
|
35
|
+
# @return [Integer]
|
36
36
|
attr_reader :year
|
37
37
|
|
38
38
|
class << self
|
39
39
|
# Determines liturgical year for the given date
|
40
40
|
#
|
41
41
|
# @param date [Date]
|
42
|
-
# @return [
|
42
|
+
# @return [Integer]
|
43
43
|
def liturgical_year(date)
|
44
44
|
year = date.year
|
45
45
|
temporale = Temporale.new year
|
@@ -64,8 +64,16 @@ module CalendariumRomanum
|
|
64
64
|
# with sensible defaults
|
65
65
|
#
|
66
66
|
# See {Celebration#initialize} for argument description.
|
67
|
-
def create_celebration(title, rank, colour, symbol: nil, date: nil)
|
68
|
-
Celebration.new(
|
67
|
+
def create_celebration(title, rank, colour, symbol: nil, date: nil, sunday: nil)
|
68
|
+
Celebration.new(
|
69
|
+
title: title,
|
70
|
+
rank: rank,
|
71
|
+
colour: colour,
|
72
|
+
symbol: symbol,
|
73
|
+
date: date,
|
74
|
+
cycle: :temporale,
|
75
|
+
sunday: sunday
|
76
|
+
)
|
69
77
|
end
|
70
78
|
|
71
79
|
C = Struct.new(:date_method, :celebration)
|
@@ -218,20 +226,24 @@ module CalendariumRomanum
|
|
218
226
|
def season(date)
|
219
227
|
range_check date
|
220
228
|
|
221
|
-
if
|
229
|
+
if first_advent_sunday <= date &&
|
222
230
|
nativity > date
|
223
231
|
Seasons::ADVENT
|
224
232
|
|
225
|
-
elsif
|
226
|
-
|
233
|
+
elsif nativity <= date &&
|
234
|
+
baptism_of_lord >= date
|
227
235
|
Seasons::CHRISTMAS
|
228
236
|
|
229
|
-
elsif
|
230
|
-
|
237
|
+
elsif ash_wednesday <= date &&
|
238
|
+
good_friday > date
|
231
239
|
Seasons::LENT
|
232
240
|
|
233
|
-
elsif
|
234
|
-
|
241
|
+
elsif good_friday <= date &&
|
242
|
+
easter_sunday >= date
|
243
|
+
Seasons::TRIDUUM
|
244
|
+
|
245
|
+
elsif easter_sunday < date &&
|
246
|
+
pentecost >= date
|
235
247
|
Seasons::EASTER
|
236
248
|
|
237
249
|
else
|
@@ -251,8 +263,10 @@ module CalendariumRomanum
|
|
251
263
|
nativity
|
252
264
|
when Seasons::LENT
|
253
265
|
ash_wednesday
|
266
|
+
when Seasons::TRIDUUM
|
267
|
+
good_friday
|
254
268
|
when Seasons::EASTER
|
255
|
-
easter_sunday
|
269
|
+
easter_sunday + 1
|
256
270
|
when Seasons::ORDINARY # ordinary time
|
257
271
|
baptism_of_lord + 1
|
258
272
|
else
|
@@ -272,11 +286,13 @@ module CalendariumRomanum
|
|
272
286
|
|
273
287
|
week = date_difference(date, week1_beginning) / WEEK + 1
|
274
288
|
|
275
|
-
if seasonn == Seasons::ORDINARY
|
289
|
+
if seasonn == Seasons::ORDINARY || seasonn == Seasons::EASTER
|
276
290
|
# ordinary time does not begin with Sunday, but the first week
|
277
291
|
# is week 1, not 0
|
278
292
|
week += 1
|
293
|
+
end
|
279
294
|
|
295
|
+
if seasonn == Seasons::ORDINARY
|
280
296
|
if date > pentecost
|
281
297
|
weeks_after_date = date_difference(Dates.first_advent_sunday(@year + 1), date) / WEEK
|
282
298
|
week = 34 - weeks_after_date
|
@@ -301,8 +317,8 @@ module CalendariumRomanum
|
|
301
317
|
# @overload get(date)
|
302
318
|
# @param date [Date]
|
303
319
|
# @overload get(month, day)
|
304
|
-
# @param month [
|
305
|
-
# @param day [
|
320
|
+
# @param month [Integer]
|
321
|
+
# @param day [Integer]
|
306
322
|
# @return (see #[])
|
307
323
|
def get(*args)
|
308
324
|
if args.size == 1 && args[0].is_a?(Date)
|
@@ -318,6 +334,17 @@ module CalendariumRomanum
|
|
318
334
|
self[date]
|
319
335
|
end
|
320
336
|
|
337
|
+
# Enumerates dates and celebrations
|
338
|
+
#
|
339
|
+
# @yield [Date, Celebration]
|
340
|
+
# @return [void, Enumerator] if called without a block, returns +Enumerator+
|
341
|
+
# @since 0.8.0
|
342
|
+
def each_day
|
343
|
+
return to_enum(__method__) unless block_given?
|
344
|
+
|
345
|
+
date_range.each {|date| yield date, self[date] }
|
346
|
+
end
|
347
|
+
|
321
348
|
# @return [Boolean]
|
322
349
|
# @since 0.6.0
|
323
350
|
def ==(b)
|
@@ -348,7 +375,7 @@ module CalendariumRomanum
|
|
348
375
|
week = Ordinalizer.ordinal season_week(seas, date)
|
349
376
|
title = I18n.t "temporale.#{seas.to_sym}.sunday", week: week
|
350
377
|
|
351
|
-
self.class.create_celebration title, rank, seas.colour
|
378
|
+
self.class.create_celebration title, rank, seas.colour, sunday: true
|
352
379
|
end
|
353
380
|
|
354
381
|
def ferial(date)
|