bibtex-ruby 4.0.1 → 4.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/History.txt +1 -0
- data/lib/bibtex/entry.rb +8 -1
- data/lib/bibtex/version.rb +1 -1
- data/test/bibtex/test_entry.rb +5 -0
- 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: a428ad531c0d99dcd0b59768129faf638c07f353
|
|
4
|
+
data.tar.gz: 61aacb13595a21341a3e54700229baf2f237fecb
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 6796f7a764624ed9895f6d99b72815610e21643f09f60b24b7c6f87ac0dff3f77918d3d8690eac67ddaac8d0846dd996f0769d92d75410162d6e284da94249b4
|
|
7
|
+
data.tar.gz: 87c7f23607942368211c3040678b121c42570cc77ae98c1d52d682ed96e29d67c44d4128e85ec38eb76ad633f8071613f69112b396921d3471bc1b2099f16397
|
data/History.txt
CHANGED
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 << (
|
|
663
|
+
k << (year || '-')
|
|
657
664
|
k << 'a'
|
|
658
665
|
k.downcase!
|
|
659
666
|
k
|
data/lib/bibtex/version.rb
CHANGED
data/test/bibtex/test_entry.rb
CHANGED
|
@@ -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
|