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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: bd0b7ed6fae8b54fe92038e224573b83cc8c1457
4
- data.tar.gz: 307152a43c8441177761785ff7c111da8dc1264a
3
+ metadata.gz: 76f5ebf60a508b2bc3ab7e389c3e0bb4652d71ac
4
+ data.tar.gz: 913081ea38244441ebba453b7aa9dfb8dcdf6cc8
5
5
  SHA512:
6
- metadata.gz: a2a9dad80be0fb13d3df9aa82a7a450ed368700e5d8c9e67201f07cd2c094d7fecc2125df34253a6ce4cd57a5189ccc25be8649f74b7747112c4eb8aceace979
7
- data.tar.gz: e39ab150cc93ccd7be0b498d73cc0e1097f53f3378faab7b04dd6a13ffe0d557cdd649a0c590518c0c26e58bccec3bc2634a756f08494659da4dfca600970165
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 ||= default_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.
@@ -20,7 +20,7 @@ module BibTeX
20
20
  module Version
21
21
  MAJOR = 4
22
22
  MINOR = 0
23
- PATCH = 10
23
+ PATCH = 11
24
24
  BUILD = nil
25
25
 
26
26
  STRING = [MAJOR, MINOR, PATCH, BUILD].compact.join('.').freeze
@@ -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.10
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-01-23 00:00:00.000000000 Z
11
+ date: 2015-03-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: latex-decode