csl 1.0.0.pre21 → 1.0.0.pre22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +2 -0
- data/.travis.yml +4 -3
- data/Gemfile +11 -4
- data/Rakefile +7 -0
- data/csl.gemspec +3 -7
- data/features/step_definitions/parser_steps.rb +3 -1
- data/lib/csl/compatibility.rb +33 -2
- data/lib/csl/errors.rb +5 -5
- data/lib/csl/extensions.rb +6 -6
- data/lib/csl/info.rb +55 -21
- data/lib/csl/loader.rb +14 -14
- data/lib/csl/locale.rb +41 -38
- data/lib/csl/locale/date.rb +18 -18
- data/lib/csl/locale/style_options.rb +7 -7
- data/lib/csl/locale/term.rb +12 -5
- data/lib/csl/node.rb +44 -42
- data/lib/csl/pretty_printer.rb +8 -8
- data/lib/csl/schema.rb +20 -7
- data/lib/csl/style.rb +15 -12
- data/lib/csl/style/choose.rb +15 -6
- data/lib/csl/style/label.rb +1 -3
- data/lib/csl/style/layout.rb +4 -4
- data/lib/csl/style/names.rb +5 -1
- data/lib/csl/style/number.rb +15 -15
- data/lib/csl/style/text.rb +33 -33
- data/lib/csl/treelike.rb +19 -19
- data/lib/csl/version.rb +1 -1
- data/spec/csl/info_spec.rb +82 -57
- data/spec/csl/locale/term_spec.rb +6 -0
- data/spec/csl/style/choose_spec.rb +24 -8
- data/spec/csl/style/label_spec.rb +2 -15
- data/spec/csl/style_spec.rb +34 -19
- data/spec/spec_helper.rb +7 -2
- metadata +9 -64
@@ -12,6 +12,12 @@ module CSL
|
|
12
12
|
end
|
13
13
|
end
|
14
14
|
|
15
|
+
describe '.specialize' do
|
16
|
+
it 'filters the passed in hash to contain only match-able entries' do
|
17
|
+
Locale::Term.specialize({ :form => 'short', :foo => 'bar' }).should == { :form => 'short' }
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
15
21
|
describe '#ordinalize' do
|
16
22
|
|
17
23
|
describe "given standard English terms" do
|
@@ -17,12 +17,20 @@ module CSL
|
|
17
17
|
describe 'when the node has a single condition' do
|
18
18
|
let(:node) { Choose::Block.new(:'is-numeric' => 'edition' )}
|
19
19
|
|
20
|
-
it 'returns an array with an array containing the type and
|
21
|
-
node.conditions.should == [[:'is-numeric', 'edition']]
|
20
|
+
it 'returns an array with an array containing the type, matcher and values of the condition' do
|
21
|
+
node.conditions.should == [[:'is-numeric', :all?, ['edition']]]
|
22
|
+
end
|
23
|
+
|
24
|
+
describe 'when the condition has multiple values' do
|
25
|
+
before { node[:'is-numeric'] << ' issue' }
|
26
|
+
|
27
|
+
it 'it splits the values in the conditions list' do
|
28
|
+
node.conditions.should == [[:'is-numeric', :all?, ['edition', 'issue']]]
|
29
|
+
end
|
22
30
|
end
|
23
31
|
|
24
32
|
describe 'when the node has two conditions' do
|
25
|
-
before
|
33
|
+
before { node[:disambiguate] = 'true' }
|
26
34
|
|
27
35
|
it 'returns an array with two elements' do
|
28
36
|
node.conditions.should have_exactly(2).items
|
@@ -30,16 +38,24 @@ module CSL
|
|
30
38
|
|
31
39
|
it 'returns both conditions as arrays' do
|
32
40
|
node.conditions.map(&:first).sort.should == [:disambiguate, :'is-numeric']
|
33
|
-
node.conditions.map(&:last).sort.should == ['edition', 'true']
|
41
|
+
node.conditions.map(&:last).sort.should == [['edition'], ['true']]
|
34
42
|
end
|
35
43
|
end
|
36
44
|
end
|
37
45
|
|
38
|
-
describe 'when the node has a
|
39
|
-
let(:node) { Choose::Block.new(:variable => 'author editor' )}
|
46
|
+
describe 'when the node has a condition with a match override' do
|
47
|
+
let(:node) { Choose::Block.new(:'variable-any' => 'author editor' )}
|
40
48
|
|
41
|
-
it '
|
42
|
-
node.conditions.should == [[:variable, 'author'
|
49
|
+
it 'strips the match override from the type name and inserts it as the matcher' do
|
50
|
+
node.conditions.should == [[:variable, :any?, ['author', 'editor']]]
|
51
|
+
end
|
52
|
+
|
53
|
+
describe 'other conditions' do
|
54
|
+
before { node[:position] = 'false' }
|
55
|
+
|
56
|
+
it 'are not affected by the override' do
|
57
|
+
node.conditions.map { |c| c[1].to_s }.sort.should == %w{ all? any? }
|
58
|
+
end
|
43
59
|
end
|
44
60
|
end
|
45
61
|
end
|
@@ -8,7 +8,7 @@ module CSL
|
|
8
8
|
it { should_not be_never_pluralize }
|
9
9
|
|
10
10
|
describe '.terms' do
|
11
|
-
Hash[
|
11
|
+
Hash[*%w{
|
12
12
|
page page
|
13
13
|
issue issue
|
14
14
|
edition edition
|
@@ -17,7 +17,7 @@ module CSL
|
|
17
17
|
chapter-number chapter
|
18
18
|
}].each do |variable, term|
|
19
19
|
it "returns #{term.inspect} for #{variable.inspect}" do
|
20
|
-
Label.terms[variable].should == term
|
20
|
+
Style::Label.terms[variable].should == term
|
21
21
|
end
|
22
22
|
end
|
23
23
|
end
|
@@ -26,19 +26,6 @@ module CSL
|
|
26
26
|
before(:each) { Style::Names.new << subject }
|
27
27
|
|
28
28
|
it { should be_names_label }
|
29
|
-
|
30
|
-
describe '#variable' do
|
31
|
-
before(:each) { subject.parent[:variable] = 'editor' }
|
32
|
-
|
33
|
-
it 'returns the names variable(s)' do
|
34
|
-
subject.variable.should == 'editor'
|
35
|
-
end
|
36
|
-
|
37
|
-
it 'returns the names variable(s) even when the local attribute is set' do
|
38
|
-
subject[:variable] = 'page'
|
39
|
-
subject.variable.should == 'editor'
|
40
|
-
end
|
41
|
-
end
|
42
29
|
end
|
43
30
|
|
44
31
|
describe '#term' do
|
data/spec/csl/style_spec.rb
CHANGED
@@ -2,15 +2,30 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
module CSL
|
4
4
|
describe Style do
|
5
|
-
|
5
|
+
before do
|
6
|
+
@style = Style.new
|
7
|
+
end
|
6
8
|
|
7
9
|
it 'has a 1.x version by default' do
|
8
|
-
|
10
|
+
@style[:version].should match(/1\.\d+(\.\d+)?/)
|
11
|
+
end
|
12
|
+
|
13
|
+
it 'has the default version' do
|
14
|
+
@style.default_attribute?(:version).should be_true
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'has a the default namespace attribute' do
|
18
|
+
@style[:xmlns].should == CSL::Schema.namespace
|
19
|
+
@style.default_attribute?(:xmlns).should be_true
|
9
20
|
end
|
10
21
|
|
11
22
|
describe '#to_xml' do
|
12
23
|
it 'returns an empty style' do
|
13
|
-
|
24
|
+
@style.to_xml.should match(/^<style[^>]*\/>/)
|
25
|
+
end
|
26
|
+
|
27
|
+
it 'includes the xml namespace' do
|
28
|
+
@style.to_xml.should match(CSL::Schema.namespace)
|
14
29
|
end
|
15
30
|
|
16
31
|
it 'supports round-trip for apa style' do
|
@@ -33,47 +48,47 @@ module CSL
|
|
33
48
|
it { should_not have_bibliography }
|
34
49
|
|
35
50
|
describe 'when it has a title' do
|
36
|
-
before
|
51
|
+
before { @style.title = 'foo' }
|
37
52
|
|
38
|
-
it { style.should have_info }
|
53
|
+
it { @style.should have_info }
|
39
54
|
|
40
55
|
it 'info.title is a text node' do
|
41
|
-
style.info.title.should be_a(TextNode)
|
56
|
+
@style.info.title.should be_a(TextNode)
|
42
57
|
end
|
43
58
|
|
44
59
|
it '#title returns the title as a string' do
|
45
|
-
style.title.should be_a(String)
|
60
|
+
@style.title.should be_a(String)
|
46
61
|
end
|
47
62
|
end
|
48
63
|
end
|
49
64
|
|
50
65
|
describe '#id accessor' do
|
51
66
|
it 'returns nil by default' do
|
52
|
-
|
67
|
+
@style.id.should be_nil
|
53
68
|
end
|
54
69
|
|
55
70
|
it 'writer sets the id to the passed-in string' do
|
56
|
-
expect { style.id = 'foobar' }.to change { style.id }.from(nil).to('foobar')
|
71
|
+
expect { @style.id = 'foobar' }.to change { @style.id }.from(nil).to('foobar')
|
57
72
|
end
|
58
73
|
end
|
59
74
|
|
60
75
|
describe 'independent and dependent styles' do
|
61
76
|
it 'styles are independent by default' do
|
62
|
-
|
77
|
+
@style.should be_independent
|
63
78
|
end
|
64
79
|
|
65
80
|
it 'styles do not have independent-parent links by default' do
|
66
|
-
|
81
|
+
@style.should_not have_independent_parent_link
|
67
82
|
end
|
68
83
|
|
69
84
|
it 'when setting an independet-parent link a style becomes dependent' do
|
70
|
-
expect { style.independent_parent_link = 'foo' }.to change { style.independent? }
|
85
|
+
expect { @style.independent_parent_link = 'foo' }.to change { @style.independent? }
|
71
86
|
end
|
72
87
|
end
|
73
88
|
|
74
89
|
describe 'macros' do
|
75
90
|
it 'has no macros by default' do
|
76
|
-
|
91
|
+
@style.should_not have_macros
|
77
92
|
end
|
78
93
|
|
79
94
|
it 'raises a validation error when adding a macro without name' do
|
@@ -81,23 +96,23 @@ module CSL
|
|
81
96
|
end
|
82
97
|
|
83
98
|
describe 'when it has an "author" macro' do
|
84
|
-
before
|
99
|
+
before { @style << Style::Macro.new(:name => 'author') }
|
85
100
|
|
86
101
|
it 'has macros' do
|
87
|
-
style.should have_macros
|
102
|
+
@style.should have_macros
|
88
103
|
end
|
89
104
|
|
90
105
|
it 'the macro is registered in the macros hash' do
|
91
|
-
style.macros.should have_key('author')
|
92
|
-
style.macros['author'].should be_a(Style::Macro)
|
106
|
+
@style.macros.should have_key('author')
|
107
|
+
@style.macros['author'].should be_a(Style::Macro)
|
93
108
|
end
|
94
109
|
|
95
110
|
it 'raises a validation error when adding a macro with a duplicate name' do
|
96
|
-
expect { style << Style::Macro.new(:name => 'author') }.to raise_error(ValidationError)
|
111
|
+
expect { @style << Style::Macro.new(:name => 'author') }.to raise_error(ValidationError)
|
97
112
|
end
|
98
113
|
|
99
114
|
it 'unregisters the macro when it is deleted' do
|
100
|
-
expect { style.delete style.macros['author'] }.to change { style.macros.length }
|
115
|
+
expect { @style.delete @style.macros['author'] }.to change { @style.macros.length }
|
101
116
|
end
|
102
117
|
end
|
103
118
|
end
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,20 +1,18 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: csl
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.0.
|
5
|
-
prerelease: 6
|
4
|
+
version: 1.0.0.pre22
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Sylvester Keil
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date: 2013-
|
11
|
+
date: 2013-04-14 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: namae
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
16
|
requirements:
|
19
17
|
- - ~>
|
20
18
|
- !ruby/object:Gem::Version
|
@@ -22,61 +20,12 @@ dependencies:
|
|
22
20
|
type: :runtime
|
23
21
|
prerelease: false
|
24
22
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
23
|
requirements:
|
27
24
|
- - ~>
|
28
25
|
- !ruby/object:Gem::Version
|
29
26
|
version: '0.3'
|
30
|
-
|
31
|
-
|
32
|
-
requirement: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
|
-
requirements:
|
35
|
-
- - ~>
|
36
|
-
- !ruby/object:Gem::Version
|
37
|
-
version: '1.1'
|
38
|
-
type: :development
|
39
|
-
prerelease: false
|
40
|
-
version_requirements: !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
|
-
requirements:
|
43
|
-
- - ~>
|
44
|
-
- !ruby/object:Gem::Version
|
45
|
-
version: '1.1'
|
46
|
-
- !ruby/object:Gem::Dependency
|
47
|
-
name: rspec
|
48
|
-
requirement: !ruby/object:Gem::Requirement
|
49
|
-
none: false
|
50
|
-
requirements:
|
51
|
-
- - ~>
|
52
|
-
- !ruby/object:Gem::Version
|
53
|
-
version: '2.7'
|
54
|
-
type: :development
|
55
|
-
prerelease: false
|
56
|
-
version_requirements: !ruby/object:Gem::Requirement
|
57
|
-
none: false
|
58
|
-
requirements:
|
59
|
-
- - ~>
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: '2.7'
|
62
|
-
- !ruby/object:Gem::Dependency
|
63
|
-
name: rake
|
64
|
-
requirement: !ruby/object:Gem::Requirement
|
65
|
-
none: false
|
66
|
-
requirements:
|
67
|
-
- - ~>
|
68
|
-
- !ruby/object:Gem::Version
|
69
|
-
version: '0.9'
|
70
|
-
type: :development
|
71
|
-
prerelease: false
|
72
|
-
version_requirements: !ruby/object:Gem::Requirement
|
73
|
-
none: false
|
74
|
-
requirements:
|
75
|
-
- - ~>
|
76
|
-
- !ruby/object:Gem::Version
|
77
|
-
version: '0.9'
|
78
|
-
description: ! "\n\t\tA Ruby parser and library for the Citation Style Language (CSL),
|
79
|
-
an open\n\t\tXML-based language to describe the formatting of citations and\n\t\tbibliographies.\n\t\t"
|
27
|
+
description: "\n\t\tA Ruby parser and library for the Citation Style Language (CSL),\n\t\tan
|
28
|
+
open XML-based language to describe the formatting of citations\n\t\tand bibliographies.\n\t\t"
|
80
29
|
email:
|
81
30
|
- http://sylvester.keil.or.at
|
82
31
|
executables: []
|
@@ -171,30 +120,26 @@ files:
|
|
171
120
|
homepage: https://github.com/inukshuk/csl-ruby
|
172
121
|
licenses:
|
173
122
|
- AGPL
|
123
|
+
metadata: {}
|
174
124
|
post_install_message:
|
175
125
|
rdoc_options: []
|
176
126
|
require_paths:
|
177
127
|
- lib
|
178
128
|
required_ruby_version: !ruby/object:Gem::Requirement
|
179
|
-
none: false
|
180
129
|
requirements:
|
181
|
-
- -
|
130
|
+
- - '>='
|
182
131
|
- !ruby/object:Gem::Version
|
183
132
|
version: '0'
|
184
|
-
segments:
|
185
|
-
- 0
|
186
|
-
hash: -1739872005928970958
|
187
133
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
188
|
-
none: false
|
189
134
|
requirements:
|
190
|
-
- -
|
135
|
+
- - '>'
|
191
136
|
- !ruby/object:Gem::Version
|
192
137
|
version: 1.3.1
|
193
138
|
requirements: []
|
194
139
|
rubyforge_project:
|
195
|
-
rubygems_version:
|
140
|
+
rubygems_version: 2.0.3
|
196
141
|
signing_key:
|
197
|
-
specification_version:
|
142
|
+
specification_version: 4
|
198
143
|
summary: A Ruby CSL parser and library
|
199
144
|
test_files:
|
200
145
|
- features/locales/loading.feature
|