bibtex-ruby 1.1.2 → 1.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.
Potentially problematic release.
This version of bibtex-ruby might be problematic. Click here for more details.
- data/Gemfile +2 -0
- data/Gemfile.lock +20 -0
- data/Manifest +9 -2
- data/README.md +146 -68
- data/Rakefile +13 -54
- data/bibtex-ruby.gemspec +36 -0
- data/examples/bib2html.rb +2 -2
- data/examples/bib2yaml.rb +1 -1
- data/lib/bibtex.rb +6 -1
- data/lib/bibtex/bibliography.rb +23 -7
- data/lib/bibtex/bibtex.y +1 -1
- data/lib/bibtex/elements.rb +57 -41
- data/lib/bibtex/entry.rb +32 -24
- data/lib/bibtex/extensions.rb +60 -0
- data/lib/bibtex/parser.rb +1 -1
- data/lib/bibtex/utilities.rb +38 -0
- data/lib/bibtex/version.rb +1 -1
- data/test/bib/03_string.bib +0 -1
- data/test/bib/11_roundtrip.bib +11 -0
- data/test/helper.rb +4 -0
- data/test/test_bibtex.rb +60 -10
- data/test/test_comment.rb +1 -4
- data/test/test_entry.rb +11 -14
- data/test/test_export.rb +2 -4
- data/test/test_preamble.rb +25 -10
- data/test/test_string.rb +55 -35
- data/test/test_utilities.rb +36 -0
- metadata +21 -53
- data.tar.gz.sig +0 -0
- data/lib/bibtex/string_replacement.rb +0 -43
- metadata.gz.sig +0 -0
@@ -0,0 +1,60 @@
|
|
1
|
+
#--
|
2
|
+
# BibTeX-Ruby
|
3
|
+
# Copyright (C) 2011 Sylvester Keil <sylvester.keil.or.at>
|
4
|
+
#
|
5
|
+
# This program is free software: you can redistribute it and/or modify
|
6
|
+
# it under the terms of the GNU General Public License as published by
|
7
|
+
# the Free Software Foundation, either version 3 of the License, or
|
8
|
+
# (at your option) any later version.
|
9
|
+
#
|
10
|
+
# This program is distributed in the hope that it will be useful,
|
11
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
13
|
+
# GNU General Public License for more details.
|
14
|
+
#
|
15
|
+
# You should have received a copy of the GNU General Public License
|
16
|
+
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
17
|
+
#++
|
18
|
+
|
19
|
+
module BibTeX
|
20
|
+
|
21
|
+
# This module contains functions to manipulate BibTeX string literals.
|
22
|
+
# It is intended to be injected in an Array that represents either the
|
23
|
+
# content of a BibTeX @string or an rvalue of a field in a BibTeX entry.
|
24
|
+
module Extensions
|
25
|
+
|
26
|
+
def self.string_replacement(obj)
|
27
|
+
raise(ArgumentError, "StringReplacement should only be injected into instances of Array, not #{obj.class}.") unless obj.is_a?(Array)
|
28
|
+
class << obj; include StringReplacement end
|
29
|
+
obj
|
30
|
+
end
|
31
|
+
|
32
|
+
module StringReplacement
|
33
|
+
# Returns a string representation of the literal.
|
34
|
+
def to_s(options={})
|
35
|
+
return '' if self.empty?
|
36
|
+
|
37
|
+
options[:quotes] ||= [nil,nil]
|
38
|
+
|
39
|
+
if self.length == 1 && !self[0].is_a?(Symbol)
|
40
|
+
[options[:quotes][0], self[0], options[:quotes][1]].join
|
41
|
+
else
|
42
|
+
self.map { |s| s.is_a?(Symbol) ? s.to_s : %Q("#{ s }") }.join(' # ')
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
# Replaces all string constants which are defined in +hash+.
|
47
|
+
def replace_strings(hash)
|
48
|
+
Extensions.string_replacement(self.map { |s| s.is_a?(Symbol) && hash.has_key?(s) ? hash[s] : s }.flatten)
|
49
|
+
end
|
50
|
+
|
51
|
+
# Joins consecutive strings separated by '#'.
|
52
|
+
def join_strings
|
53
|
+
Extensions.string_replacement(self.inject([]) { |a,b|
|
54
|
+
a << (a.last.is_a?(::String) && b.is_a?(::String) ? (a.pop + b) : b )
|
55
|
+
})
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
end
|
data/lib/bibtex/parser.rb
CHANGED
@@ -398,7 +398,7 @@ module_eval(<<'.,.,', 'bibtex.y', 66)
|
|
398
398
|
|
399
399
|
module_eval(<<'.,.,', 'bibtex.y', 68)
|
400
400
|
def _reduce_25(val, _values, result)
|
401
|
-
result = BibTeX::Entry.new(val[0].downcase.to_sym,val[2])
|
401
|
+
result = BibTeX::Entry.new(:type => val[0].downcase.to_sym, :key => val[2])
|
402
402
|
result
|
403
403
|
end
|
404
404
|
.,.,
|
@@ -0,0 +1,38 @@
|
|
1
|
+
#--
|
2
|
+
# BibTeX-Ruby
|
3
|
+
# Copyright (C) 2011 Sylvester Keil <sylvester.keil.or.at>
|
4
|
+
#
|
5
|
+
# This program is free software: you can redistribute it and/or modify
|
6
|
+
# it under the terms of the GNU General Public License as published by
|
7
|
+
# the Free Software Foundation, either version 3 of the License, or
|
8
|
+
# (at your option) any later version.
|
9
|
+
#
|
10
|
+
# This program is distributed in the hope that it will be useful,
|
11
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
13
|
+
# GNU General Public License for more details.
|
14
|
+
#
|
15
|
+
# You should have received a copy of the GNU General Public License
|
16
|
+
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
17
|
+
#++
|
18
|
+
|
19
|
+
module BibTeX
|
20
|
+
|
21
|
+
class << self
|
22
|
+
# Opens a BibTeX file and returns a corresponding +Bibliography+ object.
|
23
|
+
def open(file, options={})
|
24
|
+
Bibliography.open(file, options)
|
25
|
+
end
|
26
|
+
|
27
|
+
# Parses the given string and returns a corresponding +Bibliography+ object.
|
28
|
+
def parse(string, options={})
|
29
|
+
BibTeX::Parser.new(options).parse(string)
|
30
|
+
end
|
31
|
+
|
32
|
+
# Returns true if the given file is a valid BibTeX bibliography.
|
33
|
+
def valid?(file)
|
34
|
+
Bibliography.open(file).valid?
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
data/lib/bibtex/version.rb
CHANGED
data/test/bib/03_string.bib
CHANGED
@@ -0,0 +1,11 @@
|
|
1
|
+
@book{rails,
|
2
|
+
address = {Raleigh, North Carolina},
|
3
|
+
author = {Ruby, Sam, and Thomas, Dave, and Hansson, David Heinemeier},
|
4
|
+
booktitle = {Agile Web Development with Rails},
|
5
|
+
edition = {third},
|
6
|
+
keywords = {ruby, rails},
|
7
|
+
publisher = {The Pragmatic Bookshelf},
|
8
|
+
series = {The Facets of Ruby},
|
9
|
+
title = {Agile Web Development with Rails},
|
10
|
+
year = {2009}
|
11
|
+
}
|
data/test/helper.rb
ADDED
data/test/test_bibtex.rb
CHANGED
@@ -1,7 +1,4 @@
|
|
1
|
-
require
|
2
|
-
require 'rubygems'
|
3
|
-
require 'minitest/unit'
|
4
|
-
require 'minitest/autorun'
|
1
|
+
require 'helper.rb'
|
5
2
|
|
6
3
|
class TestBibtex < MiniTest::Unit::TestCase
|
7
4
|
|
@@ -33,16 +30,16 @@ class TestBibtex < MiniTest::Unit::TestCase
|
|
33
30
|
assert_equal([BibTeX::Entry,BibTeX::Comment,BibTeX::String,BibTeX::Preamble], bib.data.map(&:class).uniq)
|
34
31
|
assert_equal('py03', bib.data[0].key)
|
35
32
|
assert_equal(:article, bib['py03'].type)
|
36
|
-
assert_equal(
|
37
|
-
assert_equal(
|
38
|
-
assert_equal(
|
33
|
+
assert_equal("Xavier D\\'ecoret", bib['py03'][:author])
|
34
|
+
assert_equal('PyBiTex', bib['py03'][:title])
|
35
|
+
assert_equal('2003', bib['py03'][:year])
|
39
36
|
assert_equal(:article, bib['key03'].type)
|
40
|
-
assert_equal(
|
37
|
+
assert_equal('A {bunch {of} braces {in}} title', bib['key03'][:title])
|
41
38
|
#TODO missing assertions
|
42
39
|
end
|
43
40
|
|
44
41
|
def test_errors
|
45
|
-
bib = BibTeX
|
42
|
+
bib = BibTeX.open('test/bib/09_errors.bib', :debug => true)
|
46
43
|
#refute_nil(bib)
|
47
44
|
end
|
48
45
|
|
@@ -52,7 +49,60 @@ class TestBibtex < MiniTest::Unit::TestCase
|
|
52
49
|
assert_equal(BibTeX::Bibliography, bib.class)
|
53
50
|
assert_equal(3, bib.length)
|
54
51
|
assert_equal('rails', bib.data[0].key)
|
55
|
-
assert_equal(
|
52
|
+
assert_equal('2010-08-05 10:06:32 +0200', bib[:dragon]['date-modified'])
|
53
|
+
end
|
54
|
+
|
55
|
+
def test_roundtrip
|
56
|
+
file = File.read('test/bib/11_roundtrip.bib')
|
57
|
+
bib = BibTeX.parse(file, :debug => true)
|
58
|
+
refute_nil(bib)
|
59
|
+
assert_equal(BibTeX::Bibliography, bib.class)
|
60
|
+
assert_equal(1, bib.length)
|
61
|
+
assert_equal(file.gsub(/[\s]+/, ''), bib.to_s.gsub(/[\s]+/, ''))
|
62
|
+
end
|
63
|
+
|
64
|
+
def test_construct
|
65
|
+
file = File.read('test/bib/11_roundtrip.bib')
|
66
|
+
bib = BibTeX::Bibliography.new
|
67
|
+
bib << BibTeX::Entry.new({
|
68
|
+
:type => :book,
|
69
|
+
:key => 'rails',
|
70
|
+
:address => 'Raleigh, North Carolina',
|
71
|
+
:author => 'Ruby, Sam, and Thomas, Dave, and Hansson, David Heinemeier',
|
72
|
+
:booktitle => 'Agile Web Development with Rails',
|
73
|
+
:edition => 'third',
|
74
|
+
:keywords => 'ruby, rails',
|
75
|
+
:publisher => 'The Pragmatic Bookshelf',
|
76
|
+
:series => 'The Facets of Ruby',
|
77
|
+
:title => 'Agile Web Development with Rails',
|
78
|
+
:year => '2009'
|
79
|
+
})
|
80
|
+
assert_equal(file.gsub(/[\s]+/, ''), bib.to_s.gsub(/[\s]+/, ''))
|
81
|
+
end
|
82
|
+
|
83
|
+
def test_parse
|
84
|
+
file = File.read('test/bib/11_roundtrip.bib')
|
85
|
+
bib = BibTeX::Bibliography.new
|
86
|
+
bib.add(BibTeX::Element.parse(%q( @string{ pragprog = "The Pragmatic Booksehlf" } )))
|
87
|
+
bib.add(BibTeX::Element.parse(<<-END
|
88
|
+
@book{rails,
|
89
|
+
address = {Raleigh, North Carolina},
|
90
|
+
author = {Ruby, Sam, and Thomas, Dave, and Hansson, David Heinemeier},
|
91
|
+
booktitle = {Agile Web Development with Rails},
|
92
|
+
edition = {third},
|
93
|
+
keywords = {ruby, rails},
|
94
|
+
publisher = {The Pragmatic Bookshelf},
|
95
|
+
series = {The Facets of Ruby},
|
96
|
+
title = {Agile Web Development with Rails},
|
97
|
+
year = {2009}
|
98
|
+
}
|
99
|
+
END
|
100
|
+
))
|
101
|
+
|
102
|
+
assert_equal(2, bib.length)
|
103
|
+
refute_nil(bib[:rails])
|
104
|
+
bib.replace_strings
|
105
|
+
assert_equal(file.gsub(/[\s]+/, ''), bib[:rails].to_s.gsub(/[\s]+/, ''))
|
56
106
|
end
|
57
107
|
end
|
58
108
|
|
data/test/test_comment.rb
CHANGED
data/test/test_entry.rb
CHANGED
@@ -1,7 +1,4 @@
|
|
1
|
-
require
|
2
|
-
require 'rubygems'
|
3
|
-
require 'minitest/unit'
|
4
|
-
require 'minitest/autorun'
|
1
|
+
require 'helper.rb'
|
5
2
|
|
6
3
|
class TestEntry < MiniTest::Unit::TestCase
|
7
4
|
|
@@ -23,23 +20,23 @@ class TestEntry < MiniTest::Unit::TestCase
|
|
23
20
|
assert_equal(:book, bib.data[0].type)
|
24
21
|
assert_equal(:article, bib.data[1].type)
|
25
22
|
assert_equal(:article, bib.data[2].type)
|
26
|
-
assert_equal(
|
27
|
-
assert_equal(
|
28
|
-
assert_equal(
|
29
|
-
assert_equal(
|
30
|
-
assert_equal(
|
31
|
-
assert_equal(
|
32
|
-
assert_equal(
|
33
|
-
assert_equal(
|
23
|
+
assert_equal('Poe, Edgar A.', bib.data[0][:author])
|
24
|
+
assert_equal('Hawthorne, Nathaniel', bib.data[1][:author])
|
25
|
+
assert_equal('2003', bib.data[0][:year])
|
26
|
+
assert_equal('2001', bib.data[1][:year])
|
27
|
+
assert_equal('American Library', bib.data[0][:publisher])
|
28
|
+
assert_equal('American Library', bib.data[1][:publisher])
|
29
|
+
assert_equal('Selected \\emph{Poetry} and `Tales\'', bib.data[0].title)
|
30
|
+
assert_equal('Tales and Sketches', bib.data[1].title)
|
34
31
|
end
|
35
32
|
|
36
33
|
def test_ghost_methods
|
37
34
|
bib = BibTeX::Bibliography.open('test/bib/07_entry.bib', :debug => true)
|
38
35
|
refute_nil(bib)
|
39
36
|
assert_equal(BibTeX::Bibliography, bib.class)
|
40
|
-
assert_equal(
|
37
|
+
assert_equal('Poe, Edgar A.', bib.data[0].author)
|
41
38
|
|
42
|
-
expected =
|
39
|
+
expected = 'Poe, Edgar Allen'
|
43
40
|
bib.data[0].author = expected
|
44
41
|
|
45
42
|
assert_equal(expected, bib.data[0].author)
|
data/test/test_export.rb
CHANGED
data/test/test_preamble.rb
CHANGED
@@ -1,24 +1,39 @@
|
|
1
|
-
require
|
2
|
-
require 'rubygems'
|
3
|
-
require 'minitest/unit'
|
4
|
-
require 'minitest/autorun'
|
1
|
+
require 'helper.rb'
|
5
2
|
|
6
3
|
class TestPreamble < MiniTest::Unit::TestCase
|
7
4
|
|
8
5
|
def setup
|
6
|
+
@bib = BibTeX::Bibliography.open('test/bib/06_preamble.bib', :debug => true, :strict => false)
|
9
7
|
end
|
10
8
|
|
11
9
|
def teardown
|
12
10
|
end
|
13
11
|
|
14
12
|
def test_simple
|
13
|
+
refute_nil(@bib)
|
14
|
+
assert_equal(BibTeX::Bibliography, @bib.class)
|
15
|
+
assert_equal(4, @bib.data.length)
|
16
|
+
assert_equal([BibTeX::Preamble,BibTeX::String], @bib.data.map(&:class).uniq)
|
17
|
+
assert_equal('"This bibliography was created \\today"', @bib.data[0].content)
|
18
|
+
assert_equal('"Bib\\TeX"', @bib.data[1].content)
|
19
|
+
assert_equal('"Maintained by " # maintainer', @bib.data[3].content)
|
20
|
+
end
|
21
|
+
|
22
|
+
def test_roundtrip
|
23
|
+
assert_equal(%q[@preamble{ "This bibliography was created \today" }], @bib.data[0].to_s)
|
24
|
+
assert_equal(%q[@preamble{ "Bib\TeX" }], @bib.data[1].to_s)
|
25
|
+
assert_equal(%q[@string{ maintainer = "Myself" }], @bib.data[2].to_s)
|
26
|
+
assert_equal(%q[@preamble{ "Maintained by " # maintainer }], @bib.data[3].to_s)
|
27
|
+
end
|
28
|
+
|
29
|
+
def test_replacement
|
15
30
|
bib = BibTeX::Bibliography.open('test/bib/06_preamble.bib', :debug => true, :strict => false)
|
16
31
|
refute_nil(bib)
|
17
|
-
assert_equal(
|
18
|
-
|
19
|
-
assert_equal(
|
20
|
-
assert_equal(["
|
21
|
-
|
22
|
-
assert_equal(["Maintained by "
|
32
|
+
assert_equal(%q[@preamble{ "Maintained by " # maintainer }], bib.data[3].to_s)
|
33
|
+
bib.replace_strings
|
34
|
+
assert_equal('"Maintained by " # "Myself"', bib.data[3].content)
|
35
|
+
assert_equal(%q[@preamble{ "Maintained by " # "Myself" }], bib.data[3].to_s)
|
36
|
+
bib.join_strings
|
37
|
+
assert_equal(%q[@preamble{ "Maintained by Myself" }], bib.data[3].to_s)
|
23
38
|
end
|
24
39
|
end
|
data/test/test_string.rb
CHANGED
@@ -1,7 +1,4 @@
|
|
1
|
-
require
|
2
|
-
require 'rubygems'
|
3
|
-
require 'minitest/unit'
|
4
|
-
require 'minitest/autorun'
|
1
|
+
require 'helper.rb'
|
5
2
|
|
6
3
|
class TestString < MiniTest::Unit::TestCase
|
7
4
|
|
@@ -17,9 +14,10 @@ class TestString < MiniTest::Unit::TestCase
|
|
17
14
|
assert(bib.kind_of? BibTeX::Bibliography)
|
18
15
|
refute(bib.empty?)
|
19
16
|
assert_equal(bib.data.length,1)
|
20
|
-
assert(bib.data.first.
|
21
|
-
assert_equal(bib.data.first.key
|
22
|
-
assert_equal(bib.data.first.value
|
17
|
+
assert(bib.data.first.is_a?(BibTeX::String))
|
18
|
+
assert_equal(:foo, bib.data.first.key)
|
19
|
+
assert_equal('"bar"', bib.data.first.value)
|
20
|
+
assert_equal(["bar"], bib.strings[:foo])
|
23
21
|
end
|
24
22
|
|
25
23
|
def test_assignment
|
@@ -30,13 +28,13 @@ class TestString < MiniTest::Unit::TestCase
|
|
30
28
|
assert_equal(bib.data.length,17)
|
31
29
|
assert_equal(bib.data.map(&:class).uniq, [BibTeX::String])
|
32
30
|
assert_equal(bib.data.map(&:key).uniq, [:foo])
|
33
|
-
(0..10).each { |i| assert_equal(bib.data[i].value
|
34
|
-
assert_equal(bib.data[11].value,
|
35
|
-
assert_equal(bib.data[12].value,
|
36
|
-
assert_equal(bib.data[13].value,
|
37
|
-
assert_equal(bib.data[14].value,
|
38
|
-
assert_equal(bib.data[15].value,
|
39
|
-
assert_equal(bib.data[16].value,
|
31
|
+
(0..10).each { |i| assert_equal( '"bar"', bib.data[i].value) }
|
32
|
+
assert_equal(bib.data[11].value, '"\'bar\'"')
|
33
|
+
assert_equal(bib.data[12].value, '"{"}bar{"}"')
|
34
|
+
assert_equal(bib.data[13].value, '"@bar@"')
|
35
|
+
assert_equal(bib.data[14].value, '"\'bar\'"')
|
36
|
+
assert_equal(bib.data[15].value, '"{"}bar{"}"')
|
37
|
+
assert_equal(bib.data[16].value, '"{bar}"')
|
40
38
|
end
|
41
39
|
|
42
40
|
def test_replacement
|
@@ -46,32 +44,54 @@ class TestString < MiniTest::Unit::TestCase
|
|
46
44
|
refute(bib.empty?)
|
47
45
|
assert_equal(7,bib.length)
|
48
46
|
assert_equal([BibTeX::String,BibTeX::Preamble,BibTeX::Entry], bib.data.map(&:class).uniq)
|
49
|
-
assert_equal(
|
50
|
-
assert_equal(
|
51
|
-
assert_equal(
|
52
|
-
assert_equal(
|
53
|
-
assert_equal(
|
54
|
-
assert_equal(
|
55
|
-
assert_equal(
|
47
|
+
assert_equal(["foo"], bib.strings[:foo])
|
48
|
+
assert_equal(["bar"], bib.strings[:bar])
|
49
|
+
assert_equal([:foo, "bar"], bib.strings[:foobar])
|
50
|
+
assert_equal([:foobar, :foo], bib.strings[:foobarfoo])
|
51
|
+
assert_equal([:bar, "foo", :bar], bib.strings[:barfoobar])
|
52
|
+
assert_equal('"foo" # foo # foobarfoo # "bar"', bib.preamble[0].content)
|
53
|
+
assert_equal('"foo" # barfoobar', bib['manual:1'].title)
|
56
54
|
|
57
55
|
bib.replace_strings({ :include => [BibTeX::Preamble]})
|
58
|
-
assert_equal(
|
59
|
-
assert_equal(
|
60
|
-
assert_equal(
|
61
|
-
assert_equal(
|
62
|
-
assert_equal(
|
63
|
-
assert_equal(
|
64
|
-
assert_equal(
|
56
|
+
assert_equal(["foo"], bib.strings[:foo])
|
57
|
+
assert_equal(["bar"], bib.strings[:bar])
|
58
|
+
assert_equal([:foo, "bar"], bib.strings[:foobar])
|
59
|
+
assert_equal([:foobar, :foo], bib.strings[:foobarfoo])
|
60
|
+
assert_equal([:bar, "foo", :bar], bib.strings[:barfoobar])
|
61
|
+
assert_equal('"foo" # "foo" # foobar # foo # "bar"', bib.preamble[0].content)
|
62
|
+
assert_equal('"foo" # barfoobar', bib['manual:1'].title)
|
65
63
|
|
66
64
|
bib.replace_strings({ :include => [BibTeX::String]})
|
67
|
-
assert_equal(
|
68
|
-
assert_equal(
|
69
|
-
assert_equal(
|
70
|
-
assert_equal(
|
71
|
-
assert_equal(
|
65
|
+
assert_equal(['foo','bar'], bib.strings[:foobar])
|
66
|
+
assert_equal(['foo', 'bar','foo'], bib.strings[:foobarfoo])
|
67
|
+
assert_equal(['bar','foo','bar'], bib.strings[:barfoobar])
|
68
|
+
assert_equal('"foo" # "foo" # foobar # foo # "bar"', bib.preamble[0].content)
|
69
|
+
assert_equal('"foo" # barfoobar', bib['manual:1'].title)
|
72
70
|
|
73
71
|
bib.replace_strings({ :include => [BibTeX::Preamble,BibTeX::Entry]})
|
74
|
-
assert_equal(
|
75
|
-
assert_equal(
|
72
|
+
assert_equal('"foo" # "foo" # "foo" # "bar" # "foo" # "bar"', bib.preamble[0].content)
|
73
|
+
assert_equal('"foo" # "bar" # "foo" # "bar"', bib['manual:1'].title)
|
74
|
+
end
|
75
|
+
|
76
|
+
def test_roundtrip
|
77
|
+
bib = BibTeX::Bibliography.open('test/bib/04_string_replacement.bib', :debug => true)
|
78
|
+
refute_nil(bib)
|
79
|
+
assert_equal('@string{ foo = "foo" }', bib.data[0].to_s)
|
80
|
+
assert_equal('@string{ bar = "bar" }', bib.data[1].to_s)
|
81
|
+
assert_equal('@string{ foobar = foo # "bar" }', bib.data[2].to_s)
|
82
|
+
assert_equal('@string{ foobarfoo = foobar # foo }', bib.data[3].to_s)
|
83
|
+
assert_equal('@string{ barfoobar = bar # "foo" # bar }', bib.data[4].to_s)
|
84
|
+
bib.replace_strings
|
85
|
+
assert_equal('@string{ foo = "foo" }', bib.data[0].to_s)
|
86
|
+
assert_equal('@string{ bar = "bar" }', bib.data[1].to_s)
|
87
|
+
assert_equal('@string{ foobar = "foo" # "bar" }', bib.data[2].to_s)
|
88
|
+
assert_equal('@string{ foobarfoo = "foo" # "bar" # "foo" }', bib.data[3].to_s)
|
89
|
+
assert_equal('@string{ barfoobar = "bar" # "foo" # "bar" }', bib.data[4].to_s)
|
90
|
+
bib.join_strings
|
91
|
+
assert_equal('@string{ foo = "foo" }', bib.data[0].to_s)
|
92
|
+
assert_equal('@string{ bar = "bar" }', bib.data[1].to_s)
|
93
|
+
assert_equal('@string{ foobar = "foobar" }', bib.data[2].to_s)
|
94
|
+
assert_equal('@string{ foobarfoo = "foobarfoo" }', bib.data[3].to_s)
|
95
|
+
assert_equal('@string{ barfoobar = "barfoobar" }', bib.data[4].to_s)
|
76
96
|
end
|
77
97
|
end
|