citeproc-ruby 1.0.5 → 1.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +8 -2
- data/features/renderer.feature +20 -0
- data/features/support/env.rb +3 -1
- data/lib/citeproc/ruby/format.rb +5 -2
- data/lib/citeproc/ruby/renderer/macro.rb +4 -4
- data/lib/citeproc/ruby/renderer/names.rb +6 -0
- data/lib/citeproc/ruby/renderer/observer.rb +3 -1
- data/lib/citeproc/ruby/version.rb +1 -1
- data/spec/citeproc/ruby/formats/default_spec.rb +5 -2
- data/spec/citeproc/ruby/renderer/group_spec.rb +26 -0
- data/spec/spec_helper.rb +3 -1
- metadata +12 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 61a47839dcb7a73c69ebd1e7ec7fadd7996c014d
|
4
|
+
data.tar.gz: 4ea72fbdc878a1bd5217680d62f0233f7db49319
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8e8009f337db47b1efbd844d149a538add3a126dae038bec8e33692fddc3e4cda75ff0f88a9d00d68012b3c91c6d472d96afcbe15980f434d57ee82682f5220a
|
7
|
+
data.tar.gz: c170fd2378c2d198194cde8fdfe838a6ce184ff5f048cbddcd62cbe061e73441204e913be80314a63f8a848cd425fcb29f2d8470d45f7008e729c6804d1921d4
|
data/Gemfile
CHANGED
@@ -6,7 +6,7 @@ gemspec
|
|
6
6
|
|
7
7
|
group :development, :test do
|
8
8
|
gem 'rake', '~>10.0'
|
9
|
-
gem 'rspec', '~>3.0'
|
9
|
+
gem 'rspec', '~>3.0', '<3.2'
|
10
10
|
gem 'cucumber', '~>1.2'
|
11
11
|
gem 'simplecov', '~>0.8'
|
12
12
|
gem 'rubinius-coverage', :platforms => :rbx
|
@@ -14,8 +14,14 @@ group :development, :test do
|
|
14
14
|
end
|
15
15
|
|
16
16
|
group :debug do
|
17
|
+
if RUBY_VERSION >= '2.0'
|
18
|
+
gem 'byebug', :require => false, :platforms => :mri
|
19
|
+
else
|
20
|
+
gem 'debugger', :require => false, :platforms => :mri
|
21
|
+
end
|
22
|
+
|
17
23
|
gem 'ruby-debug', :require => false, :platforms => :jruby
|
18
|
-
|
24
|
+
|
19
25
|
gem 'rubinius-debugger', :require => false, :platforms => :rbx
|
20
26
|
gem 'rubinius-compiler', :require => false, :platforms => :rbx
|
21
27
|
end
|
data/features/renderer.feature
CHANGED
@@ -72,3 +72,23 @@ Feature: Rendering CSL nodes
|
|
72
72
|
| |
|
73
73
|
| pages |
|
74
74
|
|
75
|
+
@group @substitute
|
76
|
+
Scenario: Substitute in Groups
|
77
|
+
Given the following style node:
|
78
|
+
"""
|
79
|
+
<group>
|
80
|
+
<text value="by: "/>
|
81
|
+
<names variable="author">
|
82
|
+
<substitute>
|
83
|
+
<text value="Anonymous"/>
|
84
|
+
</substitute>
|
85
|
+
</names>
|
86
|
+
</group>
|
87
|
+
"""
|
88
|
+
When I render the following citation items as "text":
|
89
|
+
| author |
|
90
|
+
| Jane Doe |
|
91
|
+
| |
|
92
|
+
Then the results should be:
|
93
|
+
| by: Jane Doe |
|
94
|
+
| by: Anonymous |
|
data/features/support/env.rb
CHANGED
data/lib/citeproc/ruby/format.rb
CHANGED
@@ -229,14 +229,17 @@ module CiteProc
|
|
229
229
|
# TODO add support for stop words consisting of multiple words
|
230
230
|
#output.gsub!(/\b(\p{Lu})(\p{Lu}+)\b/) { "#{$1}#{CiteProc.downcase($2)}" }
|
231
231
|
|
232
|
-
# TODO exceptions:
|
232
|
+
# TODO exceptions: word followed by colon
|
233
|
+
first = true
|
233
234
|
output.gsub!(/\b(\p{Ll})(\p{L}+)\b/) do |word|
|
234
|
-
if Format.stopword?(word)
|
235
|
+
if Format.stopword?(word) and not first
|
235
236
|
word
|
236
237
|
else
|
238
|
+
first = false
|
237
239
|
"#{CiteProc.upcase($1)}#{$2}"
|
238
240
|
end
|
239
241
|
end
|
242
|
+
output.gsub!(/\b(\p{Ll})(\p{L}+)\b$/) { "#{CiteProc.upcase($1)}#{$2}" }
|
240
243
|
|
241
244
|
end
|
242
245
|
end
|
@@ -332,6 +332,12 @@ module CiteProc
|
|
332
332
|
# of the rendering process!
|
333
333
|
item.suppress!(*observer.accessed)
|
334
334
|
|
335
|
+
# Report a read-access using the substitution string
|
336
|
+
# for the name variable being substituted, or the first
|
337
|
+
# name variable (if there are more than one).
|
338
|
+
variable = node.parent.variable[/\w+/]
|
339
|
+
item.data.simulate_read_attribute variable, string
|
340
|
+
|
335
341
|
return string # break out of each loop!
|
336
342
|
end
|
337
343
|
|
@@ -106,8 +106,11 @@ module CiteProc
|
|
106
106
|
node[:'text-case'] = 'title'
|
107
107
|
|
108
108
|
expect(format.apply('The adventures of Huckleberry Finn', node)).to eq('The Adventures of Huckleberry Finn')
|
109
|
-
expect(format.apply(
|
110
|
-
|
109
|
+
expect(format.apply('This IS a pen that is a smith pencil', node)).to eq('This IS a Pen That Is a Smith Pencil')
|
110
|
+
expect(format.apply('of mice and men', node)).to eq('Of Mice and Men')
|
111
|
+
expect(format.apply('history of the word the', node)).to eq('History of the Word The')
|
112
|
+
expect(format.apply('faster than the speed of sound', node)).to eq('Faster than the Speed of Sound')
|
113
|
+
expect(format.apply('on the drug-resistance of enteric bacteria', node)).to eq('On the Drug-Resistance of Enteric Bacteria')
|
111
114
|
end
|
112
115
|
end
|
113
116
|
|
@@ -83,6 +83,32 @@ module CiteProc
|
|
83
83
|
end
|
84
84
|
end
|
85
85
|
end
|
86
|
+
|
87
|
+
describe 'when there is a names node with substitute in the group' do
|
88
|
+
|
89
|
+
before(:each) do
|
90
|
+
subst = CSL::Style::Substitute.new()
|
91
|
+
subst << CSL::Style::Text.new( :value => 'Anonymous')
|
92
|
+
names = CSL::Style::Names.new( :variable => 'author')
|
93
|
+
names << subst
|
94
|
+
node << names
|
95
|
+
end
|
96
|
+
|
97
|
+
describe 'when the variable is set' do
|
98
|
+
before(:each) { item.data.author = 'Some Author' }
|
99
|
+
|
100
|
+
it 'returns the content of the nested node' do
|
101
|
+
expect(renderer.render_group(item, node)).to eq('Some Author')
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
|
+
describe 'when the variable is not set' do
|
106
|
+
it 'returns the substitution of the nested node' do
|
107
|
+
expect(renderer.render_group(item, node)).to eq('Anonymous')
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
end
|
86
112
|
end
|
87
113
|
end
|
88
114
|
end
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,29 +1,35 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: citeproc-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.6
|
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-03-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: citeproc
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 1.0.2
|
20
|
+
- - "<"
|
18
21
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
22
|
+
version: '2.0'
|
20
23
|
type: :runtime
|
21
24
|
prerelease: false
|
22
25
|
version_requirements: !ruby/object:Gem::Requirement
|
23
26
|
requirements:
|
24
|
-
- - "
|
27
|
+
- - ">="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: 1.0.2
|
30
|
+
- - "<"
|
25
31
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
32
|
+
version: '2.0'
|
27
33
|
- !ruby/object:Gem::Dependency
|
28
34
|
name: csl
|
29
35
|
requirement: !ruby/object:Gem::Requirement
|