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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e4e81b938c5b2d7ee24c8f40614cc712a2816595
4
- data.tar.gz: d1b0fa4a3efa5c4f0a90083babd3ccc708dd9c73
3
+ metadata.gz: 61a47839dcb7a73c69ebd1e7ec7fadd7996c014d
4
+ data.tar.gz: 4ea72fbdc878a1bd5217680d62f0233f7db49319
5
5
  SHA512:
6
- metadata.gz: 27e961fe5c47fc447ff13ede27936e4723a6ebb6cc7ba863ab1275e72c34afe54d6cc897c99d504efcc545258ded89fcd9cf4821aee7aeeecb015e14743eec05
7
- data.tar.gz: 17c41ba68777d182e88e4e65664401ed53c47b31107e561fb5a7ec606ad1666e73de11bc2172aabf6f2f3c879eeaa0d3c3655262713350e78a58f3cd3c1d51fc
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
- gem 'debugger', :require => false, :platforms => :mri_19
24
+
19
25
  gem 'rubinius-debugger', :require => false, :platforms => :rbx
20
26
  gem 'rubinius-compiler', :require => false, :platforms => :rbx
21
27
  end
@@ -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 |
@@ -12,8 +12,10 @@ begin
12
12
  Debugger.start
13
13
  when defined?(RUBY_ENGINE) && RUBY_ENGINE == 'rbx'
14
14
  require 'rubinius/debugger'
15
- else
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
@@ -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: first, last word; followed by colon
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
@@ -1,8 +1,8 @@
1
1
  module CiteProc
2
2
  module Ruby
3
-
3
+
4
4
  class Renderer
5
-
5
+
6
6
  private
7
7
 
8
8
  # @param item [CiteProc::CitationItem]
@@ -13,8 +13,8 @@ module CiteProc
13
13
  render item, child
14
14
  }.join('')
15
15
  end
16
-
16
+
17
17
  end
18
-
18
+
19
19
  end
20
20
  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
 
@@ -25,7 +25,9 @@ module CiteProc
25
25
  end
26
26
 
27
27
  def skip?
28
- !history.empty? && history.values.all?(&:nil?)
28
+ !history.empty? && history.values.all? { |v|
29
+ v.nil? || v.respond_to?(:empty?) && v.empty?
30
+ }
29
31
  end
30
32
 
31
33
  def accessed
@@ -1,5 +1,5 @@
1
1
  module CiteProc
2
2
  module Ruby
3
- VERSION = '1.0.5'
3
+ VERSION = '1.0.6'
4
4
  end
5
5
  end
@@ -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("This IS a pen that is a smith pencil", node)).to eq('This IS a Pen That Is a Smith Pencil')
110
- #format.apply('of mice and men', node).should == 'Of Mice And Men'
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
@@ -21,8 +21,10 @@ begin
21
21
  # Debugger.start
22
22
  when defined?(RUBY_ENGINE) && RUBY_ENGINE == 'rbx'
23
23
  require 'rubinius/debugger'
24
- else
24
+ when RUBY_VERSION < '2.0'
25
25
  require 'debugger'
26
+ else
27
+ require 'byebug'
26
28
  end
27
29
  rescue LoadError
28
30
  # ignore
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.5
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-01-12 00:00:00.000000000 Z
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: '1.0'
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: '1.0'
32
+ version: '2.0'
27
33
  - !ruby/object:Gem::Dependency
28
34
  name: csl
29
35
  requirement: !ruby/object:Gem::Requirement