csl 1.2.1 → 1.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/features/step_definitions/locale_steps.rb +7 -5
- data/features/step_definitions/parser_steps.rb +8 -8
- data/features/step_definitions/style_steps.rb +3 -3
- data/lib/csl/loader.rb +3 -3
- data/lib/csl/node.rb +5 -0
- data/lib/csl/style/group.rb +1 -6
- data/lib/csl/version.rb +1 -1
- data/spec/csl/info_spec.rb +50 -50
- data/spec/csl/locale/date_spec.rb +13 -13
- data/spec/csl/locale/style_options_spec.rb +3 -3
- data/spec/csl/locale/term_spec.rb +51 -51
- data/spec/csl/locale_spec.rb +36 -36
- data/spec/csl/node_spec.rb +64 -62
- data/spec/csl/parser_spec.rb +19 -19
- data/spec/csl/schema_spec.rb +27 -26
- data/spec/csl/style/choose_spec.rb +8 -8
- data/spec/csl/style/date_spec.rb +2 -2
- data/spec/csl/style/label_spec.rb +8 -8
- data/spec/csl/style/names_spec.rb +2 -2
- data/spec/csl/style/number_spec.rb +17 -17
- data/spec/csl/style/sort_spec.rb +1 -1
- data/spec/csl/style_spec.rb +27 -27
- data/spec/csl/treelike_spec.rb +20 -20
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4ba697e8ee6beb0a5f0e7cb670c6e9e7310ef449
|
4
|
+
data.tar.gz: b533d511d930f657c16d33eb65514b740817559b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bfe06f2128b18206ffa1cc3a201b04bc6e65f6ae6b84cad7314793914568ea25db42ec0e153ece3f2fdac7d20d00cc4b31faa2b33cd1fec6aed447bc9887b207
|
7
|
+
data.tar.gz: c4b0e5a5e26af8fe88d9ada3b7ac7aeb50ea4f3925fe835525e4c0fea427347dd78712d10f4da8913b08e14ad867b12e9fdc36b5862650321ffd8beab4c9fad9
|
@@ -11,7 +11,7 @@ When /^I ordinalize the number (\d+)(?: using the (long) form(?: and (feminine|m
|
|
11
11
|
end
|
12
12
|
|
13
13
|
Then /^the ordinal should (?:be|equal) "([^"]*)"$/ do |ord|
|
14
|
-
@ordinal.
|
14
|
+
expect(@ordinal).to eq(ord)
|
15
15
|
end
|
16
16
|
|
17
17
|
When /^I ordinalize these numbers:?$/ do |table|
|
@@ -22,13 +22,15 @@ When /^I ordinalize these numbers:?$/ do |table|
|
|
22
22
|
end
|
23
23
|
|
24
24
|
Then /^the ordinals should (?:be|equal):?$/ do |table|
|
25
|
-
@ordinals.join(' ').
|
25
|
+
expect(@ordinals.join(' ')).to eq(table.rows.flatten.join(' '))
|
26
26
|
end
|
27
27
|
|
28
28
|
Then /^the locale should should have (\d+) terms$/ do |num|
|
29
|
-
@csl.terms.length.
|
29
|
+
expect(@csl.terms.length).to eq(num.to_i)
|
30
30
|
end
|
31
31
|
|
32
32
|
Then /^the (\w+[\?!]?) of the term "([^"]*)" should be "([^"]*)"$/ do |method, name, expected|
|
33
|
-
|
34
|
-
|
33
|
+
expect(
|
34
|
+
@csl.terms.detect { |t| t.name == name }.send(method)
|
35
|
+
).to eq(expected)
|
36
|
+
end
|
@@ -6,35 +6,35 @@ end
|
|
6
6
|
Then /^(?:the )?(\w+[\?!]?) should be "([^"]*)"$/ do |name, expected|
|
7
7
|
actual = @csl.send(name)
|
8
8
|
actual = !!actual if expected =~ /^true|false$/
|
9
|
-
actual.to_s.
|
9
|
+
expect(actual.to_s).to eq(expected)
|
10
10
|
end
|
11
11
|
|
12
12
|
Then /^the (\w+) (\w+) should be "([^"]*)"$/ do |outer, inner, expected|
|
13
|
-
@csl.send(outer).send(inner).to_s.
|
13
|
+
expect(@csl.send(outer).send(inner).to_s).to eq(expected)
|
14
14
|
end
|
15
15
|
|
16
16
|
Then /^the attribute "([^"]*)" should be "([^"]*)"$/ do |name, expected|
|
17
|
-
@csl[name.to_sym].
|
17
|
+
expect(@csl[name.to_sym]).to eq(expected)
|
18
18
|
end
|
19
19
|
|
20
20
|
Then /^the node should have (\d+) (\w+)$/ do |length, name|
|
21
|
-
@csl.send(name).length.
|
21
|
+
expect(@csl.send(name).length).to eq(length.to_i)
|
22
22
|
end
|
23
23
|
|
24
24
|
Then /^the (\w+) number (\d+) should have the attribute "([^"]*)" set to "([^"]*)"$/ do |name, offset, attribute, expected|
|
25
|
-
@csl.send("#{name}s")[offset.to_i - 1][attribute.to_sym].
|
25
|
+
expect(@csl.send("#{name}s")[offset.to_i - 1][attribute.to_sym]).to eq(expected)
|
26
26
|
end
|
27
27
|
|
28
28
|
Then /^the (\w+) number (\d+) should( not)? be a (\w+)$/ do |name, offset, negate, predicate|
|
29
|
-
@csl.send("#{name}s")[offset.to_i - 1].send("#{predicate}?").
|
29
|
+
expect(@csl.send("#{name}s")[offset.to_i - 1].send("#{predicate}?")).to eq(negate.nil?)
|
30
30
|
end
|
31
31
|
|
32
32
|
Then /^the (\w+) number (\d+)'s (\w+) should( not)? be "([^"]*)"$/ do |name, offset, method, negate, expected|
|
33
33
|
actual = @csl.send("#{name}s")[offset.to_i - 1].send(method).to_s
|
34
34
|
|
35
35
|
if negate.nil?
|
36
|
-
actual.
|
36
|
+
expect(actual).to eq(expected)
|
37
37
|
else
|
38
|
-
actual.
|
38
|
+
expect(actual).not_to eq(expected)
|
39
39
|
end
|
40
40
|
end
|
@@ -4,13 +4,13 @@ When /^I load the style from the string$/ do |string|
|
|
4
4
|
end
|
5
5
|
|
6
6
|
Then /^the locale (\d+) should should have (\d+) terms?$/ do |locale, term|
|
7
|
-
@csl.locales[locale.to_i - 1].terms.length.
|
7
|
+
expect(@csl.locales[locale.to_i - 1].terms.length).to eq(term.to_i)
|
8
8
|
end
|
9
9
|
|
10
10
|
Then /^the locale (\d+) (\w+\??) should be "([^"]*)"$/ do |locale, method, expected|
|
11
|
-
@csl.locales[locale.to_i - 1].send(method).to_s.
|
11
|
+
expect(@csl.locales[locale.to_i - 1].send(method).to_s).to eq(expected)
|
12
12
|
end
|
13
13
|
|
14
14
|
Then /^the style should have (\d+) contributors$/ do |num|
|
15
|
-
@csl.info.contributors.length.
|
15
|
+
expect(@csl.info.contributors.length).to eq(num.to_i)
|
16
16
|
end
|
data/lib/csl/loader.rb
CHANGED
@@ -72,11 +72,11 @@ module CSL
|
|
72
72
|
input = input.to_s
|
73
73
|
|
74
74
|
case
|
75
|
-
when File.
|
75
|
+
when File.exist?(input)
|
76
76
|
location = input
|
77
|
-
when File.
|
77
|
+
when File.exist?(extend_name(input))
|
78
78
|
location = extend_name(input)
|
79
|
-
when File.
|
79
|
+
when File.exist?(extend_path(input))
|
80
80
|
location = extend_path(input)
|
81
81
|
else
|
82
82
|
location = input
|
data/lib/csl/node.rb
CHANGED
@@ -433,6 +433,11 @@ module CSL
|
|
433
433
|
end
|
434
434
|
|
435
435
|
|
436
|
+
# The node's formatting options. If the node's parent responds
|
437
|
+
# to `inheritable_formatting_options`, these will be included
|
438
|
+
# in the result. This makes it easy for nodes to push formatting
|
439
|
+
# options to their child nodes.
|
440
|
+
#
|
436
441
|
# @return [Hash] the node's formatting options
|
437
442
|
def formatting_options
|
438
443
|
options = attributes_for Schema.attr(:formatting)
|
data/lib/csl/style/group.rb
CHANGED
@@ -5,8 +5,7 @@ module CSL
|
|
5
5
|
# element (with the exception of {Layout}). Group nodes may carry the
|
6
6
|
# delimiter attribute to separate their child elements, as well as
|
7
7
|
# affixes and display attributes (applied to the output of the group
|
8
|
-
# as a whole)
|
9
|
-
# elements).
|
8
|
+
# as a whole).
|
10
9
|
#
|
11
10
|
# Groups implicitly act as a conditionals: a Group and its child
|
12
11
|
# elements are suppressed if a) at least one rendering element in
|
@@ -27,10 +26,6 @@ module CSL
|
|
27
26
|
def formatting_options
|
28
27
|
attributes_for :display, *Schema.attr(:affixes)
|
29
28
|
end
|
30
|
-
|
31
|
-
def inheritable_formatting_options
|
32
|
-
attributes_for :'text-case', *Schema.attr(:font)
|
33
|
-
end
|
34
29
|
end
|
35
30
|
|
36
31
|
end
|
data/lib/csl/version.rb
CHANGED
data/spec/csl/info_spec.rb
CHANGED
@@ -4,23 +4,23 @@ module CSL
|
|
4
4
|
|
5
5
|
describe Info do
|
6
6
|
|
7
|
-
it {
|
8
|
-
it {
|
7
|
+
it { is_expected.not_to be_nil }
|
8
|
+
it { is_expected.not_to have_children }
|
9
9
|
|
10
10
|
before { @info = Info.new }
|
11
11
|
|
12
12
|
describe '#nodename' do
|
13
13
|
it 'returns "info"' do
|
14
|
-
subject.nodename.
|
14
|
+
expect(subject.nodename).to eq('info')
|
15
15
|
end
|
16
16
|
end
|
17
17
|
|
18
18
|
describe 'license' do
|
19
|
-
it {
|
20
|
-
it {
|
19
|
+
it { is_expected.not_to have_rights }
|
20
|
+
it { is_expected.not_to be_default_license }
|
21
21
|
|
22
22
|
it 'has no license by default' do
|
23
|
-
@info.license.
|
23
|
+
expect(@info.license).to be_nil
|
24
24
|
end
|
25
25
|
|
26
26
|
it 'setting a license adds a rights node' do
|
@@ -29,36 +29,36 @@ module CSL
|
|
29
29
|
|
30
30
|
it 'setting the default license creates the default rights node' do
|
31
31
|
@info.default_license!
|
32
|
-
@info.
|
33
|
-
@info.
|
32
|
+
expect(@info).to have_rights
|
33
|
+
expect(@info).to be_default_license
|
34
34
|
|
35
35
|
@info.rights.text = 'cc'
|
36
|
-
@info.
|
36
|
+
expect(@info).not_to be_default_license
|
37
37
|
|
38
38
|
@info.default_license!
|
39
|
-
@info.
|
39
|
+
expect(@info).to be_default_license
|
40
40
|
end
|
41
41
|
end
|
42
42
|
|
43
43
|
describe '#children' do
|
44
44
|
it 'returns a Info::Children instance' do
|
45
|
-
@info.children.
|
45
|
+
expect(@info.children).to be_a(Info::Children)
|
46
46
|
end
|
47
47
|
|
48
48
|
it 'allows to set the id by array accessor' do
|
49
|
-
|
49
|
+
expect { Info.new.children[:id] = 'foo' }.not_to raise_error
|
50
50
|
end
|
51
51
|
end
|
52
52
|
|
53
53
|
describe '#category' do
|
54
54
|
it 'returns an empty list by default' do
|
55
|
-
@info.category.
|
55
|
+
expect(@info.category).to be_empty
|
56
56
|
end
|
57
57
|
end
|
58
58
|
|
59
59
|
describe 'citation-format' do
|
60
60
|
it 'has no citation-format by default' do
|
61
|
-
@info.citation_format.
|
61
|
+
expect(@info.citation_format).to be_nil
|
62
62
|
end
|
63
63
|
|
64
64
|
it 'setting a citation-format creates a new category node' do
|
@@ -73,7 +73,7 @@ module CSL
|
|
73
73
|
before { @info.add_child Info::Category.new(:'citation-format' => 'author') }
|
74
74
|
|
75
75
|
it 'has a citation format' do
|
76
|
-
@info.citation_format.
|
76
|
+
expect(@info.citation_format).to eq(:author)
|
77
77
|
end
|
78
78
|
|
79
79
|
it 'setting a citation-format does not create a new category node' do
|
@@ -89,7 +89,7 @@ module CSL
|
|
89
89
|
before { @info.add_child Info::Category.new(:field => 'literature') }
|
90
90
|
|
91
91
|
it 'has no citation-format by default' do
|
92
|
-
@info.citation_format.
|
92
|
+
expect(@info.citation_format).to be_nil
|
93
93
|
end
|
94
94
|
|
95
95
|
it 'setting a citation-format creates a new category node' do
|
@@ -103,20 +103,20 @@ module CSL
|
|
103
103
|
end
|
104
104
|
|
105
105
|
describe 'link accessors' do
|
106
|
-
it {
|
107
|
-
it {
|
108
|
-
it {
|
106
|
+
it { is_expected.not_to have_self_link }
|
107
|
+
it { is_expected.not_to have_documentation_link }
|
108
|
+
it { is_expected.not_to have_template_link }
|
109
109
|
|
110
110
|
it 'self_link is nil by default' do
|
111
|
-
@info.self_link.
|
111
|
+
expect(@info.self_link).to be_nil
|
112
112
|
end
|
113
113
|
|
114
114
|
it 'returns nil if no suitable link is set' do
|
115
|
-
Info.new {|i| i.link = {:href => 'foo', :rel => 'documentation'} }.self_link.
|
115
|
+
expect(Info.new {|i| i.link = {:href => 'foo', :rel => 'documentation'} }.self_link).to be_nil
|
116
116
|
end
|
117
117
|
|
118
118
|
it 'returns the href value of the link if it is set' do
|
119
|
-
Info.new {|i| i.link = {:href => 'foo', :rel => 'self'} }.self_link.
|
119
|
+
expect(Info.new {|i| i.link = {:href => 'foo', :rel => 'self'} }.self_link).to eq('foo')
|
120
120
|
end
|
121
121
|
|
122
122
|
it 'setter changes the value of existing link' do
|
@@ -126,73 +126,73 @@ module CSL
|
|
126
126
|
|
127
127
|
it 'setter creates new link node if link did not exist' do
|
128
128
|
expect { @info.self_link = 'bar' }.to change { @info.has_self_link? }
|
129
|
-
@info.links[0].
|
129
|
+
expect(@info.links[0]).to be_a(Info::Link)
|
130
130
|
end
|
131
131
|
|
132
132
|
end
|
133
133
|
|
134
134
|
describe '#to_xml' do
|
135
135
|
it 'returns an empty info element by default' do
|
136
|
-
subject.to_xml.
|
136
|
+
expect(subject.to_xml).to eq('<info/>')
|
137
137
|
end
|
138
138
|
|
139
139
|
it 'prints the id if present' do
|
140
|
-
Info.new { |i| i.set_child_id 'apa' }.to_xml.
|
140
|
+
expect(Info.new { |i| i.set_child_id 'apa' }.to_xml).to eq('<info><id>apa</id></info>')
|
141
141
|
end
|
142
142
|
|
143
143
|
it 'prints the category if present' do
|
144
|
-
Info.new { |i| i.category = {:'citation-format' => 'author'} }.to_xml.
|
144
|
+
expect(Info.new { |i| i.category = {:'citation-format' => 'author'} }.to_xml).to eq('<info><category citation-format="author"/></info>')
|
145
145
|
end
|
146
146
|
end
|
147
147
|
|
148
148
|
describe '#dup' do
|
149
149
|
it 'does not copy ancestors' do
|
150
150
|
apa = Style.load(:apa).info
|
151
|
-
apa.
|
151
|
+
expect(apa).to be_a(Info)
|
152
152
|
|
153
|
-
apa.
|
154
|
-
apa.dup.
|
153
|
+
expect(apa).not_to be_root
|
154
|
+
expect(apa.dup).to be_root
|
155
155
|
end
|
156
156
|
end
|
157
157
|
|
158
158
|
describe '#deep_copy' do
|
159
159
|
it 'copies the full sub-tree' do
|
160
160
|
apa = Style.load(:apa).info
|
161
|
-
apa.
|
161
|
+
expect(apa).to be_a(Info)
|
162
162
|
|
163
163
|
xml = apa.to_xml
|
164
164
|
|
165
165
|
copy = apa.deep_copy
|
166
166
|
|
167
|
-
apa.to_xml.
|
168
|
-
copy.to_xml.
|
167
|
+
expect(apa.to_xml).to eq(xml) # original unchanged!
|
168
|
+
expect(copy.to_xml).to eq(xml)
|
169
169
|
end
|
170
170
|
end
|
171
171
|
|
172
172
|
describe '#pretty_print' do
|
173
173
|
it 'returns an empty info element by default' do
|
174
|
-
subject.pretty_print.
|
174
|
+
expect(subject.pretty_print).to eq('<info/>')
|
175
175
|
end
|
176
176
|
|
177
177
|
it 'prints the id indented if present' do
|
178
|
-
Info.new { |i| i.set_child_id 'apa' }.pretty_print.
|
178
|
+
expect(Info.new { |i| i.set_child_id 'apa' }.pretty_print).to eq("<info>\n <id>apa</id>\n</info>")
|
179
179
|
end
|
180
180
|
end
|
181
181
|
|
182
182
|
describe '#tags' do
|
183
183
|
it 'returns a list with an empty info element by default' do
|
184
|
-
subject.tags.
|
184
|
+
expect(subject.tags).to eq(['<info/>'])
|
185
185
|
end
|
186
186
|
|
187
187
|
it 'returns a nested list if id is present' do
|
188
|
-
Info.new { |i| i.set_child_id 'apa' }.tags.
|
188
|
+
expect(Info.new { |i| i.set_child_id 'apa' }.tags).to eq(['<info>', ['<id>apa</id>'], '</info>'])
|
189
189
|
end
|
190
190
|
|
191
191
|
end
|
192
192
|
end
|
193
193
|
|
194
194
|
describe Info::Author do
|
195
|
-
it {
|
195
|
+
it { is_expected.not_to be_nil }
|
196
196
|
|
197
197
|
let(:poe) {
|
198
198
|
Info::Author.new { |a|
|
@@ -203,33 +203,33 @@ module CSL
|
|
203
203
|
|
204
204
|
describe '#name' do
|
205
205
|
it 'returns nil by default' do
|
206
|
-
subject.name.
|
206
|
+
expect(subject.name).to be nil
|
207
207
|
end
|
208
208
|
|
209
209
|
it 'returns the name if set' do
|
210
|
-
poe.name.to_s.
|
210
|
+
expect(poe.name.to_s).to eq('E. A. Poe')
|
211
211
|
end
|
212
212
|
end
|
213
213
|
|
214
214
|
describe '#family' do
|
215
215
|
it "returns the author's family name" do
|
216
|
-
poe.family.
|
216
|
+
expect(poe.family).to eq('Poe')
|
217
217
|
end
|
218
218
|
end
|
219
219
|
|
220
220
|
describe '#email' do
|
221
221
|
it 'returns the email' do
|
222
|
-
poe.email.to_s.
|
222
|
+
expect(poe.email.to_s).to eq('poe@baltimore.com')
|
223
223
|
end
|
224
224
|
end
|
225
225
|
|
226
226
|
describe '#to_xml' do
|
227
227
|
it 'returns an empty author by default' do
|
228
|
-
subject.to_xml.
|
228
|
+
expect(subject.to_xml).to eq('<author/>')
|
229
229
|
end
|
230
230
|
|
231
231
|
it 'prints all children' do
|
232
|
-
poe.to_xml.
|
232
|
+
expect(poe.to_xml).to eq('<author><name>E. A. Poe</name><email>poe@baltimore.com</email></author>')
|
233
233
|
end
|
234
234
|
end
|
235
235
|
|
@@ -237,31 +237,31 @@ module CSL
|
|
237
237
|
|
238
238
|
describe Info::Contributor do
|
239
239
|
|
240
|
-
it {
|
240
|
+
it { is_expected.not_to be_nil }
|
241
241
|
|
242
242
|
let(:bruce) { Info::Contributor.new { |c| c.name = "Bruce D'Arcus" } }
|
243
243
|
|
244
244
|
describe '#name' do
|
245
245
|
it 'returns the name' do
|
246
|
-
bruce.name.to_s.
|
246
|
+
expect(bruce.name.to_s).to eq("Bruce D'Arcus")
|
247
247
|
end
|
248
248
|
end
|
249
249
|
|
250
250
|
|
251
251
|
describe '#to_xml' do
|
252
252
|
it 'returns an empty contributor by default' do
|
253
|
-
subject.to_xml.
|
253
|
+
expect(subject.to_xml).to eq('<contributor/>')
|
254
254
|
end
|
255
255
|
|
256
256
|
it 'prints the name tag if present' do
|
257
|
-
bruce.to_xml.
|
257
|
+
expect(bruce.to_xml).to eq("<contributor><name>Bruce D'Arcus</name></contributor>")
|
258
258
|
end
|
259
259
|
end
|
260
260
|
|
261
261
|
end
|
262
262
|
|
263
263
|
describe Info::Rights do
|
264
|
-
it {
|
264
|
+
it { is_expected.not_to be_nil }
|
265
265
|
|
266
266
|
describe '#dup' do
|
267
267
|
it 'copies attributes and text' do
|
@@ -269,8 +269,8 @@ module CSL
|
|
269
269
|
r[:license] = 'bar'
|
270
270
|
|
271
271
|
c = r.dup
|
272
|
-
c.text.
|
273
|
-
c[:license].
|
272
|
+
expect(c.text).to eq('foo')
|
273
|
+
expect(c[:license]).to eq('bar')
|
274
274
|
end
|
275
275
|
end
|
276
276
|
end
|