calendarium-romanum 0.4.0 → 0.8.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (106) hide show
  1. checksums.yaml +5 -5
  2. data/.gitignore +4 -0
  3. data/.rspec +2 -0
  4. data/.rubocop.yml +47 -0
  5. data/.travis.yml +22 -0
  6. data/.yardopts +3 -0
  7. data/CHANGELOG.md +431 -0
  8. data/Gemfile +25 -0
  9. data/Gemfile.lock +86 -0
  10. data/README.md +598 -0
  11. data/Rakefile +16 -0
  12. data/bin/calendariumrom +4 -1
  13. data/calendarium-romanum.gemspec +31 -0
  14. data/config/locales/cs.yml +5 -0
  15. data/config/locales/en.yml +21 -14
  16. data/config/locales/es.yml +94 -0
  17. data/config/locales/fr.yml +7 -0
  18. data/config/locales/it.yml +7 -0
  19. data/config/locales/la.yml +7 -0
  20. data/data/README.md +70 -24
  21. data/data/czech-brno-cs.txt +4 -6
  22. data/data/czech-budejovice-cs.txt +4 -6
  23. data/data/czech-cechy-cs.txt +4 -5
  24. data/data/czech-cs.txt +236 -234
  25. data/data/czech-hradec-cs.txt +3 -5
  26. data/data/czech-litomerice-cs.txt +5 -7
  27. data/data/czech-morava-cs.txt +4 -5
  28. data/data/czech-olomouc-cs.txt +2 -4
  29. data/data/czech-ostrava-cs.txt +3 -5
  30. data/data/czech-plzen-cs.txt +3 -5
  31. data/data/czech-praha-cs.txt +3 -4
  32. data/data/easter_dates.txt +67 -0
  33. data/data/universal-1969-la.txt +234 -0
  34. data/data/universal-en.txt +214 -211
  35. data/data/universal-es.txt +243 -0
  36. data/data/universal-fr.txt +214 -210
  37. data/data/universal-it.txt +214 -211
  38. data/data/universal-la.txt +214 -210
  39. data/doc/data_readme.md +2 -0
  40. data/doc/images/class_diagram.png +0 -0
  41. data/doc/images/class_diagram.puml +44 -0
  42. data/doc/yard_readme.rdoc +76 -0
  43. data/lib/calendarium-romanum.rb +35 -22
  44. data/lib/calendarium-romanum/abstract_date.rb +15 -0
  45. data/lib/calendarium-romanum/calendar.rb +207 -42
  46. data/lib/calendarium-romanum/cli.rb +63 -80
  47. data/lib/calendarium-romanum/cli/comparator.rb +63 -0
  48. data/lib/calendarium-romanum/cli/date_parser.rb +30 -0
  49. data/lib/calendarium-romanum/cli/dumper.rb +68 -0
  50. data/lib/calendarium-romanum/cli/helper.rb +23 -0
  51. data/lib/calendarium-romanum/cli/querier.rb +73 -0
  52. data/lib/calendarium-romanum/cr.rb +16 -0
  53. data/lib/calendarium-romanum/data.rb +50 -20
  54. data/lib/calendarium-romanum/day.rb +208 -32
  55. data/lib/calendarium-romanum/enum.rb +42 -25
  56. data/lib/calendarium-romanum/enums.rb +124 -44
  57. data/lib/calendarium-romanum/errors.rb +4 -0
  58. data/lib/calendarium-romanum/ordinalizer.rb +23 -2
  59. data/lib/calendarium-romanum/perpetual_calendar.rb +58 -7
  60. data/lib/calendarium-romanum/rank.rb +43 -12
  61. data/lib/calendarium-romanum/rank_predicates.rb +43 -0
  62. data/lib/calendarium-romanum/sanctorale.rb +164 -24
  63. data/lib/calendarium-romanum/sanctorale_factory.rb +74 -3
  64. data/lib/calendarium-romanum/sanctorale_loader.rb +180 -0
  65. data/lib/calendarium-romanum/sanctorale_writer.rb +119 -0
  66. data/lib/calendarium-romanum/temporale.rb +226 -94
  67. data/lib/calendarium-romanum/temporale/celebration_factory.rb +107 -0
  68. data/lib/calendarium-romanum/temporale/dates.rb +84 -16
  69. data/lib/calendarium-romanum/temporale/easter_table.rb +27 -0
  70. data/lib/calendarium-romanum/temporale/extensions.rb +15 -0
  71. data/lib/calendarium-romanum/temporale/extensions/christ_eternal_priest.rb +16 -3
  72. data/lib/calendarium-romanum/temporale/extensions/dedication_before_all_saints.rb +73 -0
  73. data/lib/calendarium-romanum/transfers.rb +60 -15
  74. data/lib/calendarium-romanum/util.rb +22 -3
  75. data/lib/calendarium-romanum/version.rb +5 -1
  76. data/liturgical_law/1969_normae_universales.md +568 -0
  77. data/liturgical_law/1977_decretum_de_celebratione_baptismatis_domini.md +58 -0
  78. data/liturgical_law/1990_decretum_de_variatione_inducenda.md +67 -0
  79. data/liturgical_law/1998_notificatio_de_occurrentia.md +57 -0
  80. data/liturgical_law/2002_normae_universales.md +946 -0
  81. data/liturgical_law/2006_notification.md +37 -0
  82. data/liturgical_law/2012_declarationes.md +38 -0
  83. data/liturgical_law/README.md +74 -0
  84. metadata +50 -28
  85. data/lib/calendarium-romanum/sanctoraleloader.rb +0 -115
  86. data/spec/abstract_date_spec.rb +0 -62
  87. data/spec/calendar_spec.rb +0 -330
  88. data/spec/celebration_spec.rb +0 -23
  89. data/spec/cli_spec.rb +0 -26
  90. data/spec/colour_spec.rb +0 -17
  91. data/spec/data_spec.rb +0 -23
  92. data/spec/date_spec.rb +0 -61
  93. data/spec/dates_spec.rb +0 -45
  94. data/spec/day_spec.rb +0 -59
  95. data/spec/enum_spec.rb +0 -51
  96. data/spec/i18n_spec.rb +0 -59
  97. data/spec/ordinalizer_spec.rb +0 -22
  98. data/spec/perpetual_calendar_spec.rb +0 -91
  99. data/spec/rank_spec.rb +0 -57
  100. data/spec/readme_spec.rb +0 -52
  101. data/spec/sanctorale_factory_spec.rb +0 -42
  102. data/spec/sanctorale_spec.rb +0 -191
  103. data/spec/sanctoraleloader_spec.rb +0 -171
  104. data/spec/season_spec.rb +0 -17
  105. data/spec/spec_helper.rb +0 -35
  106. data/spec/temporale_spec.rb +0 -519
@@ -1,45 +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
- end
@@ -1,59 +0,0 @@
1
- require_relative 'spec_helper'
2
-
3
- describe CR::Day do
4
- describe '#==' do
5
- let(:d) do
6
- described_class.new(
7
- date: Date.today,
8
- season: CR::Seasons::ORDINARY,
9
- season_week: 1,
10
- celebrations: [CR::Celebration.new]
11
- )
12
- end
13
-
14
- describe 'same content' do
15
- let(:d2) do
16
- described_class.new(
17
- date: Date.today,
18
- season: CR::Seasons::ORDINARY,
19
- season_week: 1,
20
- celebrations: [CR::Celebration.new]
21
- )
22
- end
23
-
24
- it 'is equal' do
25
- expect(d).to eq d2
26
- end
27
- end
28
-
29
- describe 'different content' do
30
- let(:d2) do
31
- described_class.new(
32
- date: Date.today,
33
- season: CR::Seasons::LENT,
34
- season_week: 1,
35
- celebrations: [CR::Celebration.new]
36
- )
37
- end
38
-
39
- it 'is different' do
40
- expect(d).not_to eq d2
41
- end
42
- end
43
-
44
- describe 'different celebrations' do
45
- let(:d2) do
46
- described_class.new(
47
- date: Date.today,
48
- season: CR::Seasons::ORDINARY,
49
- season_week: 1,
50
- celebrations: [CR::Celebration.new('another celebration')]
51
- )
52
- end
53
-
54
- it 'is different' do
55
- expect(d).not_to eq d2
56
- end
57
- end
58
- end
59
- 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,59 +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 of the Resurrection of the Lord'
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
- end
35
-
36
- describe 'Czech' do
37
- let(:locale) { 'cs' }
38
-
39
- it 'translates Temporale feast names' do
40
- expect(easter_celebration.title).to eq 'Zmrtvýchvstání Páně'
41
- end
42
-
43
- it 'translates rank names' do
44
- rank = CR::Ranks::SUNDAY_UNPRIVILEGED
45
- expect(rank.desc).to eq 'Neprivilegované neděle'
46
- expect(rank.short_desc).to eq 'neděle'
47
- end
48
- end
49
- end
50
-
51
- describe 'unsupported locale' do
52
- # I will be most happy when this locale one day moves to the 'supported' branch!
53
- let(:locale) { 'de' }
54
-
55
- it 'attemt to switch to it fails by default' do
56
-
57
- end
58
- end
59
- end
@@ -1,22 +0,0 @@
1
- require_relative 'spec_helper'
2
-
3
- describe CalendariumRomanum::Ordinalizer do
4
- describe '#english_ordinal' do
5
- {
6
- 1 => '1st',
7
- 2 => '2nd',
8
- 3 => '3rd',
9
- 4 => '4th',
10
- 11 => '11th',
11
- 12 => '12th',
12
- 13 => '13th',
13
- 21 => '21st',
14
- 22 => '22nd',
15
- 23 => '23rd',
16
- }.each_pair do |number, ordinal|
17
- it number do
18
- expect(described_class.english_ordinal(number)).to eq ordinal
19
- end
20
- end
21
- end
22
- end
@@ -1,91 +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
- describe '.new' do
12
- describe 'with sanctorale' do
13
- it 'uses the sanctorale' do
14
- pc = described_class.new(sanctorale: sanctorale)
15
-
16
- calendar = pc.calendar_for_year(year)
17
- expect(calendar.sanctorale).to be sanctorale
18
- end
19
- end
20
-
21
- describe 'with temporale options' do
22
- it 'applies the options' do
23
- pc = described_class.new(temporale_options: {transfer_to_sunday: [:epiphany]})
24
-
25
- y = 2016
26
- calendar = pc.calendar_for_year(y)
27
- epiphany_date = CR::Temporale::Dates.epiphany(y, sunday: true)
28
- expect(epiphany_date).not_to eq CR::Temporale::Dates.epiphany(y) # make sure
29
-
30
- expect(calendar.day(epiphany_date).celebrations[0].title).to have_translation 'The Epiphany of the Lord'
31
- end
32
- end
33
-
34
- describe 'with temporale factory' do
35
- it 'uses the factory' do
36
- temporale_subcls = Class.new(CR::Temporale)
37
- factory = lambda {|year| temporale_subcls.new year }
38
-
39
- pc = described_class.new(temporale_factory: factory)
40
- calendar = pc.calendar_for_year(year)
41
- expect(calendar.temporale).to be_a temporale_subcls
42
- end
43
- end
44
-
45
- describe 'with both temporale factory and options' do
46
- it 'fails' do
47
- expect do
48
- described_class.new(
49
- temporale_options: {transfer_to_sunday: [:epiphany]},
50
- temporale_factory: lambda {|year| temporale_subcls.new year }
51
- )
52
- end.to raise_exception ArgumentError
53
- end
54
- end
55
-
56
- describe 'with cache' do
57
- it 'uses the supplied object as Calendar instance cache' do
58
- cache = {}
59
- pc = described_class.new(cache: cache)
60
- calendar = pc.calendar_for_year(year)
61
- expect(cache[2000]).to be calendar
62
- end
63
- end
64
- end
65
-
66
- describe '#day' do
67
- it 'returns a Day' do
68
- expect(pcal.day(Date.today)).to be_a CR::Day
69
- end
70
- end
71
-
72
- describe '#calendar_for' do
73
- it 'returns a Calendar' do
74
- expect(pcal.calendar_for(date)).to be_a CR::Calendar
75
- end
76
- end
77
-
78
- describe '#calendar_for_year' do
79
- it 'returns a Calendar' do
80
- expect(pcal.calendar_for_year(year)).to be_a CR::Calendar
81
- end
82
- end
83
-
84
- describe 'caching' do
85
- it 'caches calendar instances' do
86
- expect(CR::Calendar).to receive(:new)
87
-
88
- 2.times { pcal.calendar_for_year(year) }
89
- end
90
- end
91
- end
@@ -1,57 +0,0 @@
1
- require_relative 'spec_helper'
2
-
3
- describe CR::Rank do
4
- describe 'comparison' do
5
- it 'memorial x ferial' do
6
- expect(CR::Ranks::MEMORIAL_GENERAL).to be > CR::Ranks::FERIAL
7
- end
8
- end
9
-
10
- describe '[]' do
11
- it 'has all existing instances indexed by rank number' do
12
- expect(CR::Ranks[1.1]).to eq CR::Ranks::TRIDUUM
13
- end
14
- end
15
-
16
- describe '#<' do
17
- it { expect(CR::Ranks[1.2]).to be < CR::Ranks[1.1] }
18
- it { expect(CR::Ranks[1.1]).not_to be < CR::Ranks[1.2] }
19
- end
20
-
21
- describe '#>' do
22
- it { expect(CR::Ranks[1.1]).to be > CR::Ranks[1.2] }
23
- it { expect(CR::Ranks[1.2]).not_to be > CR::Ranks[1.1] }
24
- end
25
-
26
- describe '#==' do
27
- it { expect(CR::Ranks[1.2]).to be == CR::Ranks[1.2] }
28
- it { expect(CR::Ranks[1.2]).not_to be == CR::Ranks[1.1] }
29
- end
30
-
31
- describe 'descriptions' do
32
- CR::Ranks.each do |rank|
33
- describe "#{rank.priority} #{rank.short_desc}" do
34
- it 'has #desc translated' do
35
- expect(rank.desc).to have_translation
36
- end
37
-
38
- it 'is has #short_desc translated' do
39
- if rank.short_desc # not set for some ranks
40
- expect(rank.short_desc).to have_translation
41
- end
42
- end
43
- end
44
- end
45
-
46
- describe '#short_desc' do
47
- it 'is not always set' do
48
- expect(CR::Ranks[1.1].short_desc).to be_nil
49
- end
50
- end
51
- end
52
-
53
- describe '#memorial?' do
54
- it { expect(CR::Ranks::MEMORIAL_OPTIONAL.memorial?).to be true }
55
- it { expect(CR::Ranks::FERIAL.memorial?).to be false }
56
- end
57
- end
@@ -1,52 +0,0 @@
1
- require 'spec_helper'
2
-
3
- class MarkdownDocument
4
- def initialize(str)
5
- @str = str
6
- end
7
-
8
- def each_ruby_example
9
- example = nil
10
- line = nil
11
- @str.each_line.with_index(1) do |l, i|
12
- if example.nil?
13
- if example_beginning?(l)
14
- example = ''
15
- line = i + 1
16
- end
17
- elsif example_end?(l)
18
- yield example, line
19
- example = nil
20
- else
21
- example += l
22
- end
23
- end
24
- end
25
-
26
- protected
27
-
28
- def example_beginning?(line)
29
- line =~ /^```ruby/
30
- end
31
-
32
- def example_end?(line)
33
- line =~ /```/
34
- end
35
- end
36
-
37
- %w(README.md data/README.md).each do |path|
38
- describe path do
39
- readme_path = File.expand_path('../../' + path, __FILE__)
40
- readme = File.read readme_path
41
- doc = MarkdownDocument.new readme
42
-
43
- doc.each_ruby_example do |code, line|
44
- describe "example L#{line}" do
45
- it 'executes without failure' do
46
- cls = Class.new
47
- cls.class_eval(code, readme_path, line)
48
- end
49
- end
50
- end
51
- end
52
- end
@@ -1,42 +0,0 @@
1
- # coding: utf-8
2
- require 'spec_helper'
3
-
4
- describe CR::SanctoraleFactory do
5
- describe '.create_layered'
6
-
7
- describe '.load_layered_from_files' do
8
- before :each do
9
- files = %w(czech-cs.txt czech-cechy-cs.txt czech-budejovice-cs.txt).collect do |f|
10
- File.join(File.expand_path('../data', File.dirname(__FILE__)), f)
11
- end
12
- @s = described_class.load_layered_from_files(*files)
13
- end
14
-
15
- it 'has celebrations from the first file' do
16
- dd = @s.get 9, 28
17
- expect(dd.size).to eq 1
18
-
19
- d = dd.first
20
- expect(d.rank).to eq CR::Ranks::SOLEMNITY_PROPER
21
- expect(d.title).to eq 'Sv. Václava, mučedníka, hlavního patrona českého národa'
22
- end
23
-
24
- it 'has celebrations from the second file' do
25
- dd = @s.get 7, 4
26
- expect(dd.size).to eq 1
27
-
28
- d = dd.first
29
- expect(d.rank).to eq CR::Ranks::MEMORIAL_PROPER
30
- expect(d.title).to eq 'Sv. Prokopa, opata'
31
- end
32
-
33
- it 'celebrations from the last file win' do
34
- dd = @s.get 12, 22
35
- expect(dd.size).to eq 1
36
-
37
- d = dd.first
38
- expect(d.rank).to eq CR::Ranks::FEAST_PROPER
39
- expect(d.title).to eq 'Výročí posvěcení katedrály sv. Mikuláše'
40
- end
41
- end
42
- end