calendarium-romanum 0.4.0 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/calendariumrom +1 -1
- data/config/locales/cs.yml +1 -0
- data/config/locales/en.yml +1 -0
- data/config/locales/fr.yml +1 -0
- data/config/locales/it.yml +1 -0
- data/config/locales/la.yml +1 -0
- data/data/czech-cs.txt +2 -1
- data/data/universal-la.txt +2 -0
- data/lib/calendarium-romanum.rb +24 -22
- data/lib/calendarium-romanum/calendar.rb +66 -16
- data/lib/calendarium-romanum/cli.rb +84 -52
- data/lib/calendarium-romanum/data.rb +12 -12
- data/lib/calendarium-romanum/day.rb +35 -14
- data/lib/calendarium-romanum/enum.rb +2 -4
- data/lib/calendarium-romanum/enums.rb +1 -1
- data/lib/calendarium-romanum/errors.rb +4 -0
- data/lib/calendarium-romanum/ordinalizer.rb +13 -1
- data/lib/calendarium-romanum/rank.rb +5 -5
- data/lib/calendarium-romanum/sanctorale.rb +2 -2
- data/lib/calendarium-romanum/sanctoraleloader.rb +31 -24
- data/lib/calendarium-romanum/temporale.rb +64 -83
- data/lib/calendarium-romanum/temporale/celebration_factory.rb +48 -0
- data/lib/calendarium-romanum/temporale/dates.rb +14 -14
- data/lib/calendarium-romanum/util.rb +22 -1
- data/lib/calendarium-romanum/version.rb +4 -1
- data/spec/calendar_spec.rb +232 -3
- data/spec/celebration_factory_spec.rb +16 -0
- data/spec/celebration_spec.rb +20 -0
- data/spec/cli_spec.rb +140 -11
- data/spec/date_parser_spec.rb +68 -0
- data/spec/date_spec.rb +8 -8
- data/spec/day_spec.rb +57 -8
- data/spec/i18n_spec.rb +0 -1
- data/spec/ordinalizer_spec.rb +29 -15
- data/spec/readme_spec.rb +4 -0
- data/spec/sanctorale_spec.rb +3 -3
- data/spec/sanctoraleloader_spec.rb +16 -11
- data/spec/spec_helper.rb +11 -0
- data/spec/temporale_spec.rb +56 -3
- metadata +6 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4faa0e6242f3815ad7bdc2b32c13c61f203cd5e6
|
4
|
+
data.tar.gz: 78018940d6ae8129c0625db963543991bf980350
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f3b27ee6cd3919d97b6a819baa88cf694a9eedf9b5182ddf766dedf39a9ef85fef8c90962d6fee8417ac3261d0062d158bb60f9cd7a801fcd67f7e1d2d816e85
|
7
|
+
data.tar.gz: 2cdfdb4bb9d604e5c1b6e59e604719634458c5b0859c79d70d2cb6fe80bf29139ec5400273f83f7e81854144b88cc75affb49f4dfd25681648f1464dc68fb9d7
|
data/bin/calendariumrom
CHANGED
data/config/locales/cs.yml
CHANGED
data/config/locales/en.yml
CHANGED
data/config/locales/fr.yml
CHANGED
data/config/locales/it.yml
CHANGED
data/config/locales/la.yml
CHANGED
data/data/czech-cs.txt
CHANGED
@@ -204,6 +204,7 @@ country: cz
|
|
204
204
|
7 m : Panny Marie Růžencové
|
205
205
|
9 R : Sv. Dionýsia, biskupa, a druhů, mučedníků
|
206
206
|
9 : Sv. Jana Leonardiho, kněze
|
207
|
+
11 : Sv. Jana XXIII., papeže
|
207
208
|
12 : Sv. Radima, biskupa
|
208
209
|
14 R : Sv. Kalista I., papeže a mučedníka
|
209
210
|
15 m : Sv. Terezie od Ježíše, panny a učitelky církve
|
@@ -214,7 +215,7 @@ country: cz
|
|
214
215
|
19 R : Sv. Jana de Brébeuf a Izáka Joguese, kněží, a druhů, mučedníků
|
215
216
|
19 : Sv. Pavla od Kříže, kněze
|
216
217
|
21 : Bl. Karla Rakouského
|
217
|
-
22 :
|
218
|
+
22 : Sv. Jana Pavla II., papeže
|
218
219
|
23 : Sv. Jana Kapistránského, kněze
|
219
220
|
24 : Sv. Antonína Marie Klareta, biskupa
|
220
221
|
28 f R : Sv. Šimona a Judy, apoštolů
|
data/data/universal-la.txt
CHANGED
@@ -185,6 +185,7 @@ locale: la
|
|
185
185
|
7 m : B. Mariae Virginis a Rosario
|
186
186
|
9 R : Ss. Dionysii, episcopi, et sociorum, martyrum
|
187
187
|
9 : S. Ioannis Leonardi, presbyteri
|
188
|
+
11 : S. Ioannis XXIII, papae
|
188
189
|
14 R : S. Callisti I, papae et martyris
|
189
190
|
15 m : S. Teresiae a Iesu, virginis et Ecclesiae doctoris
|
190
191
|
16 : S. Hedvigis, religiosae
|
@@ -193,6 +194,7 @@ locale: la
|
|
193
194
|
18 f R : S. Lucae, evangelistae
|
194
195
|
19 R : Ss. Ioannis de Brébeuf et Isaac Jogues, presbyterorum, et sociorum, martyrum
|
195
196
|
19 : S. Pauli a Cruce, presbyteri
|
197
|
+
22 : S. Ioannis Pauli II, papae
|
196
198
|
23 : S. Ioannis de Capestrano, presbyteri
|
197
199
|
24 : S. Antonii Mariae Claret, episcopi
|
198
200
|
28 f R : Ss. Simonis et Iudae, apostolorum
|
data/lib/calendarium-romanum.rb
CHANGED
@@ -1,23 +1,25 @@
|
|
1
|
-
%w
|
2
|
-
version
|
3
|
-
i18n_setup
|
4
|
-
rank
|
5
|
-
enum
|
6
|
-
enums
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
temporale/
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
1
|
+
%w(
|
2
|
+
version
|
3
|
+
i18n_setup
|
4
|
+
rank
|
5
|
+
enum
|
6
|
+
enums
|
7
|
+
errors
|
8
|
+
data
|
9
|
+
day
|
10
|
+
calendar
|
11
|
+
perpetual_calendar
|
12
|
+
temporale/dates
|
13
|
+
temporale/celebration_factory
|
14
|
+
temporale/extensions/christ_eternal_priest
|
15
|
+
temporale
|
16
|
+
sanctorale
|
17
|
+
sanctoraleloader
|
18
|
+
sanctorale_factory
|
19
|
+
transfers
|
20
|
+
abstract_date
|
21
|
+
util
|
22
|
+
ordinalizer
|
23
|
+
).each do |f|
|
24
|
+
require_relative File.join('calendarium-romanum', f)
|
23
25
|
end
|
@@ -14,18 +14,20 @@ module CalendariumRomanum
|
|
14
14
|
# year: Integer
|
15
15
|
# returns a calendar for the liturgical year beginning with
|
16
16
|
# Advent of the specified civil year.
|
17
|
-
def initialize(year, sanctorale=nil, temporale=nil)
|
17
|
+
def initialize(year, sanctorale = nil, temporale = nil, vespers: false)
|
18
18
|
if year < (EFFECTIVE_FROM.year - 1)
|
19
19
|
raise system_not_effective
|
20
20
|
end
|
21
21
|
|
22
22
|
if temporale && temporale.year != year
|
23
|
-
raise ArgumentError.new(
|
23
|
+
raise ArgumentError.new('Temporale year must be the same as year.')
|
24
24
|
end
|
25
25
|
|
26
26
|
@year = year
|
27
27
|
@sanctorale = sanctorale || Sanctorale.new
|
28
28
|
@temporale = temporale || Temporale.new(year)
|
29
|
+
@populate_vespers = vespers
|
30
|
+
|
29
31
|
@transferred = Transfers.new(@temporale, @sanctorale)
|
30
32
|
end
|
31
33
|
|
@@ -33,15 +35,15 @@ module CalendariumRomanum
|
|
33
35
|
def mk_date(*args)
|
34
36
|
ex = TypeError.new('Date, DateTime or three Integers expected')
|
35
37
|
|
36
|
-
if args.size == 3
|
38
|
+
if args.size == 3
|
37
39
|
args.each do |a|
|
38
40
|
unless a.is_a? Integer
|
39
41
|
raise ex
|
40
42
|
end
|
41
43
|
end
|
42
|
-
return Date.new
|
44
|
+
return Date.new(*args)
|
43
45
|
|
44
|
-
elsif args.size == 1
|
46
|
+
elsif args.size == 1
|
45
47
|
a = args.first
|
46
48
|
unless a.is_a? Date
|
47
49
|
raise ex
|
@@ -56,7 +58,7 @@ module CalendariumRomanum
|
|
56
58
|
# creates a Calendar for the liturgical year including given
|
57
59
|
# date
|
58
60
|
def for_day(date, *constructor_args)
|
59
|
-
|
61
|
+
new(Temporale.liturgical_year(date), *constructor_args)
|
60
62
|
end
|
61
63
|
end # class << self
|
62
64
|
|
@@ -70,21 +72,29 @@ module CalendariumRomanum
|
|
70
72
|
return false
|
71
73
|
end
|
72
74
|
|
73
|
-
|
75
|
+
year == obj.year
|
76
|
+
end
|
77
|
+
|
78
|
+
def [](args)
|
79
|
+
if(args.is_a?(Range))
|
80
|
+
args.map{|date| day(date)}
|
81
|
+
else
|
82
|
+
day(*args)
|
83
|
+
end
|
74
84
|
end
|
75
85
|
|
76
86
|
# accepts date information represented as
|
77
87
|
# Date, DateTime, or two to three integers
|
78
88
|
# (month - day or year - month - day);
|
79
89
|
# returns filled Day for the specified day
|
80
|
-
def day(*args)
|
90
|
+
def day(*args, vespers: false)
|
81
91
|
if args.size == 2
|
82
92
|
date = Date.new(@year, *args)
|
83
93
|
unless @temporale.date_range.include? date
|
84
94
|
date = Date.new(@year + 1, *args)
|
85
95
|
end
|
86
96
|
else
|
87
|
-
date = self.class.mk_date
|
97
|
+
date = self.class.mk_date(*args)
|
88
98
|
range_check date
|
89
99
|
end
|
90
100
|
|
@@ -92,13 +102,26 @@ module CalendariumRomanum
|
|
92
102
|
raise system_not_effective
|
93
103
|
end
|
94
104
|
|
105
|
+
celebrations = celebrations_for(date)
|
106
|
+
vespers_celebration = nil
|
107
|
+
if @populate_vespers || vespers
|
108
|
+
begin
|
109
|
+
vespers_celebration = first_vespers_on(date, celebrations)
|
110
|
+
rescue RangeError
|
111
|
+
# there is exactly one possible case when
|
112
|
+
# range_check(date) passes and range_check(date + 1) fails:
|
113
|
+
vespers_celebration = Temporale::CelebrationFactory.first_advent_sunday
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
95
117
|
s = @temporale.season(date)
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
118
|
+
Day.new(
|
119
|
+
date: date,
|
120
|
+
season: s,
|
121
|
+
season_week: @temporale.season_week(s, date),
|
122
|
+
celebrations: celebrations,
|
123
|
+
vespers: vespers_celebration
|
124
|
+
)
|
102
125
|
end
|
103
126
|
|
104
127
|
# Sunday lectionary cycle
|
@@ -139,10 +162,37 @@ module CalendariumRomanum
|
|
139
162
|
end
|
140
163
|
st.unshift t
|
141
164
|
return st
|
165
|
+
elsif t.symbol == :immaculate_heart &&
|
166
|
+
[Ranks::MEMORIAL_GENERAL, Ranks::MEMORIAL_PROPER].include?(st.first.rank)
|
167
|
+
optional_memorials = ([t] + st).collect do |celebration|
|
168
|
+
celebration.change rank: Ranks::MEMORIAL_OPTIONAL
|
169
|
+
end
|
170
|
+
ferial = temporale.send :ferial, date # ugly and evil
|
171
|
+
return [ferial] + optional_memorials
|
172
|
+
end
|
173
|
+
end
|
174
|
+
|
175
|
+
[t]
|
176
|
+
end
|
177
|
+
|
178
|
+
def first_vespers_on(date, celebrations)
|
179
|
+
tomorrow = date + 1
|
180
|
+
tomorrow_celebrations = celebrations_for(tomorrow)
|
181
|
+
|
182
|
+
c = tomorrow_celebrations.first
|
183
|
+
if c.rank >= Ranks::SOLEMNITY_PROPER ||
|
184
|
+
c.rank == Ranks::SUNDAY_UNPRIVILEGED ||
|
185
|
+
(c.rank == Ranks::FEAST_LORD_GENERAL && tomorrow.sunday?)
|
186
|
+
if c.symbol == :ash_wednesday || c.symbol == :good_friday
|
187
|
+
return nil
|
188
|
+
end
|
189
|
+
|
190
|
+
if c.rank > celebrations.first.rank || c.symbol == :easter_sunday
|
191
|
+
return c
|
142
192
|
end
|
143
193
|
end
|
144
194
|
|
145
|
-
|
195
|
+
nil
|
146
196
|
end
|
147
197
|
|
148
198
|
def system_not_effective
|
@@ -8,39 +8,37 @@ module CalendariumRomanum
|
|
8
8
|
desc 'query 2007-06-05', 'show calendar information for a specified date'
|
9
9
|
option :calendar, default: 'universal-en', aliases: :c
|
10
10
|
option :locale, default: 'en', aliases: :l
|
11
|
-
def query(date_str=nil)
|
11
|
+
def query(date_str = nil)
|
12
12
|
I18n.locale = options[:locale]
|
13
|
+
calendar = options[:calendar]
|
14
|
+
if File.exist?(calendar)
|
15
|
+
begin
|
16
|
+
sanctorale = SanctoraleLoader.new.load_from_file(calendar)
|
17
|
+
rescue CalendariumRomanum::InvalidDataError
|
18
|
+
die! 'Invalid file format.'
|
19
|
+
end
|
20
|
+
else
|
21
|
+
data_file = Data[calendar]
|
13
22
|
|
14
|
-
|
15
|
-
|
16
|
-
STDERR.puts 'Invalid calendar. See subcommand `calendars` for valid options.'
|
17
|
-
exit 1
|
18
|
-
end
|
19
|
-
sanctorale = data_file.load
|
20
|
-
|
21
|
-
date =
|
22
|
-
if date_str
|
23
|
-
begin
|
24
|
-
Date.parse(date_str)
|
25
|
-
rescue ArgumentError
|
26
|
-
STDERR.puts 'Invalid date.'
|
27
|
-
exit 1
|
28
|
-
end
|
29
|
-
else
|
30
|
-
Date.today
|
23
|
+
if data_file.nil?
|
24
|
+
die! "Invalid calendar. Either loading a calendar from filesystem did not succeed, \n or a preinstalled calendar was specified which doesn't exist. See subcommand `calendars` for valid options."
|
31
25
|
end
|
32
|
-
|
33
|
-
|
26
|
+
sanctorale = data_file.load
|
27
|
+
end
|
34
28
|
|
35
|
-
|
36
|
-
puts "season: #{day.season}"
|
37
|
-
puts
|
29
|
+
pcal = PerpetualCalendar.new sanctorale: sanctorale
|
38
30
|
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
31
|
+
if date_str
|
32
|
+
begin
|
33
|
+
parsed_date = DateParser.new(date_str)
|
34
|
+
parsed_date.date_range.each do |day|
|
35
|
+
print_single_date(pcal, day)
|
36
|
+
end
|
37
|
+
rescue ArgumentError
|
38
|
+
die! 'Invalid date.'
|
39
|
+
end
|
40
|
+
else
|
41
|
+
print_single_date(pcal, Date.today)
|
44
42
|
end
|
45
43
|
end
|
46
44
|
|
@@ -54,51 +52,85 @@ module CalendariumRomanum
|
|
54
52
|
loader = SanctoraleLoader.new
|
55
53
|
files.each do |path|
|
56
54
|
s = Sanctorale.new
|
57
|
-
|
55
|
+
begin
|
56
|
+
loader.load_from_file path, s
|
57
|
+
rescue Errno::ENOENT, InvalidDataError => err
|
58
|
+
die! err.message
|
59
|
+
end
|
58
60
|
end
|
59
61
|
end
|
60
62
|
|
61
63
|
desc 'cmp FILE1, FILE2', 'detect differences in rank and colour of corresponding celebrations'
|
62
64
|
def cmp(a, b)
|
63
65
|
loader = SanctoraleLoader.new
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
s = Sanctorale.new
|
68
|
-
loader.load_from_file source, s
|
69
|
-
sanctorales << s
|
70
|
-
end
|
66
|
+
paths = [a, b]
|
67
|
+
sanctoralia = paths.collect {|source| loader.load_from_file source }
|
68
|
+
names = paths.collect {|source| File.basename source }
|
71
69
|
|
72
70
|
# a leap year must be chosen in order to iterate over
|
73
71
|
# all possible days of a Sanctorale
|
74
72
|
Year.new(1990).each_day do |d|
|
75
|
-
|
76
|
-
if celebs.find {|cc| cc.nil? }
|
77
|
-
next
|
78
|
-
end
|
73
|
+
a, b = sanctoralia.collect {|s| s.get(d) }
|
79
74
|
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
75
|
+
0.upto([a.size, b.size].max - 1) do |i|
|
76
|
+
ca = a[i]
|
77
|
+
cb = b[i]
|
78
|
+
compared = [ca, cb]
|
79
|
+
differences = []
|
84
80
|
|
85
|
-
|
86
|
-
|
81
|
+
if compared.index(&:nil?)
|
82
|
+
notnili = compared.index {|c| !c.nil? }
|
87
83
|
|
88
|
-
|
89
|
-
puts "#{
|
90
|
-
|
91
|
-
print_celebration cb
|
84
|
+
print date(d)
|
85
|
+
puts " only in #{names[notnili]}:"
|
86
|
+
puts celebration(compared[notnili])
|
92
87
|
puts
|
88
|
+
next
|
93
89
|
end
|
90
|
+
|
91
|
+
differences << 'rank' if ca.rank != cb.rank
|
92
|
+
differences << 'colour' if ca.colour != cb.colour
|
93
|
+
|
94
|
+
next if differences.empty?
|
95
|
+
print date(d)
|
96
|
+
puts " differs in #{differences.join(', ')}"
|
97
|
+
puts celebration(ca)
|
98
|
+
puts celebration(cb)
|
99
|
+
puts
|
94
100
|
end
|
95
101
|
end
|
96
102
|
end
|
97
103
|
|
98
104
|
private
|
99
105
|
|
100
|
-
def
|
101
|
-
|
106
|
+
def date(d)
|
107
|
+
"#{d.month}/#{d.day}"
|
108
|
+
end
|
109
|
+
|
110
|
+
def celebration(c)
|
111
|
+
"#{c.rank.priority} #{c.colour.symbol} | #{c.title}"
|
112
|
+
end
|
113
|
+
|
114
|
+
def die!(message, code = 1)
|
115
|
+
STDERR.puts message
|
116
|
+
exit code
|
102
117
|
end
|
118
|
+
|
119
|
+
def print_single_date(calendar, date)
|
120
|
+
day = calendar.day date
|
121
|
+
|
122
|
+
puts date
|
123
|
+
puts "season: #{day.season.name}"
|
124
|
+
puts
|
125
|
+
|
126
|
+
rank_length = day.celebrations.collect {|c| c.rank.short_desc.nil? ? 0 : c.rank.short_desc.size }.max
|
127
|
+
day.celebrations.each do |c|
|
128
|
+
next if c.rank.short_desc.nil?
|
129
|
+
print c.rank.short_desc.rjust(rank_length)
|
130
|
+
print ' : '
|
131
|
+
puts c.title
|
132
|
+
end
|
133
|
+
end
|
134
|
+
|
103
135
|
end
|
104
136
|
end
|