bibtex-ruby 4.4.7 → 5.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/Gemfile +23 -24
- data/History.txt +4 -0
- data/Rakefile +23 -25
- data/bibtex-ruby.gemspec +1 -1
- data/examples/bib2html.rb +5 -6
- data/examples/bib2yaml.rb +2 -2
- data/features/step_definitions/bibtex_steps.rb +3 -6
- data/features/step_definitions/name_steps.rb +1 -2
- data/lib/bibtex.rb +11 -13
- data/lib/bibtex/bibliography.rb +45 -58
- data/lib/bibtex/compatibility.rb +3 -5
- data/lib/bibtex/elements.rb +49 -42
- data/lib/bibtex/entry.rb +80 -84
- data/lib/bibtex/entry/citeproc_converter.rb +47 -52
- data/lib/bibtex/entry/rdf_converter.rb +97 -63
- data/lib/bibtex/error.rb +10 -11
- data/lib/bibtex/extensions.rb +2 -5
- data/lib/bibtex/filters.rb +4 -9
- data/lib/bibtex/filters/latex.rb +0 -2
- data/lib/bibtex/filters/linebreaks.rb +0 -2
- data/lib/bibtex/lexer.rb +81 -81
- data/lib/bibtex/names.rb +24 -28
- data/lib/bibtex/replaceable.rb +15 -17
- data/lib/bibtex/utilities.rb +5 -10
- data/lib/bibtex/value.rb +28 -34
- data/lib/bibtex/version.rb +6 -6
- data/test/benchmark.rb +20 -22
- data/test/bibtex/entry/test_rdf_converter.rb +3 -5
- data/test/bibtex/test_bibliography.rb +22 -35
- data/test/bibtex/test_elements.rb +7 -15
- data/test/bibtex/test_entry.rb +78 -87
- data/test/bibtex/test_filters.rb +8 -7
- data/test/bibtex/test_lexer.rb +10 -13
- data/test/bibtex/test_name_parser.rb +6 -9
- data/test/bibtex/test_names.rb +50 -55
- data/test/bibtex/test_parser.rb +30 -34
- data/test/bibtex/test_string.rb +8 -9
- data/test/bibtex/test_utilities.rb +6 -9
- data/test/bibtex/test_value.rb +41 -43
- data/test/helper.rb +3 -6
- data/test/macruby.rb +12 -13
- data/test/profile.rb +16 -16
- data/test/test_bibtex.rb +10 -15
- data/test/test_export.rb +5 -13
- metadata +4 -4
data/test/bibtex/test_string.rb
CHANGED
@@ -2,11 +2,10 @@ require 'helper.rb'
|
|
2
2
|
|
3
3
|
module BibTeX
|
4
4
|
class StringTest < Minitest::Spec
|
5
|
-
|
6
5
|
describe 'when parsing a simple string' do
|
7
6
|
before do
|
8
7
|
@bib = BibTeX.parse('@string{ foo = "bar" }')
|
9
|
-
end
|
8
|
+
end
|
10
9
|
it 'should should not be empty' do
|
11
10
|
assert_equal 1, @bib.length
|
12
11
|
end
|
@@ -21,14 +20,14 @@ module BibTeX
|
|
21
20
|
end
|
22
21
|
end
|
23
22
|
|
24
|
-
#
|
23
|
+
#
|
25
24
|
# def test_replacement
|
26
25
|
# bib = BibTeX::Bibliography.open(Test.fixtures(:string_replacement), :debug => false)
|
27
26
|
# refute_nil(bib)
|
28
27
|
# assert(bib.kind_of?(BibTeX::Bibliography))
|
29
28
|
# refute(bib.empty?)
|
30
29
|
# assert_equal(7,bib.length)
|
31
|
-
# assert_equal([BibTeX::String,BibTeX::Preamble,BibTeX::Entry], bib.data.map(&:class).uniq)
|
30
|
+
# assert_equal([BibTeX::String,BibTeX::Preamble,BibTeX::Entry], bib.data.map(&:class).uniq)
|
32
31
|
# assert_equal(["foo"], bib.strings[:foo])
|
33
32
|
# assert_equal(["bar"], bib.strings[:bar])
|
34
33
|
# assert_equal([:foo, "bar"], bib.strings[:foobar])
|
@@ -36,7 +35,7 @@ module BibTeX
|
|
36
35
|
# assert_equal([:bar, "foo", :bar], bib.strings[:barfoobar])
|
37
36
|
# assert_equal('"foo" # foo # foobarfoo # "bar"', bib.preambles[0].content)
|
38
37
|
# assert_equal('"foo" # barfoobar', bib[:'manual:1'].title)
|
39
|
-
#
|
38
|
+
#
|
40
39
|
# bib.replace_strings({ :filter => [:preamble]})
|
41
40
|
# assert_equal(["foo"], bib.strings[:foo])
|
42
41
|
# assert_equal(["bar"], bib.strings[:bar])
|
@@ -45,19 +44,19 @@ module BibTeX
|
|
45
44
|
# assert_equal([:bar, "foo", :bar], bib.strings[:barfoobar])
|
46
45
|
# assert_equal('"foo" # "foo" # foobar # foo # "bar"', bib.preambles[0].content)
|
47
46
|
# assert_equal('"foo" # barfoobar', bib[:'manual:1'].title)
|
48
|
-
#
|
47
|
+
#
|
49
48
|
# bib.replace_strings({ :filter => [:string]})
|
50
49
|
# assert_equal(['foo','bar'], bib.strings[:foobar])
|
51
50
|
# assert_equal(['foo', 'bar','foo'], bib.strings[:foobarfoo])
|
52
51
|
# assert_equal(['bar','foo','bar'], bib.strings[:barfoobar])
|
53
52
|
# assert_equal('"foo" # "foo" # foobar # foo # "bar"', bib.preambles[0].content)
|
54
53
|
# assert_equal('"foo" # barfoobar', bib[:'manual:1'].title)
|
55
|
-
#
|
54
|
+
#
|
56
55
|
# bib.replace_strings({ :filter => [:preamble,:entry]})
|
57
56
|
# assert_equal('"foo" # "foo" # "foo" # "bar" # "foo" # "bar"', bib.preambles[0].content)
|
58
57
|
# assert_equal('"foo" # "bar" # "foo" # "bar"', bib[:'manual:1'].title)
|
59
58
|
# end
|
60
|
-
#
|
59
|
+
#
|
61
60
|
# def test_roundtrip
|
62
61
|
# bib = BibTeX::Bibliography.open(Test.fixtures(:string_replacement), :debug => false)
|
63
62
|
# refute_nil(bib)
|
@@ -80,4 +79,4 @@ module BibTeX
|
|
80
79
|
# assert_equal('@string{ barfoobar = "barfoobar" }', bib.data[4].to_s)
|
81
80
|
# end
|
82
81
|
end
|
83
|
-
end
|
82
|
+
end
|
@@ -1,16 +1,14 @@
|
|
1
1
|
require 'helper.rb'
|
2
2
|
|
3
3
|
module BibTeX
|
4
|
-
|
5
4
|
class TestBibtex < Minitest::Unit::TestCase
|
6
|
-
|
7
5
|
def test_empty?
|
8
6
|
assert BibTeX.open(Test.fixtures(:empty)).empty?
|
9
7
|
refute BibTeX.open(Test.fixtures(:bibdesk)).empty?
|
10
8
|
end
|
11
9
|
|
12
10
|
def test_parse
|
13
|
-
bib = BibTeX.parse
|
11
|
+
bib = BibTeX.parse ' @book{ id, author = {Poe, Edgar Allen}, title = "Ligeia" } '
|
14
12
|
assert_equal 1, bib.length
|
15
13
|
assert_equal 'Ligeia', bib[:id].title
|
16
14
|
assert_equal 'Poe, Edgar Allen', bib[:id].author.to_s
|
@@ -20,15 +18,14 @@ module BibTeX
|
|
20
18
|
log_level = BibTeX.log.level
|
21
19
|
BibTeX.log.level = Logger::ERROR
|
22
20
|
|
23
|
-
refute BibTeX.parse(
|
24
|
-
assert BibTeX.parse(
|
25
|
-
assert BibTeX.parse(
|
26
|
-
refute BibTeX.parse(
|
27
|
-
refute BibTeX.parse(
|
21
|
+
refute BibTeX.parse(' @book{ id, author = {Poe, Edgar Allen}, title = "Ligeia" } ').valid?
|
22
|
+
assert BibTeX.parse(' @book{ id, author = {Poe, Edgar Allen}, title = "Ligeia", publisher = "Penguin", year = 1996 } ').valid?
|
23
|
+
assert BibTeX.parse(' @book{ id, editor = {Poe, Edgar Allen}, title = "Ligeia", publisher = "Penguin", year = 1996 } ').valid?
|
24
|
+
refute BibTeX.parse(' @book{ id, xxxxxx = {Poe, Edgar Allen}, title = "Ligeia", publisher = "Penguin", year = 1996 } ').valid?
|
25
|
+
refute BibTeX.parse(' @book{ id, author = {Poe, Edgar Allen}, title = "Lig"eia", publisher = "Penguin", year = 1996 } ').valid?
|
28
26
|
assert BibTeX.valid?(Test.fixtures(:bibdesk))
|
29
27
|
|
30
28
|
BibTeX.log.level = log_level
|
31
29
|
end
|
32
30
|
end
|
33
|
-
|
34
31
|
end
|
data/test/bibtex/test_value.rb
CHANGED
@@ -14,59 +14,58 @@ end
|
|
14
14
|
|
15
15
|
module BibTeX
|
16
16
|
class ValueTest < Minitest::Spec
|
17
|
-
|
18
|
-
|
19
|
-
it "should return a duplicate when called with a Value subclass" do
|
17
|
+
describe '::create' do
|
18
|
+
it 'should return a duplicate when called with a Value subclass' do
|
20
19
|
val = Value.new('value')
|
21
|
-
names = Names.new(Name.new(:
|
20
|
+
names = Names.new(Name.new(first: 'first_name'))
|
22
21
|
|
23
22
|
assert_equal val.dup, Value.create(val)
|
24
23
|
assert_equal names.dup, Value.create(names)
|
25
24
|
end
|
26
25
|
|
27
|
-
it
|
26
|
+
it 'should return a new Value object when called with other arguments' do
|
28
27
|
assert_equal Value.new('value'), Value.create('value')
|
29
28
|
end
|
30
29
|
end
|
31
30
|
|
32
|
-
describe
|
33
|
-
it
|
31
|
+
describe 'when empty' do
|
32
|
+
it 'should be equal to an empty string' do
|
34
33
|
assert Value.new == ''
|
35
34
|
assert Value.new('') == ''
|
36
35
|
end
|
37
|
-
it
|
36
|
+
it 'should be empty' do
|
38
37
|
assert Value.new.empty?
|
39
38
|
assert Value.new('').empty?
|
40
39
|
end
|
41
|
-
it
|
40
|
+
it 'should match an empty pattern' do
|
42
41
|
assert Value.new =~ //
|
43
42
|
assert Value.new('') =~ //
|
44
43
|
end
|
45
44
|
end
|
46
45
|
|
47
|
-
describe
|
48
|
-
it
|
46
|
+
describe '#join' do
|
47
|
+
it 'should return empty string when empty' do
|
49
48
|
assert_equal '', Value.new.join.to_s
|
50
49
|
assert_equal '', Value.new('').join.to_s
|
51
50
|
end
|
52
|
-
it
|
51
|
+
it 'should return the string if atomic' do
|
53
52
|
assert_equal 'foo', Value.new('foo').join.to_s
|
54
53
|
end
|
55
|
-
it
|
54
|
+
it 'should return a string concatenation of all strings when containing only strings' do
|
56
55
|
assert_equal 'foobar', Value.new('foo', 'bar').join.to_s
|
57
|
-
assert_equal 'foobar', Value.new([
|
56
|
+
assert_equal 'foobar', Value.new(%w[foo bar]).join.to_s
|
58
57
|
end
|
59
|
-
it
|
58
|
+
it 'should should be atomic after join when containing only strings' do
|
60
59
|
refute Value.new('foo', 'bar').atomic?
|
61
60
|
assert Value.new('foo', 'bar').join.atomic?
|
62
61
|
end
|
63
|
-
it
|
62
|
+
it 'should do nothing when containing only symbols' do
|
64
63
|
value = Value.new(:foo)
|
65
64
|
assert_equal value, value.join
|
66
65
|
value = Value.new(:foo, :bar)
|
67
66
|
assert_equal value, value.join
|
68
67
|
end
|
69
|
-
it
|
68
|
+
it 'should do nothing when containing only symbols and a single string' do
|
70
69
|
value = Value.new(:foo, 'bar')
|
71
70
|
assert_equal value, value.join
|
72
71
|
value = Value.new('foo', :bar)
|
@@ -84,65 +83,65 @@ module BibTeX
|
|
84
83
|
end
|
85
84
|
end
|
86
85
|
|
87
|
-
describe
|
88
|
-
it
|
86
|
+
describe '#to_s' do
|
87
|
+
it 'should return the string if atomic' do
|
89
88
|
assert_equal 'foo bar', Value.new('foo bar').to_s
|
90
89
|
end
|
91
|
-
it
|
90
|
+
it 'should return the symbol as string when containing only a single symbol' do
|
92
91
|
assert_equal 'foo', Value.new(:foo).to_s
|
93
92
|
end
|
94
|
-
it
|
93
|
+
it 'should return all string tokens concatenated by #' do
|
95
94
|
assert_equal '"foo" # "bar"', Value.new('foo', 'bar').to_s
|
96
95
|
end
|
97
|
-
it
|
96
|
+
it 'should return all symbol tokens concatenated by #' do
|
98
97
|
assert_equal 'foo # bar', Value.new(:foo, :bar).to_s
|
99
98
|
end
|
100
|
-
it
|
99
|
+
it 'should return all symbol and string tokens concatenated by #' do
|
101
100
|
assert_equal 'foo # "bar"', Value.new(:foo, 'bar').to_s
|
102
101
|
assert_equal '"foo" # bar', Value.new('foo', :bar).to_s
|
103
102
|
end
|
104
103
|
end
|
105
104
|
|
106
|
-
describe
|
105
|
+
describe 'conversions' do
|
107
106
|
before do
|
108
107
|
@values = [Value.new('foo'), Value.new('foo', :bar)]
|
109
108
|
end
|
110
109
|
|
111
|
-
describe
|
112
|
-
it
|
110
|
+
describe '#convert' do
|
111
|
+
it 'converts the value when given a filter instance' do
|
113
112
|
assert_equal ['FOO', '"FOO" # bar'], @values.map { |v| v.convert(Upcase.instance).to_s }
|
114
113
|
end
|
115
114
|
|
116
|
-
it
|
115
|
+
it 'converts the value when given a filter class' do
|
117
116
|
assert_equal ['FOO', '"FOO" # bar'], @values.map { |v| v.convert(Upcase).to_s }
|
118
117
|
end
|
119
118
|
|
120
|
-
it
|
119
|
+
it 'converts the value when given the name of a filter' do
|
121
120
|
assert_equal ['FOO', '"FOO" # bar'], @values.map { |v| v.convert(:upcase).to_s }
|
122
121
|
assert_equal ['FOO', '"FOO" # bar'], @values.map { |v| v.convert('upcase').to_s }
|
123
122
|
assert_equal ['fooa', '"fooa" # bar'], @values.map { |v| v.convert('suffixa').to_s }
|
124
123
|
end
|
125
124
|
|
126
|
-
it
|
125
|
+
it 'applies multiple filters in the order passed' do
|
127
126
|
@values.map { |v| v.convert(:upcase, :suffixa).to_s }.must_equal ['FOOa', '"FOOa" # bar']
|
128
127
|
@values.map { |v| v.convert(:suffixa, :upcase).to_s }.must_equal ['FOOA', '"FOOA" # bar']
|
129
128
|
end
|
130
129
|
|
131
|
-
it
|
130
|
+
it 'converts the value when using a ghost method' do
|
132
131
|
assert_equal ['FOO', '"FOO" # bar'], @values.map { |v| v.convert_upcase.to_s }
|
133
132
|
end
|
134
133
|
|
135
|
-
it
|
134
|
+
it 'does not alter the value when using a filter name' do
|
136
135
|
@values.each { |v| v.convert(:upcase) }
|
137
136
|
assert_equal ['foo', '"foo" # bar'], @values.map(&:to_s)
|
138
137
|
end
|
139
138
|
|
140
|
-
it
|
141
|
-
@values.each
|
139
|
+
it 'does not alter the value when using a ghost method' do
|
140
|
+
@values.each(&:convert_upcase)
|
142
141
|
assert_equal ['foo', '"foo" # bar'], @values.map(&:to_s)
|
143
142
|
end
|
144
143
|
|
145
|
-
it
|
144
|
+
it 'raises argument error when a filter cannot be resolved' do
|
146
145
|
assert_raises ArgumentError do
|
147
146
|
@values[0].convert(:foo)
|
148
147
|
end
|
@@ -153,23 +152,23 @@ module BibTeX
|
|
153
152
|
end
|
154
153
|
end
|
155
154
|
|
156
|
-
describe
|
157
|
-
it
|
155
|
+
describe '#convert!' do
|
156
|
+
it 'converts the value when given the name of a filter' do
|
158
157
|
assert_equal ['FOO', '"FOO" # bar'], @values.map { |v| v.convert!(:upcase).to_s }
|
159
158
|
end
|
160
159
|
|
161
|
-
it
|
160
|
+
it 'alters the value when given the name of a filter' do
|
162
161
|
@values.each { |v| v.convert!(:upcase) }
|
163
162
|
assert_equal ['FOO', '"FOO" # bar'], @values.map(&:to_s)
|
164
163
|
end
|
165
164
|
|
166
|
-
it
|
167
|
-
@values.each
|
165
|
+
it 'alters the value when using a ghost method' do
|
166
|
+
@values.each(&:convert_upcase!)
|
168
167
|
assert_equal ['FOO', '"FOO" # bar'], @values.map(&:to_s)
|
169
168
|
end
|
170
169
|
end
|
171
170
|
|
172
|
-
describe
|
171
|
+
describe 'value' do
|
173
172
|
it 'returns numbers as strings' do
|
174
173
|
assert Value.new(42).v.is_a?(::String)
|
175
174
|
assert Value.new(-42).v.is_a?(::String)
|
@@ -177,13 +176,12 @@ module BibTeX
|
|
177
176
|
end
|
178
177
|
end
|
179
178
|
|
180
|
-
describe
|
179
|
+
describe '#to_s' do
|
181
180
|
it 'accepts a :filter option and convert the values accordingly without changing the value' do
|
182
|
-
assert_equal '"FOO" # bar', @values[1].to_s(:
|
181
|
+
assert_equal '"FOO" # bar', @values[1].to_s(filter: :upcase)
|
183
182
|
assert_equal '"foo" # bar', @values[1].to_s
|
184
183
|
end
|
185
184
|
end
|
186
185
|
end
|
187
|
-
|
188
186
|
end
|
189
187
|
end
|
data/test/helper.rb
CHANGED
@@ -6,13 +6,12 @@ rescue LoadError
|
|
6
6
|
end
|
7
7
|
|
8
8
|
begin
|
9
|
-
|
10
|
-
when RUBY_PLATFORM < 'java'
|
9
|
+
if RUBY_PLATFORM < 'java'
|
11
10
|
require 'debug'
|
12
11
|
Debugger.start
|
13
|
-
|
12
|
+
elsif defined?(RUBY_ENGINE) && RUBY_ENGINE == 'rbx'
|
14
13
|
require 'rubinius/debugger'
|
15
|
-
|
14
|
+
elsif defined?(RUBY_VERSION) && RUBY_VERSION < '2.0'
|
16
15
|
require 'debugger'
|
17
16
|
else
|
18
17
|
require 'byebug'
|
@@ -32,12 +31,10 @@ require 'bibtex'
|
|
32
31
|
|
33
32
|
module BibTeX
|
34
33
|
module Test
|
35
|
-
|
36
34
|
class << self
|
37
35
|
def fixtures(name)
|
38
36
|
File.expand_path("../fixtures/#{name}.bib", __FILE__)
|
39
37
|
end
|
40
38
|
end
|
41
|
-
|
42
39
|
end
|
43
40
|
end
|
data/test/macruby.rb
CHANGED
@@ -1,20 +1,19 @@
|
|
1
|
-
|
2
1
|
# sudo dtrace -qs test/macruby.d -c "macruby -Ilib -rrubygems test/macruby.rb"
|
3
2
|
|
4
3
|
require 'bibtex'
|
5
4
|
|
6
|
-
input =
|
7
|
-
@book{pickaxe,
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
}
|
5
|
+
input = <<~END
|
6
|
+
@book{pickaxe,
|
7
|
+
Address = {Raleigh, North Carolina},
|
8
|
+
Author = {Thomas, Dave, and Fowler, Chad, and Hunt, Andy},
|
9
|
+
Date-Added = {2010-08-05 09:54:07 +0200},
|
10
|
+
Date-Modified = {2010-08-05 10:07:01 +0200},
|
11
|
+
Keywords = {ruby},
|
12
|
+
Publisher = {The Pragmatic Bookshelf},
|
13
|
+
Series = {The Facets of Ruby},
|
14
|
+
Title = {Programming Ruby 1.9: The Pragmatic Programmer's Guide},
|
15
|
+
Year = {2009}
|
16
|
+
}
|
18
17
|
END
|
19
18
|
|
20
19
|
lexer = BibTeX::Lexer.new
|
data/test/profile.rb
CHANGED
@@ -1,28 +1,28 @@
|
|
1
|
-
require File.expand_path('
|
1
|
+
require File.expand_path('../lib/bibtex.rb', __dir__)
|
2
2
|
|
3
3
|
require 'ruby-prof'
|
4
4
|
|
5
|
-
data =
|
6
|
-
@book{pickaxe,
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
}
|
5
|
+
data = <<~END
|
6
|
+
@book{pickaxe,
|
7
|
+
Address = {Raleigh, North Carolina},
|
8
|
+
Author = "Thomas, Dave, and Fowler, Chad, and Hunt, Andy",
|
9
|
+
Date-Added = {2010-08-05 09:54:07 +0200},
|
10
|
+
Date-Modified = {2010-08-05 10:07:01 +0200},
|
11
|
+
Keywords = {ruby},
|
12
|
+
Publisher = {The Pragmatic Bookshelf},
|
13
|
+
Series = {The Facets of Ruby},
|
14
|
+
Title = {Programming Ruby 1.9: The Pragmatic Programmer's Guide},
|
15
|
+
Year = {2009}
|
16
|
+
}
|
17
17
|
END
|
18
18
|
|
19
|
-
data
|
19
|
+
data *= 50
|
20
20
|
# data = File.open(File.expand_path('../fixtures/benchmark.bib', __FILE__)).read
|
21
21
|
|
22
22
|
result = RubyProf.profile do
|
23
|
-
|
23
|
+
BibTeX.parse(data)
|
24
24
|
# BibTeX::Lexer.new.analyse(data)
|
25
25
|
end
|
26
26
|
|
27
27
|
printer = RubyProf::DotPrinter.new(result)
|
28
|
-
printer.print(File.open(File.expand_path('
|
28
|
+
printer.print(File.open(File.expand_path('profile.dot', __dir__), 'w'), min_percent: 5)
|
data/test/test_bibtex.rb
CHANGED
@@ -3,31 +3,28 @@ require 'timeout'
|
|
3
3
|
|
4
4
|
module BibTeX
|
5
5
|
class TestBibtex < Minitest::Unit::TestCase
|
6
|
+
def setup; end
|
6
7
|
|
7
|
-
def
|
8
|
-
end
|
9
|
-
|
10
|
-
def teardown
|
11
|
-
end
|
8
|
+
def teardown; end
|
12
9
|
|
13
10
|
def test_empty
|
14
|
-
bib = BibTeX::Bibliography.open(Test.fixtures(:empty), :
|
11
|
+
bib = BibTeX::Bibliography.open(Test.fixtures(:empty), debug: false)
|
15
12
|
refute_nil(bib)
|
16
13
|
assert_equal(BibTeX::Bibliography, bib.class)
|
17
14
|
assert(bib.empty?)
|
18
15
|
end
|
19
16
|
|
20
17
|
def test_no_bibtex
|
21
|
-
bib = BibTeX::Bibliography.open(Test.fixtures(:no_bibtex), :
|
18
|
+
bib = BibTeX::Bibliography.open(Test.fixtures(:no_bibtex), debug: false)
|
22
19
|
refute_nil(bib)
|
23
20
|
assert_equal(BibTeX::Bibliography, bib.class)
|
24
21
|
assert(bib.empty?)
|
25
22
|
end
|
26
23
|
|
27
24
|
def test_decoret
|
28
|
-
bib = BibTeX::Bibliography.open(Test.fixtures(:decoret), :
|
25
|
+
bib = BibTeX::Bibliography.open(Test.fixtures(:decoret), debug: false)
|
29
26
|
assert_equal(15, bib.length)
|
30
|
-
assert_equal([BibTeX::Entry,BibTeX::Comment,BibTeX::String,BibTeX::Preamble], bib.data.map(&:class).uniq)
|
27
|
+
assert_equal([BibTeX::Entry, BibTeX::Comment, BibTeX::String, BibTeX::Preamble], bib.data.map(&:class).uniq)
|
31
28
|
assert_equal('py03', bib.data[0].key)
|
32
29
|
assert_equal(:article, bib[:py03].type)
|
33
30
|
assert_equal("D\\'ecoret, Xavier", bib[:py03][:author].to_s)
|
@@ -35,7 +32,7 @@ module BibTeX
|
|
35
32
|
assert_equal('2003', bib[:py03][:year])
|
36
33
|
assert_equal(:article, bib[:key03].type)
|
37
34
|
assert_equal('A {bunch {of} braces {in}} title', bib[:key03][:title])
|
38
|
-
#TODO missing assertions
|
35
|
+
# TODO: missing assertions
|
39
36
|
end
|
40
37
|
|
41
38
|
# def test_errors
|
@@ -44,7 +41,7 @@ module BibTeX
|
|
44
41
|
# end
|
45
42
|
|
46
43
|
def test_bibdesk
|
47
|
-
bib = BibTeX::Bibliography.open(Test.fixtures(:bibdesk), :
|
44
|
+
bib = BibTeX::Bibliography.open(Test.fixtures(:bibdesk), debug: false)
|
48
45
|
assert_equal 3, bib.length
|
49
46
|
assert_equal 'rails', bib[0].key
|
50
47
|
assert_equal '2010-08-05 10:06:32 +0200', bib[:dragon]['date-modified']
|
@@ -77,7 +74,7 @@ module BibTeX
|
|
77
74
|
|
78
75
|
def test_parse
|
79
76
|
bib = BibTeX::Bibliography.new
|
80
|
-
bib.add(BibTeX::Element.parse(
|
77
|
+
bib.add(BibTeX::Element.parse(' @string{ pragprog = "The Pragmatic Bookshelf" } '))
|
81
78
|
bib.add(BibTeX::Element.parse(<<-END))
|
82
79
|
@book{rails,
|
83
80
|
address = {Raleigh, North Carolina},
|
@@ -95,7 +92,7 @@ module BibTeX
|
|
95
92
|
assert_equal(2, bib.length)
|
96
93
|
refute_nil(bib[:rails])
|
97
94
|
bib.replace_strings
|
98
|
-
|
95
|
+
assert_equal 'The Pragmatic Bookshelf', bib['rails'].publisher
|
99
96
|
end
|
100
97
|
|
101
98
|
def test_logger_can_be_assigned
|
@@ -121,7 +118,5 @@ EOF
|
|
121
118
|
EOF
|
122
119
|
end
|
123
120
|
end
|
124
|
-
|
125
121
|
end
|
126
|
-
|
127
122
|
end
|