bibtex-ruby 4.0.10 → 4.0.11
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/lib/bibtex/entry.rb +6 -2
- data/lib/bibtex/version.rb +1 -1
- data/test/bibtex/test_entry.rb +14 -0
- data/test/test_bibtex.rb +20 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 76f5ebf60a508b2bc3ab7e389c3e0bb4652d71ac
|
4
|
+
data.tar.gz: 913081ea38244441ebba453b7aa9dfb8dcdf6cc8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0ee938d5a946519323900e97c735332dbdc84f556d54fe049f01397c69493d1b83eb11e6ec1e4b26509c0c8b01e69c3ce0f75837e621cf638ecfaca5ff2b06c2
|
7
|
+
data.tar.gz: 634d2c070ee0aa37d298f1dab46b19e38ec981d18531c0afe9542a30c43a007611980b632dad0bcddb7007114351e34ab0a973c170ae3ee1e631923f50c5b839
|
data/lib/bibtex/entry.rb
CHANGED
@@ -193,7 +193,11 @@ module BibTeX
|
|
193
193
|
end
|
194
194
|
|
195
195
|
def key
|
196
|
-
@key
|
196
|
+
if @key.nil? || @key.empty?
|
197
|
+
@key = default_key
|
198
|
+
else
|
199
|
+
@key
|
200
|
+
end
|
197
201
|
end
|
198
202
|
|
199
203
|
alias id key
|
@@ -345,7 +349,7 @@ module BibTeX
|
|
345
349
|
alias get []
|
346
350
|
|
347
351
|
def fetch(name, default = nil)
|
348
|
-
get(name) || block_given? ? yield(name) : default
|
352
|
+
get(name) || (block_given? ? yield(name) : default)
|
349
353
|
end
|
350
354
|
|
351
355
|
# Adds a new field (name-value pair) to the entry.
|
data/lib/bibtex/version.rb
CHANGED
data/test/bibtex/test_entry.rb
CHANGED
@@ -659,5 +659,19 @@ module BibTeX
|
|
659
659
|
refute @book.valid?
|
660
660
|
end
|
661
661
|
end
|
662
|
+
|
663
|
+
describe '#fetch' do
|
664
|
+
let(:pages){ '1--2' }
|
665
|
+
let(:entry){
|
666
|
+
e = Entry.new
|
667
|
+
e.add(:pages, pages)
|
668
|
+
}
|
669
|
+
|
670
|
+
describe '(:pages)' do
|
671
|
+
it 'should fetch pages' do
|
672
|
+
assert_equal(entry.fetch(:pages), pages)
|
673
|
+
end
|
674
|
+
end
|
675
|
+
end
|
662
676
|
end
|
663
677
|
end
|
data/test/test_bibtex.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'helper.rb'
|
2
|
+
require 'timeout'
|
2
3
|
|
3
4
|
module BibTeX
|
4
5
|
class TestBibtex < Minitest::Unit::TestCase
|
@@ -102,6 +103,25 @@ module BibTeX
|
|
102
103
|
BibTeX.log = logger
|
103
104
|
end
|
104
105
|
|
106
|
+
def test_missing_key
|
107
|
+
assert_raises(BibTeX::ParseError) do
|
108
|
+
BibTeX.parse(<<EOF)
|
109
|
+
@article{}
|
110
|
+
EOF
|
111
|
+
end
|
112
|
+
assert(
|
113
|
+
BibTeX.parse(<<EOF, allow_missing_keys: true)
|
114
|
+
@article{}
|
115
|
+
EOF
|
116
|
+
)
|
117
|
+
timeout(2) do
|
118
|
+
BibTeX.parse(<<EOF, allow_missing_keys: true)
|
119
|
+
@article{},
|
120
|
+
@article{}
|
121
|
+
EOF
|
122
|
+
end
|
123
|
+
end
|
124
|
+
|
105
125
|
end
|
106
126
|
|
107
127
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bibtex-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.0.
|
4
|
+
version: 4.0.11
|
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-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: latex-decode
|