bibtex-ruby 6.1.0 → 6.2.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.
- checksums.yaml +4 -4
- data/Gemfile +0 -6
- data/Rakefile +1 -1
- data/bibtex-ruby.gemspec +1 -0
- data/lib/bibtex/compatibility.rb +6 -20
- data/lib/bibtex/entry/rdf_converter.rb +0 -8
- data/lib/bibtex/entry.rb +2 -3
- data/lib/bibtex/lexer.rb +1 -1
- data/lib/bibtex/version.rb +1 -1
- data/lib/bibtex.rb +2 -0
- data/test/bibtex/test_lexer.rb +23 -9
- data/test/bibtex/test_utilities.rb +1 -1
- data/test/test_bibtex.rb +7 -11
- metadata +17 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 333784b37e105aee5f6f28e49793bd6cb4d969da35f34577007a48d496de7f5d
|
4
|
+
data.tar.gz: c2d544d145cfd202c099246ce91432746c535e49b38df9436adf043d4353e937
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fa8ff3fe9544b77d3c0de73e82ae1ff95f7708f0d63fa81b6e0a99e536170b550a275bb5321048463d4e301a31d467657b2f80876bc50e380498299fc0a99a2e
|
7
|
+
data.tar.gz: 4e08f81624ebec89855ad80b3cc7f5d1b7a40ca9bc64dcec44d8c091a3e38d4a93e9b0c8733954a8ff910c87ecda01d1f6e84e287dbf7f46afb75eae2ea0339f
|
data/Gemfile
CHANGED
@@ -15,11 +15,6 @@ end
|
|
15
15
|
group :test do
|
16
16
|
gem 'cucumber'
|
17
17
|
gem 'minitest', require: false
|
18
|
-
gem 'unicode', '~>0.4', platforms: %i[mswin mingw mri]
|
19
|
-
end
|
20
|
-
|
21
|
-
group :extra do
|
22
|
-
gem 'redcarpet', platforms: [:ruby]
|
23
18
|
end
|
24
19
|
|
25
20
|
group :profile do
|
@@ -32,7 +27,6 @@ group :coverage do
|
|
32
27
|
end
|
33
28
|
|
34
29
|
group :development do
|
35
|
-
gem 'iconv', platforms: [:ruby]
|
36
30
|
gem 'rake'
|
37
31
|
gem 'yard'
|
38
32
|
end
|
data/Rakefile
CHANGED
data/bibtex-ruby.gemspec
CHANGED
@@ -27,6 +27,7 @@ Gem::Specification.new do |s|
|
|
27
27
|
|
28
28
|
s.add_runtime_dependency('racc', ['~>1.7'])
|
29
29
|
s.add_runtime_dependency('latex-decode', ['~>0.0'])
|
30
|
+
s.add_runtime_dependency('logger', ['~>1.7'])
|
30
31
|
|
31
32
|
s.files = File.open('Manifest').readlines.map(&:chomp)
|
32
33
|
s.test_files = Dir.glob('test/**/test*.rb')
|
data/lib/bibtex/compatibility.rb
CHANGED
@@ -1,23 +1,9 @@
|
|
1
1
|
module BibTeX
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
@iconv = Iconv.new('ascii//translit//ignore', 'utf-8')
|
9
|
-
|
10
|
-
def self.transliterate(str)
|
11
|
-
@iconv.iconv(str)
|
12
|
-
end
|
13
|
-
rescue LoadError
|
14
|
-
@iconv_replacements = Hash['ä', 'ae', 'ö', 'oe', 'ü', 'ue', 'Ä', 'Ae', 'Ö', 'Oe', 'Ü', 'Ue', 'ß', 'ss']
|
15
|
-
|
16
|
-
# Returns +str+ transliterated containing only ASCII characters.
|
17
|
-
def self.transliterate(str)
|
18
|
-
str.gsub(/[äöüÄÖÜß]/, @iconv_replacements)
|
19
|
-
end
|
20
|
-
ensure
|
21
|
-
$VERBOSE = original_verbosity
|
2
|
+
def self.transliterate(str)
|
3
|
+
str
|
4
|
+
.unicode_normalize(:nfkd)
|
5
|
+
.encode(Encoding::ASCII, invalid: :replace, undef: :replace, replace: '')
|
6
|
+
rescue
|
7
|
+
str.gsub(/[^\x20-\x7E]/, '')
|
22
8
|
end
|
23
9
|
end
|
data/lib/bibtex/entry.rb
CHANGED
@@ -676,12 +676,11 @@ module BibTeX
|
|
676
676
|
def default_key
|
677
677
|
k = names[0]
|
678
678
|
k = k.respond_to?(:family) ? k.family : k.to_s
|
679
|
-
k = BibTeX.transliterate(k).
|
679
|
+
k = BibTeX.transliterate(k).tr('"\'', '')
|
680
680
|
k = k[/[A-Za-z-]+/] || 'unknown'
|
681
681
|
k << (year.to_s[/\d+/] || '-')
|
682
682
|
k << 'a'
|
683
|
-
k.downcase
|
684
|
-
k
|
683
|
+
k.downcase
|
685
684
|
end
|
686
685
|
end
|
687
686
|
end
|
data/lib/bibtex/lexer.rb
CHANGED
@@ -58,7 +58,7 @@ module BibTeX
|
|
58
58
|
string: /string/io,
|
59
59
|
comment: /comment\b/io,
|
60
60
|
preamble: /preamble\b/io,
|
61
|
-
key: %r{\s*[[:alpha:][:digit:] /:_!$\?\.%+;&\*'"-]+,}io,
|
61
|
+
key: %r{\s*[[:alpha:][:digit:] /:_!$\?\.%+;&\*'"{}-]+,}io,
|
62
62
|
optional_key: %r{\s*[[:alpha:][:digit:] /:_!$\?\.%+;&\*'"-]*,}io
|
63
63
|
}
|
64
64
|
|
data/lib/bibtex/version.rb
CHANGED
data/lib/bibtex.rb
CHANGED
data/test/bibtex/test_lexer.rb
CHANGED
@@ -7,33 +7,47 @@ module BibTeX
|
|
7
7
|
end
|
8
8
|
|
9
9
|
it 'strips line breaks by default' do
|
10
|
-
Lexer.new.analyse(%(@string{ x = "foo\nbar" })).stack[-3]
|
11
|
-
|
10
|
+
assert_equal Lexer.new.analyse(%(@string{ x = "foo\nbar" })).stack[-3],
|
11
|
+
[:STRING_LITERAL, 'foo bar']
|
12
12
|
end
|
13
13
|
|
14
14
|
it 'strips whitespace after line breaks by default' do
|
15
|
-
Lexer.new.analyse(%(@string{ x = "foo\n bar" })).stack[-3]
|
16
|
-
|
15
|
+
assert_equal Lexer.new.analyse(%(@string{ x = "foo\n bar" })).stack[-3],
|
16
|
+
[:STRING_LITERAL, 'foo bar']
|
17
17
|
end
|
18
18
|
|
19
19
|
it 'matches KEY tokens' do
|
20
|
-
Lexer.new.analyse('@misc{foo, }').symbols
|
20
|
+
assert_equal Lexer.new.analyse('@misc{foo, }').symbols,
|
21
|
+
[:AT, :NAME, :LBRACE, :KEY, :RBRACE, false]
|
21
22
|
end
|
22
23
|
|
23
24
|
it 'matches KEY tokens with non-ascii characters' do
|
24
|
-
Lexer.new.analyse('@misc{löwe, }').symbols
|
25
|
+
assert_equal Lexer.new.analyse('@misc{löwe, }').symbols,
|
26
|
+
[:AT, :NAME, :LBRACE, :KEY, :RBRACE, false]
|
25
27
|
end
|
26
28
|
|
27
29
|
it 'matches KEY tokens after whitespace' do
|
28
|
-
Lexer.new.analyse('@misc{ foo, }').symbols
|
30
|
+
assert_equal Lexer.new.analyse('@misc{ foo, }').symbols,
|
31
|
+
[:AT, :NAME, :LBRACE, :KEY, :RBRACE, false]
|
32
|
+
end
|
33
|
+
|
34
|
+
it 'matches KEY token with braces' do
|
35
|
+
assert_equal Lexer.new.analyse('@misc{fo{o, }').symbols,
|
36
|
+
[:AT, :NAME, :LBRACE, :KEY, :RBRACE, false]
|
37
|
+
assert_equal Lexer.new.analyse('@misc{fo}o, }').symbols,
|
38
|
+
[:AT, :NAME, :LBRACE, :KEY, :RBRACE, false]
|
39
|
+
assert_equal Lexer.new.analyse('@misc{foo:{bar}, }').symbols,
|
40
|
+
[:AT, :NAME, :LBRACE, :KEY, :RBRACE, false]
|
29
41
|
end
|
30
42
|
|
31
43
|
it "doesn't start a comment for types starting with but not equal @comment" do
|
32
|
-
Lexer.new.analyse('@commentary{staudinger, }').symbols
|
44
|
+
assert_equal Lexer.new.analyse('@commentary{staudinger, }').symbols,
|
45
|
+
[:AT, :NAME, :LBRACE, :KEY, :RBRACE, false]
|
33
46
|
end
|
34
47
|
|
35
48
|
it "doesn't start a preamble for types starting with but not equal @preamble" do
|
36
|
-
Lexer.new.analyse('@preamblestring{ preamble }').symbols
|
49
|
+
assert_equal Lexer.new.analyse('@preamblestring{ preamble }').symbols,
|
50
|
+
[:AT, :NAME, :LBRACE, :NAME, :RBRACE, false]
|
37
51
|
end
|
38
52
|
end
|
39
53
|
end
|
data/test/test_bibtex.rb
CHANGED
@@ -102,21 +102,17 @@ module BibTeX
|
|
102
102
|
|
103
103
|
def test_missing_key
|
104
104
|
assert_raises(BibTeX::ParseError) do
|
105
|
-
BibTeX.parse(
|
106
|
-
|
107
|
-
EOF
|
105
|
+
BibTeX.parse(<<-EOF)
|
106
|
+
@article{}
|
107
|
+
EOF
|
108
108
|
end
|
109
|
-
|
110
|
-
BibTeX.parse(<<EOF, allow_missing_keys: true)
|
109
|
+
refute_empty BibTeX.parse(<<-EOF, allow_missing_keys: true)
|
111
110
|
@article{}
|
112
|
-
EOF
|
113
|
-
)
|
114
|
-
Timeout.timeout(2) do
|
115
|
-
BibTeX.parse(<<EOF, allow_missing_keys: true)
|
111
|
+
EOF
|
112
|
+
refute_empty BibTeX.parse(<<-EOF, allow_missing_keys: true)
|
116
113
|
@article{},
|
117
114
|
@article{}
|
118
|
-
EOF
|
119
|
-
end
|
115
|
+
EOF
|
120
116
|
end
|
121
117
|
end
|
122
118
|
end
|
metadata
CHANGED
@@ -1,14 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bibtex-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 6.
|
4
|
+
version: 6.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sylvester Keil
|
8
|
-
autorequire:
|
9
8
|
bindir: bin
|
10
9
|
cert_chain: []
|
11
|
-
date:
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
12
11
|
dependencies:
|
13
12
|
- !ruby/object:Gem::Dependency
|
14
13
|
name: racc
|
@@ -38,6 +37,20 @@ dependencies:
|
|
38
37
|
- - "~>"
|
39
38
|
- !ruby/object:Gem::Version
|
40
39
|
version: '0.0'
|
40
|
+
- !ruby/object:Gem::Dependency
|
41
|
+
name: logger
|
42
|
+
requirement: !ruby/object:Gem::Requirement
|
43
|
+
requirements:
|
44
|
+
- - "~>"
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: '1.7'
|
47
|
+
type: :runtime
|
48
|
+
prerelease: false
|
49
|
+
version_requirements: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - "~>"
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '1.7'
|
41
54
|
description: |
|
42
55
|
BibTeX-Ruby is the Rubyist's swiss-army-knife for all things BibTeX. It
|
43
56
|
includes a parser for all common BibTeX objects (@string, @preamble,
|
@@ -142,7 +155,6 @@ homepage: http://inukshuk.github.com/bibtex-ruby
|
|
142
155
|
licenses:
|
143
156
|
- GPL-3.0-or-later
|
144
157
|
metadata: {}
|
145
|
-
post_install_message:
|
146
158
|
rdoc_options: []
|
147
159
|
require_paths:
|
148
160
|
- lib
|
@@ -157,8 +169,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
157
169
|
- !ruby/object:Gem::Version
|
158
170
|
version: '0'
|
159
171
|
requirements: []
|
160
|
-
rubygems_version: 3.
|
161
|
-
signing_key:
|
172
|
+
rubygems_version: 3.7.0
|
162
173
|
specification_version: 4
|
163
174
|
summary: A BibTeX parser, converter and API for Ruby.
|
164
175
|
test_files:
|