citeproc 1.0.1 → 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +11 -5
- data/features/step_definitions/processor.rb +9 -9
- data/features/support/env.rb +6 -4
- data/lib/citeproc/item.rb +5 -0
- data/lib/citeproc/version.rb +1 -1
- data/spec/citeproc/abbreviate_spec.rb +5 -5
- data/spec/citeproc/assets_spec.rb +8 -8
- data/spec/citeproc/attributes_spec.rb +3 -3
- data/spec/citeproc/bibliography_spec.rb +10 -10
- data/spec/citeproc/citation_data_spec.rb +12 -12
- data/spec/citeproc/date_spec.rb +89 -89
- data/spec/citeproc/engine_spec.rb +2 -2
- data/spec/citeproc/extensions_spec.rb +20 -20
- data/spec/citeproc/item_spec.rb +15 -15
- data/spec/citeproc/names_spec.rb +130 -130
- data/spec/citeproc/processor_spec.rb +8 -8
- data/spec/citeproc/selector_spec.rb +12 -12
- data/spec/citeproc/utilities_spec.rb +1 -1
- data/spec/citeproc/variable_spec.rb +46 -46
- data/spec/spec_helper.rb +3 -2
- data/tasks/testsuite.rb +0 -3
- metadata +11 -11
@@ -9,8 +9,8 @@ module CiteProc
|
|
9
9
|
|
10
10
|
it { should_not be nil }
|
11
11
|
|
12
|
-
it { p.engine.
|
13
|
-
it { p.engine.name.
|
12
|
+
it { expect(p.engine).not_to be nil }
|
13
|
+
it { expect(p.engine.name).to eq('citeproc-ruby') }
|
14
14
|
|
15
15
|
describe '#register' do
|
16
16
|
|
@@ -31,7 +31,7 @@ module CiteProc
|
|
31
31
|
end
|
32
32
|
|
33
33
|
it 'returns the processor' do
|
34
|
-
(p << palefire).
|
34
|
+
expect(p << palefire).to be_equal(p)
|
35
35
|
end
|
36
36
|
|
37
37
|
end
|
@@ -40,7 +40,7 @@ module CiteProc
|
|
40
40
|
|
41
41
|
describe 'when there is no item with the passed-in id' do
|
42
42
|
it 'returns nil' do
|
43
|
-
p[:palefire].
|
43
|
+
expect(p[:palefire]).to be nil
|
44
44
|
end
|
45
45
|
end
|
46
46
|
|
@@ -48,7 +48,7 @@ module CiteProc
|
|
48
48
|
before(:each) { p.register(palefire) }
|
49
49
|
|
50
50
|
it 'returns the item' do
|
51
|
-
p[:palefire].
|
51
|
+
expect(p[:palefire]).to equal(palefire)
|
52
52
|
end
|
53
53
|
end
|
54
54
|
end
|
@@ -65,11 +65,11 @@ module CiteProc
|
|
65
65
|
|
66
66
|
describe 'when passed a hash' do
|
67
67
|
it 'registers the value with the key as id' do
|
68
|
-
p.update(:foo => palefire)[:foo].
|
68
|
+
expect(p.update(:foo => palefire)[:foo]).to equal(palefire)
|
69
69
|
end
|
70
70
|
|
71
71
|
it 'converts the value to an item' do
|
72
|
-
p.update(:foo => { :title => 'The Story of Foo' })[:foo].
|
72
|
+
expect(p.update(:foo => { :title => 'The Story of Foo' })[:foo]).to be_a(Item)
|
73
73
|
end
|
74
74
|
end
|
75
75
|
|
@@ -88,7 +88,7 @@ module CiteProc
|
|
88
88
|
describe 'when no items have been processed' do
|
89
89
|
|
90
90
|
it 'returns an empty bibliography' do
|
91
|
-
p.bibliography.
|
91
|
+
expect(p.bibliography).to be_empty
|
92
92
|
end
|
93
93
|
|
94
94
|
# it 'returns a bibliography of all registered items if invoked with :all'
|
@@ -11,24 +11,24 @@ module CiteProc
|
|
11
11
|
|
12
12
|
|
13
13
|
it 'should have no skip_condtions by default' do
|
14
|
-
Selector.new.skip_conditions.
|
14
|
+
expect(Selector.new.skip_conditions).to be_empty
|
15
15
|
end
|
16
16
|
|
17
17
|
it 'should have no condtions by default' do
|
18
|
-
Selector.new.conditions.
|
18
|
+
expect(Selector.new.conditions).to be_empty
|
19
19
|
end
|
20
20
|
|
21
21
|
describe 'constructing' do
|
22
22
|
|
23
23
|
%w{ all none any skip }.each do |matcher|
|
24
24
|
it "accepts the ruby style matcher '#{matcher}'" do
|
25
|
-
Selector.new(matcher => {}).
|
25
|
+
expect(Selector.new(matcher => {})).not_to be nil
|
26
26
|
end
|
27
27
|
end
|
28
28
|
|
29
29
|
%w{ include exclude select quash }.each do |matcher|
|
30
30
|
it "accepts the citeproc-js style matcher '#{matcher}'" do
|
31
|
-
Selector.new(matcher => {}).
|
31
|
+
expect(Selector.new(matcher => {})).not_to be nil
|
32
32
|
end
|
33
33
|
end
|
34
34
|
|
@@ -38,7 +38,7 @@ module CiteProc
|
|
38
38
|
# it 'accepts a citeproc json style hash'
|
39
39
|
|
40
40
|
it 'accepts a json object (select)' do
|
41
|
-
Selector.new(
|
41
|
+
expect(Selector.new(
|
42
42
|
"select" => [
|
43
43
|
{
|
44
44
|
"field" => "type",
|
@@ -48,7 +48,7 @@ module CiteProc
|
|
48
48
|
"value" => "1990s"
|
49
49
|
}
|
50
50
|
]
|
51
|
-
).conditions.
|
51
|
+
).conditions.size).to eq(2)
|
52
52
|
end
|
53
53
|
end
|
54
54
|
|
@@ -58,31 +58,31 @@ module CiteProc
|
|
58
58
|
describe '#to_citeproc' do
|
59
59
|
|
60
60
|
it 'returns nil by default' do
|
61
|
-
Selector.new.to_citeproc.
|
61
|
+
expect(Selector.new.to_citeproc).to be nil
|
62
62
|
end
|
63
63
|
|
64
64
|
it 'converts all matcher to select' do
|
65
|
-
Selector.new(:all => { :a => 'b' }).to_citeproc.
|
65
|
+
expect(Selector.new(:all => { :a => 'b' }).to_citeproc).to eq({ 'select' => [{ 'field' => 'a', 'value' => 'b' }]})
|
66
66
|
end
|
67
67
|
|
68
68
|
it 'converts any matcher to include' do
|
69
|
-
Selector.new(:any => { :a => 'b' }).to_citeproc.
|
69
|
+
expect(Selector.new(:any => { :a => 'b' }).to_citeproc).to eq({ 'include' => [{ 'field' => 'a', 'value' => 'b' }]})
|
70
70
|
end
|
71
71
|
|
72
72
|
it 'converts none matcher to exclude' do
|
73
|
-
Selector.new(:none => { :a => 'b' }).to_citeproc.
|
73
|
+
expect(Selector.new(:none => { :a => 'b' }).to_citeproc).to eq({ 'exclude' => [{ 'field' => 'a', 'value' => 'b' }]})
|
74
74
|
end
|
75
75
|
end
|
76
76
|
|
77
77
|
describe '#matches?' do
|
78
78
|
it 'always matches by default' do
|
79
|
-
Selector.new.matches?(nil).
|
79
|
+
expect(Selector.new.matches?(nil)).to be_true
|
80
80
|
end
|
81
81
|
end
|
82
82
|
|
83
83
|
describe '#skip?' do
|
84
84
|
it 'never skips when by default' do
|
85
|
-
Selector.new.skip?(nil).
|
85
|
+
expect(Selector.new.skip?(nil)).to be_false
|
86
86
|
end
|
87
87
|
end
|
88
88
|
end
|
@@ -7,159 +7,159 @@ module CiteProc
|
|
7
7
|
it { should be_an_instance_of(Variable) }
|
8
8
|
|
9
9
|
it 'is empty by default' do
|
10
|
-
Variable.new.
|
10
|
+
expect(Variable.new).to be_empty
|
11
11
|
end
|
12
12
|
|
13
13
|
it 'equals an empty string (==) by default' do
|
14
|
-
Variable.new.
|
14
|
+
expect(Variable.new).to eq('')
|
15
15
|
end
|
16
16
|
|
17
17
|
it 'matches an empty pattern by default' do
|
18
|
-
Variable.new.
|
18
|
+
expect(Variable.new).to match(/^$/)
|
19
19
|
end
|
20
20
|
|
21
21
|
it 'accepts a string value' do
|
22
|
-
Variable.new('test').
|
22
|
+
expect(Variable.new('test')).to eq('test')
|
23
23
|
end
|
24
24
|
|
25
25
|
it 'accepts a numeric value' do
|
26
|
-
Variable.new(23).
|
26
|
+
expect(Variable.new(23)).to eq('23')
|
27
27
|
end
|
28
28
|
|
29
29
|
it 'accepts a floating point value' do
|
30
|
-
Variable.new(23.12).
|
30
|
+
expect(Variable.new(23.12)).to eq('23.12')
|
31
31
|
end
|
32
32
|
end
|
33
33
|
|
34
34
|
describe '.fields' do
|
35
35
|
it 'contains :names fields' do
|
36
|
-
Variable.fields[:names].
|
37
|
-
Variable.fields[:name].
|
36
|
+
expect(Variable.fields[:names]).not_to be_empty
|
37
|
+
expect(Variable.fields[:name]).to equal Variable.fields[:names]
|
38
38
|
end
|
39
39
|
|
40
40
|
it 'contains :date fields' do
|
41
|
-
Variable.fields[:date].
|
42
|
-
Variable.fields[:dates].
|
41
|
+
expect(Variable.fields[:date]).not_to be_empty
|
42
|
+
expect(Variable.fields[:dates]).to equal Variable.fields[:date]
|
43
43
|
end
|
44
44
|
|
45
45
|
it 'contains :text fields' do
|
46
|
-
Variable.fields[:text].
|
46
|
+
expect(Variable.fields[:text]).not_to be_empty
|
47
47
|
end
|
48
48
|
|
49
49
|
it 'contains :number fields' do
|
50
|
-
Variable.fields[:numbers].
|
51
|
-
Variable.fields[:number].
|
50
|
+
expect(Variable.fields[:numbers]).not_to be_empty
|
51
|
+
expect(Variable.fields[:number]).not_to be_empty
|
52
52
|
end
|
53
53
|
|
54
54
|
it 'accepts either string or symbol input' do
|
55
|
-
Variable.fields[:names].
|
55
|
+
expect(Variable.fields[:names]).to equal Variable.fields['names']
|
56
56
|
end
|
57
57
|
end
|
58
58
|
|
59
59
|
describe '.types' do
|
60
60
|
it 'given a field name returns the corresponding type' do
|
61
|
-
Variable.types.values_at(:author, :issued, :abstract, :issue).
|
61
|
+
expect(Variable.types.values_at(:author, :issued, :abstract, :issue)).to eq([:names, :date, :text, :number])
|
62
62
|
end
|
63
63
|
|
64
64
|
it 'accepts either string or symbol input' do
|
65
|
-
Variable.types.
|
66
|
-
Variable.types['author'].
|
65
|
+
expect(Variable.types).to have_key(:author)
|
66
|
+
expect(Variable.types['author']).to equal Variable.types[:author]
|
67
67
|
end
|
68
68
|
end
|
69
69
|
|
70
70
|
describe '#to_s' do
|
71
71
|
it 'displays the value' do
|
72
|
-
Variable.new('test').to_s.
|
72
|
+
expect(Variable.new('test').to_s).to eq('test')
|
73
73
|
end
|
74
74
|
end
|
75
75
|
|
76
76
|
describe '#to_i' do
|
77
77
|
it 'returns zero by default' do
|
78
|
-
Variable.new.to_i.
|
78
|
+
expect(Variable.new.to_i).to eq(0)
|
79
79
|
end
|
80
80
|
|
81
81
|
context 'when the value is numeric' do
|
82
82
|
%w{ -23 -1 0 1 23 }.each do |value|
|
83
83
|
it "returns the integer value (#{value})" do
|
84
|
-
Variable.new(value).to_i.
|
84
|
+
expect(Variable.new(value).to_i).to equal(value.to_i)
|
85
85
|
end
|
86
86
|
end
|
87
87
|
|
88
88
|
it 'returns only the first numeric value if there are several' do
|
89
|
-
Variable.new('testing 1, 2, 3...').to_i.
|
89
|
+
expect(Variable.new('testing 1, 2, 3...').to_i).to eq(1)
|
90
90
|
end
|
91
91
|
end
|
92
92
|
end
|
93
93
|
|
94
94
|
describe '#to_f' do
|
95
95
|
it 'returns zero by default' do
|
96
|
-
Variable.new.to_f.
|
96
|
+
expect(Variable.new.to_f).to eq(0.0)
|
97
97
|
end
|
98
98
|
|
99
99
|
context 'when the value is numeric' do
|
100
100
|
%w{ -23.2 -1.45 0.2 1.733 23 }.each do |value|
|
101
101
|
it "returns the integer value (#{value})" do
|
102
|
-
Variable.new(value).to_f.
|
102
|
+
expect(Variable.new(value).to_f).to eq(value.to_f)
|
103
103
|
end
|
104
104
|
end
|
105
105
|
|
106
106
|
it 'returns only the first numeric value if there are several' do
|
107
|
-
Variable.new('testing 1, 2, 3...').to_f.
|
107
|
+
expect(Variable.new('testing 1, 2, 3...').to_f).to eq(1.0)
|
108
108
|
end
|
109
109
|
|
110
110
|
it 'works with dot and comma separators' do
|
111
|
-
Variable.new('1,23').to_f.
|
111
|
+
expect(Variable.new('1,23').to_f).to eq(Variable.new('1.23').to_f)
|
112
112
|
end
|
113
113
|
end
|
114
114
|
end
|
115
115
|
|
116
116
|
describe '#numeric?' do
|
117
117
|
it 'returns false by default' do
|
118
|
-
Variable.new.
|
118
|
+
expect(Variable.new).not_to be_numeric
|
119
119
|
end
|
120
120
|
|
121
121
|
context 'variable contains a number' do
|
122
122
|
it 'returns true (string initialized)' do
|
123
|
-
Variable.new('23').
|
124
|
-
Variable.new('X23').
|
125
|
-
Variable.new('23rd').
|
123
|
+
expect(Variable.new('23')).to be_numeric
|
124
|
+
expect(Variable.new('X23')).to be_numeric
|
125
|
+
expect(Variable.new('23rd')).to be_numeric
|
126
126
|
end
|
127
127
|
it 'returns true (integer initialized)' do
|
128
|
-
Variable.new(23).
|
128
|
+
expect(Variable.new(23)).to be_numeric
|
129
129
|
end
|
130
130
|
end
|
131
131
|
|
132
132
|
context 'variable does not contain a number' do
|
133
133
|
it 'returns false for strings' do
|
134
|
-
Variable.new('test').
|
134
|
+
expect(Variable.new('test')).not_to be_numeric
|
135
135
|
end
|
136
136
|
end
|
137
137
|
|
138
138
|
context 'variable contains numbers but is not numeric' do
|
139
139
|
it 'returns false for strings' do
|
140
|
-
Variable.new('23rd test').
|
141
|
-
Variable.new('23rd, 24th & 25th edition').
|
140
|
+
expect(Variable.new('23rd test')).not_to be_numeric
|
141
|
+
expect(Variable.new('23rd, 24th & 25th edition')).not_to be_numeric
|
142
142
|
end
|
143
143
|
end
|
144
144
|
|
145
145
|
context 'variable contains multiple numbers' do
|
146
146
|
it 'returns true for simple ranges' do
|
147
|
-
Variable.new('23-24').
|
148
|
-
Variable.new('23 - 24').
|
149
|
-
Variable.new('23- 24').
|
147
|
+
expect(Variable.new('23-24')).to be_numeric
|
148
|
+
expect(Variable.new('23 - 24')).to be_numeric
|
149
|
+
expect(Variable.new('23- 24')).to be_numeric
|
150
150
|
end
|
151
151
|
|
152
152
|
it 'returns true for simple lists' do
|
153
|
-
Variable.new('23,24').
|
154
|
-
Variable.new('23 , 24').
|
155
|
-
Variable.new('23, 24').
|
156
|
-
Variable.new('23 ,24').
|
157
|
-
Variable.new('23 ,24,25 , 26, 27').
|
153
|
+
expect(Variable.new('23,24')).to be_numeric
|
154
|
+
expect(Variable.new('23 , 24')).to be_numeric
|
155
|
+
expect(Variable.new('23, 24')).to be_numeric
|
156
|
+
expect(Variable.new('23 ,24')).to be_numeric
|
157
|
+
expect(Variable.new('23 ,24,25 , 26, 27')).to be_numeric
|
158
158
|
end
|
159
159
|
|
160
160
|
it 'returns true for complex lists' do
|
161
|
-
Variable.new('23rd, 24th & 25th').
|
162
|
-
Variable.new('X23, A2-49th & 25th & A1, B2').
|
161
|
+
expect(Variable.new('23rd, 24th & 25th')).to be_numeric
|
162
|
+
expect(Variable.new('X23, A2-49th & 25th & A1, B2')).to be_numeric
|
163
163
|
end
|
164
164
|
end
|
165
165
|
end
|
@@ -167,12 +167,12 @@ module CiteProc
|
|
167
167
|
describe '#strip_markup' do
|
168
168
|
let(:greeting) { '<h1>hello<b> world</b></h1>' }
|
169
169
|
it 'returns a string stripped of html tags' do
|
170
|
-
Variable.new(greeting).strip_markup.
|
170
|
+
expect(Variable.new(greeting).strip_markup).to eq('hello world')
|
171
171
|
end
|
172
172
|
it 'does not alter the value itself' do
|
173
173
|
v = Variable.new(greeting)
|
174
174
|
v.strip_markup
|
175
|
-
v.
|
175
|
+
expect(v).to eq(greeting)
|
176
176
|
end
|
177
177
|
end
|
178
178
|
|
@@ -181,7 +181,7 @@ module CiteProc
|
|
181
181
|
it 'strips of html tags' do
|
182
182
|
v = Variable.new(greeting)
|
183
183
|
v.strip_markup!
|
184
|
-
v.
|
184
|
+
expect(v).to eq('hello world')
|
185
185
|
end
|
186
186
|
end
|
187
187
|
|
data/spec/spec_helper.rb
CHANGED
@@ -12,14 +12,15 @@ begin
|
|
12
12
|
# Debugger.start
|
13
13
|
when defined?(RUBY_ENGINE) && RUBY_ENGINE == 'rbx'
|
14
14
|
require 'rubinius/debugger'
|
15
|
-
|
15
|
+
when RUBY_VERSION < '2.0'
|
16
16
|
require 'debugger'
|
17
|
+
else
|
18
|
+
require 'byebug'
|
17
19
|
end
|
18
20
|
rescue LoadError
|
19
21
|
# ignore
|
20
22
|
end
|
21
23
|
|
22
|
-
|
23
24
|
$:.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
24
25
|
$:.unshift(File.dirname(__FILE__))
|
25
26
|
|
data/tasks/testsuite.rb
CHANGED
@@ -9,9 +9,6 @@ module CSL
|
|
9
9
|
quotes_PunctuationWithInnerQuote # replaces single quotes and apostrophes
|
10
10
|
sort_SubstituteTitle # ---
|
11
11
|
substitute_SuppressOrdinaryVariable # citeproc-js bug?
|
12
|
-
sort_VariousNameMacros1 # ---
|
13
|
-
sort_VariousNameMacros2 # ---
|
14
|
-
sort_VariousNameMacros3 # ---
|
15
12
|
sort_FamilyOnly # invalid CSL (no layout) / ANZ after Aardvark?
|
16
13
|
name_ParticleCaps3 # " in family name
|
17
14
|
testers_SecondAutoGeneratedZoteroPluginTest # uses <sc> for small-caps
|
metadata
CHANGED
@@ -1,27 +1,27 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: citeproc
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sylvester Keil
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-03-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: namae
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - ~>
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '0.8'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - ~>
|
24
|
+
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0.8'
|
27
27
|
description: "\n A cite processor interface for Citation Style Language (CSL) styles.\n
|
@@ -32,10 +32,10 @@ executables: []
|
|
32
32
|
extensions: []
|
33
33
|
extra_rdoc_files: []
|
34
34
|
files:
|
35
|
-
- .document
|
36
|
-
- .rspec
|
37
|
-
- .simplecov
|
38
|
-
- .yardopts
|
35
|
+
- ".document"
|
36
|
+
- ".rspec"
|
37
|
+
- ".simplecov"
|
38
|
+
- ".yardopts"
|
39
39
|
- AGPL
|
40
40
|
- BSDL
|
41
41
|
- Gemfile
|
@@ -91,17 +91,17 @@ require_paths:
|
|
91
91
|
- lib
|
92
92
|
required_ruby_version: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
|
-
- -
|
94
|
+
- - ">="
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: 1.9.3
|
97
97
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
98
98
|
requirements:
|
99
|
-
- -
|
99
|
+
- - ">="
|
100
100
|
- !ruby/object:Gem::Version
|
101
101
|
version: '0'
|
102
102
|
requirements: []
|
103
103
|
rubyforge_project:
|
104
|
-
rubygems_version: 2.
|
104
|
+
rubygems_version: 2.4.5
|
105
105
|
signing_key:
|
106
106
|
specification_version: 4
|
107
107
|
summary: A cite processor interface.
|