bibtex-ruby 3.1.6 → 4.0.0
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.
Potentially problematic release.
This version of bibtex-ruby might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/History.txt +6 -0
- data/features/issues/non_ascii_default_keys.feature +3 -3
- data/lib/bibtex/bibtex.y +2 -2
- data/lib/bibtex/entry.rb +4 -4
- data/lib/bibtex/entry/citeproc_converter.rb +2 -1
- data/lib/bibtex/name_parser.rb +2 -2
- data/lib/bibtex/parser.rb +3 -3
- data/lib/bibtex/version.rb +3 -3
- data/test/bibtex/test_elements.rb +3 -3
- data/test/bibtex/test_entry.rb +12 -12
- data/test/test_bibtex.rb +1 -1
- data/test/test_export.rb +2 -2
- 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: ed46f17c426f678a6782c0e226710d4508edc484
|
4
|
+
data.tar.gz: d70e405f4c1f9783cf3a2a8c515837eab7a7d3b9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 24999b5c3f94cd6de3fc4dfc773399421829cac09189cbd5ae2599fa8c99ae195dfb8087a892582117b63b41ed46c782d2ecb925ece19de56b7fea98bc5bada9
|
7
|
+
data.tar.gz: b867a6b26356e16d650257edf0f27d770f19406729728376ed6ac58bdffdd1637c8fac9292c6623e0efe930f9bc2319b857db5707950aa31c6d361792a961273
|
data/History.txt
CHANGED
@@ -8,7 +8,7 @@ Feature: Parse BibTeX files and convert LaTeX to Unicode
|
|
8
8
|
When I create an entry with these elements:
|
9
9
|
| type | author | title | location | year |
|
10
10
|
| book | Christian Müller | Title | Berlin | 2013 |
|
11
|
-
Then my bibliography should contain an entry with a key like "
|
11
|
+
Then my bibliography should contain an entry with a key like "m(u|ue)?ller2013a"
|
12
12
|
|
13
13
|
@default_keys
|
14
14
|
Scenario: Multiple entries with an author whose name contains non-ASCII characters
|
@@ -16,5 +16,5 @@ Feature: Parse BibTeX files and convert LaTeX to Unicode
|
|
16
16
|
| type | author | title | location | year |
|
17
17
|
| book | Christian Müller | First Title | Berlin | 2013 |
|
18
18
|
| book | Christian Müller | Second Title | Berlin | 2013 |
|
19
|
-
Then my bibliography should contain an entry with a key like "
|
20
|
-
And my bibliography should contain an entry with a key like "
|
19
|
+
Then my bibliography should contain an entry with a key like "m(ue?)?ller2013a"
|
20
|
+
And my bibliography should contain an entry with a key like "m(ue?)?ller2013b"
|
data/lib/bibtex/bibtex.y
CHANGED
@@ -67,7 +67,7 @@ rule
|
|
67
67
|
| entry_head assignments COMMA RBRACE { result = val[0] << val[1] }
|
68
68
|
| entry_head RBRACE { result = val[0] }
|
69
69
|
|
70
|
-
entry_head : NAME LBRACE opt_key { result = BibTeX::Entry.new(:
|
70
|
+
entry_head : NAME LBRACE opt_key { result = BibTeX::Entry.new(:bibtex_type => val[0].downcase.to_sym, :bibtex_key => val[2]) }
|
71
71
|
|
72
72
|
opt_key : { missing_key }
|
73
73
|
| KEY
|
@@ -138,4 +138,4 @@ require 'bibtex/lexer'
|
|
138
138
|
raise ParseError, message
|
139
139
|
end
|
140
140
|
|
141
|
-
# -*- racc -*-
|
141
|
+
# -*- racc -*-
|
data/lib/bibtex/entry.rb
CHANGED
@@ -73,8 +73,8 @@ module BibTeX
|
|
73
73
|
def initialize(attributes = {})
|
74
74
|
@fields = {}
|
75
75
|
|
76
|
-
self.type = attributes.delete(:
|
77
|
-
self.key = attributes.delete(:
|
76
|
+
self.type = attributes.delete(:bibtex_type) if attributes.has_key?(:bibtex_type)
|
77
|
+
self.key = attributes.delete(:bibtex_key) if attributes.has_key?(:bibtex_key)
|
78
78
|
|
79
79
|
add(attributes)
|
80
80
|
|
@@ -621,7 +621,7 @@ module BibTeX
|
|
621
621
|
|
622
622
|
def to_hash(options = {})
|
623
623
|
options[:quotes] ||= %w({ })
|
624
|
-
hash = { :
|
624
|
+
hash = { :bibtex_key => key, :bibtex_type => type }
|
625
625
|
each_pair { |k,v| hash[k] = v.to_s(options) }
|
626
626
|
hash
|
627
627
|
end
|
@@ -651,7 +651,7 @@ module BibTeX
|
|
651
651
|
def default_key
|
652
652
|
k = names[0]
|
653
653
|
k = k.respond_to?(:family) ? k.family : k.to_s
|
654
|
-
k = BibTeX.transliterate(k)
|
654
|
+
k = BibTeX.transliterate(k).gsub(/["']/, '')
|
655
655
|
k = k[/[A-Za-z-]+/] || 'unknown'
|
656
656
|
k << (has_field?(:year) ? year : '-')
|
657
657
|
k << 'a'
|
@@ -16,6 +16,7 @@ class BibTeX::Entry::CiteProcConverter
|
|
16
16
|
institution publisher
|
17
17
|
organization publisher
|
18
18
|
howpublished publisher
|
19
|
+
type genre
|
19
20
|
}.map(&:intern)]).freeze
|
20
21
|
|
21
22
|
CSL_FIELDS = %w{
|
@@ -71,7 +72,7 @@ class BibTeX::Entry::CiteProcConverter
|
|
71
72
|
end
|
72
73
|
end
|
73
74
|
|
74
|
-
methods = self.class.instance_methods(false) - [:convert
|
75
|
+
methods = self.class.instance_methods(false) - [:convert!, :hash]
|
75
76
|
methods.each { |m| send(m) }
|
76
77
|
|
77
78
|
hash
|
data/lib/bibtex/name_parser.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
#
|
2
2
|
# DO NOT MODIFY!!!!
|
3
|
-
# This file is automatically generated by Racc 1.4.
|
3
|
+
# This file is automatically generated by Racc 1.4.11
|
4
4
|
# from Racc grammer file "".
|
5
5
|
#
|
6
6
|
|
@@ -444,4 +444,4 @@ def _reduce_none(val, _values, result)
|
|
444
444
|
end
|
445
445
|
|
446
446
|
end # class NameParser
|
447
|
-
end # module BibTeX
|
447
|
+
end # module BibTeX
|
data/lib/bibtex/parser.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
#
|
2
2
|
# DO NOT MODIFY!!!!
|
3
|
-
# This file is automatically generated by Racc 1.4.
|
3
|
+
# This file is automatically generated by Racc 1.4.11
|
4
4
|
# from Racc grammer file "".
|
5
5
|
#
|
6
6
|
|
@@ -417,7 +417,7 @@ module_eval(<<'.,.,', 'bibtex.y', 67)
|
|
417
417
|
|
418
418
|
module_eval(<<'.,.,', 'bibtex.y', 69)
|
419
419
|
def _reduce_26(val, _values, result)
|
420
|
-
result = BibTeX::Entry.new(:
|
420
|
+
result = BibTeX::Entry.new(:bibtex_type => val[0].downcase.to_sym, :bibtex_key => val[2])
|
421
421
|
result
|
422
422
|
end
|
423
423
|
.,.,
|
@@ -471,4 +471,4 @@ def _reduce_none(val, _values, result)
|
|
471
471
|
end
|
472
472
|
|
473
473
|
end # class Parser
|
474
|
-
end # module BibTeX
|
474
|
+
end # module BibTeX
|
data/lib/bibtex/version.rb
CHANGED
@@ -15,11 +15,11 @@ module BibTeX
|
|
15
15
|
end
|
16
16
|
|
17
17
|
it 'accepts a Hash and returns an Entry' do
|
18
|
-
Element.parse({ :
|
18
|
+
Element.parse({ :bibtex_type => :book })[0].type.must_be :==, :book
|
19
19
|
end
|
20
20
|
|
21
21
|
it 'accepts an array of hashes' do
|
22
|
-
Element.parse([{ :
|
22
|
+
Element.parse([{ :bibtex_type => :book }, { :bibtex_type => :misc }])[1].type.must_be :==, :misc
|
23
23
|
end
|
24
24
|
|
25
25
|
end
|
@@ -61,4 +61,4 @@ module BibTeX
|
|
61
61
|
|
62
62
|
end
|
63
63
|
|
64
|
-
end
|
64
|
+
end
|
data/test/bibtex/test_entry.rb
CHANGED
@@ -216,12 +216,12 @@ module BibTeX
|
|
216
216
|
end
|
217
217
|
|
218
218
|
it 'includes type and all defined fields' do
|
219
|
-
assert_equal 'book', Entry.new(:
|
220
|
-
assert_equal 'book|title:foo', Entry.new(:
|
219
|
+
assert_equal 'book', Entry.new(:bibtex_type => 'book').digest
|
220
|
+
assert_equal 'book|title:foo', Entry.new(:bibtex_type => 'book', :title => 'foo').digest
|
221
221
|
end
|
222
222
|
|
223
223
|
it 'accepts a filter' do
|
224
|
-
assert_equal 'book|year:2012', Entry.new(:
|
224
|
+
assert_equal 'book|year:2012', Entry.new(:bibtex_type => 'book', :title => 'foo', :year => 2012).digest([:year])
|
225
225
|
end
|
226
226
|
end
|
227
227
|
|
@@ -468,8 +468,8 @@ module BibTeX
|
|
468
468
|
|
469
469
|
def test_creation_from_hash
|
470
470
|
entry = BibTeX::Entry.new({
|
471
|
-
:
|
472
|
-
:
|
471
|
+
:bibtex_type => 'book',
|
472
|
+
:bibtex_key => :raven,
|
473
473
|
:author => 'Poe, Edgar A.',
|
474
474
|
:title => 'The Raven'
|
475
475
|
})
|
@@ -496,10 +496,10 @@ module BibTeX
|
|
496
496
|
|
497
497
|
def test_sorting
|
498
498
|
entries = []
|
499
|
-
entries << Entry.new({ :
|
500
|
-
entries << Entry.new({ :
|
501
|
-
entries << Entry.new({ :
|
502
|
-
entries << Entry.new({ :
|
499
|
+
entries << Entry.new({ :bibtex_type => 'book', :bibtex_key => 'raven3', :author => 'Poe, Edgar A.', :title => 'The Raven'})
|
500
|
+
entries << Entry.new({ :bibtex_type => 'book', :bibtex_key => 'raven2', :author => 'Poe, Edgar A.', :title => 'The Raven'})
|
501
|
+
entries << Entry.new({ :bibtex_type => 'book', :bibtex_key => 'raven1', :author => 'Poe, Edgar A.', :title => 'The Raven'})
|
502
|
+
entries << Entry.new({ :bibtex_type => 'book', :bibtex_key => 'raven1', :author => 'Poe, Edgar A.', :title => 'The Aven'})
|
503
503
|
|
504
504
|
entries.sort!
|
505
505
|
|
@@ -510,9 +510,9 @@ module BibTeX
|
|
510
510
|
|
511
511
|
describe 'default keys' do
|
512
512
|
before {
|
513
|
-
@e1 = Entry.new(:
|
514
|
-
@e2 = Entry.new(:
|
515
|
-
@e3 = Entry.new(:
|
513
|
+
@e1 = Entry.new(:bibtex_type => 'book', :author => 'Poe, Edgar A.', :title => 'The Raven', :editor => 'John Hopkins', :year => 1996)
|
514
|
+
@e2 = Entry.new(:bibtex_type => 'book', :title => 'The Raven', :editor => 'John Hopkins', :year => 1996)
|
515
|
+
@e3 = Entry.new(:bibtex_type => 'book', :author => 'Poe, Edgar A.', :title => 'The Raven', :editor => 'John Hopkins')
|
516
516
|
}
|
517
517
|
|
518
518
|
it 'should return "unknown-a" for an empty Entry' do
|
data/test/test_bibtex.rb
CHANGED
@@ -59,7 +59,7 @@ module BibTeX
|
|
59
59
|
# file = File.read(Test.fixtures(:roundtrip))
|
60
60
|
# bib = BibTeX::Bibliography.new
|
61
61
|
# bib << BibTeX::Entry.new({
|
62
|
-
# :
|
62
|
+
# :bibtex_type => :book,
|
63
63
|
# :key => 'rails',
|
64
64
|
# :address => 'Raleigh, North Carolina',
|
65
65
|
# :author => 'Ruby, Sam and Thomas, Dave and Hansson Heinemeier, David',
|
data/test/test_export.rb
CHANGED
@@ -16,7 +16,7 @@ module BibTeX
|
|
16
16
|
yaml = YAML.load(bib.to_yaml)
|
17
17
|
refute_nil(yaml)
|
18
18
|
assert_equal(3, yaml.length)
|
19
|
-
assert_equal(%w[ dragon pickaxe rails], yaml.map { |y| y[:
|
19
|
+
assert_equal(%w[ dragon pickaxe rails], yaml.map { |y| y[:bibtex_key] }.sort)
|
20
20
|
assert_equal('{The Facets of Ruby}', yaml[0][:series])
|
21
21
|
end
|
22
22
|
|
@@ -25,7 +25,7 @@ module BibTeX
|
|
25
25
|
json = JSON.parse(bib.to_json)
|
26
26
|
refute_nil(json)
|
27
27
|
assert_equal(3, json.length)
|
28
|
-
assert_equal(%w[ dragon pickaxe rails], json.map { |y| y['
|
28
|
+
assert_equal(%w[ dragon pickaxe rails], json.map { |y| y['bibtex_key'] }.sort)
|
29
29
|
assert_equal('{The Facets of Ruby}', json[0]['series'])
|
30
30
|
end
|
31
31
|
|
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
|
+
version: 4.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sylvester Keil
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-07-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: latex-decode
|