bibtex-ruby 4.0.1 → 4.0.2

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: 2a027f55fbfc21baadb0ed5b95eb858ec0ab5cbc
4
- data.tar.gz: 891369c64cff100d3cfc2f5ed134b3484512ee93
3
+ metadata.gz: a428ad531c0d99dcd0b59768129faf638c07f353
4
+ data.tar.gz: 61aacb13595a21341a3e54700229baf2f237fecb
5
5
  SHA512:
6
- metadata.gz: 3ac72b61e9b34fb3777f4b1e41ece613461496d943c7989393b06944f166eff031f3c63e37add9c51080ab300ae52f7aa51d7ef95ef723fa0a5f4776b5e697d2
7
- data.tar.gz: 70d6e04c3e33d39a10cf6a9ecf9e8c056a7660c1db047ca81735821caabd3398829ca963e67fbba4aca7f6aa74fc333f03bef14a19ee6a31a138782133e1c8ae
6
+ metadata.gz: 6796f7a764624ed9895f6d99b72815610e21643f09f60b24b7c6f87ac0dff3f77918d3d8690eac67ddaac8d0846dd996f0769d92d75410162d6e284da94249b4
7
+ data.tar.gz: 87c7f23607942368211c3040678b121c42570cc77ae98c1d52d682ed96e29d67c44d4128e85ec38eb76ad633f8071613f69112b396921d3471bc1b2099f16397
data/History.txt CHANGED
@@ -3,6 +3,7 @@
3
3
 
4
4
  * BREAKING: Support type/key fields. Rename type -> bibtex_type
5
5
  and key -> bibtex_key in key-value exports.
6
+ * Add support for BibLaTeX date syntax
6
7
 
7
8
  3.1.6 / 2014-06-17
8
9
  ==================
data/lib/bibtex/entry.rb CHANGED
@@ -645,6 +645,13 @@ module BibTeX
645
645
 
646
646
  alias to_bibo to_rdf
647
647
 
648
+ def year
649
+ return fields[:year] if has_field?(:year)
650
+ return unless has_field?(:date)
651
+
652
+ fields[:date].to_s[/\d{4}/]
653
+ end
654
+
648
655
  private
649
656
 
650
657
  # Returns a default key for this entry.
@@ -653,7 +660,7 @@ module BibTeX
653
660
  k = k.respond_to?(:family) ? k.family : k.to_s
654
661
  k = BibTeX.transliterate(k).gsub(/["']/, '')
655
662
  k = k[/[A-Za-z-]+/] || 'unknown'
656
- k << (has_field?(:year) ? year : '-')
663
+ k << (year || '-')
657
664
  k << 'a'
658
665
  k.downcase!
659
666
  k
@@ -20,7 +20,7 @@ module BibTeX
20
20
  module Version
21
21
  MAJOR = 4
22
22
  MINOR = 0
23
- PATCH = 1
23
+ PATCH = 2
24
24
  BUILD = nil
25
25
 
26
26
  STRING = [MAJOR, MINOR, PATCH, BUILD].compact.join('.').freeze
@@ -530,6 +530,7 @@ module BibTeX
530
530
  @e1 = Entry.new(:bibtex_type => 'book', :author => 'Poe, Edgar A.', :title => 'The Raven', :editor => 'John Hopkins', :year => 1996)
531
531
  @e2 = Entry.new(:bibtex_type => 'book', :title => 'The Raven', :editor => 'John Hopkins', :year => 1996)
532
532
  @e3 = Entry.new(:bibtex_type => 'book', :author => 'Poe, Edgar A.', :title => 'The Raven', :editor => 'John Hopkins')
533
+ @e4 = Entry.new(:bibtex_type => 'book', :author => 'Poe, Edgar A.', :title => 'The Raven', :editor => 'John Hopkins', :date => '2003-09')
533
534
  }
534
535
 
535
536
  it 'should return "unknown-a" for an empty Entry' do
@@ -551,6 +552,10 @@ module BibTeX
551
552
  it 'skips the year if not present' do
552
553
  @e3.key.must_be :==, 'poe-a'
553
554
  end
555
+
556
+ it 'extracts the year from the date field if present' do
557
+ @e4.key.must_be :==, 'poe2003a'
558
+ end
554
559
  end
555
560
 
556
561
  describe 'when the entry is added to a Bibliography' 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.1
4
+ version: 4.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sylvester Keil