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,40 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe CR::Temporale::CelebrationFactory do
4
- describe '.first_advent_sunday' do
5
- it 'returns Celebration equal to the one returned by Temporale' do
6
- year = 2000
7
- temporale = CR::Temporale.new(year)
8
- date = CR::Temporale::Dates.first_advent_sunday(year)
9
-
10
- c = temporale.get(date)
11
- c2 = described_class.first_advent_sunday
12
-
13
- expect(c2).to eq c
14
- end
15
- end
16
-
17
- describe '.each' do
18
- it 'yields' do
19
- expect {|b| described_class.each(&b) }.to yield_control
20
- end
21
-
22
- it 'yields Celebrations' do
23
- described_class.each do |c|
24
- expect(c).to be_a CR::Celebration
25
- end
26
- end
27
-
28
- it 'returns Enumerator if called without a block' do
29
- expect(described_class.each).to be_a Enumerator
30
- end
31
- end
32
-
33
- describe 'celebration titles are properly translated' do
34
- described_class.each do |celebration|
35
- it celebration.symbol.to_s do
36
- expect(celebration.title).to have_translation
37
- end
38
- end
39
- end
40
- end
@@ -1,67 +0,0 @@
1
- require_relative 'spec_helper'
2
-
3
- describe CR::Celebration do
4
- describe '#==' do
5
- let(:c) { described_class.new('title') }
6
-
7
- describe 'same content' do
8
- let(:c2) { described_class.new('title') }
9
-
10
- it 'is equal' do
11
- expect(c).to eq c2
12
- end
13
- end
14
-
15
- describe 'different content' do
16
- let(:c2) { described_class.new('another title') }
17
-
18
- it 'is different' do
19
- expect(c).not_to eq c2
20
- end
21
- end
22
- end
23
-
24
- describe '#change' do
25
- let(:c) { described_class.new('title') }
26
-
27
- it 'produces a new instance' do
28
- c2 = c.change rank: CR::Ranks::SOLEMNITY_GENERAL
29
- expect(c2).not_to be c
30
- end
31
-
32
- it 'sets specified properties' do
33
- c2 = c.change rank: CR::Ranks::SOLEMNITY_GENERAL
34
- expect(c2.rank).not_to eq c.rank
35
- expect(c2.rank).to be CR::Ranks::SOLEMNITY_GENERAL
36
- end
37
-
38
- it 'copies the rest' do
39
- c2 = c.change rank: CR::Ranks::SOLEMNITY_GENERAL
40
- expect(c2.title).to be c.title # reference copying is no problem, Celebrations are immutable
41
- end
42
- end
43
-
44
- describe '#temporale?, #sanctorale?' do
45
- let(:tc) { described_class.new.change(cycle: :temporale) }
46
- let(:sc) { described_class.new.change(cycle: :sanctorale) }
47
- let(:nc) { described_class.new.change(cycle: anything) }
48
-
49
- it { expect(tc.temporale?).to be true }
50
- it { expect(tc.sanctorale?).to be false }
51
-
52
- it { expect(sc.sanctorale?).to be true }
53
- it { expect(sc.temporale?).to be false }
54
-
55
- it { expect(nc.sanctorale?).to be false }
56
- it { expect(nc.temporale?).to be false }
57
- end
58
-
59
- describe '#to_s' do
60
- it do
61
- I18n.with_locale(:en) do
62
- celebration = CR::PerpetualCalendar.new[Date.new(2000, 1, 8)].celebrations[0]
63
- expect(celebration.to_s).to eq "#<CalendariumRomanum::Celebration @title=\"Saturday after Epiphany\" @rank=#<CalendariumRomanum::Rank @priority=3.13 desc=\"Ferials\"> @colour=#<CalendariumRomanum::Colour white> symbol=nil date=nil cycle=:temporale>"
64
- end
65
- end
66
- end
67
- end
@@ -1,169 +0,0 @@
1
- require 'spec_helper'
2
- require 'calendarium-romanum/cli'
3
-
4
- describe CalendariumRomanum::CLI, type: :aruba do
5
- let(:path_universal_la) { CR::Data::GENERAL_ROMAN_LATIN.path }
6
- let(:path_universal_en) { CR::Data::GENERAL_ROMAN_ENGLISH.path }
7
-
8
- before :each do
9
- prepend_environment_variable('RUBYLIB', File.expand_path('../../lib', __FILE__) + ':')
10
- end
11
-
12
- describe 'subcommands' do
13
- describe 'errors' do
14
- describe 'no errors detected' do
15
- before(:each) { run "calendariumrom errors #{path_universal_la}" }
16
- it { expect(last_command).to be_successfully_executed }
17
- it { expect(all_output).to be_empty }
18
- end
19
-
20
- describe 'non-existent file' do
21
- before(:each) { run 'calendariumrom errors does-not-exist.txt' }
22
- it { expect(all_output).to include 'No such file or directory' }
23
- it { expect(last_command).to have_exit_status 1 }
24
- end
25
-
26
- describe 'errors detected' do
27
- before(:each) do
28
- write_file 'data.txt', file_content
29
- run 'calendariumrom errors data.txt'
30
- end
31
-
32
- describe 'completely broken record' do
33
- let(:file_content) { 'invalid content' }
34
-
35
- it { expect(all_output).to eq "L1: Syntax error, line skipped 'invalid content'\n" }
36
- it { expect(last_command).to have_exit_status 1 }
37
- end
38
-
39
- describe 'wrong month title (month does not exist)' do
40
- let(:file_content) { "= 13\n" }
41
-
42
- it { expect(all_output).to start_with 'L1: Invalid month' }
43
- it { expect(last_command).to have_exit_status 1 }
44
- end
45
- end
46
- end
47
-
48
- describe 'cmp' do
49
- describe 'contents match' do
50
- before(:each) { run "calendariumrom cmp #{path_universal_la} #{path_universal_en}" }
51
-
52
- it { expect(all_output).to be_empty }
53
- it { expect(last_command).to be_successfully_executed }
54
- end
55
-
56
- describe 'contents do not match' do
57
- before(:each) do
58
- write_file 'cal1.txt', content1
59
- write_file 'cal2.txt', content2
60
- run 'calendariumrom cmp cal1.txt cal2.txt'
61
- end
62
-
63
- describe 'in rank' do
64
- let(:content1) { '1/11 : St. None, abbot' }
65
- let(:content2) { '1/11 m : St. None, abbot' }
66
-
67
- it { expect(all_output).to include '1/11' }
68
- it { expect(all_output).to include 'St. None, abbot' }
69
- it { expect(all_output).to include 'differs in rank' }
70
- it { expect(last_command).to be_successfully_executed }
71
- end
72
-
73
- describe 'in colour' do
74
- let(:content1) { '1/11 : St. None, abbot' }
75
- let(:content2) { '1/11 R : St. None, abbot and martyr' }
76
-
77
- it { expect(all_output).to include '1/11' }
78
- it { expect(all_output).to include 'St. None, abbot' }
79
- it { expect(all_output).to include 'differs in colour' }
80
- it { expect(last_command).to be_successfully_executed }
81
- end
82
-
83
- describe 'in optional memorial count' do
84
- let(:content1) { '1/11 : St. None, abbot' }
85
- let(:content2) { "1/11 : St. None, abbot\n1/11 : St. Nulla, abbess" }
86
-
87
- it { expect(all_output).to include '1/11' }
88
- it { expect(all_output).to include 'St. Nulla, abbess' }
89
- it { expect(all_output).to include 'only in cal2.txt' }
90
- it { expect(last_command).to be_successfully_executed }
91
- end
92
-
93
- describe 'only in one source' do
94
- let(:content1) { '' }
95
- let(:content2) { '1/11 : St. None, abbot' }
96
-
97
- it { expect(all_output).to include '1/11' }
98
- it { expect(all_output).to include 'St. None, abbot' }
99
- it { expect(all_output).to include 'only in cal2.txt' }
100
- it { expect(last_command).to be_successfully_executed }
101
- end
102
- end
103
- end
104
-
105
- describe 'query' do
106
- describe 'invalid data file from file system' do
107
- before(:each) do
108
- write_file 'invalid.txt', 'Foo bar baz'
109
- run 'calendariumrom query --calendar invalid.txt 2017-10-03'
110
- end
111
-
112
- it { expect(all_output).to include 'Invalid file format.' }
113
- it { expect(last_command).to have_exit_status 1 }
114
- end
115
-
116
- describe 'correct data file from file system' do
117
- before(:each) { run "calendariumrom query --calendar #{path_universal_la} 2017-10-03" }
118
-
119
- it { expect(all_output).to include 'season: Ordinary Time' }
120
- it { expect(last_command).to be_successfully_executed }
121
- end
122
-
123
- describe 'correct season naming' do
124
- before(:each) { run 'calendariumrom query 2017-10-03' }
125
-
126
- it { expect(all_output).to include 'season: Ordinary Time' }
127
- it { expect(last_command).to be_successfully_executed }
128
- end
129
-
130
- describe 'correct month querying' do
131
- before(:each) { run 'calendariumrom query 2015-06' }
132
-
133
- it { expect(all_output).to include 'Saint Cyril of Alexandria' }
134
- it { expect(all_output).to include 'Saint Anthony of Padua, priest and doctor' }
135
- it { expect(last_command).to be_successfully_executed }
136
- end
137
-
138
- describe 'correct year querying' do
139
- before(:each) { run 'calendariumrom query 2013' }
140
-
141
- it { expect(all_output).to include 'Saint John the Apostle and evangelist' }
142
- it { expect(all_output).to include 'Saint Paul of the Cross, priest' }
143
- it { expect(last_command).to be_successfully_executed }
144
- end
145
-
146
- describe 'prints primary celebrations' do
147
- before(:each) { run 'calendariumrom query 2018-12-25' }
148
-
149
- it { expect(all_output).to include "2018-12-25\nseason: Christmas Season\n\nChristmas" }
150
- it { expect(last_command).to be_successfully_executed }
151
- end
152
- end
153
-
154
- describe 'calendars' do
155
- before(:each) { run 'calendariumrom calendars' }
156
-
157
- it { expect(all_output).to include 'universal-en' }
158
- it { expect(all_output).to include 'czech-praha-cs' }
159
- it { expect(last_command).to be_successfully_executed }
160
- end
161
-
162
- describe 'version' do
163
- before(:each) { run 'calendariumrom version' }
164
-
165
- it { expect(all_output).to include CR::VERSION }
166
- it { expect(all_output).to include CR::RELEASE_DATE.strftime('%Y-%m-%d') }
167
- end
168
- end
169
- end
@@ -1,22 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe CR::Colour do
4
- CR::Colours.each do |colour|
5
- describe colour do
6
- describe '#name' do
7
- it { expect(colour.name).to have_translation }
8
- end
9
- end
10
- end
11
-
12
- describe 'indexing' do
13
- it 'is indexed by symbol' do
14
- expect(CR::Colours[:red]).to be CR::Colours::RED
15
- end
16
- end
17
-
18
- describe '#to_s' do
19
- it { expect(CR::Colours::RED.to_s)
20
- .to eq '#<CalendariumRomanum::Colour red>' }
21
- end
22
- end
@@ -1,46 +0,0 @@
1
- require_relative 'spec_helper'
2
-
3
- describe CalendariumRomanum::Data do
4
- describe 'all available data files are included' do
5
- data_path = File.expand_path '../data', File.dirname(__FILE__)
6
- glob = File.join(data_path, '*.txt')
7
-
8
- Dir[glob].each do |file|
9
- it "#{file} has it's Data entry" do
10
- expect(described_class.all)
11
- .to include(an_object_having_attributes(path: file))
12
- end
13
- end
14
- end
15
-
16
- describe 'all can be loaded' do
17
- described_class.each do |data|
18
- it data.siglum do
19
- expect { data.load }.not_to raise_exception
20
- end
21
- end
22
- end
23
-
24
- describe '#load_with_parents' do
25
- let(:sanctorale) { CR::Data['czech-olomouc-cs'].load_with_parents }
26
-
27
- it 'loads the specified calendar' do
28
- expect(sanctorale.get(6, 30).first.title)
29
- .to eq 'Výročí posvěcení katedrály sv. Václava'
30
- end
31
-
32
- it 'loads the parent calendar' do
33
- c = sanctorale.get(5, 6).first
34
-
35
- expect(c.title).to eq 'Sv. Jana Sarkandra, kněze a mučedníka'
36
- expect(c.rank).to be CR::Ranks::MEMORIAL_PROPER
37
- end
38
-
39
- it 'loads the grand-parent calendar' do
40
- c = sanctorale.get(9, 28).first
41
-
42
- expect(c.title).to eq 'Sv. Václava, mučedníka, hlavního patrona českého národa'
43
- expect(c.rank).to eq CR::Ranks::SOLEMNITY_PROPER
44
- end
45
- end
46
- end
@@ -1,68 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe CR::Util::DateParser do
4
- describe 'new' do
5
- it 'should accept a full date YYYY/MM/DD' do
6
- date_str = '2017/10/06'
7
- expect do
8
- described_class.new(date_str)
9
- end.not_to raise_exception
10
- end
11
-
12
- it 'should accept a full date YYYY-MM-DD' do
13
- date_str = '2017-10-06'
14
- expect do
15
- described_class.new(date_str)
16
- end.not_to raise_exception
17
- end
18
-
19
- it 'should accept a month range YYYY/MM' do
20
- date_str = '2017/10'
21
- expect do
22
- described_class.new(date_str)
23
- end.not_to raise_exception
24
- end
25
-
26
- it 'should accept a month range YYYY-MM' do
27
- date_str = '2017-10'
28
- expect do
29
- described_class.new(date_str)
30
- end.not_to raise_exception
31
- end
32
-
33
- it 'should accept a year range YYYY' do
34
- date_str = '2017'
35
- expect do
36
- described_class.new(date_str)
37
- end.not_to raise_exception
38
- end
39
-
40
- it 'should not accept an invalid month' do
41
- date_str = '2017-15'
42
- expect do
43
- described_class.new(date_str)
44
- end.to raise_exception(ArgumentError)
45
- end
46
-
47
- it 'should not accept an invalid day' do
48
- date_str = '2017-10-48'
49
- expect do
50
- described_class.new(date_str)
51
- end.to raise_exception(ArgumentError)
52
- end
53
-
54
- it 'should not accept a not-matching string' do
55
- date_str = 'foobar'
56
- expect do
57
- described_class.new(date_str)
58
- end.to raise_exception(ArgumentError)
59
- end
60
-
61
- it 'should not accept an empty string' do
62
- date_str = ''
63
- expect do
64
- described_class.new(date_str)
65
- end.to raise_exception(ArgumentError)
66
- end
67
- end
68
- end
@@ -1,61 +0,0 @@
1
- require 'spec_helper'
2
-
3
- # expectations concerning the Ruby implementation
4
- describe Date do
5
- describe '#-' do
6
- it 'returns Rational' do
7
- date_diff = Date.new(2013, 5, 5) - Date.new(2013, 5, 1)
8
- expect(date_diff).to be_a Rational
9
- expect(date_diff.numerator).to eq 4
10
- end
11
- end
12
-
13
- describe 'range' do
14
- let(:range) { (Date.new(2000, 1, 1) .. Date.new(2010, 1, 1)) }
15
-
16
- # please note that the RSpec 'include' matcher cannot
17
- # be used here, because it does't simply test
18
- # if `n.include?(x)` returns true (see it's implementation)
19
- # and it yields misleading results when testing inclusion
20
- # of DateTime in a Date range.
21
- describe 'test Date inclusion' do
22
- it 'includes' do
23
- expect(range.include?(Date.new(2005, 3, 3))).to be true
24
- end
25
-
26
- it 'excludes' do
27
- expect(range.include?(Date.new(1995, 3, 3))).to be false
28
- end
29
- end
30
-
31
- describe 'test DateTime inclusion' do
32
- # DateTime without time details is treated just like Date
33
- describe 'without time specified' do
34
- it 'excludes' do
35
- expect(range.include?(DateTime.new(1995, 3, 3))).to be false
36
- end
37
-
38
- it 'includes' do
39
- expect(range.include?(DateTime.new(2005, 3, 3))).to be true
40
- end
41
- end
42
-
43
- # treatment of a DateTime with time details is different
44
- describe 'with time specified' do
45
- it 'excludes a DateTime not falling in the range' do
46
- expect(range.include?(DateTime.new(1995, 3, 3, 1, 1, 1))).to be false
47
- end
48
-
49
- it '... but also one *falling* in the range!' do
50
- expect(range.include?(DateTime.new(2005, 3, 3, 1, 1, 1))).to be false
51
- end
52
- end
53
- end
54
- end
55
-
56
- describe 'inheritance' do
57
- it 'is inherited by DateTime' do
58
- expect(DateTime.new).to be_a Date
59
- end
60
- end
61
- end