bibtex-ruby 4.0.7 → 4.0.8

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of bibtex-ruby might be problematic. Click here for more details.

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c7a917862a039a5641b35b371a597ebea9141d47
4
- data.tar.gz: 2a30a1a920629248546abd01669efe45444fc432
3
+ metadata.gz: 0d64317001625640bf064c17d4887b6b928856de
4
+ data.tar.gz: 50cb45e9195303203aebc75d80e47cd854faef6b
5
5
  SHA512:
6
- metadata.gz: a489427d5cd6f669fc5d6786645eb0aa35bd7623ee43feab48e23ccc74e1654339e7fe99d77ff585612de64ee5eb8de99d406d8acdde5a78cf6342dd67325ddb
7
- data.tar.gz: d808da11cc305ce4ba79f48de8fe7ddf5e66d5164fc6b34cf07b6f7c0ce848bca0cdfeade47e70db7102ed38de84500bbf88655cf61675110ff86296bb81fff9
6
+ metadata.gz: 022b85f39d311a2eeae7f4e442ab01f221b8f80f6b8db30802626022850772c8f22da68c9bba7120f51b01c23864b82a826681ef26d57409e8098d57f0655674
7
+ data.tar.gz: c0ee691a2a1d7ad70f6e05f5e1a998aad491c8b959287d0a09841fe7aa53d133829732c9cb66ee59e717d43d6a8681cf0da66d5e7d5716d08b9276d6463556be
data/History.txt CHANGED
@@ -1,7 +1,8 @@
1
- 4.0.7 / 2015-01-12
1
+ 4.0.8 / 2015-01-12
2
2
  ==================
3
3
  * Ruby 2.2 support
4
4
  * Added Entry#month_numeric
5
+ * Added support for numeric values
5
6
 
6
7
  4.0.4 / 2014-10-10
7
8
  ==================
data/lib/bibtex/value.rb CHANGED
@@ -191,7 +191,14 @@ module BibTeX
191
191
  # joined by a '#', additionally, all string tokens will be turned into
192
192
  # string literals (i.e., delimitted by quotes).
193
193
  def value
194
- atomic? ? @tokens[0] : @tokens.map { |v| v.is_a?(::String) ? v.inspect : v }.join(' # ')
194
+ case
195
+ when numeric?
196
+ @tokens[0].to_i
197
+ when atomic?
198
+ @tokens[0]
199
+ else
200
+ @tokens.map { |v| v.is_a?(::String) ? v.inspect : v }.join(' # ')
201
+ end
195
202
  end
196
203
 
197
204
  alias :v :value
@@ -231,7 +238,7 @@ module BibTeX
231
238
 
232
239
  # Returns true if the Value's content is numeric.
233
240
  def numeric?
234
- to_s =~ /^\s*[+-]?\d+[\/\.]?\d*\s*$/
241
+ atomic? && tokens[0] =~ /^\s*[+-]?\d+[\/\.]?\d*\s*$/
235
242
  end
236
243
 
237
244
  def to_citeproc (options = {})
@@ -20,7 +20,7 @@ module BibTeX
20
20
  module Version
21
21
  MAJOR = 4
22
22
  MINOR = 0
23
- PATCH = 7
23
+ PATCH = 8
24
24
  BUILD = nil
25
25
 
26
26
  STRING = [MAJOR, MINOR, PATCH, BUILD].compact.join('.').freeze
@@ -98,13 +98,13 @@ module BibTeX
98
98
  value.is_a?(::String) ? value.upcase : value
99
99
  end
100
100
  end
101
-
101
+
102
102
  class SuffixA < BibTeX::Filter
103
103
  def apply(value)
104
104
  value.is_a?(::String) ? "#{value}a" : value
105
105
  end
106
106
  end
107
-
107
+
108
108
  @values = [Value.new('foo'), Value.new('foo', :bar)]
109
109
  end
110
110
 
@@ -141,7 +141,7 @@ module BibTeX
141
141
  @values.each { |v| v.convert_upcase }
142
142
  assert_equal ['foo', '"foo" # bar'], @values.map(&:to_s)
143
143
  end
144
-
144
+
145
145
  it "raises argument error when a filter cannot be resolved" do
146
146
  assert_raises ArgumentError do
147
147
  @values[0].convert(:foo)
@@ -167,7 +167,14 @@ module BibTeX
167
167
  @values.each { |v| v.convert_upcase! }
168
168
  assert_equal ['FOO', '"FOO" # bar'], @values.map(&:to_s)
169
169
  end
170
+ end
170
171
 
172
+ describe "value" do
173
+ it 'returns numbers as numbers' do
174
+ assert Value.new('42').v.is_a?(::Fixnum)
175
+ assert Value.new('-42').v.is_a?(::Fixnum)
176
+ assert Value.new('a42').v.is_a?(::String)
177
+ end
171
178
  end
172
179
 
173
180
  describe "#to_s" do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bibtex-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.0.7
4
+ version: 4.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sylvester Keil