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
data/spec/readme_spec.rb
CHANGED
@@ -36,6 +36,10 @@ end
|
|
36
36
|
|
37
37
|
%w(README.md data/README.md).each do |path|
|
38
38
|
describe path do
|
39
|
+
before :each do
|
40
|
+
STDERR.stub(:puts)
|
41
|
+
end
|
42
|
+
|
39
43
|
readme_path = File.expand_path('../../' + path, __FILE__)
|
40
44
|
readme = File.read readme_path
|
41
45
|
doc = MarkdownDocument.new readme
|
data/spec/sanctorale_spec.rb
CHANGED
@@ -12,7 +12,7 @@ describe CR::Sanctorale do
|
|
12
12
|
describe '#get' do
|
13
13
|
describe 'for an empty day' do
|
14
14
|
it 'returns an Array' do
|
15
|
-
expect(s.get(1,3)).to be_an Array
|
15
|
+
expect(s.get(1, 3)).to be_an Array
|
16
16
|
end
|
17
17
|
end
|
18
18
|
|
@@ -31,8 +31,8 @@ describe CR::Sanctorale do
|
|
31
31
|
|
32
32
|
it 'may have more CR::Celebrations for a day' do
|
33
33
|
[
|
34
|
-
|
35
|
-
|
34
|
+
'S. Fabiani, papae et martyris',
|
35
|
+
'S. Sebastiani, martyris'
|
36
36
|
].each {|t| s.add 1, 20, CR::Celebration.new(t, CR::Ranks::MEMORIAL_OPTIONAL) }
|
37
37
|
expect(s.get(1, 20).size).to eq 2
|
38
38
|
end
|
@@ -1,7 +1,6 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe CR::SanctoraleLoader do
|
4
|
-
|
5
4
|
before :each do
|
6
5
|
@s = CR::Sanctorale.new
|
7
6
|
@l = CR::SanctoraleLoader.new
|
@@ -43,7 +42,7 @@ describe CR::SanctoraleLoader do
|
|
43
42
|
|
44
43
|
describe '#load_from_file' do
|
45
44
|
it 'loads something from file' do
|
46
|
-
@l.load_from_file(File.join(%w
|
45
|
+
@l.load_from_file(File.join(%w(data universal-la.txt)), @s)
|
47
46
|
expect(@s.size).to be > 190
|
48
47
|
end
|
49
48
|
end
|
@@ -77,7 +76,6 @@ describe CR::SanctoraleLoader do
|
|
77
76
|
# say we specify a proper calendar of a church dedicated to St. George
|
78
77
|
|
79
78
|
it 'sets rank if specified' do
|
80
|
-
|
81
79
|
str = '4/23 s R : S. Georgii, martyris'
|
82
80
|
@l.load_from_string str, @s
|
83
81
|
celeb = @s.get(4, 23).first
|
@@ -113,58 +111,65 @@ describe CR::SanctoraleLoader do
|
|
113
111
|
str = 'line without standard beginning'
|
114
112
|
expect do
|
115
113
|
@l.load_from_string str, @s
|
116
|
-
end.to raise_exception /Syntax error/
|
114
|
+
end.to raise_exception(CR::InvalidDataError, /Syntax error/)
|
117
115
|
end
|
118
116
|
end
|
119
117
|
|
120
118
|
describe 'syntactically correct data making no sense' do
|
119
|
+
it 'invalid month heading' do
|
120
|
+
str = '= 13'
|
121
|
+
expect do
|
122
|
+
@l.load_from_string str, @s
|
123
|
+
end.to raise_exception(CR::InvalidDataError, /Invalid month/)
|
124
|
+
end
|
125
|
+
|
121
126
|
it 'invalid month' do
|
122
127
|
str = '100/25 f : In conversione S. Pauli, apostoli'
|
123
128
|
expect do
|
124
129
|
@l.load_from_string str, @s
|
125
|
-
end.to raise_exception /Invalid month/
|
130
|
+
end.to raise_exception(CR::InvalidDataError, /Invalid month/)
|
126
131
|
end
|
127
132
|
|
128
133
|
it 'line with day only, without preceding month heading' do
|
129
134
|
str = '25 f : In conversione S. Pauli, apostoli'
|
130
135
|
expect do
|
131
136
|
@l.load_from_string str, @s
|
132
|
-
end.to raise_exception /Invalid month/
|
137
|
+
end.to raise_exception(CR::InvalidDataError, /Invalid month/)
|
133
138
|
end
|
134
139
|
|
135
140
|
it 'invalid day' do
|
136
141
|
str = '1/250 f : In conversione S. Pauli, apostoli'
|
137
142
|
expect do
|
138
143
|
@l.load_from_string str, @s
|
139
|
-
end.to raise_exception /Invalid day/
|
144
|
+
end.to raise_exception(CR::InvalidDataError, /Invalid day/)
|
140
145
|
end
|
141
146
|
|
142
147
|
it 'invalid month heading' do
|
143
148
|
str = '= 0'
|
144
149
|
expect do
|
145
150
|
@l.load_from_string str, @s
|
146
|
-
end.to raise_exception /Invalid month/
|
151
|
+
end.to raise_exception(CR::InvalidDataError, /Invalid month/)
|
147
152
|
end
|
148
153
|
|
149
154
|
it 'invalid rank' do
|
150
155
|
str = '1/25 X : In conversione S. Pauli, apostoli'
|
151
156
|
expect do
|
152
157
|
@l.load_from_string str, @s
|
153
|
-
end.to raise_exception /Syntax error/
|
158
|
+
end.to raise_exception(CR::InvalidDataError, /Syntax error/)
|
154
159
|
end
|
155
160
|
|
156
161
|
it 'invalid numeric rank' do
|
157
162
|
str = '4/23 s8.4 R : S. Georgii, martyris'
|
158
163
|
expect do
|
159
164
|
@l.load_from_string str, @s
|
160
|
-
end.to raise_exception /rank/
|
165
|
+
end.to raise_exception(CR::InvalidDataError, /rank/)
|
161
166
|
end
|
162
167
|
|
163
168
|
it 'invalid combination of rank latter and number' do
|
164
169
|
str = '4/23 m2.5 R : S. Georgii, martyris'
|
165
170
|
expect do
|
166
171
|
@l.load_from_string str, @s
|
167
|
-
end.to raise_exception /rank/
|
172
|
+
end.to raise_exception(CR::InvalidDataError, /rank/)
|
168
173
|
end
|
169
174
|
end
|
170
175
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,3 +1,10 @@
|
|
1
|
+
require 'simplecov'
|
2
|
+
SimpleCov.start do
|
3
|
+
add_filter 'lib/calendarium-romanum/cli.rb'
|
4
|
+
end
|
5
|
+
|
6
|
+
require 'aruba/rspec'
|
7
|
+
|
1
8
|
# This file was generated by the `rspec --init` command. Conventionally, all
|
2
9
|
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
|
3
10
|
# Require this file using `require "spec_helper"` to ensure that it is only
|
@@ -33,3 +40,7 @@ CR = CalendariumRomanum
|
|
33
40
|
|
34
41
|
I18n.enforce_available_locales = true
|
35
42
|
I18n.locale = ENV['LOCALE'] || :en
|
43
|
+
|
44
|
+
# make the gem's executable(s) easily available for aruba
|
45
|
+
gem_bin = File.expand_path('../../bin', __FILE__)
|
46
|
+
ENV['PATH'] = "#{gem_bin}:#{ENV['PATH']}"
|
data/spec/temporale_spec.rb
CHANGED
@@ -2,7 +2,6 @@
|
|
2
2
|
require_relative 'spec_helper'
|
3
3
|
|
4
4
|
describe CR::Temporale do
|
5
|
-
|
6
5
|
before :all do
|
7
6
|
@t = @t12 = described_class.new 2012
|
8
7
|
@t13 = described_class.new 2013
|
@@ -84,6 +83,39 @@ describe CR::Temporale do
|
|
84
83
|
end
|
85
84
|
end
|
86
85
|
|
86
|
+
describe '#season_beginning' do
|
87
|
+
let(:year) { 2016 }
|
88
|
+
let(:options) { {} }
|
89
|
+
let(:t) { described_class.new(year, **options) }
|
90
|
+
|
91
|
+
describe 'unsupported season' do
|
92
|
+
it 'fails' do
|
93
|
+
season = CR::Season.new(:strawberry_season, CR::Colours::RED)
|
94
|
+
expect do
|
95
|
+
t.season_beginning season
|
96
|
+
end.to raise_exception(ArgumentError, /unsupported season/)
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
describe 'Ordinary Time' do
|
101
|
+
describe 'Epiphany not transferred' do
|
102
|
+
it do
|
103
|
+
expect(t.season_beginning(CR::Seasons::ORDINARY))
|
104
|
+
.to eq Date.new(2017, 1, 9)
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
describe 'Epiphany transferred' do
|
109
|
+
let(:t) { described_class.new(year, transfer_to_sunday: [:epiphany]) }
|
110
|
+
|
111
|
+
it do
|
112
|
+
expect(t.season_beginning(CR::Seasons::ORDINARY))
|
113
|
+
.to eq Date.new(2017, 1, 10)
|
114
|
+
end
|
115
|
+
end
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
87
119
|
describe '#get' do
|
88
120
|
it 'returns a Celebration' do
|
89
121
|
expect(@t13.get(8, 12)).to be_a CR::Celebration
|
@@ -172,6 +204,7 @@ describe CR::Temporale do
|
|
172
204
|
expect(c.rank).to eq CR::Ranks::PRIMARY
|
173
205
|
expect(c.title).to have_translation 'The Nativity of the Lord'
|
174
206
|
expect(c.colour).to eq CR::Colours::WHITE
|
207
|
+
expect(c.symbol).to eq :nativity
|
175
208
|
end
|
176
209
|
|
177
210
|
it 'day in the octave of Nativity' do
|
@@ -242,6 +275,7 @@ describe CR::Temporale do
|
|
242
275
|
expect(c.rank).to eq CR::Ranks::TRIDUUM
|
243
276
|
expect(c.title).to have_translation 'Easter Sunday of the Resurrection of the Lord'
|
244
277
|
expect(c.colour).to eq CR::Colours::WHITE
|
278
|
+
expect(c.symbol).to eq :easter_sunday
|
245
279
|
end
|
246
280
|
|
247
281
|
it 'Ascension' do
|
@@ -256,6 +290,7 @@ describe CR::Temporale do
|
|
256
290
|
expect(c.rank).to eq CR::Ranks::PRIMARY
|
257
291
|
expect(c.title).to have_translation 'Pentecost Sunday'
|
258
292
|
expect(c.colour).to eq CR::Colours::RED
|
293
|
+
expect(c.symbol).to eq :pentecost
|
259
294
|
end
|
260
295
|
|
261
296
|
it 'Trinity' do
|
@@ -343,6 +378,10 @@ describe CR::Temporale do
|
|
343
378
|
it 'ferial' do
|
344
379
|
expect(title_for(12, 2)).to have_translation 'Monday, 1st week of Advent'
|
345
380
|
end
|
381
|
+
|
382
|
+
it 'ferial before Christmas' do
|
383
|
+
expect(title_for(12, 17)).to have_translation '17th December'
|
384
|
+
end
|
346
385
|
end
|
347
386
|
|
348
387
|
describe 'Christmas time' do
|
@@ -434,7 +473,7 @@ describe CR::Temporale do
|
|
434
473
|
|
435
474
|
it 'French' do
|
436
475
|
I18n.with_locale(:fr) do
|
437
|
-
expect(title_for(5, 5)).to eq 'Lundi, 3 semaine de Pâques'
|
476
|
+
expect(title_for(5, 5)).to eq 'Lundi, 3ème semaine de Pâques'
|
438
477
|
end
|
439
478
|
end
|
440
479
|
|
@@ -463,8 +502,10 @@ describe CR::Temporale do
|
|
463
502
|
end
|
464
503
|
|
465
504
|
describe 'Solemnities transferred to a Sunday' do
|
505
|
+
let(:year) { 2016 }
|
466
506
|
let(:transferred) { [:epiphany, :ascension, :corpus_christi] }
|
467
|
-
let(:t) { described_class.new(
|
507
|
+
let(:t) { described_class.new(year, transfer_to_sunday: transferred) }
|
508
|
+
let(:t_notransfer) { described_class.new(year) }
|
468
509
|
|
469
510
|
it 'Epiphany' do
|
470
511
|
date = Date.new(2017, 1, 8)
|
@@ -488,6 +529,18 @@ describe CR::Temporale do
|
|
488
529
|
expect(c.title).to have_translation 'The Baptism of the Lord'
|
489
530
|
end
|
490
531
|
|
532
|
+
describe 'Ordinary Time numbering after transferred Epiphany' do
|
533
|
+
it 'ferials correct' do
|
534
|
+
first_ot_tuesday = Date.new(2017, 1, 10)
|
535
|
+
expect(t.get(first_ot_tuesday)).to eq t_notransfer.get(first_ot_tuesday)
|
536
|
+
end
|
537
|
+
|
538
|
+
it 'Sundays correct' do
|
539
|
+
second_ot_sunday = Date.new(2017, 1, 15)
|
540
|
+
expect(t.get(second_ot_sunday)).to eq t_notransfer.get(second_ot_sunday)
|
541
|
+
end
|
542
|
+
end
|
543
|
+
|
491
544
|
it 'Ascension' do
|
492
545
|
date = Date.new(2017, 5, 28)
|
493
546
|
expect(date).to be_sunday # make sure
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: calendarium-romanum
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jakub Pavlík
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-11-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|
@@ -118,6 +118,7 @@ files:
|
|
118
118
|
- lib/calendarium-romanum/day.rb
|
119
119
|
- lib/calendarium-romanum/enum.rb
|
120
120
|
- lib/calendarium-romanum/enums.rb
|
121
|
+
- lib/calendarium-romanum/errors.rb
|
121
122
|
- lib/calendarium-romanum/i18n_setup.rb
|
122
123
|
- lib/calendarium-romanum/ordinalizer.rb
|
123
124
|
- lib/calendarium-romanum/perpetual_calendar.rb
|
@@ -126,6 +127,7 @@ files:
|
|
126
127
|
- lib/calendarium-romanum/sanctorale_factory.rb
|
127
128
|
- lib/calendarium-romanum/sanctoraleloader.rb
|
128
129
|
- lib/calendarium-romanum/temporale.rb
|
130
|
+
- lib/calendarium-romanum/temporale/celebration_factory.rb
|
129
131
|
- lib/calendarium-romanum/temporale/dates.rb
|
130
132
|
- lib/calendarium-romanum/temporale/extensions/christ_eternal_priest.rb
|
131
133
|
- lib/calendarium-romanum/transfers.rb
|
@@ -133,10 +135,12 @@ files:
|
|
133
135
|
- lib/calendarium-romanum/version.rb
|
134
136
|
- spec/abstract_date_spec.rb
|
135
137
|
- spec/calendar_spec.rb
|
138
|
+
- spec/celebration_factory_spec.rb
|
136
139
|
- spec/celebration_spec.rb
|
137
140
|
- spec/cli_spec.rb
|
138
141
|
- spec/colour_spec.rb
|
139
142
|
- spec/data_spec.rb
|
143
|
+
- spec/date_parser_spec.rb
|
140
144
|
- spec/date_spec.rb
|
141
145
|
- spec/dates_spec.rb
|
142
146
|
- spec/day_spec.rb
|