bibtex-ruby 2.3.3 → 2.3.4
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of bibtex-ruby might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/History.txt +5 -0
- data/Manifest +0 -1
- data/Rakefile +1 -1
- data/lib/bibtex/bibliography.rb +50 -4
- data/lib/bibtex/elements.rb +1 -1
- data/lib/bibtex/entry.rb +1 -1
- data/lib/bibtex/lexer.rb +1 -1
- data/lib/bibtex/value.rb +1 -1
- data/lib/bibtex/version.rb +2 -2
- data/test/bibtex/test_bibliography.rb +31 -0
- data/test/bibtex/test_parser.rb +12 -0
- metadata +9 -10
- data/Gemfile.lock +0 -110
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5b09dca8a81cca150971cdfabcc448c4ffdd2ee7
|
4
|
+
data.tar.gz: 68f2f2564edf0a61eb80944f25f684a7d9fab0e8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 589c95707591059f965b4bfe7167211a707da6b5f125d349b9b2457657f4f3ac16d70b6039b7022a8d32161d2cc33f6a0409cd2c7ea3c7013041b5c7a890caef
|
7
|
+
data.tar.gz: 1406695031be8949fd6495328d99586e5b4e8d781f2d9fe6a93d3b8cf186d9f36ee0a64bfd00eaf789f7acb668070b82a07d32c12d24827e34ddd23d2cd44e05
|
data/History.txt
CHANGED
data/Manifest
CHANGED
data/Rakefile
CHANGED
@@ -85,7 +85,7 @@ desc 'Updates the Manifest file'
|
|
85
85
|
task :manifest => ['clean', 'racc'] do
|
86
86
|
m = File.open('Manifest', 'w')
|
87
87
|
m.print FileList['**/*'].reject{ |f|
|
88
|
-
f.start_with?('coverage') || f
|
88
|
+
f.start_with?('coverage') || f =~ /(rbc|swp|~|lock)$/
|
89
89
|
}.join("\n")
|
90
90
|
m.close
|
91
91
|
end
|
data/lib/bibtex/bibliography.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
#--
|
2
2
|
# BibTeX-Ruby
|
3
|
-
# Copyright (C) 2010-
|
3
|
+
# Copyright (C) 2010-2013 Sylvester Keil <sylvester.keil.or.at>
|
4
4
|
#
|
5
5
|
# This program is free software: you can redistribute it and/or modify
|
6
6
|
# it under the terms of the GNU General Public License as published by
|
@@ -107,7 +107,12 @@ module BibTeX
|
|
107
107
|
@errors = other.errors.dup
|
108
108
|
@data, @strings = [], {}
|
109
109
|
@entries = Hash.new { |h,k| h.fetch(k.to_s, nil) }
|
110
|
-
|
110
|
+
|
111
|
+
other.each do |element|
|
112
|
+
add element.dup
|
113
|
+
end
|
114
|
+
|
115
|
+
self
|
111
116
|
end
|
112
117
|
|
113
118
|
# Adds a new element, or a list of new elements to the bibliography.
|
@@ -511,13 +516,17 @@ module BibTeX
|
|
511
516
|
|
512
517
|
def select_duplicates_by(*arguments)
|
513
518
|
arguments = [:year, :title] if arguments.empty?
|
519
|
+
block = Proc.new if block_given?
|
514
520
|
|
515
|
-
group_by(*arguments) { |digest|
|
521
|
+
group_by(*arguments) { |digest, entry|
|
516
522
|
|
517
523
|
# 1.8 compatibility
|
518
|
-
digest = digest[0] if digest.is_a?(Array)
|
524
|
+
# digest = digest[0] if digest.is_a?(Array)
|
519
525
|
|
520
526
|
digest.gsub(/\s+/, '').downcase
|
527
|
+
digest = block.call(disgest, entry) unless block.nil?
|
528
|
+
digest
|
529
|
+
|
521
530
|
}.values.select { |d| d.length > 1 }
|
522
531
|
end
|
523
532
|
|
@@ -527,6 +536,43 @@ module BibTeX
|
|
527
536
|
!select_duplicates_by.empty?
|
528
537
|
end
|
529
538
|
|
539
|
+
# call-seq:
|
540
|
+
# bib.uniq! -> bib
|
541
|
+
# bib.uniq!(:title, :year) -> bib
|
542
|
+
# bib.uniq! { |digest, entry| ... } -> bib
|
543
|
+
# bib.uniq!(:title) { |digest, entry| ... } -> bib
|
544
|
+
#
|
545
|
+
# Removes duplicate entries from the Bibliography.
|
546
|
+
#
|
547
|
+
# All arguments given will be used to calculate a digest
|
548
|
+
# for each entry. If a block is given, it will be be passed
|
549
|
+
# the computed digest as well as each entry; the block
|
550
|
+
# must then yield the final digest that will be used to
|
551
|
+
# compute duplicates.
|
552
|
+
#
|
553
|
+
# This method will always retain the first entry and will
|
554
|
+
# discard subsequent duplicates on the basis of each entry's
|
555
|
+
# digest.
|
556
|
+
#
|
557
|
+
# @see Entry#digest
|
558
|
+
# @see @duplicates_by
|
559
|
+
#
|
560
|
+
def uniq!(*arguments, &block)
|
561
|
+
select_duplicates_by(*arguments, &block).each do |dupes|
|
562
|
+
dupes.shift
|
563
|
+
dupes.each do |dupe|
|
564
|
+
self.remove dupe
|
565
|
+
end
|
566
|
+
end
|
567
|
+
|
568
|
+
self
|
569
|
+
end
|
570
|
+
|
571
|
+
# Experimental!
|
572
|
+
# Returns a new Bibliography with all duplicates removed.
|
573
|
+
def uniq(*arguments, &block)
|
574
|
+
dup.uniq!
|
575
|
+
end
|
530
576
|
|
531
577
|
private
|
532
578
|
|
data/lib/bibtex/elements.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
#--
|
2
2
|
# BibTeX-Ruby
|
3
|
-
# Copyright (C) 2010-
|
3
|
+
# Copyright (C) 2010-2013 Sylvester Keil <sylvester.keil.or.at>
|
4
4
|
#
|
5
5
|
# This program is free software: you can redistribute it and/or modify
|
6
6
|
# it under the terms of the GNU General Public License as published by
|
data/lib/bibtex/entry.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
#--
|
2
2
|
# BibTeX-Ruby
|
3
|
-
# Copyright (C) 2010-
|
3
|
+
# Copyright (C) 2010-2013 Sylvester Keil <sylvester.keil.or.at>
|
4
4
|
#
|
5
5
|
# This program is free software: you can redistribute it and/or modify
|
6
6
|
# it under the terms of the GNU General Public License as published by
|
data/lib/bibtex/lexer.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
#--
|
2
2
|
# BibTeX-Ruby
|
3
|
-
# Copyright (C) 2010-
|
3
|
+
# Copyright (C) 2010-2013 Sylvester Keil <http://sylvester.keil.or.at>
|
4
4
|
#
|
5
5
|
# This program is free software: you can redistribute it and/or modify
|
6
6
|
# it under the terms of the GNU General Public License as published by
|
data/lib/bibtex/value.rb
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
#--
|
4
4
|
# BibTeX-Ruby
|
5
|
-
# Copyright (C) 2010-
|
5
|
+
# Copyright (C) 2010-2013 Sylvester Keil <sylvester.keil.or.at>
|
6
6
|
#
|
7
7
|
# This program is free software: you can redistribute it and/or modify
|
8
8
|
# it under the terms of the GNU General Public License as published by
|
data/lib/bibtex/version.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
#--
|
2
2
|
# BibTeX-Ruby
|
3
|
-
# Copyright (C) 2010-
|
3
|
+
# Copyright (C) 2010-2013 Sylvester Keil <sylvester.keil.or.at>
|
4
4
|
#
|
5
5
|
# This program is free software: you can redistribute it and/or modify
|
6
6
|
# it under the terms of the GNU General Public License as published by
|
@@ -20,7 +20,7 @@ module BibTeX
|
|
20
20
|
module Version
|
21
21
|
MAJOR = 2
|
22
22
|
MINOR = 3
|
23
|
-
PATCH =
|
23
|
+
PATCH = 4
|
24
24
|
BUILD = nil
|
25
25
|
|
26
26
|
STRING = [MAJOR, MINOR, PATCH, BUILD].compact.join('.').freeze
|
@@ -279,6 +279,37 @@ module BibTeX
|
|
279
279
|
|
280
280
|
end
|
281
281
|
|
282
|
+
describe '#uniq!' do
|
283
|
+
before do
|
284
|
+
@a = BibTeX.parse <<-END
|
285
|
+
@book{b1,
|
286
|
+
title = {FOO},
|
287
|
+
year = {2013},
|
288
|
+
author = {Doe, John}}
|
289
|
+
@book{b2,
|
290
|
+
title = {BAR},
|
291
|
+
year = {2013},
|
292
|
+
author = {Doe, John}}
|
293
|
+
END
|
294
|
+
@b = BibTeX.parse <<-END
|
295
|
+
@book{b3,
|
296
|
+
title = {FOO},
|
297
|
+
year = {2013},
|
298
|
+
author = {Doe, Jane}}
|
299
|
+
END
|
300
|
+
end
|
301
|
+
|
302
|
+
it 'returns the bibliography unchanged if there are no duplicates' do
|
303
|
+
assert @a.length == @a.uniq!.length
|
304
|
+
assert @b.length == @b.uniq!.length
|
305
|
+
end
|
306
|
+
|
307
|
+
it 'removes duplicate entries and returns the bibliography' do
|
308
|
+
assert @a.length > @a.uniq!(:author).length
|
309
|
+
end
|
310
|
+
|
311
|
+
end
|
312
|
+
|
282
313
|
describe 'given a filter' do
|
283
314
|
before do
|
284
315
|
@filter = Object
|
data/test/bibtex/test_parser.rb
CHANGED
@@ -150,6 +150,18 @@ module BibTeX
|
|
150
150
|
|
151
151
|
end
|
152
152
|
|
153
|
+
describe 'year values' do
|
154
|
+
it 'parses non-numeric year literals' do
|
155
|
+
assert_equal 'to appear',
|
156
|
+
Parser.new.parse("@article{x, year = {to appear}}")['x'].year.to_s
|
157
|
+
end
|
158
|
+
|
159
|
+
it 'parses numeric year literals' do
|
160
|
+
assert_equal 1993,
|
161
|
+
Parser.new.parse("@article{x, year = { 1993 }}")['x'].year.to_i
|
162
|
+
end
|
163
|
+
end
|
164
|
+
|
153
165
|
describe 'given an entry with missing commas between fields' do
|
154
166
|
before do
|
155
167
|
@level = BibTeX.log.level
|
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: 2.3.
|
4
|
+
version: 2.3.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sylvester Keil
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-08-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: latex-decode
|
@@ -54,7 +54,6 @@ extensions: []
|
|
54
54
|
extra_rdoc_files: []
|
55
55
|
files:
|
56
56
|
- Gemfile
|
57
|
-
- Gemfile.lock
|
58
57
|
- Guardfile
|
59
58
|
- History.txt
|
60
59
|
- LICENSE
|
@@ -158,17 +157,17 @@ signing_key:
|
|
158
157
|
specification_version: 4
|
159
158
|
summary: A BibTeX parser, converter and API for Ruby.
|
160
159
|
test_files:
|
161
|
-
- test/bibtex/
|
160
|
+
- test/bibtex/test_bibliography.rb
|
161
|
+
- test/bibtex/test_elements.rb
|
162
|
+
- test/bibtex/test_entry.rb
|
163
|
+
- test/bibtex/test_filters.rb
|
162
164
|
- test/bibtex/test_lexer.rb
|
165
|
+
- test/bibtex/test_name_parser.rb
|
163
166
|
- test/bibtex/test_names.rb
|
164
167
|
- test/bibtex/test_parser.rb
|
165
|
-
- test/bibtex/test_bibliography.rb
|
166
|
-
- test/bibtex/test_filters.rb
|
167
|
-
- test/bibtex/test_utilities.rb
|
168
168
|
- test/bibtex/test_string.rb
|
169
|
-
- test/bibtex/
|
170
|
-
- test/bibtex/
|
171
|
-
- test/bibtex/test_elements.rb
|
169
|
+
- test/bibtex/test_utilities.rb
|
170
|
+
- test/bibtex/test_value.rb
|
172
171
|
- test/test_bibtex.rb
|
173
172
|
- test/test_export.rb
|
174
173
|
has_rdoc: yard
|
data/Gemfile.lock
DELETED
@@ -1,110 +0,0 @@
|
|
1
|
-
PATH
|
2
|
-
remote: .
|
3
|
-
specs:
|
4
|
-
bibtex-ruby (2.3.3)
|
5
|
-
latex-decode (>= 0.0.6)
|
6
|
-
multi_json (~> 1.3)
|
7
|
-
|
8
|
-
GEM
|
9
|
-
remote: https://rubygems.org/
|
10
|
-
specs:
|
11
|
-
addressable (2.3.5)
|
12
|
-
builder (3.2.2)
|
13
|
-
coderay (1.0.9)
|
14
|
-
columnize (0.3.6)
|
15
|
-
cucumber (1.3.5)
|
16
|
-
builder (>= 2.1.2)
|
17
|
-
diff-lcs (>= 1.1.3)
|
18
|
-
gherkin (~> 2.12.0)
|
19
|
-
multi_json (~> 1.7.5)
|
20
|
-
multi_test (>= 0.0.2)
|
21
|
-
debugger (1.6.1)
|
22
|
-
columnize (>= 0.3.1)
|
23
|
-
debugger-linecache (~> 1.2.0)
|
24
|
-
debugger-ruby_core_source (~> 1.2.3)
|
25
|
-
debugger-linecache (1.2.0)
|
26
|
-
debugger-ruby_core_source (1.2.3)
|
27
|
-
diff-lcs (1.2.4)
|
28
|
-
ffi (1.9.0)
|
29
|
-
formatador (0.2.4)
|
30
|
-
gherkin (2.12.0)
|
31
|
-
multi_json (~> 1.3)
|
32
|
-
gnuplot (2.6.2)
|
33
|
-
guard (1.8.1)
|
34
|
-
formatador (>= 0.2.4)
|
35
|
-
listen (>= 1.0.0)
|
36
|
-
lumberjack (>= 1.0.2)
|
37
|
-
pry (>= 0.9.10)
|
38
|
-
thor (>= 0.14.6)
|
39
|
-
guard-cucumber (1.4.0)
|
40
|
-
cucumber (>= 1.2.0)
|
41
|
-
guard (>= 1.1.0)
|
42
|
-
guard-minitest (1.0.1)
|
43
|
-
guard (>= 1.8)
|
44
|
-
minitest (>= 2.1)
|
45
|
-
latex-decode (0.1.1)
|
46
|
-
unicode (~> 0.4)
|
47
|
-
linecache (0.46)
|
48
|
-
rbx-require-relative (> 0.0.4)
|
49
|
-
listen (1.2.2)
|
50
|
-
rb-fsevent (>= 0.9.3)
|
51
|
-
rb-inotify (>= 0.9)
|
52
|
-
rb-kqueue (>= 0.2)
|
53
|
-
lumberjack (1.0.4)
|
54
|
-
method_source (0.8.2)
|
55
|
-
minitest (4.7.5)
|
56
|
-
minitest-colorize (0.0.5)
|
57
|
-
minitest (>= 2.0)
|
58
|
-
multi_json (1.7.7)
|
59
|
-
multi_test (0.0.2)
|
60
|
-
pry (0.9.12.2)
|
61
|
-
coderay (~> 1.0.5)
|
62
|
-
method_source (~> 0.8)
|
63
|
-
slop (~> 3.4)
|
64
|
-
racc (1.4.9)
|
65
|
-
rake (10.1.0)
|
66
|
-
rb-fsevent (0.9.3)
|
67
|
-
rb-inotify (0.9.0)
|
68
|
-
ffi (>= 0.5.0)
|
69
|
-
rb-kqueue (0.2.0)
|
70
|
-
ffi (>= 0.5.0)
|
71
|
-
rbx-require-relative (0.0.9)
|
72
|
-
rdf (0.3.11.1)
|
73
|
-
addressable (>= 2.2.6)
|
74
|
-
redcarpet (3.0.0)
|
75
|
-
ruby-debug (0.10.4)
|
76
|
-
columnize (>= 0.1)
|
77
|
-
ruby-debug-base (~> 0.10.4.0)
|
78
|
-
ruby-debug-base (0.10.4)
|
79
|
-
linecache (>= 0.3)
|
80
|
-
ruby-prof (0.13.0)
|
81
|
-
simplecov (0.7.1)
|
82
|
-
multi_json (~> 1.0)
|
83
|
-
simplecov-html (~> 0.7.1)
|
84
|
-
simplecov-html (0.7.1)
|
85
|
-
slop (3.4.6)
|
86
|
-
thor (0.18.1)
|
87
|
-
unicode (0.4.4)
|
88
|
-
yard (0.8.7)
|
89
|
-
|
90
|
-
PLATFORMS
|
91
|
-
ruby
|
92
|
-
|
93
|
-
DEPENDENCIES
|
94
|
-
bibtex-ruby!
|
95
|
-
cucumber (~> 1.0)
|
96
|
-
debugger
|
97
|
-
gnuplot (~> 2.4)
|
98
|
-
guard-cucumber
|
99
|
-
guard-minitest
|
100
|
-
minitest (~> 4.0)
|
101
|
-
minitest-colorize
|
102
|
-
racc
|
103
|
-
rake
|
104
|
-
rdf (~> 0.3)
|
105
|
-
redcarpet
|
106
|
-
ruby-debug
|
107
|
-
ruby-prof (~> 0.10)
|
108
|
-
simplecov
|
109
|
-
unicode
|
110
|
-
yard
|