csl 1.4.5 → 1.6.0
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 +5 -5
- data/.github/workflows/ci.yml +26 -0
- data/BSDL +1 -1
- data/Gemfile +9 -30
- data/README.md +1 -5
- data/Rakefile +0 -8
- data/csl.gemspec +10 -13
- data/cucumber.yml +1 -1
- data/lib/csl/locale.rb +4 -4
- data/lib/csl/locale/term.rb +1 -1
- data/lib/csl/node.rb +2 -2
- data/lib/csl/treelike.rb +11 -7
- data/lib/csl/version.rb +1 -1
- metadata +30 -92
- data/.rspec +0 -3
- data/.simplecov +0 -4
- data/Guardfile +0 -15
- data/features/locales/loading.feature +0 -57
- data/features/locales/ordinalize.feature +0 -713
- data/features/parser/choose.feature +0 -16
- data/features/parser/info.feature +0 -27
- data/features/parser/localized_dates.feature +0 -35
- data/features/parser/terms.feature +0 -28
- data/features/step_definitions/locale_steps.rb +0 -36
- data/features/step_definitions/parser_steps.rb +0 -40
- data/features/step_definitions/style_steps.rb +0 -16
- data/features/style/loading.feature +0 -53
- data/features/support/env.rb +0 -24
- data/spec/csl/info_spec.rb +0 -278
- data/spec/csl/locale/date_spec.rb +0 -63
- data/spec/csl/locale/style_options_spec.rb +0 -19
- data/spec/csl/locale/term_spec.rb +0 -255
- data/spec/csl/locale_spec.rb +0 -245
- data/spec/csl/node_spec.rb +0 -273
- data/spec/csl/parser_spec.rb +0 -112
- data/spec/csl/schema_spec.rb +0 -112
- data/spec/csl/style/bibliography_spec.rb +0 -7
- data/spec/csl/style/choose_spec.rb +0 -66
- data/spec/csl/style/citation_spec.rb +0 -7
- data/spec/csl/style/date_spec.rb +0 -21
- data/spec/csl/style/group_spec.rb +0 -7
- data/spec/csl/style/label_spec.rb +0 -44
- data/spec/csl/style/layout_spec.rb +0 -7
- data/spec/csl/style/macro_spec.rb +0 -7
- data/spec/csl/style/names_spec.rb +0 -36
- data/spec/csl/style/number_spec.rb +0 -85
- data/spec/csl/style/sort_spec.rb +0 -11
- data/spec/csl/style/text_spec.rb +0 -7
- data/spec/csl/style_spec.rb +0 -137
- data/spec/csl/treelike_spec.rb +0 -151
- data/spec/fixtures/locales/locales-de-DE.xml +0 -298
- data/spec/fixtures/locales/locales-en-GB.xml +0 -304
- data/spec/fixtures/locales/locales-en-US.xml +0 -304
- data/spec/fixtures/styles/apa.csl +0 -443
- data/spec/spec_helper.rb +0 -57
@@ -1,66 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
module CSL
|
4
|
-
class Style
|
5
|
-
|
6
|
-
describe Choose do
|
7
|
-
|
8
|
-
end
|
9
|
-
|
10
|
-
describe Choose::Block do
|
11
|
-
|
12
|
-
describe '#conditions' do
|
13
|
-
it 'returns an empty list by default' do
|
14
|
-
expect(Choose::Block.new.conditions).to be_empty
|
15
|
-
end
|
16
|
-
|
17
|
-
describe 'when the node has a single condition' do
|
18
|
-
let(:node) { Choose::Block.new(:'is-numeric' => 'edition' )}
|
19
|
-
|
20
|
-
it 'returns an array with an array containing the type, matcher and values of the condition' do
|
21
|
-
expect(node.conditions).to eq([[:'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
|
-
expect(node.conditions).to eq([[:'is-numeric', :all?, ['edition', 'issue']]])
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
describe 'when the node has two conditions' do
|
33
|
-
before { node[:disambiguate] = 'true' }
|
34
|
-
|
35
|
-
it 'returns an array with two elements' do
|
36
|
-
expect(node.conditions.size).to eq(2)
|
37
|
-
end
|
38
|
-
|
39
|
-
it 'returns both conditions as arrays' do
|
40
|
-
expect(node.conditions.map(&:first).sort).to eq([:disambiguate, :'is-numeric'])
|
41
|
-
expect(node.conditions.map(&:last).sort).to eq([['edition'], ['true']])
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
describe 'when the node has a condition with a match override' do
|
47
|
-
let(:node) { Choose::Block.new(:'variable-any' => 'author editor' )}
|
48
|
-
|
49
|
-
it 'strips the match override from the type name and inserts it as the matcher' do
|
50
|
-
expect(node.conditions).to eq([[: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
|
-
expect(node.conditions.map { |c| c[1].to_s }.sort).to eq(%w{ all? any? })
|
58
|
-
end
|
59
|
-
end
|
60
|
-
end
|
61
|
-
end
|
62
|
-
|
63
|
-
end
|
64
|
-
|
65
|
-
end
|
66
|
-
end
|
data/spec/csl/style/date_spec.rb
DELETED
@@ -1,21 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
module CSL
|
4
|
-
describe Style::Date do
|
5
|
-
|
6
|
-
end
|
7
|
-
|
8
|
-
describe Style::DatePart do
|
9
|
-
|
10
|
-
describe '#numeric-leading-zeros?' do
|
11
|
-
|
12
|
-
it { is_expected.not_to be_numeric_leading_zeros }
|
13
|
-
|
14
|
-
it 'returns true when the form is set accordingly' do
|
15
|
-
subject[:form] = 'numeric-leading-zeros'
|
16
|
-
expect(subject).to be_numeric_leading_zeros
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
end
|
21
|
-
end
|
@@ -1,44 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
module CSL
|
4
|
-
describe Style::Label do
|
5
|
-
|
6
|
-
it { is_expected.not_to be_names_label }
|
7
|
-
it { is_expected.not_to be_always_pluralize }
|
8
|
-
it { is_expected.not_to be_never_pluralize }
|
9
|
-
|
10
|
-
describe '.terms' do
|
11
|
-
Hash[*%w{
|
12
|
-
page page
|
13
|
-
issue issue
|
14
|
-
edition edition
|
15
|
-
number-of-pages page
|
16
|
-
number-of-volumes volume
|
17
|
-
chapter-number chapter
|
18
|
-
}].each do |variable, term|
|
19
|
-
it "returns #{term.inspect} for #{variable.inspect}" do
|
20
|
-
expect(Style::Label.terms[variable]).to eq(term)
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
describe 'a label inside a names node' do
|
26
|
-
before(:each) { Style::Names.new << subject }
|
27
|
-
|
28
|
-
it { is_expected.to be_names_label }
|
29
|
-
end
|
30
|
-
|
31
|
-
describe '#term' do
|
32
|
-
it { is_expected.to be_empty }
|
33
|
-
|
34
|
-
it 'returns the term for the current variable' do
|
35
|
-
subject[:variable] = 'page'
|
36
|
-
expect(subject.term).to eq('page')
|
37
|
-
|
38
|
-
subject[:variable] = 'number-of-volumes'
|
39
|
-
expect(subject.term).to eq('volume')
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
end
|
44
|
-
end
|
@@ -1,36 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
module CSL
|
4
|
-
describe Style::Names do
|
5
|
-
|
6
|
-
end
|
7
|
-
|
8
|
-
describe Style::Name do
|
9
|
-
|
10
|
-
it { is_expected.to be_delimiter_contextually_precedes_last }
|
11
|
-
|
12
|
-
[:never, :always, :contextually].each do |setting|
|
13
|
-
setter = "delimiter_#{setting}_precedes_last!"
|
14
|
-
predicate = "delimiter_#{setting}_precedes_last?"
|
15
|
-
|
16
|
-
describe "##{setter}" do
|
17
|
-
it 'sets the delimiter precedes last option accordingly' do
|
18
|
-
expect(subject.send(setter).send(predicate)).to eq(true)
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
end
|
24
|
-
|
25
|
-
describe Style::NamePart do
|
26
|
-
|
27
|
-
end
|
28
|
-
|
29
|
-
describe Style::EtAl do
|
30
|
-
|
31
|
-
end
|
32
|
-
|
33
|
-
describe Style::Substitute do
|
34
|
-
|
35
|
-
end
|
36
|
-
end
|
@@ -1,85 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
module CSL
|
4
|
-
describe Style::Number do
|
5
|
-
|
6
|
-
describe '.new' do
|
7
|
-
it 'returns an empty number tag by default' do
|
8
|
-
expect(Style::Number.new.attributes).to be_empty
|
9
|
-
end
|
10
|
-
|
11
|
-
it 'accepts a form attribute' do
|
12
|
-
expect(Style::Number.new(:form => 'roman')).to be_roman
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
describe '#numeric?' do
|
17
|
-
it 'returns true by default' do
|
18
|
-
expect(Style::Number.new).to be_numeric
|
19
|
-
end
|
20
|
-
|
21
|
-
it 'returns false if the form attribute is set to a value other than :numeric' do
|
22
|
-
expect(Style::Number.new(:form => 'foo')).not_to be_numeric
|
23
|
-
end
|
24
|
-
|
25
|
-
it 'returns false if the form attribute is set to :numeric' do
|
26
|
-
expect(Style::Number.new(:form => 'numeric')).to be_numeric
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
describe '#roman?' do
|
31
|
-
it 'returns false by default' do
|
32
|
-
expect(Style::Number.new).not_to be_roman
|
33
|
-
end
|
34
|
-
|
35
|
-
it 'returns false if the form attribute is set to a value other than :numeric' do
|
36
|
-
expect(Style::Number.new(:form => 'ordinal')).not_to be_roman
|
37
|
-
end
|
38
|
-
|
39
|
-
it 'returns false if the form attribute is set to :roman' do
|
40
|
-
expect(Style::Number.new(:form => 'roman')).to be_roman
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
describe '#ordinal?' do
|
45
|
-
it 'returns false by default' do
|
46
|
-
expect(Style::Number.new).not_to be_ordinal
|
47
|
-
end
|
48
|
-
|
49
|
-
it 'returns false if the form attribute is set to a value other than :ordinal' do
|
50
|
-
expect(Style::Number.new(:form => 'long-ordinal')).not_to be_ordinal
|
51
|
-
end
|
52
|
-
|
53
|
-
it 'returns false if the form attribute is set to :ordinal' do
|
54
|
-
expect(Style::Number.new(:form => 'ordinal')).to be_ordinal
|
55
|
-
expect(Style::Number.new(:form => :ordinal)).to be_ordinal
|
56
|
-
end
|
57
|
-
end
|
58
|
-
|
59
|
-
describe '#long_ordinal?' do
|
60
|
-
it 'returns false by default' do
|
61
|
-
expect(Style::Number.new).not_to be_long_ordinal
|
62
|
-
end
|
63
|
-
|
64
|
-
it 'returns false if the form attribute is set to a value other than :"long-ordinal"' do
|
65
|
-
expect(Style::Number.new(:form => 'ordinal')).not_to be_long_ordinal
|
66
|
-
end
|
67
|
-
|
68
|
-
it 'returns false if the form attribute is set to :ordinal' do
|
69
|
-
expect(Style::Number.new(:form => 'long-ordinal')).to be_long_ordinal
|
70
|
-
end
|
71
|
-
end
|
72
|
-
|
73
|
-
|
74
|
-
describe '#to_xml' do
|
75
|
-
it 'returns an empty number tag by default' do
|
76
|
-
expect(Style::Number.new.to_xml).to eq('<number/>')
|
77
|
-
end
|
78
|
-
|
79
|
-
it 'returns a tag with a all attribute assignments' do
|
80
|
-
expect(Style::Number.new(:form => 'roman').to_xml).to eq('<number form="roman"/>')
|
81
|
-
end
|
82
|
-
end
|
83
|
-
|
84
|
-
end
|
85
|
-
end
|
data/spec/csl/style/sort_spec.rb
DELETED
data/spec/csl/style/text_spec.rb
DELETED
data/spec/csl/style_spec.rb
DELETED
@@ -1,137 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
module CSL
|
4
|
-
describe Style do
|
5
|
-
let(:style) { Style.new }
|
6
|
-
|
7
|
-
it 'has a 1.x version by default' do
|
8
|
-
expect(style[:version]).to match(/1\.\d+(\.\d+)?/)
|
9
|
-
end
|
10
|
-
|
11
|
-
it 'has the default version' do
|
12
|
-
expect(style.default_attribute?(:version)).to be_truthy
|
13
|
-
end
|
14
|
-
|
15
|
-
it 'has a the default namespace attribute' do
|
16
|
-
expect(style[:xmlns]).to eq(CSL::Schema.namespace)
|
17
|
-
expect(style.default_attribute?(:xmlns)).to be_truthy
|
18
|
-
end
|
19
|
-
|
20
|
-
describe '#to_xml' do
|
21
|
-
it 'returns an empty style' do
|
22
|
-
expect(style.to_xml).to match(/^<style[^>]*\/>/)
|
23
|
-
end
|
24
|
-
|
25
|
-
it 'includes the xml namespace' do
|
26
|
-
expect(style.to_xml).to match(CSL::Schema.namespace)
|
27
|
-
end
|
28
|
-
|
29
|
-
it 'supports round-trip for apa style' do
|
30
|
-
apa = Style.load(:apa)
|
31
|
-
expect(apa).to be_a(Style)
|
32
|
-
|
33
|
-
xml = apa.to_xml
|
34
|
-
expect(xml).to match(/^<style[^>]*>/)
|
35
|
-
|
36
|
-
expect(Style.parse(xml)).to be_a(Style)
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
describe '#deep_copy' do
|
41
|
-
it 'works on apa style' do
|
42
|
-
apa = Style.load(:apa)
|
43
|
-
expect(apa).to be_a(Style)
|
44
|
-
|
45
|
-
xml = apa.to_xml
|
46
|
-
|
47
|
-
copy = apa.deep_copy
|
48
|
-
|
49
|
-
expect(apa.to_xml).to eq(xml) # original unchanged!
|
50
|
-
expect(copy.to_xml).to eq(xml)
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
describe '#children' do
|
55
|
-
|
56
|
-
it { is_expected.not_to have_info }
|
57
|
-
it { is_expected.not_to have_locale }
|
58
|
-
it { is_expected.not_to have_macro }
|
59
|
-
it { is_expected.not_to have_citation }
|
60
|
-
it { is_expected.not_to have_bibliography }
|
61
|
-
|
62
|
-
describe 'when it has a title' do
|
63
|
-
before { style.title = 'foo' }
|
64
|
-
|
65
|
-
it { expect(style).to have_info }
|
66
|
-
|
67
|
-
it 'info.title is a text node' do
|
68
|
-
expect(style.info.title).to be_a(TextNode)
|
69
|
-
end
|
70
|
-
|
71
|
-
it '#title returns the title as a string' do
|
72
|
-
expect(style.title).to be_a(String)
|
73
|
-
end
|
74
|
-
end
|
75
|
-
end
|
76
|
-
|
77
|
-
describe '#id accessor' do
|
78
|
-
it 'returns nil by default' do
|
79
|
-
expect(style.id).to be_nil
|
80
|
-
end
|
81
|
-
|
82
|
-
it 'writer sets the id to the passed-in string' do
|
83
|
-
expect { style.id = 'foobar' }.to change { style.id }.from(nil).to('foobar')
|
84
|
-
end
|
85
|
-
end
|
86
|
-
|
87
|
-
describe 'independent and dependent styles' do
|
88
|
-
it 'styles are independent by default' do
|
89
|
-
expect(style).to be_independent
|
90
|
-
end
|
91
|
-
|
92
|
-
it 'styles do not have independent-parent links by default' do
|
93
|
-
expect(style).not_to have_independent_parent_link
|
94
|
-
end
|
95
|
-
|
96
|
-
it 'when setting an independet-parent link a style becomes dependent' do
|
97
|
-
expect { style.independent_parent_link = 'foo' }.to change { style.independent? }
|
98
|
-
end
|
99
|
-
|
100
|
-
it 'looks up independent styles parents locally first' do
|
101
|
-
style.independent_parent_link = 'http://example.com/non-existent/styles/apa'
|
102
|
-
expect(style.independent_parent).to eq Style.load('apa')
|
103
|
-
end
|
104
|
-
end
|
105
|
-
|
106
|
-
describe 'macros' do
|
107
|
-
it 'has no macros by default' do
|
108
|
-
expect(style).not_to have_macros
|
109
|
-
end
|
110
|
-
|
111
|
-
it 'raises a validation error when adding a macro without name' do
|
112
|
-
expect { Style.new << Style::Macro.new }.to raise_error(ValidationError)
|
113
|
-
end
|
114
|
-
|
115
|
-
describe 'when it has an "author" macro' do
|
116
|
-
before { style << Style::Macro.new(:name => 'author') }
|
117
|
-
|
118
|
-
it 'has macros' do
|
119
|
-
expect(style).to have_macros
|
120
|
-
end
|
121
|
-
|
122
|
-
it 'the macro is registered in the macros hash' do
|
123
|
-
expect(style.macros).to have_key('author')
|
124
|
-
expect(style.macros['author']).to be_a(Style::Macro)
|
125
|
-
end
|
126
|
-
|
127
|
-
it 'raises a validation error when adding a macro with a duplicate name' do
|
128
|
-
expect { style << Style::Macro.new(:name => 'author') }.to raise_error(ValidationError)
|
129
|
-
end
|
130
|
-
|
131
|
-
it 'unregisters the macro when it is deleted' do
|
132
|
-
expect { style.delete style.macros['author'] }.to change { style.macros.length }
|
133
|
-
end
|
134
|
-
end
|
135
|
-
end
|
136
|
-
end
|
137
|
-
end
|