calendarium-romanum 0.7.0 → 0.7.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (45) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +4 -0
  3. data/.rspec +2 -0
  4. data/.rubocop.yml +47 -0
  5. data/.travis.yml +20 -0
  6. data/.yardopts +3 -0
  7. data/CHANGELOG.md +340 -0
  8. data/Gemfile +25 -0
  9. data/Gemfile.lock +86 -0
  10. data/README.md +515 -0
  11. data/Rakefile +9 -0
  12. data/calendarium-romanum.gemspec +26 -0
  13. data/doc/data_readme.md +2 -0
  14. data/doc/images/class_diagram.png +0 -0
  15. data/doc/images/class_diagram.puml +44 -0
  16. data/doc/yard_readme.rdoc +76 -0
  17. data/lib/calendarium-romanum/sanctorale.rb +29 -3
  18. data/lib/calendarium-romanum/sanctorale_factory.rb +2 -2
  19. data/lib/calendarium-romanum/sanctorale_loader.rb +3 -3
  20. data/lib/calendarium-romanum/version.rb +2 -2
  21. metadata +17 -26
  22. data/spec/abstract_date_spec.rb +0 -70
  23. data/spec/calendar_spec.rb +0 -756
  24. data/spec/celebration_factory_spec.rb +0 -40
  25. data/spec/celebration_spec.rb +0 -67
  26. data/spec/cli_spec.rb +0 -169
  27. data/spec/colour_spec.rb +0 -22
  28. data/spec/data_spec.rb +0 -46
  29. data/spec/date_parser_spec.rb +0 -68
  30. data/spec/date_spec.rb +0 -61
  31. data/spec/dates_spec.rb +0 -73
  32. data/spec/day_spec.rb +0 -151
  33. data/spec/enum_spec.rb +0 -51
  34. data/spec/i18n_spec.rb +0 -68
  35. data/spec/ordinalizer_spec.rb +0 -44
  36. data/spec/perpetual_calendar_spec.rb +0 -125
  37. data/spec/rank_spec.rb +0 -77
  38. data/spec/readme_spec.rb +0 -58
  39. data/spec/sanctorale_factory_spec.rb +0 -146
  40. data/spec/sanctorale_loader_spec.rb +0 -229
  41. data/spec/sanctorale_spec.rb +0 -281
  42. data/spec/season_spec.rb +0 -22
  43. data/spec/spec_helper.rb +0 -46
  44. data/spec/temporale_spec.rb +0 -693
  45. data/spec/year_spec.rb +0 -25
@@ -1,73 +0,0 @@
1
- require_relative 'spec_helper'
2
-
3
- describe CR::Temporale::Dates do
4
- let(:today) { Date.new 2014, 3, 16 }
5
-
6
- describe '#weekday_before' do
7
- describe 'works well for all 7 weekdays' do
8
- [
9
- [0, Date.new(2014, 3, 9)],
10
- [1, Date.new(2014, 3, 10)],
11
- [2, Date.new(2014, 3, 11)],
12
- [3, Date.new(2014, 3, 12)],
13
- [4, Date.new(2014, 3, 13)],
14
- [5, Date.new(2014, 3, 14)],
15
- [6, Date.new(2014, 3, 15)],
16
- ].each do |e|
17
- day_num, expected = e
18
- it day_num do
19
- actual = described_class.weekday_before(day_num, today)
20
- expect(actual).to eq expected
21
- end
22
- end
23
- end
24
- end
25
-
26
- describe '#weekday_after aliases' do
27
- describe 'works well for all 7 weekdays' do
28
- [
29
- [:monday_after, Date.new(2014, 3, 17)],
30
- [:tuesday_after, Date.new(2014, 3, 18)],
31
- [:wednesday_after, Date.new(2014, 3, 19)],
32
- [:thursday_after, Date.new(2014, 3, 20)],
33
- [:friday_after, Date.new(2014, 3, 21)],
34
- [:saturday_after, Date.new(2014, 3, 22)],
35
- [:sunday_after, Date.new(2014, 3, 23)],
36
- ].each do |e|
37
- method, expected = e
38
- it method do
39
- actual = described_class.public_send(method, today)
40
- expect(actual).to eq expected
41
- end
42
- end
43
- end
44
- end
45
-
46
- describe 'transferable solemnities' do
47
- # for sake of simplicity a year has been chosen when
48
- # none of the transferable solemnities falls on a Sunday
49
- let(:year) { 2013 }
50
-
51
- %i(epiphany ascension corpus_christi).each do |solemnity|
52
- it solemnity.to_s do
53
- transferred =
54
- described_class.public_send(solemnity, year, sunday: true)
55
- not_transferred =
56
- described_class.public_send(solemnity, year)
57
-
58
- expect(transferred).not_to eq not_transferred
59
- expect(transferred).to be_sunday
60
- end
61
- end
62
-
63
- it 'Baptism of the Lord' do
64
- transferred =
65
- described_class.baptism_of_lord(year, epiphany_on_sunday: true)
66
- not_transferred =
67
- described_class.baptism_of_lord(year)
68
-
69
- expect(transferred).to be_monday
70
- expect(not_transferred).to be_sunday
71
- end
72
- end
73
- end
@@ -1,151 +0,0 @@
1
- require_relative 'spec_helper'
2
-
3
- describe CR::Day do
4
- let(:d) do
5
- described_class.new(
6
- date: Date.today,
7
- season: CR::Seasons::ORDINARY,
8
- season_week: 1,
9
- celebrations: [CR::Celebration.new],
10
- vespers: vespers
11
- )
12
- end
13
-
14
- let(:vespers) { nil }
15
-
16
- describe '.new' do
17
- it 'works without arguments' do
18
- expect do
19
- described_class.new
20
- end.not_to raise_exception
21
- end
22
-
23
- it 'makes a shallow copy of celebrations' do
24
- celebrations = [CR::Celebration.new]
25
- day = described_class.new celebrations: celebrations
26
-
27
- expect(day.celebrations).to eq celebrations
28
- expect(day.celebrations).not_to be celebrations
29
-
30
- expect(day.celebrations[0]).to be celebrations[0]
31
- end
32
- end
33
-
34
- describe '#==' do
35
- describe 'same content' do
36
- let(:d2) do
37
- described_class.new(
38
- date: Date.today,
39
- season: CR::Seasons::ORDINARY,
40
- season_week: 1,
41
- celebrations: [CR::Celebration.new]
42
- )
43
- end
44
-
45
- it 'is equal' do
46
- expect(d).to eq d2
47
- end
48
- end
49
-
50
- describe 'different content' do
51
- let(:d2) do
52
- described_class.new(
53
- date: Date.today,
54
- season: CR::Seasons::LENT,
55
- season_week: 1,
56
- celebrations: [CR::Celebration.new]
57
- )
58
- end
59
-
60
- it 'is different' do
61
- expect(d).not_to eq d2
62
- end
63
- end
64
-
65
- describe 'different celebrations' do
66
- let(:d2) do
67
- described_class.new(
68
- date: Date.today,
69
- season: CR::Seasons::ORDINARY,
70
- season_week: 1,
71
- celebrations: [CR::Celebration.new('another celebration')]
72
- )
73
- end
74
-
75
- it 'is different' do
76
- expect(d).not_to eq d2
77
- end
78
- end
79
-
80
- describe 'different Vespers' do
81
- let(:d2) do
82
- described_class.new(
83
- date: Date.today,
84
- season: CR::Seasons::ORDINARY,
85
- season_week: 1,
86
- celebrations: [CR::Celebration.new],
87
- vespers: CR::Temporale::CelebrationFactory.palm_sunday
88
- )
89
- end
90
-
91
- it 'is different' do
92
- expect(d).not_to eq d2
93
- end
94
- end
95
- end
96
-
97
- describe '#vespers_from_following?' do
98
- describe 'vespers not set' do
99
- it { expect(d.vespers_from_following?).to be false }
100
- end
101
-
102
- describe 'vespers set' do
103
- let(:vespers) { CR::Celebration.new }
104
-
105
- it { expect(d.vespers_from_following?).to be true }
106
- end
107
- end
108
-
109
- describe '#to_s' do
110
- it do
111
- I18n.with_locale(:en) do
112
- day = CR::PerpetualCalendar.new[Date.new(2000, 1, 8)]
113
- expect(day.to_s).to eq "#<CalendariumRomanum::Day @date=2000-01-08 @season=#<CalendariumRomanum::Season christmas> @season_week=2 celebrations=[#<CalendariumRomanum::Celebration @title=\"Saturday after Epiphany\" @rank=#<CalendariumRomanum::Rank @priority=3.13 desc=\"Ferials\"> @colour=#<CalendariumRomanum::Colour white> symbol=nil date=nil cycle=:temporale>] vespers=nil>"
114
- end
115
- end
116
- end
117
-
118
- describe '#weekday' do
119
- let(:sunday) { Date.new 2018, 5, 20 }
120
- let(:saturday) { sunday - 1 }
121
-
122
- it 'Sunday' do
123
- expect(sunday).to be_sunday # make sure
124
-
125
- d = described_class.new(date: sunday)
126
- expect(d.weekday).to be 0
127
- end
128
-
129
- it 'Saturday' do
130
- d = described_class.new(date: saturday)
131
- expect(d.weekday).to be 6
132
- end
133
- end
134
-
135
- describe '#weekday_name' do
136
- let(:sunday) { Date.new 2018, 5, 20 }
137
- let(:saturday) { sunday - 1 }
138
-
139
- it 'Sunday' do
140
- expect(sunday).to be_sunday # make sure
141
-
142
- d = described_class.new(date: sunday)
143
- expect(d.weekday_name).to eq(I18n.t('0', scope: 'weekday'))
144
- end
145
-
146
- it 'Saturday' do
147
- d = described_class.new(date: saturday)
148
- expect(d.weekday_name).to eq(I18n.t('6', scope: 'weekday'))
149
- end
150
- end
151
- end
@@ -1,51 +0,0 @@
1
- require_relative 'spec_helper'
2
-
3
- describe CalendariumRomanum::Enum do
4
- let(:enum_values) { [:a, :b] }
5
-
6
- let(:test_class) do
7
- Class.new(described_class) { values { [:a, :b] } }
8
- end
9
-
10
- describe '.all' do
11
- it 'returns all values in the original order' do
12
- expect(test_class.all).to eq enum_values
13
- end
14
- end
15
-
16
- describe '.each' do
17
- it 'yields all values in the original order' do
18
- expect {|b| test_class.each(&b) }.to yield_successive_args(*enum_values)
19
- end
20
- end
21
-
22
- describe '[]' do
23
- describe 'default indexing' do
24
- it 'finds first element' do
25
- expect(test_class[0]).to be :a
26
- end
27
-
28
- it 'finds last element' do
29
- expect(test_class[1]).to be :b
30
- end
31
-
32
- it 'returns nil for index out of range' do
33
- expect(test_class[2]).to be nil
34
- end
35
- end
36
-
37
- describe 'indexed by a custom property' do
38
- let(:test_class) do
39
- Class.new(described_class) { values(index_by: :to_s) { [1] } }
40
- end
41
-
42
- it 'finds the element' do
43
- expect(test_class['1']).to eq 1
44
- end
45
-
46
- it 'returns nil for an unknown index' do
47
- expect(test_class[1]).to be nil
48
- end
49
- end
50
- end
51
- end
@@ -1,68 +0,0 @@
1
- # coding: utf-8
2
- require_relative 'spec_helper'
3
-
4
- describe 'internationalization' do
5
- before :all do
6
- I18n.backend.load_translations
7
- end
8
-
9
- let(:temporale) { CR::Temporale.new(2016) }
10
- let(:easter_celebration) { temporale.get Date.new(2017, 4, 16) }
11
-
12
- describe 'supported locales' do
13
- before :each do
14
- @last_locale = I18n.locale
15
- I18n.locale = locale
16
- end
17
-
18
- after :each do
19
- I18n.locale = @last_locale
20
- end
21
-
22
- describe 'English' do
23
- let(:locale) { 'en' }
24
-
25
- it 'translates Temporale feast names' do
26
- expect(easter_celebration.title).to eq 'Easter Sunday'
27
- end
28
-
29
- it 'translates rank names' do
30
- rank = CR::Ranks::SUNDAY_UNPRIVILEGED
31
- expect(rank.desc).to eq 'Unprivileged Sundays'
32
- expect(rank.short_desc).to eq 'Sunday'
33
- end
34
-
35
- it 'translates day weekday_names' do
36
- sunday = CR::Day.new(date: Date.new(2018, 5, 20))
37
- expect(sunday.weekday_name).to eq 'Sunday'
38
- end
39
- end
40
-
41
- describe 'Czech' do
42
- let(:locale) { 'cs' }
43
-
44
- it 'translates Temporale feast names' do
45
- expect(easter_celebration.title).to eq 'Zmrtvýchvstání Páně'
46
- end
47
-
48
- it 'translates rank names' do
49
- rank = CR::Ranks::SUNDAY_UNPRIVILEGED
50
- expect(rank.desc).to eq 'Neprivilegované neděle'
51
- expect(rank.short_desc).to eq 'neděle'
52
- end
53
-
54
- it 'translates day weekday_names' do
55
- sunday = CR::Day.new(date: Date.new(2018, 5, 20))
56
- expect(sunday.weekday_name).to eq 'Neděle'
57
- end
58
- end
59
- end
60
-
61
- describe 'unsupported locale' do
62
- # I will be most happy when this locale one day moves to the 'supported' branch!
63
- let(:locale) { 'de' }
64
-
65
- it 'attemt to switch to it fails by default' do
66
- end
67
- end
68
- end
@@ -1,44 +0,0 @@
1
- require_relative 'spec_helper'
2
-
3
- describe CalendariumRomanum::Ordinalizer do
4
- describe '#ordinal' do
5
- describe 'English' do
6
- {
7
- 1 => '1st',
8
- 2 => '2nd',
9
- 3 => '3rd',
10
- 4 => '4th',
11
- 11 => '11th',
12
- 12 => '12th',
13
- 13 => '13th',
14
- 21 => '21st',
15
- 22 => '22nd',
16
- 23 => '23rd',
17
- }.each_pair do |number, ordinal|
18
- it number do
19
- expect(described_class.ordinal(number, locale: :en)).to eq ordinal
20
- end
21
- end
22
- end
23
-
24
- describe 'French' do
25
- {
26
- 1 => '1er',
27
- 2 => '2ème',
28
- 3 => '3ème',
29
- }.each_pair do |number, ordinal|
30
- it number do
31
- expect(described_class.ordinal(number, locale: :fr)).to eq ordinal
32
- end
33
- end
34
- end
35
-
36
- describe 'unsupported locale' do
37
- [1, 2, 3].each do |number|
38
- it number do
39
- expect(described_class.ordinal(number, locale: :unsupported)).to eq number
40
- end
41
- end
42
- end
43
- end
44
- end
@@ -1,125 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe CR::PerpetualCalendar do
4
- let(:pcal) { described_class.new }
5
-
6
- let(:date) { Date.new(2000, 1, 1) }
7
- let(:year) { 2000 }
8
-
9
- let(:sanctorale) { CR::Data::GENERAL_ROMAN_ENGLISH.load }
10
-
11
- let(:factory) { CR::Temporale::CelebrationFactory }
12
-
13
- describe '.new' do
14
- describe 'with sanctorale' do
15
- it 'uses the sanctorale' do
16
- pc = described_class.new(sanctorale: sanctorale)
17
-
18
- calendar = pc.calendar_for_year(year)
19
- expect(calendar.sanctorale).to be sanctorale
20
- end
21
- end
22
-
23
- describe 'with temporale options' do
24
- it 'applies the options' do
25
- pc = described_class.new(temporale_options: {transfer_to_sunday: [:epiphany]})
26
-
27
- y = 2016
28
- calendar = pc.calendar_for_year(y)
29
- epiphany_date = CR::Temporale::Dates.epiphany(y, sunday: true)
30
-
31
- expect(calendar.day(epiphany_date).celebrations[0]).to eq factory.epiphany
32
- end
33
- end
34
-
35
- describe 'with temporale factory' do
36
- it 'uses the factory' do
37
- temporale_subcls = Class.new(CR::Temporale)
38
- factory = lambda {|year| temporale_subcls.new year }
39
-
40
- pc = described_class.new(temporale_factory: factory)
41
- calendar = pc.calendar_for_year(year)
42
- expect(calendar.temporale).to be_a temporale_subcls
43
- end
44
- end
45
-
46
- describe 'with both temporale factory and options' do
47
- it 'fails' do
48
- expect do
49
- described_class.new(
50
- temporale_options: {transfer_to_sunday: [:epiphany]},
51
- temporale_factory: lambda {|year| }
52
- )
53
- end.to raise_exception ArgumentError
54
- end
55
- end
56
-
57
- describe 'with cache' do
58
- it 'uses the supplied object as Calendar instance cache' do
59
- cache = {}
60
- pc = described_class.new(cache: cache)
61
- calendar = pc.calendar_for_year(year)
62
- expect(cache[2000]).to be calendar
63
- end
64
- end
65
- end
66
-
67
- describe '#day' do
68
- it 'returns a Day' do
69
- expect(pcal.day(Date.today)).to be_a CR::Day
70
- end
71
- end
72
-
73
- describe '#[]' do
74
- describe 'arguments' do
75
- describe 'single Date' do
76
- it 'returns a Day' do
77
- expect(pcal[Date.today]).to be_a CR::Day
78
- end
79
- end
80
-
81
- describe 'Range of Dates' do
82
- shared_examples 'range' do
83
- it 'returns an Array of Days' do
84
- result = pcal[range]
85
- expect(result).to be_an Array
86
- expect(result[0]).to be_a CR::Day
87
- end
88
- end
89
-
90
- describe 'of the same liturgical year' do
91
- let(:range) { Date.new(2010, 1, 1) .. Date.new(2010, 1, 5) }
92
-
93
- include_examples 'range'
94
- end
95
-
96
- describe 'across boundaries of the liturgical year' do
97
- let(:first_advent) { CR::Temporale::Dates.first_advent_sunday(2010) }
98
- let(:range) { (first_advent - 1) .. (first_advent + 1) }
99
-
100
- include_examples 'range'
101
- end
102
- end
103
- end
104
- end
105
-
106
- describe '#calendar_for' do
107
- it 'returns a Calendar' do
108
- expect(pcal.calendar_for(date)).to be_a CR::Calendar
109
- end
110
- end
111
-
112
- describe '#calendar_for_year' do
113
- it 'returns a Calendar' do
114
- expect(pcal.calendar_for_year(year)).to be_a CR::Calendar
115
- end
116
- end
117
-
118
- describe 'caching' do
119
- it 'caches calendar instances' do
120
- expect(CR::Calendar).to receive(:new)
121
-
122
- 2.times { pcal.calendar_for_year(year) }
123
- end
124
- end
125
- end