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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d8b87649ab1cf5fb6c463ac3d0bfbc38d52063b0bbb5b9e46cb653e29edd697a
4
- data.tar.gz: 0d08d2dcb18309792bcd1ca37918de1e212201a548c3591eab381e2aa65c1d10
3
+ metadata.gz: b9758639d1863a9801e17e0986cdb4aa9256a20f8038adc8ce593decd1a8dc16
4
+ data.tar.gz: 7fc4c40e952ff4c33811651df3a676f36d9545c384135ee6e3083e36d5cc8620
5
5
  SHA512:
6
- metadata.gz: 3646b9ab287939c2644a77614558b83d367806491782e973e6763e3172fcaa77a5cadfe001860ab5293c9f09ee742d25207efbd1a6bad8a7b5f59ae27f5ee863
7
- data.tar.gz: ad1a67151f49f0112b95178b2a1f920b7163ab4a2aefddc77494df2d552cb1a038dda58ef9c14955077fa2c1aa83f2fdeabbece54adbccf8d9fd9d2e6f16b5d8
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', '~>1.8', platforms: %i[mri_18 jruby]
4
+ gem 'json', '~>2.0', platforms: %i[mri_18 jruby]
5
5
 
6
- gem 'rdf', '~>2.0.0'
7
- gem 'rdf-vocab', '~>2.0.0'
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', '~>1.3'
16
- gem 'minitest', '~>4.7', require: false
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', '~>2.4', platforms: [:mri]
31
- gem 'ruby-prof', '~>0.14', platforms: [:mri]
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.7', require: false
36
- gem 'simplecov', '~>0.8', require: false, platforms: [:ruby]
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', '~> 0.71.0', require: false
37
+ gem 'rubocop', require: false
43
38
  gem 'yard'
44
39
  end
@@ -1,3 +1,8 @@
1
+ 5.1.0 / 2020-01-17
2
+ ==================
3
+ * Use File.read instead of Kernel.open in BibTeX.open
4
+ * Fix Ruby 2.7 deprecation warnings
5
+
1
6
  5.0.0 / 2019-06-12
2
7
  ==================
3
8
  * Dropped support for Ruby < 2.3
data/Manifest CHANGED
@@ -1,5 +1,4 @@
1
1
  Gemfile
2
- Guardfile
3
2
  History.txt
4
3
  LICENSE
5
4
  Manifest
@@ -97,4 +96,4 @@ test/macruby.d
97
96
  test/macruby.rb
98
97
  test/profile.rb
99
98
  test/test_bibtex.rb
100
- test/test_export.rb
99
+ test/test_export.rb
data/Rakefile CHANGED
@@ -21,7 +21,7 @@ YARD::Rake::YardocTask.new
21
21
  Rake::TestTask.new(:test_task) do |t|
22
22
  t.libs << 'lib' << 'test'
23
23
  t.test_files = FileList['test/**/test_*.rb']
24
- t.verbose = true
24
+ # t.verbose = true
25
25
  end
26
26
 
27
27
  begin
@@ -1,5 +1,5 @@
1
- lib = File.expand_path('../lib/', __FILE__)
2
- $:.unshift lib unless $:.include?(lib)
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.3.0'
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
- END_DESCRIPTION
26
+ END_DESCRIPTION
27
27
 
28
28
  s.add_runtime_dependency('latex-decode', ['~>0.0'])
29
29
 
@@ -11,7 +11,7 @@ rescue LoadError
11
11
  # ignore
12
12
  end
13
13
 
14
- require 'minitest/unit'
14
+ require 'minitest'
15
15
  require 'bibtex'
16
16
 
17
17
  World(MiniTest::Assertions)
@@ -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(Kernel.open(path, 'r:UTF-8').read, options)
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(&Proc.new)
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(&Proc.new)
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
@@ -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(&Proc.new)
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, &Proc.new) : 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
@@ -28,7 +28,7 @@ module BibTeX
28
28
  module Filters
29
29
  LOAD_PATH = [File.expand_path(__dir__), 'filters'].join('/').freeze
30
30
 
31
- Dir.glob("#{LOAD_PATH}/*.rb").each do |filter|
31
+ Dir.glob("#{LOAD_PATH}/*.rb").sort.each do |filter|
32
32
  require filter
33
33
  end
34
34
 
@@ -560,4 +560,4 @@ def _reduce_none(val, _values, result)
560
560
  end
561
561
 
562
562
  end # class NameParser
563
- end # module BibTeX
563
+ end # module BibTeX
@@ -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
@@ -19,8 +19,8 @@
19
19
  module BibTeX
20
20
  module Version
21
21
  MAJOR = 5
22
- MINOR = 0
23
- PATCH = 1
22
+ MINOR = 1
23
+ PATCH = 0
24
24
  BUILD = nil
25
25
 
26
26
  STRING = [MAJOR, MINOR, PATCH, BUILD].compact.join('.').freeze
@@ -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.must_be :==, 6
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.must_be :==, 6
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.must_be :==, 5
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.must_be :==, 'rüby'
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
@@ -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
 
@@ -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
- assert_equal nil, Filters.resolve(:foobar)
32
- assert_equal nil, Filters.resolve('foobar')
33
- assert_equal nil, Filters.resolve(nil)
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
@@ -17,9 +17,6 @@ rescue LoadError
17
17
  end
18
18
 
19
19
  require 'minitest/autorun'
20
- require 'minitest/ansi'
21
-
22
- Minitest::ANSI.use!
23
20
 
24
21
  require 'tempfile'
25
22
 
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.1
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: 2019-11-18 00:00:00.000000000 Z
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.3.0
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.0.6
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