bibtex-ruby 5.0.1 → 5.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +10 -15
- data/History.txt +5 -0
- data/Manifest +1 -2
- data/Rakefile +1 -1
- data/bibtex-ruby.gemspec +4 -4
- data/features/support/env.rb +1 -1
- data/lib/bibtex/bibliography.rb +8 -14
- data/lib/bibtex/entry.rb +4 -4
- data/lib/bibtex/filters.rb +1 -1
- data/lib/bibtex/name_parser.rb +1 -1
- data/lib/bibtex/parser.rb +1 -1
- data/lib/bibtex/version.rb +2 -2
- data/test/bibtex/test_bibliography.rb +10 -10
- data/test/bibtex/test_entry.rb +6 -6
- data/test/bibtex/test_filters.rb +3 -3
- data/test/helper.rb +0 -3
- metadata +6 -7
- data/Guardfile +0 -22
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b9758639d1863a9801e17e0986cdb4aa9256a20f8038adc8ce593decd1a8dc16
|
4
|
+
data.tar.gz: 7fc4c40e952ff4c33811651df3a676f36d9545c384135ee6e3083e36d5cc8620
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 88c9411586003c0fd091fd505ed74057aca7c367281af3fa6632cb510eb2b25e11940f134f28824c07fd5d047de3fc62615556da914d78ff1e5b7e49125c501b
|
7
|
+
data.tar.gz: 5254bae56f6cdefd6076f324d241348b5e6b211e0f4d763ae7f37fcce38448041e522ca5646138f6bf89a08e546d2761a42f9b7e895732fef36d8de3fa59eb84
|
data/Gemfile
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
source 'https://rubygems.org'
|
2
2
|
gemspec
|
3
3
|
|
4
|
-
gem 'json', '~>
|
4
|
+
gem 'json', '~>2.0', platforms: %i[mri_18 jruby]
|
5
5
|
|
6
|
-
gem 'rdf', '~>
|
7
|
-
gem 'rdf-vocab', '~>
|
6
|
+
gem 'rdf', '~>3.0'
|
7
|
+
gem 'rdf-vocab', '~>3.0'
|
8
8
|
|
9
9
|
group :debug do
|
10
10
|
gem 'byebug', require: false, platforms: :mri
|
@@ -12,33 +12,28 @@ group :debug do
|
|
12
12
|
end
|
13
13
|
|
14
14
|
group :test do
|
15
|
-
gem 'cucumber'
|
16
|
-
gem 'minitest',
|
17
|
-
gem 'minitest-ansi'
|
15
|
+
gem 'cucumber'
|
16
|
+
gem 'minitest', require: false
|
18
17
|
gem 'unicode', '~>0.4', platforms: %i[mswin mingw mri]
|
19
18
|
end
|
20
19
|
|
21
20
|
group :extra do
|
22
|
-
gem 'rb-fsevent', require: false if RUBY_PLATFORM =~ /darwin/i
|
23
|
-
|
24
|
-
gem 'guard-cucumber', platforms: [:ruby]
|
25
|
-
gem 'guard-minitest', platforms: [:ruby]
|
26
21
|
gem 'redcarpet', platforms: [:ruby]
|
27
22
|
end
|
28
23
|
|
29
24
|
group :profile do
|
30
|
-
gem 'gnuplot',
|
31
|
-
gem 'ruby-prof',
|
25
|
+
gem 'gnuplot', platforms: [:mri]
|
26
|
+
gem 'ruby-prof', platforms: [:mri]
|
32
27
|
end
|
33
28
|
|
34
29
|
group :coverage do
|
35
|
-
gem 'coveralls', '~>0.
|
36
|
-
gem 'simplecov',
|
30
|
+
gem 'coveralls', '~>0.8', require: false
|
31
|
+
gem 'simplecov', require: false, platforms: [:ruby]
|
37
32
|
end
|
38
33
|
|
39
34
|
group :development do
|
40
35
|
gem 'iconv', platforms: [:ruby]
|
41
36
|
gem 'rake'
|
42
|
-
gem 'rubocop',
|
37
|
+
gem 'rubocop', require: false
|
43
38
|
gem 'yard'
|
44
39
|
end
|
data/History.txt
CHANGED
data/Manifest
CHANGED
data/Rakefile
CHANGED
data/bibtex-ruby.gemspec
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
lib = File.expand_path('
|
2
|
-
|
1
|
+
lib = File.expand_path('lib', __dir__)
|
2
|
+
$LOAD_PATH.unshift lib unless $LOAD_PATH.include?(lib)
|
3
3
|
|
4
4
|
require 'bibtex/version'
|
5
5
|
|
@@ -7,7 +7,7 @@ Gem::Specification.new do |s|
|
|
7
7
|
s.name = 'bibtex-ruby'
|
8
8
|
s.version = BibTeX::Version::STRING.dup
|
9
9
|
s.platform = Gem::Platform::RUBY
|
10
|
-
s.required_ruby_version = '>= 2.
|
10
|
+
s.required_ruby_version = '>= 2.4.0'
|
11
11
|
s.authors = ['Sylvester Keil']
|
12
12
|
s.email = ['sylvester@keil.or.at']
|
13
13
|
s.homepage = 'http://inukshuk.github.com/bibtex-ruby'
|
@@ -23,7 +23,7 @@ Gem::Specification.new do |s|
|
|
23
23
|
supports cross-references, and decodes common LaTeX formatting
|
24
24
|
instructions to unicode; if you are in a hurry, it also allows for easy
|
25
25
|
export/conversion to formats such as YAML, JSON, CSL, and XML (BibTeXML).
|
26
|
-
|
26
|
+
END_DESCRIPTION
|
27
27
|
|
28
28
|
s.add_runtime_dependency('latex-decode', ['~>0.0'])
|
29
29
|
|
data/features/support/env.rb
CHANGED
data/lib/bibtex/bibliography.rb
CHANGED
@@ -47,7 +47,7 @@ module BibTeX
|
|
47
47
|
# -:filter: convert all entries using the sepcified filter (not set by default)
|
48
48
|
#
|
49
49
|
def open(path, options = {})
|
50
|
-
b = parse(
|
50
|
+
b = parse(File.read(path), options)
|
51
51
|
b.path = path
|
52
52
|
return b unless block_given?
|
53
53
|
|
@@ -144,9 +144,9 @@ module BibTeX
|
|
144
144
|
self
|
145
145
|
end
|
146
146
|
|
147
|
-
def each
|
147
|
+
def each(&block)
|
148
148
|
if block_given?
|
149
|
-
data.each(&
|
149
|
+
data.each(&block)
|
150
150
|
self
|
151
151
|
else
|
152
152
|
to_enum
|
@@ -339,14 +339,9 @@ module BibTeX
|
|
339
339
|
# Sets all fields matching the passed-in pattern to the supplied value.
|
340
340
|
# If a block is given, each matching entry will be passed to the block
|
341
341
|
# instead. Returns the bibliography.
|
342
|
-
def unify(field, pattern, value = nil)
|
342
|
+
def unify(field, pattern, value = nil, &block)
|
343
343
|
pattern = Regexp.new(pattern) unless pattern.is_a?(Regexp)
|
344
|
-
|
345
|
-
block = if block_given?
|
346
|
-
Proc.new
|
347
|
-
else
|
348
|
-
proc { |e| e[field] = value }
|
349
|
-
end
|
344
|
+
block = proc { |e| e[field] = value } unless block_given?
|
350
345
|
|
351
346
|
each_entry do |entry|
|
352
347
|
block.call(entry) if entry.field?(field) && entry[field].to_s =~ pattern
|
@@ -489,9 +484,9 @@ module BibTeX
|
|
489
484
|
|
490
485
|
alias q query
|
491
486
|
|
492
|
-
def each_entry
|
487
|
+
def each_entry(&block)
|
493
488
|
if block_given?
|
494
|
-
q('@entry').each(&
|
489
|
+
q('@entry').each(&block)
|
495
490
|
else
|
496
491
|
q('@entry').to_enum
|
497
492
|
end
|
@@ -507,9 +502,8 @@ module BibTeX
|
|
507
502
|
other.respond_to?(:to_a) ? to_a <=> other.to_a : nil
|
508
503
|
end
|
509
504
|
|
510
|
-
def select_duplicates_by(*arguments)
|
505
|
+
def select_duplicates_by(*arguments, &block)
|
511
506
|
arguments = %i[year title] if arguments.empty?
|
512
|
-
block = Proc.new if block_given?
|
513
507
|
|
514
508
|
group_by(*arguments) do |digest, entry|
|
515
509
|
# 1.8 compatibility
|
data/lib/bibtex/entry.rb
CHANGED
@@ -164,9 +164,9 @@ module BibTeX
|
|
164
164
|
# pair as parameters.
|
165
165
|
#
|
166
166
|
# If no block is given, an enumerator is returned instead.
|
167
|
-
def each
|
167
|
+
def each(&block)
|
168
168
|
if block_given?
|
169
|
-
fields.each(&
|
169
|
+
fields.each(&block)
|
170
170
|
self
|
171
171
|
else
|
172
172
|
to_enum
|
@@ -606,8 +606,8 @@ module BibTeX
|
|
606
606
|
# the block returns true (the block will be called with each key-value pair).
|
607
607
|
#
|
608
608
|
# @see #convert!
|
609
|
-
def convert(*filters)
|
610
|
-
block_given? ? dup.convert!(*filters, &
|
609
|
+
def convert(*filters, &block)
|
610
|
+
block_given? ? dup.convert!(*filters, &block) : dup.convert!(*filters)
|
611
611
|
end
|
612
612
|
|
613
613
|
# In-place variant of @see #convert
|
data/lib/bibtex/filters.rb
CHANGED
data/lib/bibtex/name_parser.rb
CHANGED
data/lib/bibtex/parser.rb
CHANGED
data/lib/bibtex/version.rb
CHANGED
@@ -27,11 +27,11 @@ module BibTeX
|
|
27
27
|
|
28
28
|
describe '.parse' do
|
29
29
|
it 'accepts filters' do
|
30
|
-
Bibliography.parse("@misc{k, title = {\\''u}}", filter: 'latex')[0].title.must_be :==, 'ü'
|
30
|
+
_(Bibliography.parse("@misc{k, title = {\\''u}}", filter: 'latex')[0].title).must_be :==, 'ü'
|
31
31
|
end
|
32
32
|
|
33
33
|
it 'accepts filters in an array' do
|
34
|
-
Bibliography.parse("@misc{k, title = {\\''u}}", filter: ['latex'])[0].title.must_be :==, 'ü'
|
34
|
+
_(Bibliography.parse("@misc{k, title = {\\''u}}", filter: ['latex'])[0].title).must_be :==, 'ü'
|
35
35
|
end
|
36
36
|
end
|
37
37
|
|
@@ -252,15 +252,15 @@ module BibTeX
|
|
252
252
|
|
253
253
|
describe '#query' do
|
254
254
|
it 'returns all elements when passed no arguments' do
|
255
|
-
@bib.query.length
|
255
|
+
assert_equal 6, @bib.query.length
|
256
256
|
end
|
257
257
|
|
258
258
|
it 'returns all elements when passed :all and an empty condition' do
|
259
|
-
@bib.query(:all, '').length
|
259
|
+
assert_equal 6, @bib.query(:all, '').length
|
260
260
|
end
|
261
261
|
|
262
262
|
it 'returns all entries when passed a * wildcard' do
|
263
|
-
@bib.query('@*').length
|
263
|
+
assert_equal 5, @bib.query('@*').length
|
264
264
|
end
|
265
265
|
end
|
266
266
|
|
@@ -393,7 +393,7 @@ module BibTeX
|
|
393
393
|
end
|
394
394
|
|
395
395
|
it 'converts LaTeX umlauts' do
|
396
|
-
@bib.convert(:latex)['rails'].keywords
|
396
|
+
assert_equal 'rüby', @bib.convert(:latex)['rails'].keywords
|
397
397
|
end
|
398
398
|
end
|
399
399
|
|
@@ -405,16 +405,16 @@ module BibTeX
|
|
405
405
|
@bib.to_xml.write(@bibtexml, 2)
|
406
406
|
@bibtexml.rewind
|
407
407
|
xml = REXML::Document.new(@bibtexml)
|
408
|
-
xml.root.namespace.must_be :==, 'http://bibtexml.sf.net/'
|
409
|
-
xml.root.get_elements('//bibtex:entry').wont_be_empty
|
408
|
+
_(xml.root.namespace).must_be :==, 'http://bibtexml.sf.net/'
|
409
|
+
_(xml.root.get_elements('//bibtex:entry')).wont_be_empty
|
410
410
|
end
|
411
411
|
|
412
412
|
it 'supports exporting to extended BibTeXML' do
|
413
413
|
@bib.to_xml(extended: true).write(@bibtexml, 2)
|
414
414
|
@bibtexml.rewind
|
415
415
|
xml = REXML::Document.new(@bibtexml)
|
416
|
-
xml.root.namespace.must_be :==, 'http://bibtexml.sf.net/'
|
417
|
-
xml.root.get_elements('//bibtex:person').wont_be_empty
|
416
|
+
_(xml.root.namespace).must_be :==, 'http://bibtexml.sf.net/'
|
417
|
+
_(xml.root.get_elements('//bibtex:person')).wont_be_empty
|
418
418
|
end
|
419
419
|
end
|
420
420
|
end
|
data/test/bibtex/test_entry.rb
CHANGED
@@ -4,7 +4,7 @@ module BibTeX
|
|
4
4
|
class EntryTest < Minitest::Spec
|
5
5
|
describe 'a new entry' do
|
6
6
|
it "won't be nil" do
|
7
|
-
Entry.new.wont_be_nil
|
7
|
+
_(Entry.new).wont_be_nil
|
8
8
|
end
|
9
9
|
end
|
10
10
|
|
@@ -23,7 +23,7 @@ module BibTeX
|
|
23
23
|
|
24
24
|
it 'is not cross-referenced by default' do
|
25
25
|
assert_equal false, Entry.new.cross_referenced?
|
26
|
-
Entry.new.cross_referenced_by.must_be_empty
|
26
|
+
_(Entry.new.cross_referenced_by).must_be_empty
|
27
27
|
end
|
28
28
|
|
29
29
|
describe 'given a bibliography with cross referenced entries' do
|
@@ -74,26 +74,26 @@ module BibTeX
|
|
74
74
|
describe 'when a "title" is set in the entry itself' do
|
75
75
|
before { @bib['a1'].title = 'A1' }
|
76
76
|
it 'returns the title' do
|
77
|
-
@bib['a1'].title.must_be :==, 'A1'
|
77
|
+
_(@bib['a1'].title).must_be :==, 'A1'
|
78
78
|
end
|
79
79
|
end
|
80
80
|
|
81
81
|
describe 'when "title" is undefined for the entry but defined in the reference' do
|
82
82
|
it 'returns the referenced title' do
|
83
|
-
@bib['a1'].title.must_be :==, @bib['a'].title
|
83
|
+
_(@bib['a1'].title).must_be :==, @bib['a'].title
|
84
84
|
end
|
85
85
|
end
|
86
86
|
|
87
87
|
describe 'when "booktitle" is undefined for the entry but defined in the reference' do
|
88
88
|
before { @bib['a'].booktitle = 'A Booktitle' }
|
89
89
|
it 'returns the referenced booktitle' do
|
90
|
-
@bib['a1'].booktitle.must_be :==, @bib['a'].booktitle
|
90
|
+
_(@bib['a1'].booktitle).must_be :==, @bib['a'].booktitle
|
91
91
|
end
|
92
92
|
end
|
93
93
|
|
94
94
|
describe 'when "booktitle" is undefined for the entry and the reference but the reference has a "title"' do
|
95
95
|
it "returns the reference's title" do
|
96
|
-
@bib['a1'].booktitle.must_be :==, @bib['a'].title
|
96
|
+
_(@bib['a1'].booktitle).must_be :==, @bib['a'].title
|
97
97
|
end
|
98
98
|
end
|
99
99
|
|
data/test/bibtex/test_filters.rb
CHANGED
@@ -28,9 +28,9 @@ module BibTeX
|
|
28
28
|
end
|
29
29
|
|
30
30
|
it 'should return nil if there is no filter by that name' do
|
31
|
-
|
32
|
-
|
33
|
-
|
31
|
+
assert_nil Filters.resolve(:foobar)
|
32
|
+
assert_nil Filters.resolve('foobar')
|
33
|
+
assert_nil Filters.resolve(nil)
|
34
34
|
end
|
35
35
|
end
|
36
36
|
end
|
data/test/helper.rb
CHANGED
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: 5.0
|
4
|
+
version: 5.1.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:
|
11
|
+
date: 2020-01-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: latex-decode
|
@@ -40,7 +40,6 @@ extensions: []
|
|
40
40
|
extra_rdoc_files: []
|
41
41
|
files:
|
42
42
|
- Gemfile
|
43
|
-
- Guardfile
|
44
43
|
- History.txt
|
45
44
|
- LICENSE
|
46
45
|
- Manifest
|
@@ -137,22 +136,20 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
137
136
|
requirements:
|
138
137
|
- - ">="
|
139
138
|
- !ruby/object:Gem::Version
|
140
|
-
version: 2.
|
139
|
+
version: 2.4.0
|
141
140
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
142
141
|
requirements:
|
143
142
|
- - ">="
|
144
143
|
- !ruby/object:Gem::Version
|
145
144
|
version: '0'
|
146
145
|
requirements: []
|
147
|
-
rubygems_version: 3.
|
146
|
+
rubygems_version: 3.1.2
|
148
147
|
signing_key:
|
149
148
|
specification_version: 4
|
150
149
|
summary: A BibTeX parser, converter and API for Ruby.
|
151
150
|
test_files:
|
152
151
|
- test/bibtex/entry/test_rdf_converter.rb
|
153
|
-
- test/bibtex/test_bibliography.rb
|
154
152
|
- test/bibtex/test_elements.rb
|
155
|
-
- test/bibtex/test_filters.rb
|
156
153
|
- test/bibtex/test_lexer.rb
|
157
154
|
- test/bibtex/test_name_parser.rb
|
158
155
|
- test/bibtex/test_names.rb
|
@@ -161,5 +158,7 @@ test_files:
|
|
161
158
|
- test/bibtex/test_utilities.rb
|
162
159
|
- test/bibtex/test_value.rb
|
163
160
|
- test/bibtex/test_entry.rb
|
161
|
+
- test/bibtex/test_filters.rb
|
162
|
+
- test/bibtex/test_bibliography.rb
|
164
163
|
- test/test_bibtex.rb
|
165
164
|
- test/test_export.rb
|
data/Guardfile
DELETED
@@ -1,22 +0,0 @@
|
|
1
|
-
# A sample Guardfile
|
2
|
-
# More info at https://github.com/guard/guard#readme
|
3
|
-
|
4
|
-
guard 'cucumber' do
|
5
|
-
watch(%r{^features/.+\.feature$})
|
6
|
-
watch(%r{^features/support/.+$}) { 'features' }
|
7
|
-
watch(%r{^features/step_definitions/(.+)_steps\.rb$}) { |m| Dir[File.join("**/#{m[1]}.feature")][0] || 'features' }
|
8
|
-
end
|
9
|
-
|
10
|
-
guard 'minitest' do
|
11
|
-
ignore(%r|swp$|)
|
12
|
-
|
13
|
-
# with Minitest::Unit
|
14
|
-
watch(%r|^test/(.*)/?test_(.*)\.rb|)
|
15
|
-
watch(%r|^lib/(.*)([^/]+)\.rb|) { |m| "test/#{m[1]}test_#{m[2]}.rb" }
|
16
|
-
watch(%r|^test/helper\.rb|) { 'test' }
|
17
|
-
|
18
|
-
# with Minitest::Spec
|
19
|
-
# watch(%r|^spec/(.*)_spec\.rb|)
|
20
|
-
# watch(%r|^lib/(.*)([^/]+)\.rb|) { |m| "spec/#{m[1]}#{m[2]}_spec.rb" }
|
21
|
-
# watch(%r|^spec/spec_helper\.rb|) { "spec" }
|
22
|
-
end
|