citeproc-ruby 1.1.8 → 1.1.10

Sign up to get free protection for your applications and to get access to all the features.
Files changed (42) hide show
  1. checksums.yaml +5 -5
  2. data/Gemfile +10 -32
  3. data/lib/citeproc/ruby/renderer.rb +2 -1
  4. data/lib/citeproc/ruby/version.rb +1 -1
  5. metadata +14 -84
  6. data/.rspec +0 -3
  7. data/.rubocop.yml +0 -1156
  8. data/.simplecov +0 -4
  9. data/Guardfile +0 -14
  10. data/features/bibliography.feature +0 -25
  11. data/features/locale_overrides.feature +0 -31
  12. data/features/name_options.feature +0 -37
  13. data/features/names.feature +0 -198
  14. data/features/renderer.feature +0 -94
  15. data/features/sort.feature +0 -50
  16. data/features/step_definitions/engine.rb +0 -21
  17. data/features/step_definitions/renderer.rb +0 -85
  18. data/features/style_immanent_locale_terms.feature +0 -30
  19. data/features/support/env.rb +0 -35
  20. data/features/support/hooks.rb +0 -10
  21. data/spec/citeproc/ruby/engine_spec.rb +0 -120
  22. data/spec/citeproc/ruby/formats/default_spec.rb +0 -168
  23. data/spec/citeproc/ruby/formats/html_spec.rb +0 -167
  24. data/spec/citeproc/ruby/renderer/choose_spec.rb +0 -293
  25. data/spec/citeproc/ruby/renderer/date_spec.rb +0 -173
  26. data/spec/citeproc/ruby/renderer/group_spec.rb +0 -114
  27. data/spec/citeproc/ruby/renderer/history_spec.rb +0 -47
  28. data/spec/citeproc/ruby/renderer/label_spec.rb +0 -225
  29. data/spec/citeproc/ruby/renderer/layout_spec.rb +0 -41
  30. data/spec/citeproc/ruby/renderer/macro_spec.rb +0 -31
  31. data/spec/citeproc/ruby/renderer/names_spec.rb +0 -396
  32. data/spec/citeproc/ruby/renderer/number_spec.rb +0 -120
  33. data/spec/citeproc/ruby/renderer/text_spec.rb +0 -125
  34. data/spec/citeproc/ruby/renderer_spec.rb +0 -65
  35. data/spec/fixtures/items.rb +0 -113
  36. data/spec/fixtures/locales/locales-de-DE.xml +0 -298
  37. data/spec/fixtures/locales/locales-en-US.xml +0 -304
  38. data/spec/fixtures/locales/locales-fr-FR.xml +0 -317
  39. data/spec/fixtures/styles/apa-with-different-translations.csl +0 -451
  40. data/spec/fixtures/styles/apa.csl +0 -443
  41. data/spec/fixtures/styles/modern-language-association-8th-edition.csl +0 -293
  42. data/spec/spec_helper.rb +0 -73
@@ -1,167 +0,0 @@
1
- require 'spec_helper'
2
-
3
- module CiteProc
4
- module Ruby
5
-
6
- describe 'Formats::Html' do
7
- it 'can be created with an options hash' do
8
- expect(Formats::Html.new(:css_only => true)).to be_css_only
9
- end
10
- end
11
-
12
- describe 'Formats::Html#apply' do
13
- let(:format) { Format.load 'html' }
14
- let(:node) { CSL::Style::Text.new }
15
-
16
- describe 'text-case formats' do
17
- it 'supports lowercase' do
18
- node[:'text-case'] = 'lowercase'
19
- expect(format.apply('Foo BAR', node)).to eq('foo bar')
20
- end
21
- end
22
-
23
- describe 'entity escaping' do
24
- it 'escapes entities in the original text' do
25
- node[:'text-case'] = 'lowercase'
26
- expect(format.apply('Foo & BAR', node)).to eq('foo & bar')
27
- end
28
-
29
- it 'does not not apply casing to escaped entities' do
30
- node[:'text-case'] = 'uppercase'
31
- expect(format.apply('Foo & BAR', node)).to eq('FOO & BAR')
32
- end
33
-
34
- it 'escapes entities in affixes' do
35
- node[:prefix] = '<'
36
- node[:suffix] = '>'
37
- expect(format.apply('foo', node)).to eq('&lt;foo&gt;')
38
- end
39
-
40
- it 'escapes entities in quotes' do
41
- locale = CSL::Locale.new
42
- locale.store 'open-quote', '<'
43
- locale.store 'close-quote', '>'
44
-
45
- node[:quotes] = true
46
- expect(format.apply('foo', node, locale)).to eq('&lt;foo&gt;')
47
- end
48
- end
49
-
50
- describe 'affixes' do
51
- it 'are added after text formats have been applied' do
52
- node[:prefix] = 'foo'
53
- node[:suffix] = 'ooo'
54
- node[:'font-style'] = 'italic'
55
-
56
- expect(format.apply('ooo', node)).to eq('foo<i>ooo</i>ooo')
57
- end
58
-
59
- it 'are added before text formats have been applied for layout nodes' do
60
- layout = CSL::Style::Layout.new
61
-
62
- layout[:prefix] = 'foo'
63
- layout[:suffix] = 'ooo'
64
- layout[:'font-style'] = 'italic'
65
-
66
- expect(format.apply('ooo', layout)).to eq('<i>foooooooo</i>')
67
- end
68
- end
69
-
70
- describe 'font-style' do
71
- it 'supports italic in both modes' do
72
- node[:'font-style'] = 'italic'
73
-
74
- expect(format.apply('foo bar', node)).to eq('<i>foo bar</i>')
75
-
76
- format.config[:italic] = 'em'
77
- expect(format.apply('foo bar', node)).to eq('<em>foo bar</em>')
78
-
79
- format.config[:css_only] = true
80
- expect(format.apply('foo bar', node)).to eq('<span style="font-style: italic">foo bar</span>')
81
- end
82
-
83
- it 'supports normal and oblique via css' do
84
- node[:'font-style'] = 'oblique'
85
- expect(format.apply('foo bar', node)).to eq('<span style="font-style: oblique">foo bar</span>')
86
-
87
- node[:'font-style'] = 'normal'
88
- expect(format.apply('foo bar', node)).to eq('<span style="font-style: normal">foo bar</span>')
89
- end
90
- end
91
-
92
- it 'supports font-variant via css' do
93
- node[:'font-variant'] = 'small-caps'
94
- expect(format.apply('foo bar', node)).to eq('<span style="font-variant: small-caps">foo bar</span>')
95
- end
96
-
97
- describe 'font-weight' do
98
- it 'supports bold in both modes' do
99
- node[:'font-weight'] = 'bold'
100
-
101
- expect(format.apply('foo bar', node)).to eq('<b>foo bar</b>')
102
-
103
- format.config[:bold] = 'strong'
104
- expect(format.apply('foo bar', node)).to eq('<strong>foo bar</strong>')
105
-
106
- format.config[:css_only] = true
107
- expect(format.apply('foo bar', node)).to eq('<span style="font-weight: bold">foo bar</span>')
108
- end
109
-
110
- it 'supports normal and light via css' do
111
- node[:'font-weight'] = 'light'
112
- expect(format.apply('foo bar', node)).to eq('<span style="font-weight: light">foo bar</span>')
113
-
114
- node[:'font-weight'] = 'normal'
115
- expect(format.apply('foo bar', node)).to eq('<span style="font-weight: normal">foo bar</span>')
116
- end
117
- end
118
-
119
- it 'supports text-decoration via css' do
120
- node[:'text-decoration'] = 'underline'
121
- expect(format.apply('foo bar', node)).to eq('<span style="text-decoration: underline">foo bar</span>')
122
- end
123
-
124
- it 'supports vertical-align via css' do
125
- node[:'vertical-align'] = 'sup'
126
- expect(format.apply('foo bar', node)).to eq('<span style="vertical-align: super">foo bar</span>')
127
- end
128
-
129
- describe 'display' do
130
- it 'is supported in an outer container' do
131
- node[:'display'] = 'block'
132
- node[:'text-decoration'] = 'underline'
133
- expect(format.apply('foo bar', node)).to eq('<div class="csl-block"><span style="text-decoration: underline">foo bar</span></div>')
134
-
135
- node[:prefix] = '('
136
- expect(format.apply('foo bar', node)).to eq('<div class="csl-block">(<span style="text-decoration: underline">foo bar</span></div>')
137
- end
138
- end
139
-
140
- describe 'bibliography formats' do
141
- let(:bibliography) do
142
- CiteProc::Bibliography.new do |b|
143
- b.push 'id-1', 'foo'
144
- b.push 'id-2', 'bar'
145
- end
146
- end
147
-
148
- it 'can be applied' do
149
- format.config[:bib_indent] = nil
150
- format.bibliography(bibliography)
151
- expect(bibliography.join).to eq('<ol class="csl-bibliography"><li class="csl-entry">foo</li><li class="csl-entry">bar</li></ol>')
152
- end
153
-
154
- it 'can be customized' do
155
- format.config[:bib_indent] = nil
156
- format.config[:bib_entry_class] = nil
157
- format.config[:bib_entry] = 'span'
158
- format.config[:bib_container] = 'div'
159
-
160
- format.bibliography(bibliography)
161
- expect(bibliography.join).to eq('<div class="csl-bibliography"><span>foo</span><span>bar</span></div>')
162
- end
163
- end
164
- end
165
-
166
- end
167
- end
@@ -1,293 +0,0 @@
1
- require 'spec_helper'
2
-
3
- module CiteProc
4
- module Ruby
5
- describe 'Conditional Rendering Elements' do
6
- let(:renderer) { Renderer.new }
7
-
8
- let(:item) {
9
- i = CiteProc::CitationItem.new(:id => 'ID-1')
10
- i.data = CiteProc::Item.new(:id => 'ID-1')
11
- i
12
- }
13
-
14
- describe 'Renderer#render_choose' do
15
- let(:node) { CSL::Style::Choose.new }
16
-
17
- it 'returns an empty string by default' do
18
- expect(renderer.render(item, node)).to eq('')
19
- end
20
-
21
- describe 'when there is a single nested block' do
22
- let(:block) do
23
- CSL::Style::Choose::Block.new do |b|
24
- b << CSL::Style::Text.new( :term => 'retrieved')
25
- end
26
- end
27
-
28
- before(:each) { node << block }
29
-
30
- it 'returns the content of the nested node when the condition evaluates' do
31
- block[:variable] = 'issue'
32
- item.data[:issue] = 1
33
- expect(renderer.render(item, node)).to eq('retrieved')
34
- end
35
-
36
- it 'returns an empty string when the condition does not hold' do
37
- block[:variable] = 'issue'
38
- expect(renderer.render(item, node)).to eq('')
39
- end
40
- end
41
- end
42
-
43
- describe 'Renderer#render_block' do
44
- let(:node) { CSL::Style::Choose::Block.new }
45
-
46
- it 'returns an empty string by default' do
47
- expect(renderer.render(item, node)).to eq('')
48
- end
49
-
50
- describe 'when there is a text node in the block' do
51
- before(:each) { node << CSL::Style::Text.new( :term => 'retrieved') }
52
-
53
- it 'returns the content of the nested node when there is no condition' do
54
- expect(renderer.render(item, node)).to eq('retrieved')
55
- end
56
- end
57
- end
58
-
59
- describe 'Renderer#evaluates?' do
60
- let(:node) { CSL::Style::Choose::Block.new }
61
-
62
- it 'returns true by default (else block)' do
63
- expect(renderer.evaluates?(item, node)).to be_truthy
64
- end
65
-
66
- it 'fails if there is an unknown condition type' do
67
- allow(node).to receive(:conditions).and_return([[:unknown, :all?, 'x']])
68
- expect { renderer.evaluates?(item, node) }.to raise_error(RuntimeError)
69
- end
70
-
71
- it 'returns false for disambiguate (implementation pending)' do
72
- node[:disambiguate] = true
73
- expect(renderer.evaluates?(item, node)).to be_falsey
74
- end
75
-
76
- it 'returns false for position (implementation pending)' do
77
- node[:position] = 'first'
78
- expect(renderer.evaluates?(item, node)).to be_falsey
79
- end
80
-
81
- describe 'for is-numeric conditions' do
82
- before { node[:'is-numeric'] = 'note archive' }
83
-
84
- it 'returns false unless all variables are numeric' do
85
- expect(renderer.evaluates?(item, node)).to be_falsey
86
-
87
- item.data[:archive] = 1
88
- expect(renderer.evaluates?(item, node)).to be_falsey
89
-
90
- item.data[:note] = 'L2d'
91
- expect(renderer.evaluates?(item, node)).to be_truthy
92
-
93
- item.data[:archive] = 'second'
94
- expect(renderer.evaluates?(item, node)).to be_falsey
95
- end
96
- end
97
-
98
- describe 'for is-uncertain-date conditions' do
99
- before { node[:'is-uncertain-date'] = 'issued' }
100
-
101
- it 'returns false unless all variables contain uncertain dates' do
102
- expect(renderer.evaluates?(item, node)).to be_falsey
103
-
104
- item.data[:issued] = 2012
105
- expect(renderer.evaluates?(item, node)).to be_falsey
106
-
107
- item.data[:issued].uncertain!
108
- expect(renderer.evaluates?(item, node)).to be_truthy
109
- end
110
- end
111
-
112
- describe 'for locator conditions' do
113
- before { node[:locator] = 'figure book sub-verbo' }
114
-
115
- it 'returns false unless the locator matches all of the given locators' do
116
- expect(renderer.evaluates?(item, node)).to be_falsey
117
-
118
- item.locator = :book
119
- expect(renderer.evaluates?(item, node)).to be_falsey
120
-
121
- item.locator = 'volume'
122
- expect(renderer.evaluates?(item, node)).to be_falsey
123
-
124
- item.locator = 'figure'
125
- expect(renderer.evaluates?(item, node)).to be_falsey
126
- end
127
-
128
- describe 'when the match attribute is set to "any"' do
129
- before { node[:match] = 'any' }
130
-
131
- it 'returns false unless the locator matches any of the given locators' do
132
- expect(renderer.evaluates?(item, node)).to be_falsey
133
-
134
- item.locator = :book
135
- expect(renderer.evaluates?(item, node)).to be_truthy
136
-
137
- item.locator = 'volume'
138
- expect(renderer.evaluates?(item, node)).to be_falsey
139
-
140
- item.locator = 'figure'
141
- expect(renderer.evaluates?(item, node)).to be_truthy
142
- end
143
-
144
- it 'matches "sub verbo" as "sub-verbo"' do
145
- item.locator = 'sub-verbo'
146
- expect(renderer.evaluates?(item, node)).to be_truthy
147
-
148
- item.locator = 'sub verbo'
149
- expect(renderer.evaluates?(item, node)).to be_truthy
150
- end
151
- end
152
- end
153
-
154
- describe 'for type conditions' do
155
- before { node[:type] = 'book treaty' }
156
-
157
- it 'returns false unless the type matches all of the given types' do
158
- expect(renderer.evaluates?(item, node)).to be_falsey
159
-
160
- item.data[:type] = :book
161
- expect(renderer.evaluates?(item, node)).to be_falsey
162
-
163
- item.data[:type] = 'article'
164
- expect(renderer.evaluates?(item, node)).to be_falsey
165
-
166
- item.data[:type] = 'treaty'
167
- expect(renderer.evaluates?(item, node)).to be_falsey
168
- end
169
-
170
- describe 'when the match attribute is set to "any"' do
171
- before { node[:match] = 'any' }
172
-
173
- it 'returns false unless the locator matches any of the given locators' do
174
- expect(renderer.evaluates?(item, node)).to be_falsey
175
-
176
- item.data[:type] = :book
177
- expect(renderer.evaluates?(item, node)).to be_truthy
178
-
179
- item.data[:type] = 'article'
180
- expect(renderer.evaluates?(item, node)).to be_falsey
181
-
182
- item.data[:type] = 'treaty'
183
- expect(renderer.evaluates?(item, node)).to be_truthy
184
- end
185
- end
186
- end
187
-
188
- describe 'for variable conditions' do
189
- before { node[:variable] = 'volume issue' }
190
-
191
- it 'returns false unless the item has all variables' do
192
- expect(renderer.evaluates?(item, node)).to be_falsey
193
-
194
- item.data[:volume] = 1
195
- expect(renderer.evaluates?(item, node)).to be_falsey
196
-
197
- item.data[:issue] = 1
198
- expect(renderer.evaluates?(item, node)).to be_truthy
199
-
200
- item.data[:volume] = nil
201
- expect(renderer.evaluates?(item, node)).to be_falsey
202
- end
203
-
204
- describe 'with internal negations' do
205
- before { node[:variable] = 'volume not:issue' }
206
-
207
- it 'returns false unless the item has (or does not have) all variables' do
208
- expect(renderer.evaluates?(item, node)).to be_falsey
209
-
210
- item.data[:volume] = 1
211
- expect(renderer.evaluates?(item, node)).to be_truthy
212
-
213
- item.data[:issue] = 1
214
- expect(renderer.evaluates?(item, node)).to be_falsey
215
-
216
- item.data[:volume] = nil
217
- expect(renderer.evaluates?(item, node)).to be_falsey
218
- end
219
- end
220
-
221
- describe 'and the any-matcher' do
222
- before { node[:match] = 'any' }
223
-
224
- it 'returns false unless the item has any of the variables' do
225
- expect(renderer.evaluates?(item, node)).to be_falsey
226
-
227
- item.data[:volume] = 1
228
- expect(renderer.evaluates?(item, node)).to be_truthy
229
-
230
- item.data[:issue] = 1
231
- expect(renderer.evaluates?(item, node)).to be_truthy
232
-
233
- item.data[:volume] = nil
234
- expect(renderer.evaluates?(item, node)).to be_truthy
235
- end
236
-
237
- describe 'with internal negations' do
238
- before { node[:variable] = 'volume not:issue' }
239
-
240
- it 'returns false unless the item has (or does not have) any of the variables' do
241
- expect(renderer.evaluates?(item, node)).to be_truthy
242
-
243
- item.data[:volume] = 1
244
- expect(renderer.evaluates?(item, node)).to be_truthy
245
-
246
- item.data[:issue] = 1
247
- expect(renderer.evaluates?(item, node)).to be_truthy
248
-
249
- item.data[:volume] = nil
250
- expect(renderer.evaluates?(item, node)).to be_falsey
251
- end
252
- end
253
- end
254
-
255
- describe 'and the none-matcher' do
256
- before { node[:match] = 'none' }
257
-
258
- it 'returns false unless the item has none of the variables' do
259
- expect(renderer.evaluates?(item, node)).to be_truthy
260
-
261
- item.data[:volume] = 1
262
- expect(renderer.evaluates?(item, node)).to be_falsey
263
-
264
- item.data[:issue] = 1
265
- expect(renderer.evaluates?(item, node)).to be_falsey
266
-
267
- item.data[:volume] = nil
268
- expect(renderer.evaluates?(item, node)).to be_falsey
269
- end
270
-
271
- describe 'with internal negations' do
272
- before { node[:variable] = 'volume not:issue' }
273
-
274
- it 'returns false unless the item has (or does not have) none of the variables' do
275
- expect(renderer.evaluates?(item, node)).to be_falsey
276
-
277
- item.data[:volume] = 1
278
- expect(renderer.evaluates?(item, node)).to be_falsey
279
-
280
- item.data[:issue] = 1
281
- expect(renderer.evaluates?(item, node)).to be_falsey
282
-
283
- item.data[:volume] = nil
284
- expect(renderer.evaluates?(item, node)).to be_truthy
285
- end
286
- end
287
- end
288
- end
289
- end
290
-
291
- end
292
- end
293
- end