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 +4 -4
- data/History.txt +2 -1
- data/lib/bibtex/value.rb +9 -2
- data/lib/bibtex/version.rb +1 -1
- data/test/bibtex/test_value.rb +10 -3
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0d64317001625640bf064c17d4887b6b928856de
|
4
|
+
data.tar.gz: 50cb45e9195303203aebc75d80e47cd854faef6b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 022b85f39d311a2eeae7f4e442ab01f221b8f80f6b8db30802626022850772c8f22da68c9bba7120f51b01c23864b82a826681ef26d57409e8098d57f0655674
|
7
|
+
data.tar.gz: c0ee691a2a1d7ad70f6e05f5e1a998aad491c8b959287d0a09841fe7aa53d133829732c9cb66ee59e717d43d6a8681cf0da66d5e7d5716d08b9276d6463556be
|
data/History.txt
CHANGED
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
|
-
|
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
|
-
|
241
|
+
atomic? && tokens[0] =~ /^\s*[+-]?\d+[\/\.]?\d*\s*$/
|
235
242
|
end
|
236
243
|
|
237
244
|
def to_citeproc (options = {})
|
data/lib/bibtex/version.rb
CHANGED
data/test/bibtex/test_value.rb
CHANGED
@@ -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
|