csl 1.0.2 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.coveralls.yml +1 -0
- data/.gitignore +1 -0
- data/.simplecov +3 -1
- data/.travis.yml +4 -10
- data/AGPL +1 -1
- data/BSDL +2 -2
- data/Gemfile +22 -12
- data/README.md +20 -11
- data/Rakefile +6 -1
- data/csl.gemspec +4 -2
- data/features/parser/choose.feature +16 -0
- data/features/step_definitions/parser_steps.rb +10 -0
- data/features/support/env.rb +16 -2
- data/lib/csl.rb +7 -4
- data/lib/csl/compatibility.rb +10 -16
- data/lib/csl/info.rb +3 -2
- data/lib/csl/locale.rb +92 -19
- data/lib/csl/locale/term.rb +41 -2
- data/lib/csl/name_options.rb +44 -0
- data/lib/csl/node.rb +54 -6
- data/lib/csl/parser.rb +17 -17
- data/lib/csl/schema.rb +37 -32
- data/lib/csl/style.rb +32 -8
- data/lib/csl/style/bibliography.rb +46 -9
- data/lib/csl/style/choose.rb +4 -2
- data/lib/csl/style/citation.rb +10 -11
- data/lib/csl/style/group.rb +13 -6
- data/lib/csl/style/label.rb +1 -1
- data/lib/csl/style/layout.rb +4 -4
- data/lib/csl/style/names.rb +161 -22
- data/lib/csl/style/sort.rb +74 -18
- data/lib/csl/style/text.rb +6 -4
- data/lib/csl/treelike.rb +16 -5
- data/lib/csl/version.rb +2 -2
- data/spec/csl/locale/term_spec.rb +70 -70
- data/spec/csl/locale_spec.rb +140 -99
- data/spec/csl/parser_spec.rb +26 -26
- data/spec/csl/schema_spec.rb +15 -15
- data/spec/csl/style/layout_spec.rb +2 -2
- data/spec/csl/style/sort_spec.rb +11 -0
- data/spec/spec_helper.rb +13 -4
- metadata +20 -14
data/spec/csl/parser_spec.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
module CSL
|
4
|
-
|
4
|
+
|
5
5
|
describe Parser do
|
6
6
|
|
7
7
|
describe '.instance' do
|
@@ -13,7 +13,7 @@ module CSL
|
|
13
13
|
Parser.engines.each_pair do |name, parser|
|
14
14
|
describe "when using the #{name} parser " do
|
15
15
|
before(:all) { Parser.instance.parser = parser }
|
16
|
-
|
16
|
+
|
17
17
|
describe '#parse' do
|
18
18
|
|
19
19
|
describe 'for <foo/>' do
|
@@ -38,7 +38,7 @@ module CSL
|
|
38
38
|
|
39
39
|
describe 'for <foo bar="x"/>' do
|
40
40
|
let(:source) { '<foo bar="x"/>' }
|
41
|
-
|
41
|
+
|
42
42
|
it 'returns a node with attributes' do
|
43
43
|
Parser.instance.parse(source).should have_attributes
|
44
44
|
end
|
@@ -54,7 +54,7 @@ module CSL
|
|
54
54
|
|
55
55
|
describe 'for <foo>Foo Bar</foo>' do
|
56
56
|
let(:source) { '<foo>Foo Bar</foo>' }
|
57
|
-
|
57
|
+
|
58
58
|
it 'returns text node' do
|
59
59
|
Parser.instance.parse(source).should be_textnode
|
60
60
|
end
|
@@ -63,30 +63,30 @@ module CSL
|
|
63
63
|
it 'returns a regular node for <x>\n <y/></x>' do
|
64
64
|
Parser.instance.parse("<x>\n <y/></x>").should_not be_textnode
|
65
65
|
end
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
66
|
+
|
67
|
+
describe 'xml comments' do
|
68
|
+
it 'ignores comment-only documents' do
|
69
|
+
Parser.instance.parse("<!--x></x-->").should be_nil
|
70
|
+
end
|
71
|
+
|
72
|
+
it 'ignores comments in normal nodes' do
|
73
|
+
Parser.instance.parse("<x><!-- comment --></x>").should_not have_children
|
74
|
+
end
|
75
|
+
|
76
|
+
it 'ignores comments in text nodes' do
|
77
|
+
node = Parser.instance.parse("<x>foo<!-- comment --></x>")
|
78
|
+
node.should be_textnode
|
79
|
+
node.should_not have_children
|
80
|
+
node.text.should == 'foo'
|
81
|
+
end
|
82
|
+
|
83
|
+
end
|
84
|
+
|
85
85
|
end
|
86
|
-
|
86
|
+
|
87
87
|
end
|
88
88
|
end
|
89
89
|
|
90
90
|
end
|
91
|
-
|
92
|
-
end
|
91
|
+
|
92
|
+
end
|
data/spec/csl/schema_spec.rb
CHANGED
@@ -2,21 +2,21 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
module CSL
|
4
4
|
describe 'Schema' do
|
5
|
-
|
5
|
+
|
6
6
|
it 'cannot be instantiated' do
|
7
7
|
Schema.should_not respond_to(:new)
|
8
8
|
end
|
9
|
-
|
9
|
+
|
10
10
|
describe '.version' do
|
11
11
|
it 'returns a version string' do
|
12
12
|
Schema.version.should match(/^\d+\.\d+\.\d+/)
|
13
13
|
end
|
14
|
-
|
14
|
+
|
15
15
|
it 'is greater than 1.0' do
|
16
16
|
Schema.version.split(/\./)[0].to_i.should >= 1
|
17
17
|
end
|
18
18
|
end
|
19
|
-
|
19
|
+
|
20
20
|
describe '.variables' do
|
21
21
|
it 'contains :names fields' do
|
22
22
|
Schema.variables[:names].should_not be_empty
|
@@ -36,43 +36,43 @@ module CSL
|
|
36
36
|
Schema.variables[:numbers].should_not be_empty
|
37
37
|
Schema.variables[:number].should_not be_empty
|
38
38
|
end
|
39
|
-
|
39
|
+
|
40
40
|
it 'accepts either string or symbol input' do
|
41
41
|
Schema.variables[:names].should equal Schema.variables['names']
|
42
|
-
end
|
42
|
+
end
|
43
43
|
end
|
44
|
-
|
44
|
+
|
45
45
|
describe '.types' do
|
46
46
|
it 'returns an array' do
|
47
47
|
Schema.types.should be_a(Array)
|
48
48
|
end
|
49
|
-
|
49
|
+
|
50
50
|
it 'is not empty' do
|
51
51
|
Schema.types.should_not be_empty
|
52
52
|
end
|
53
|
-
|
53
|
+
|
54
54
|
it 'includes :article' do
|
55
55
|
Schema.types.should include(:article)
|
56
56
|
end
|
57
57
|
end
|
58
|
-
|
58
|
+
|
59
59
|
describe '.categories' do
|
60
60
|
it 'given a field name returns the corresponding type' do
|
61
61
|
Schema.categories.values_at(:author, :issued, :abstract, :issue).should ==
|
62
62
|
[:names, :date, :text, :number]
|
63
63
|
end
|
64
|
-
|
64
|
+
|
65
65
|
it 'accepts either string or symbol input' do
|
66
66
|
Schema.categories.should have_key(:author)
|
67
67
|
Schema.categories['author'].should equal Schema.categories[:author]
|
68
68
|
end
|
69
69
|
end
|
70
|
-
|
70
|
+
|
71
71
|
describe '.validate' do
|
72
72
|
it 'accepts and validates a locale instance' do
|
73
73
|
Schema.validate(Locale.load('en-US')).should == []
|
74
74
|
end
|
75
|
-
|
75
|
+
|
76
76
|
it 'accepts and validates a locale file path' do
|
77
77
|
Schema.validate(File.join(Locale.root, 'locales-en-US.xml')).should == []
|
78
78
|
end
|
@@ -103,9 +103,9 @@ module CSL
|
|
103
103
|
</stle>
|
104
104
|
})[0][0].should == 0 # error on line 0 -> parse error
|
105
105
|
end
|
106
|
-
|
106
|
+
|
107
107
|
# TODO fix nokogiri/jing validation
|
108
108
|
end unless RUBY_PLATFORM =~ /java/i
|
109
|
-
|
109
|
+
|
110
110
|
end
|
111
111
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,9 +1,18 @@
|
|
1
1
|
begin
|
2
|
-
|
3
|
-
|
4
|
-
|
2
|
+
require 'simplecov'
|
3
|
+
require 'coveralls' if ENV['CI']
|
4
|
+
rescue LoadError
|
5
|
+
# ignore
|
6
|
+
end
|
7
|
+
|
8
|
+
begin
|
9
|
+
case
|
10
|
+
when RUBY_PLATFORM < 'java'
|
11
|
+
require 'debug'
|
12
|
+
Debugger.start
|
13
|
+
when defined?(RUBY_ENGINE) && RUBY_ENGINE == 'rbx'
|
14
|
+
require 'rubinius/debugger'
|
5
15
|
else
|
6
|
-
require 'simplecov'
|
7
16
|
require 'debugger'
|
8
17
|
end
|
9
18
|
rescue LoadError
|
metadata
CHANGED
@@ -1,27 +1,27 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: csl
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
4
|
+
version: 1.1.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:
|
11
|
+
date: 2014-01-28 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.7'
|
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.7'
|
27
27
|
description: "\n\t\tA Ruby parser and full API for the Citation Style Language (CSL),\n\t\tan
|
@@ -32,12 +32,13 @@ executables: []
|
|
32
32
|
extensions: []
|
33
33
|
extra_rdoc_files: []
|
34
34
|
files:
|
35
|
-
- .
|
36
|
-
- .
|
37
|
-
- .
|
38
|
-
- .
|
39
|
-
- .
|
40
|
-
- .
|
35
|
+
- ".coveralls.yml"
|
36
|
+
- ".document"
|
37
|
+
- ".gitignore"
|
38
|
+
- ".rspec"
|
39
|
+
- ".simplecov"
|
40
|
+
- ".travis.yml"
|
41
|
+
- ".yardopts"
|
41
42
|
- AGPL
|
42
43
|
- BSDL
|
43
44
|
- Gemfile
|
@@ -48,6 +49,7 @@ files:
|
|
48
49
|
- cucumber.yml
|
49
50
|
- features/locales/loading.feature
|
50
51
|
- features/locales/ordinalize.feature
|
52
|
+
- features/parser/choose.feature
|
51
53
|
- features/parser/info.feature
|
52
54
|
- features/parser/localized_dates.feature
|
53
55
|
- features/parser/terms.feature
|
@@ -67,6 +69,7 @@ files:
|
|
67
69
|
- lib/csl/locale/date.rb
|
68
70
|
- lib/csl/locale/style_options.rb
|
69
71
|
- lib/csl/locale/term.rb
|
72
|
+
- lib/csl/name_options.rb
|
70
73
|
- lib/csl/node.rb
|
71
74
|
- lib/csl/parser.rb
|
72
75
|
- lib/csl/pretty_printer.rb
|
@@ -104,6 +107,7 @@ files:
|
|
104
107
|
- spec/csl/style/macro_spec.rb
|
105
108
|
- spec/csl/style/names_spec.rb
|
106
109
|
- spec/csl/style/number_spec.rb
|
110
|
+
- spec/csl/style/sort_spec.rb
|
107
111
|
- spec/csl/style/text_spec.rb
|
108
112
|
- spec/csl/style_spec.rb
|
109
113
|
- spec/csl/treelike_spec.rb
|
@@ -127,23 +131,24 @@ require_paths:
|
|
127
131
|
- lib
|
128
132
|
required_ruby_version: !ruby/object:Gem::Requirement
|
129
133
|
requirements:
|
130
|
-
- -
|
134
|
+
- - ">="
|
131
135
|
- !ruby/object:Gem::Version
|
132
|
-
version:
|
136
|
+
version: 1.9.3
|
133
137
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
134
138
|
requirements:
|
135
|
-
- -
|
139
|
+
- - ">="
|
136
140
|
- !ruby/object:Gem::Version
|
137
141
|
version: '0'
|
138
142
|
requirements: []
|
139
143
|
rubyforge_project:
|
140
|
-
rubygems_version: 2.
|
144
|
+
rubygems_version: 2.2.1
|
141
145
|
signing_key:
|
142
146
|
specification_version: 4
|
143
147
|
summary: A Ruby CSL parser and library
|
144
148
|
test_files:
|
145
149
|
- features/locales/loading.feature
|
146
150
|
- features/locales/ordinalize.feature
|
151
|
+
- features/parser/choose.feature
|
147
152
|
- features/parser/info.feature
|
148
153
|
- features/parser/localized_dates.feature
|
149
154
|
- features/parser/terms.feature
|
@@ -170,6 +175,7 @@ test_files:
|
|
170
175
|
- spec/csl/style/macro_spec.rb
|
171
176
|
- spec/csl/style/names_spec.rb
|
172
177
|
- spec/csl/style/number_spec.rb
|
178
|
+
- spec/csl/style/sort_spec.rb
|
173
179
|
- spec/csl/style/text_spec.rb
|
174
180
|
- spec/csl/style_spec.rb
|
175
181
|
- spec/csl/treelike_spec.rb
|