csl 1.3.2 → 1.4.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 +4 -4
- data/features/locales/loading.feature +2 -2
- data/features/parser/localized_dates.feature +33 -33
- data/features/parser/terms.feature +1 -1
- data/features/style/loading.feature +33 -33
- data/lib/csl/locale.rb +24 -2
- data/lib/csl/version.rb +1 -1
- data/spec/csl/locale_spec.rb +33 -4
- data/spec/csl/style_spec.rb +25 -27
- 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: 4c96baa9f034b77ad151b2128a0fe71abdb5fcce
|
4
|
+
data.tar.gz: 0a6f6c77c9cafdaf1b17a2bdb409c027268c6128
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fdc03ad00c37bb330330dcdb20bd5e7233cfb130aa8e57213c51db877e99a4520d86d65c3c6b7bf7c435d84c50a240e096eaea4d20f3394367c292e7fdfb4c8c
|
7
|
+
data.tar.gz: cb38396b2dc1608de0fbd61d42a6f0798ed7ece661def1e105d75fdc020fbaf5094d729dbd0361194a3ceb0692ac94ed3378fad3cb64f6c6fa579fc92aa0e948
|
@@ -41,7 +41,7 @@ Feature: Loading CSL Locales
|
|
41
41
|
<multiple>Ref.</multiple>
|
42
42
|
</term>
|
43
43
|
<term name="retrieved">abgerufen</term>
|
44
|
-
|
44
|
+
|
45
45
|
<!-- LONG ROLE FORMS -->
|
46
46
|
<term name="author">
|
47
47
|
<single/>
|
@@ -54,4 +54,4 @@ Feature: Loading CSL Locales
|
|
54
54
|
And the region should be "AT"
|
55
55
|
And the attribute "version" should be "1.0"
|
56
56
|
And the locale should should have 14 terms
|
57
|
-
And the plural of the term "reference" should be "Referenzen"
|
57
|
+
And the plural of the term "reference" should be "Referenzen"
|
@@ -1,35 +1,35 @@
|
|
1
1
|
Feature: Parse CSL localized date elements
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
2
|
+
As a hacker of CSL styles
|
3
|
+
I want to be able to parse CSL localized date strings
|
4
|
+
|
5
|
+
Scenario: A text date
|
6
|
+
When I parse the CSL string in the Locale scope
|
7
|
+
"""
|
8
|
+
<date form="text">
|
9
|
+
<date-part name="month" suffix=" "/>
|
10
|
+
<date-part name="day" form="numeric-leading-zeros" suffix=", "/>
|
11
|
+
<date-part name="year"/>
|
12
|
+
</date>
|
13
|
+
"""
|
14
|
+
Then the nodename should be "date"
|
15
|
+
And the attribute "form" should be "text"
|
16
|
+
And the node should have 3 parts
|
17
|
+
And text? should be "true"
|
18
|
+
And the part number 1 should have the attribute "name" set to "month"
|
19
|
+
|
20
|
+
Scenario: A numeric date
|
21
|
+
When I parse the CSL string in the Locale scope
|
22
|
+
"""
|
23
|
+
<date form="numeric">
|
24
|
+
<date-part name="month" form="numeric-leading-zeros" suffix="/"/>
|
25
|
+
<date-part name="day" form="numeric-leading-zeros" suffix="/"/>
|
26
|
+
<date-part name="year"/>
|
27
|
+
</date>
|
28
|
+
"""
|
29
|
+
Then the nodename should be "date"
|
30
|
+
And the attribute "form" should be "numeric"
|
31
|
+
And the node should have 3 parts
|
32
|
+
And text? should be "false"
|
33
|
+
And numeric? should be "true"
|
34
|
+
And the part number 3 should have the attribute "name" set to "year"
|
19
35
|
|
20
|
-
Scenario: A numeric date
|
21
|
-
When I parse the CSL string in the Locale scope
|
22
|
-
"""
|
23
|
-
<date form="numeric">
|
24
|
-
<date-part name="month" form="numeric-leading-zeros" suffix="/"/>
|
25
|
-
<date-part name="day" form="numeric-leading-zeros" suffix="/"/>
|
26
|
-
<date-part name="year"/>
|
27
|
-
</date>
|
28
|
-
"""
|
29
|
-
Then the nodename should be "date"
|
30
|
-
And the attribute "form" should be "numeric"
|
31
|
-
And the node should have 3 parts
|
32
|
-
And text? should be "false"
|
33
|
-
And numeric? should be "true"
|
34
|
-
And the part number 3 should have the attribute "name" set to "year"
|
35
|
-
|
@@ -8,41 +8,41 @@ Feature: Loading CSL Style
|
|
8
8
|
<?xml version="1.0" encoding="utf-8"?>
|
9
9
|
<style xmlns="http://purl.org/net/xbiblio/csl" class="in-text" version="1.0" demote-non-dropping-particle="never">
|
10
10
|
<info>
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
11
|
+
<title>American Psychological Association 6th Edition</title>
|
12
|
+
<id>http://www.zotero.org/styles/apa</id>
|
13
|
+
<link href="http://www.zotero.org/styles/apa" rel="self"/>
|
14
|
+
<link href="http://owl.english.purdue.edu/owl/resource/560/01/" rel="documentation"/>
|
15
|
+
<author>
|
16
|
+
<name>Simon Kornblith</name>
|
17
|
+
<email>simon@simonster.com</email>
|
18
|
+
</author>
|
19
|
+
<contributor>
|
20
|
+
<name>Bruce D'Arcus</name>
|
21
|
+
</contributor>
|
22
|
+
<contributor>
|
23
|
+
<name>Curtis M. Humphrey</name>
|
24
|
+
</contributor>
|
25
|
+
<contributor>
|
26
|
+
<name>Richard Karnesky</name>
|
27
|
+
<email>karnesky+zotero@gmail.com</email>
|
28
|
+
<uri>http://arc.nucapt.northwestern.edu/Richard_Karnesky</uri>
|
29
|
+
</contributor>
|
30
|
+
<contributor>
|
31
|
+
<name>Sebastian Karcher</name>
|
32
|
+
</contributor>
|
33
|
+
<category field="psychology"/>
|
34
|
+
<category field="generic-base"/>
|
35
|
+
<category citation-format="author-date"/>
|
36
|
+
<updated>2010-01-27T20:08:03+00:00</updated>
|
37
|
+
<rights>This work is licensed under a Creative Commons Attribution-Share Alike 3.0 License: http://creativecommons.org/licenses/by-sa/3.0/</rights>
|
38
38
|
</info>
|
39
39
|
<locale xml:lang="en">
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
40
|
+
<terms>
|
41
|
+
<term name="translator" form="short">
|
42
|
+
<single>trans.</single>
|
43
|
+
<multiple>trans.</multiple>
|
44
|
+
</term>
|
45
|
+
</terms>
|
46
46
|
</locale>
|
47
47
|
</style>
|
48
48
|
"""
|
data/lib/csl/locale.rb
CHANGED
@@ -101,13 +101,13 @@ module CSL
|
|
101
101
|
def initialize(*arguments)
|
102
102
|
case arguments.length
|
103
103
|
when 0
|
104
|
-
locale, attributes, options =
|
104
|
+
locale, attributes, options = nil, {}, nil
|
105
105
|
when 1
|
106
106
|
if arguments[0].is_a?(Hash)
|
107
107
|
arguments[0] = arguments[0].symbolize_keys
|
108
108
|
|
109
109
|
locale = arguments[0].delete(:lang) ||
|
110
|
-
arguments[0].delete(:'xml:lang')
|
110
|
+
arguments[0].delete(:'xml:lang')
|
111
111
|
|
112
112
|
attributes, options = arguments
|
113
113
|
else
|
@@ -371,6 +371,17 @@ module CSL
|
|
371
371
|
language && language == Locale.languages[region]
|
372
372
|
end
|
373
373
|
|
374
|
+
def like?(other)
|
375
|
+
return false unless other.is_a? Locale
|
376
|
+
return true if universal? || other.universal?
|
377
|
+
|
378
|
+
language == other.language
|
379
|
+
end
|
380
|
+
|
381
|
+
def universal?
|
382
|
+
language.nil?
|
383
|
+
end
|
384
|
+
|
374
385
|
def validate
|
375
386
|
Schema.validate self
|
376
387
|
end
|
@@ -389,6 +400,7 @@ module CSL
|
|
389
400
|
others.each do |other|
|
390
401
|
merge_options other
|
391
402
|
merge_dates other
|
403
|
+
merge_terms other
|
392
404
|
end
|
393
405
|
|
394
406
|
self
|
@@ -485,6 +497,16 @@ module CSL
|
|
485
497
|
|
486
498
|
self
|
487
499
|
end
|
500
|
+
|
501
|
+
def merge_terms(other)
|
502
|
+
return self unless other.has_terms?
|
503
|
+
|
504
|
+
other.each_term do |term|
|
505
|
+
store term.deep_copy
|
506
|
+
end
|
507
|
+
|
508
|
+
self
|
509
|
+
end
|
488
510
|
end
|
489
511
|
|
490
512
|
end
|
data/lib/csl/version.rb
CHANGED
data/spec/csl/locale_spec.rb
CHANGED
@@ -48,12 +48,12 @@ module CSL
|
|
48
48
|
describe '.new' do
|
49
49
|
it { is_expected.not_to be_nil }
|
50
50
|
|
51
|
-
it '
|
52
|
-
expect(Locale.new.language).to
|
51
|
+
it 'has no language' do
|
52
|
+
expect(Locale.new.language).to be_nil
|
53
53
|
end
|
54
54
|
|
55
|
-
it '
|
56
|
-
expect(Locale.new.region).to
|
55
|
+
it 'has no region' do
|
56
|
+
expect(Locale.new.region).to be_nil
|
57
57
|
end
|
58
58
|
|
59
59
|
it 'contains no dates by default' do
|
@@ -87,6 +87,12 @@ module CSL
|
|
87
87
|
|
88
88
|
end
|
89
89
|
|
90
|
+
describe '.parse' do
|
91
|
+
it 'does not set a default language' do
|
92
|
+
expect(Locale.parse('<locale/>').language).to be_nil
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
90
96
|
describe '#set' do
|
91
97
|
|
92
98
|
it 'when passed "en-GB" sets language to :en and region to :GB' do
|
@@ -149,6 +155,29 @@ module CSL
|
|
149
155
|
expect(locale).to have_dates
|
150
156
|
end
|
151
157
|
end
|
158
|
+
|
159
|
+
describe 'terms' do
|
160
|
+
let(:us) { Locale.load('en-US') }
|
161
|
+
|
162
|
+
it 'does not change the terms if none are set on either locale' do
|
163
|
+
expect { locale.merge!(Locale.new) }.not_to change { locale.terms.to_s }
|
164
|
+
end
|
165
|
+
|
166
|
+
it 'overrides terms with those of the other locale' do
|
167
|
+
expect(locale).not_to have_terms
|
168
|
+
|
169
|
+
locale.merge! us
|
170
|
+
expect(locale).to have_terms
|
171
|
+
end
|
172
|
+
|
173
|
+
it 'makes copies of the terms' do
|
174
|
+
locale.merge! us
|
175
|
+
expect(locale).to have_terms
|
176
|
+
|
177
|
+
expect(locale.terms.first).to eq(us.terms.first)
|
178
|
+
expect(locale.terms.first).not_to be(us.terms.first)
|
179
|
+
end
|
180
|
+
end
|
152
181
|
end
|
153
182
|
|
154
183
|
describe '#legacy?' do
|
data/spec/csl/style_spec.rb
CHANGED
@@ -2,30 +2,28 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
module CSL
|
4
4
|
describe Style do
|
5
|
-
|
6
|
-
@style = Style.new
|
7
|
-
end
|
5
|
+
let(:style) { Style.new }
|
8
6
|
|
9
7
|
it 'has a 1.x version by default' do
|
10
|
-
expect(
|
8
|
+
expect(style[:version]).to match(/1\.\d+(\.\d+)?/)
|
11
9
|
end
|
12
10
|
|
13
11
|
it 'has the default version' do
|
14
|
-
expect(
|
12
|
+
expect(style.default_attribute?(:version)).to be_truthy
|
15
13
|
end
|
16
14
|
|
17
15
|
it 'has a the default namespace attribute' do
|
18
|
-
expect(
|
19
|
-
expect(
|
16
|
+
expect(style[:xmlns]).to eq(CSL::Schema.namespace)
|
17
|
+
expect(style.default_attribute?(:xmlns)).to be_truthy
|
20
18
|
end
|
21
19
|
|
22
20
|
describe '#to_xml' do
|
23
21
|
it 'returns an empty style' do
|
24
|
-
expect(
|
22
|
+
expect(style.to_xml).to match(/^<style[^>]*\/>/)
|
25
23
|
end
|
26
24
|
|
27
25
|
it 'includes the xml namespace' do
|
28
|
-
expect(
|
26
|
+
expect(style.to_xml).to match(CSL::Schema.namespace)
|
29
27
|
end
|
30
28
|
|
31
29
|
it 'supports round-trip for apa style' do
|
@@ -62,52 +60,52 @@ module CSL
|
|
62
60
|
it { is_expected.not_to have_bibliography }
|
63
61
|
|
64
62
|
describe 'when it has a title' do
|
65
|
-
before {
|
63
|
+
before { style.title = 'foo' }
|
66
64
|
|
67
|
-
it { expect(
|
65
|
+
it { expect(style).to have_info }
|
68
66
|
|
69
67
|
it 'info.title is a text node' do
|
70
|
-
expect(
|
68
|
+
expect(style.info.title).to be_a(TextNode)
|
71
69
|
end
|
72
70
|
|
73
71
|
it '#title returns the title as a string' do
|
74
|
-
expect(
|
72
|
+
expect(style.title).to be_a(String)
|
75
73
|
end
|
76
74
|
end
|
77
75
|
end
|
78
76
|
|
79
77
|
describe '#id accessor' do
|
80
78
|
it 'returns nil by default' do
|
81
|
-
expect(
|
79
|
+
expect(style.id).to be_nil
|
82
80
|
end
|
83
81
|
|
84
82
|
it 'writer sets the id to the passed-in string' do
|
85
|
-
expect {
|
83
|
+
expect { style.id = 'foobar' }.to change { style.id }.from(nil).to('foobar')
|
86
84
|
end
|
87
85
|
end
|
88
86
|
|
89
87
|
describe 'independent and dependent styles' do
|
90
88
|
it 'styles are independent by default' do
|
91
|
-
expect(
|
89
|
+
expect(style).to be_independent
|
92
90
|
end
|
93
91
|
|
94
92
|
it 'styles do not have independent-parent links by default' do
|
95
|
-
expect(
|
93
|
+
expect(style).not_to have_independent_parent_link
|
96
94
|
end
|
97
95
|
|
98
96
|
it 'when setting an independet-parent link a style becomes dependent' do
|
99
|
-
expect {
|
97
|
+
expect { style.independent_parent_link = 'foo' }.to change { style.independent? }
|
100
98
|
end
|
101
99
|
|
102
100
|
it 'looks up independent styles parents locally first' do
|
103
|
-
|
104
|
-
expect(
|
101
|
+
style.independent_parent_link = 'http://example.com/non-existent/styles/apa'
|
102
|
+
expect(style.independent_parent).to eq Style.load('apa')
|
105
103
|
end
|
106
104
|
end
|
107
105
|
|
108
106
|
describe 'macros' do
|
109
107
|
it 'has no macros by default' do
|
110
|
-
expect(
|
108
|
+
expect(style).not_to have_macros
|
111
109
|
end
|
112
110
|
|
113
111
|
it 'raises a validation error when adding a macro without name' do
|
@@ -115,23 +113,23 @@ module CSL
|
|
115
113
|
end
|
116
114
|
|
117
115
|
describe 'when it has an "author" macro' do
|
118
|
-
before {
|
116
|
+
before { style << Style::Macro.new(:name => 'author') }
|
119
117
|
|
120
118
|
it 'has macros' do
|
121
|
-
expect(
|
119
|
+
expect(style).to have_macros
|
122
120
|
end
|
123
121
|
|
124
122
|
it 'the macro is registered in the macros hash' do
|
125
|
-
expect(
|
126
|
-
expect(
|
123
|
+
expect(style.macros).to have_key('author')
|
124
|
+
expect(style.macros['author']).to be_a(Style::Macro)
|
127
125
|
end
|
128
126
|
|
129
127
|
it 'raises a validation error when adding a macro with a duplicate name' do
|
130
|
-
expect {
|
128
|
+
expect { style << Style::Macro.new(:name => 'author') }.to raise_error(ValidationError)
|
131
129
|
end
|
132
130
|
|
133
131
|
it 'unregisters the macro when it is deleted' do
|
134
|
-
expect {
|
132
|
+
expect { style.delete style.macros['author'] }.to change { style.macros.length }
|
135
133
|
end
|
136
134
|
end
|
137
135
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: csl
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sylvester Keil
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-05-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: namae
|