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,77 +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
-
58
- describe '#sunday?' do
59
- it { expect(CR::Ranks::SUNDAY_UNPRIVILEGED.sunday?).to be true }
60
- it { expect(CR::Ranks::FERIAL.sunday?).to be false }
61
- end
62
-
63
- describe '#ferial?' do
64
- it { expect(CR::Ranks::FERIAL.ferial?).to be true }
65
- it { expect(CR::Ranks::FERIAL_PRIVILEGED.ferial?).to be true }
66
- it { expect(CR::Ranks::MEMORIAL_OPTIONAL.ferial?).to be false }
67
- end
68
-
69
- describe '#to_s' do
70
- it do
71
- I18n.with_locale(:en) do
72
- expect(CR::Ranks::FERIAL.to_s)
73
- .to eq '#<CalendariumRomanum::Rank @priority=3.13 desc="Ferials">'
74
- end
75
- end
76
- end
77
- end
@@ -1,58 +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
- before :each do
40
- # README examples sometimes print, but we don't want them
41
- # to distort test output
42
- allow(STDERR).to receive :puts
43
- end
44
-
45
- readme_path = File.expand_path('../../' + path, __FILE__)
46
- readme = File.read readme_path
47
- doc = MarkdownDocument.new readme
48
-
49
- doc.each_ruby_example do |code, line|
50
- describe "example L#{line}" do
51
- it 'executes without failure' do
52
- cls = Class.new
53
- cls.class_eval(code, readme_path, line)
54
- end
55
- end
56
- end
57
- end
58
- end
@@ -1,146 +0,0 @@
1
- # coding: utf-8
2
- require 'spec_helper'
3
-
4
- describe CR::SanctoraleFactory do
5
- describe '.create_layered' do
6
- describe 'metadata handling' do
7
- let(:metadata_a) { {'title' => 'Calendar', 'foo' => 'bar'} }
8
- let(:metadata_b) { {'title' => 'Second calendar', 'some' => 'handsome', 'extends' => ['with_a']} }
9
- let(:metadata_nonhash) { [:something] }
10
- let(:with_a) { CR::Sanctorale.new.tap {|s| s.metadata = metadata_a }}
11
- let(:with_b) { CR::Sanctorale.new.tap {|s| s.metadata = metadata_b } }
12
- let(:without) { CR::Sanctorale.new }
13
- let(:with_nonhash) { CR::Sanctorale.new.tap {|s| s.metadata = metadata_nonhash } }
14
-
15
- it 'creates merged metadata' do
16
- merged = {
17
- # conflicting key - later wins
18
- 'title' => 'Second calendar',
19
- # non-conflicting key from the first
20
- 'foo' => 'bar',
21
- # non-conflicting key from the second
22
- 'some' => 'handsome',
23
- }
24
-
25
- result = described_class.create_layered(with_a, with_b)
26
-
27
- expect(merged).to be < result.metadata
28
-
29
- # key 'extends' has special meaning and is therefore
30
- # always deleted from merged metadata
31
- expect(result.metadata).not_to have_key 'extends'
32
- end
33
-
34
- it 'stores original metadata' do
35
- result = described_class.create_layered(with_a, with_b)
36
- expect(result.metadata['components'])
37
- .to eq [metadata_a, metadata_b]
38
- end
39
-
40
- it 'overwrites key "components" if it exists' do
41
- result = described_class.create_layered(
42
- with_a,
43
- # this calendar's metadata have key 'components',
44
- # but that key is special and we always set it's contents
45
- # when merging
46
- CR::Sanctorale.new.tap {|s| s.metadata = {'components' => :c} }
47
- )
48
- expect(result.metadata['components'])
49
- .to eq [metadata_a, {'components' => :c}]
50
- end
51
-
52
- it 'copes with nil metadata on the first place' do
53
- result = described_class.create_layered(without, with_a)
54
-
55
- expect(metadata_a).to be < result.metadata
56
- expect(result.metadata['components'])
57
- .to eq [nil, metadata_a] # nils are preserved in 'components'
58
- end
59
-
60
- it 'copes with nil metadata on the last place' do
61
- result = described_class.create_layered(with_a, without)
62
-
63
- expect(metadata_a).to be < result.metadata
64
- expect(result.metadata['components'])
65
- .to eq [metadata_a, nil]
66
- end
67
-
68
- it 'copes with all nil' do
69
- result = described_class.create_layered(without, without)
70
-
71
- expect(result.metadata['components'])
72
- .to eq [nil, nil]
73
- end
74
-
75
- it 'copes with non-Hash metadata' do
76
- result = described_class.create_layered(
77
- with_a,
78
- with_nonhash
79
- )
80
- # non-Hash metadata are not merged, but they do appear
81
- # in 'components'
82
- expect(metadata_a).to be < result.metadata
83
- expect(result.metadata['components'])
84
- .to eq [metadata_a, metadata_nonhash]
85
- end
86
-
87
- it 'copes with all non-Hash' do
88
- result = described_class.create_layered(with_nonhash)
89
-
90
- expect(result.metadata['components'])
91
- .to eq [metadata_nonhash]
92
- end
93
- end
94
- end
95
-
96
- shared_examples 'calendar layering České Budějovice' do
97
- it 'has celebrations from the first file' do
98
- dd = layered_sanctorale.get 9, 28
99
- expect(dd.size).to eq 1
100
-
101
- d = dd.first
102
- expect(d.rank).to eq CR::Ranks::SOLEMNITY_PROPER
103
- expect(d.title).to eq 'Sv. Václava, mučedníka, hlavního patrona českého národa'
104
- end
105
-
106
- it 'has celebrations from the second file' do
107
- dd = layered_sanctorale.get 7, 4
108
- expect(dd.size).to eq 1
109
-
110
- d = dd.first
111
- expect(d.rank).to eq CR::Ranks::MEMORIAL_PROPER
112
- expect(d.title).to eq 'Sv. Prokopa, opata'
113
- end
114
-
115
- it 'celebrations from the last file win' do
116
- dd = layered_sanctorale.get 12, 22
117
- expect(dd.size).to eq 1
118
-
119
- d = dd.first
120
- expect(d.rank).to eq CR::Ranks::FEAST_PROPER
121
- expect(d.title).to eq 'Výročí posvěcení katedrály sv. Mikuláše'
122
- end
123
- end
124
-
125
- describe '.load_layered_from_files' do
126
- let(:layered_sanctorale) do
127
- files = %w(czech-cs.txt czech-cechy-cs.txt czech-budejovice-cs.txt).collect do |f|
128
- File.join(File.expand_path('../data', File.dirname(__FILE__)), f)
129
- end
130
-
131
- described_class.load_layered_from_files(*files)
132
- end
133
-
134
- include_examples 'calendar layering České Budějovice'
135
- end
136
-
137
- describe '.load_with_parents' do
138
- let(:layered_sanctorale) do
139
- path = File.join(File.expand_path('../data', File.dirname(__FILE__)), 'czech-budejovice-cs.txt')
140
-
141
- described_class.load_with_parents path
142
- end
143
-
144
- include_examples 'calendar layering České Budějovice'
145
- end
146
- end
@@ -1,229 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe CR::SanctoraleLoader do
4
- let(:s) { CR::Sanctorale.new }
5
- let(:l) { CR::SanctoraleLoader.new }
6
-
7
- describe 'data sources' do
8
- describe '#load_from_string' do
9
- before :each do
10
- str = '1/3 : Ss.mi Nominis Iesu'
11
- l.load_from_string str, s
12
- end
13
-
14
- it 'loads one entry' do
15
- expect(s.size).to eq 1
16
- end
17
- end
18
-
19
- describe '#load_from_file' do
20
- it 'loads something from file' do
21
- l.load_from_file(File.join(%w(data universal-la.txt)), s)
22
- expect(s.size).to be > 190
23
- end
24
- end
25
- end
26
-
27
- describe 'record/file format' do
28
- let(:record) { '4/25 f R : S. Marci, evangelistae' }
29
- let(:result) { l.send :load_line, record }
30
-
31
- describe 'title' do
32
- it 'loads it' do
33
- expect(result.title).to eq 'S. Marci, evangelistae'
34
- end
35
- end
36
-
37
- describe 'date' do
38
- describe 'full date as part of the record' do
39
- it 'loads date' do
40
- expect(result.date).to eq CR::AbstractDate.new(4, 25)
41
- end
42
- end
43
-
44
- describe 'month as heading' do
45
- before :each do
46
- str = [
47
- # month heading + day-only record
48
- '= 1',
49
- '25 f : In conversione S. Pauli, apostoli',
50
- # record with full date specified
51
- '4/25 f r : S. Marci, evangelistae',
52
- ].join "\n"
53
- l.load_from_string str, s
54
- end
55
-
56
- it 'loads a month heading and uses the month for subsequent records' do
57
- expect(s.get(1, 25)).not_to be_empty
58
- end
59
-
60
- it 'still allows full date specified in the record' do
61
- expect(s.get(4, 25)).not_to be_empty
62
- end
63
- end
64
- end
65
-
66
- describe 'colour' do
67
- describe 'not specified - sets default' do
68
- let(:record) { '4/25 : S. Marci, evangelistae' }
69
- it { expect(result.colour).to eq CR::Colours::WHITE }
70
- end
71
-
72
- describe 'sets colour if specified' do
73
- let(:record) { '4/25 f R : S. Marci, evangelistae' }
74
- it { expect(result.colour).to eq CR::Colours::RED }
75
- end
76
-
77
- describe 'sets colour if specified (lowercase)' do
78
- let(:record) { '4/25 f r : S. Marci, evangelistae' }
79
- it { expect(result.colour).to eq CR::Colours::RED }
80
- end
81
- end
82
-
83
- describe 'rank' do
84
- # say we specify a proper calendar of a church dedicated to St. George
85
- describe 'not specified - sets default' do
86
- let(:record) { '4/23 : S. Georgii, martyris' }
87
- it { expect(result.rank).to eq CR::Ranks::MEMORIAL_OPTIONAL }
88
- end
89
-
90
- describe 'sets rank if specified' do
91
- let(:record) { '4/23 s R : S. Georgii, martyris' }
92
- it { expect(result.rank).to eq CR::Ranks::SOLEMNITY_GENERAL }
93
- end
94
-
95
- describe 'sets rank if specified (uppercase)' do
96
- let(:record) { '4/23 S R : S. Georgii, martyris' }
97
- it { expect(result.rank).to eq CR::Ranks::SOLEMNITY_GENERAL }
98
- end
99
-
100
- describe 'sets exact rank if specified' do
101
- let(:record) { '4/23 s1.4 R : S. Georgii, martyris' }
102
- it { expect(result.rank).to eq CR::Ranks::SOLEMNITY_PROPER }
103
- end
104
-
105
- describe 'sets exact rank if specified only by number' do
106
- let(:record) { '4/23 1.4 R : S. Georgii, martyris' }
107
- it { expect(result.rank).to eq CR::Ranks::SOLEMNITY_PROPER }
108
- end
109
- end
110
-
111
- describe 'symbol' do
112
- describe 'not specified - sets default' do
113
- let(:record) { '4/23 : S. Georgii, martyris' }
114
- it { expect(result.symbol).to be nil }
115
- end
116
-
117
- describe 'specified - uses it' do
118
- let(:record) { '4/23 george : S. Georgii, martyris' }
119
- it { expect(result.symbol).to be :george }
120
- end
121
-
122
- describe 'supported characters' do
123
- let(:record) { '4/29 none_123 : S. Nullius, abbatis' }
124
- it { expect(result.symbol).to be :none_123 }
125
- end
126
- end
127
- end
128
-
129
- describe 'Celebration properties set regardless of the loaded data' do
130
- describe 'cycle' do
131
- it 'always sets it to :sanctorale' do
132
- str = '4/23 1.4 R : S. Georgii, martyris'
133
- record = l.send :load_line, str
134
- expect(record.cycle).to be :sanctorale
135
- end
136
- end
137
- end
138
-
139
- describe 'invalid input' do
140
- describe 'syntax errors' do
141
- it 'invalid syntax' do
142
- str = 'line without standard beginning'
143
- expect do
144
- l.load_from_string str, s
145
- end.to raise_exception(CR::InvalidDataError, /Syntax error/)
146
- end
147
- end
148
-
149
- describe 'syntactically correct data making no sense' do
150
- it 'invalid month heading' do
151
- str = '= 13'
152
- expect do
153
- l.load_from_string str, s
154
- end.to raise_exception(CR::InvalidDataError, /Invalid month/)
155
- end
156
-
157
- it 'one more invalid month heading' do
158
- str = '= 0'
159
- expect do
160
- l.load_from_string str, s
161
- end.to raise_exception(CR::InvalidDataError, /Invalid month/)
162
- end
163
-
164
- it 'invalid month' do
165
- str = '100/25 f : In conversione S. Pauli, apostoli'
166
- expect do
167
- l.load_from_string str, s
168
- end.to raise_exception(CR::InvalidDataError, /Invalid month/)
169
- end
170
-
171
- it 'line with day only, without preceding month heading' do
172
- str = '25 f : In conversione S. Pauli, apostoli'
173
- expect do
174
- l.load_from_string str, s
175
- end.to raise_exception(CR::InvalidDataError, /Invalid month/)
176
- end
177
-
178
- it 'invalid day' do
179
- str = '1/250 f : In conversione S. Pauli, apostoli'
180
- expect do
181
- l.load_from_string str, s
182
- end.to raise_exception(CR::InvalidDataError, /Invalid day/)
183
- end
184
-
185
- it 'invalid rank' do
186
- str = '1/25 X : In conversione S. Pauli, apostoli'
187
- expect do
188
- l.load_from_string str, s
189
- end.to raise_exception(CR::InvalidDataError, /Syntax error/)
190
- end
191
-
192
- it 'invalid numeric rank' do
193
- str = '4/23 s8.4 R : S. Georgii, martyris'
194
- expect do
195
- l.load_from_string str, s
196
- end.to raise_exception(CR::InvalidDataError, /rank/)
197
- end
198
-
199
- it 'invalid combination of rank latter and number' do
200
- str = '4/23 m2.5 R : S. Georgii, martyris'
201
- expect do
202
- l.load_from_string str, s
203
- end.to raise_exception(CR::InvalidDataError, /rank/)
204
- end
205
- end
206
- end
207
-
208
- describe 'YAML front matter (YFM)' do
209
- it 'sets metadata nil if YFM is not provided' do
210
- expect(l.load_from_string('').metadata)
211
- .to be nil
212
- end
213
-
214
- it 'loads metadata if provided' do
215
- expect(l.load_from_string("---\nkey: value\n---").metadata)
216
- .to eq({'key' => 'value'})
217
- end
218
-
219
- it 'does not load metadata with no end' do
220
- # Since YFM is being processed on encountering the closing
221
- # triple-dash, YFM spanning the whole file and not properly
222
- # closed will not be loaded.
223
- # (Implementation detail and crazy edge case, may change
224
- # in future without warning.)
225
- expect(l.load_from_string("---\nkey: value").metadata)
226
- .to be nil
227
- end
228
- end
229
- end