bibtex-ruby 1.2.1 → 1.3.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 +6 -1
- data/Gemfile.lock +48 -5
- data/History.txt +16 -1
- data/Manifest +43 -19
- data/README.md +178 -167
- data/Rakefile +26 -5
- data/auto.watchr +6 -0
- data/bibtex-ruby.gemspec +8 -5
- data/examples/bib2html.rb +28 -18
- data/features/bibtex.feature +96 -0
- data/features/entries.feature +67 -0
- data/features/issues/slash_keys.feature +21 -0
- data/features/names.feature +72 -0
- data/features/preambles.feature +27 -0
- data/features/query.feature +56 -0
- data/features/replacement.feature +68 -0
- data/features/step_definitions/bibtex_steps.rb +74 -0
- data/features/step_definitions/name_steps.rb +13 -0
- data/features/strings.feature +52 -0
- data/features/support/env.rb +7 -0
- data/lib/bibtex.rb +5 -1
- data/lib/bibtex/bibliography.rb +218 -95
- data/lib/bibtex/bibtex.y +18 -15
- data/lib/bibtex/elements.rb +130 -136
- data/lib/bibtex/entry.rb +133 -69
- data/lib/bibtex/extensions.rb +0 -35
- data/lib/bibtex/lexer.rb +9 -9
- data/lib/bibtex/name_parser.output +464 -0
- data/lib/bibtex/name_parser.rb +490 -0
- data/lib/bibtex/names.rb +162 -0
- data/lib/bibtex/names.y +196 -0
- data/lib/bibtex/parser.output +5 -5
- data/lib/bibtex/parser.rb +19 -16
- data/lib/bibtex/replaceable.rb +52 -0
- data/lib/bibtex/utilities.rb +23 -5
- data/lib/bibtex/value.rb +201 -0
- data/lib/bibtex/version.rb +1 -1
- data/test/benchmark.rb +52 -0
- data/test/bibtex/test_bibliography.rb +141 -0
- data/test/bibtex/test_elements.rb +40 -0
- data/test/bibtex/test_entry.rb +99 -0
- data/test/bibtex/test_names.rb +23 -0
- data/test/bibtex/test_parser.rb +79 -0
- data/test/bibtex/test_string.rb +83 -0
- data/test/bibtex/test_utilities.rb +34 -0
- data/test/bibtex/test_value.rb +70 -0
- data/test/{bib/10_bibdesk.bib → fixtures/bibdesk.bib} +1 -1
- data/test/{bib/05_comment.bib → fixtures/comment.bib} +0 -0
- data/test/{bib/08_decoret.bib → fixtures/decoret.bib} +0 -0
- data/test/{bib/00_empty.bib → fixtures/empty.bib} +0 -0
- data/test/{bib/07_entry.bib → fixtures/entry.bib} +0 -0
- data/test/{bib/09_errors.bib → fixtures/errors.bib} +0 -0
- data/test/{bib/01_no_bibtex.bib → fixtures/no_bibtex.bib} +0 -0
- data/test/{bib/06_preamble.bib → fixtures/preamble.bib} +1 -1
- data/test/{bib/11_roundtrip.bib → fixtures/roundtrip.bib} +1 -1
- data/test/helper.rb +17 -2
- data/test/test_bibtex.rb +87 -93
- data/test/test_export.rb +18 -22
- metadata +85 -30
- data/test/bib/02_string.bib +0 -1
- data/test/bib/03_string.bib +0 -25
- data/test/bib/04_string_replacement.bib +0 -16
- data/test/test_comment.rb +0 -21
- data/test/test_entry.rb +0 -98
- data/test/test_preamble.rb +0 -39
- data/test/test_string.rb +0 -97
- data/test/test_utilities.rb +0 -36
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -1,6 +1,6 @@
|
|
1
1
|
@book{rails,
|
2
2
|
address = {Raleigh, North Carolina},
|
3
|
-
author = {Ruby, Sam
|
3
|
+
author = {Ruby, Sam and Thomas, Dave and Hansson Heinemeier, David},
|
4
4
|
booktitle = {Agile Web Development with Rails},
|
5
5
|
edition = {third},
|
6
6
|
keywords = {ruby, rails},
|
data/test/helper.rb
CHANGED
@@ -1,4 +1,19 @@
|
|
1
1
|
require File.expand_path('../../lib/bibtex.rb', __FILE__)
|
2
|
-
|
3
|
-
require '
|
2
|
+
|
3
|
+
require 'mini_shoulda'
|
4
4
|
require 'minitest/autorun'
|
5
|
+
require 'redgreen'
|
6
|
+
|
7
|
+
require 'tempfile'
|
8
|
+
|
9
|
+
module BibTeX
|
10
|
+
module Test
|
11
|
+
|
12
|
+
class << self
|
13
|
+
def fixtures(name)
|
14
|
+
File.expand_path("../fixtures/#{name}.bib", __FILE__)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
19
|
+
end
|
data/test/test_bibtex.rb
CHANGED
@@ -1,108 +1,102 @@
|
|
1
1
|
require 'helper.rb'
|
2
2
|
|
3
|
-
|
3
|
+
module BibTeX
|
4
|
+
class TestBibtex < MiniTest::Unit::TestCase
|
4
5
|
|
5
|
-
|
6
|
-
|
6
|
+
def setup
|
7
|
+
end
|
7
8
|
|
8
|
-
|
9
|
-
|
9
|
+
def teardown
|
10
|
+
end
|
10
11
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
12
|
+
def test_empty
|
13
|
+
bib = BibTeX::Bibliography.open(Test.fixtures(:empty), :debug => false)
|
14
|
+
refute_nil(bib)
|
15
|
+
assert_equal(BibTeX::Bibliography, bib.class)
|
16
|
+
assert(bib.empty?)
|
17
|
+
end
|
17
18
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
19
|
+
def test_no_bibtex
|
20
|
+
bib = BibTeX::Bibliography.open(Test.fixtures(:no_bibtex), :debug => false)
|
21
|
+
refute_nil(bib)
|
22
|
+
assert_equal(BibTeX::Bibliography, bib.class)
|
23
|
+
assert(bib.empty?)
|
24
|
+
end
|
24
25
|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
#TODO missing assertions
|
39
|
-
end
|
26
|
+
def test_decoret
|
27
|
+
bib = BibTeX::Bibliography.open(Test.fixtures(:decoret), :debug => false)
|
28
|
+
assert_equal(15, bib.length)
|
29
|
+
assert_equal([BibTeX::Entry,BibTeX::Comment,BibTeX::String,BibTeX::Preamble], bib.data.map(&:class).uniq)
|
30
|
+
assert_equal(:py03, bib.data[0].key)
|
31
|
+
assert_equal(:article, bib[:py03].type)
|
32
|
+
assert_equal("D\\'ecoret, Xavier", bib[:py03][:author])
|
33
|
+
assert_equal('PyBiTex', bib[:py03][:title])
|
34
|
+
assert_equal('2003', bib[:py03][:year])
|
35
|
+
assert_equal(:article, bib[:key03].type)
|
36
|
+
assert_equal('A {bunch {of} braces {in}} title', bib[:key03][:title])
|
37
|
+
#TODO missing assertions
|
38
|
+
end
|
40
39
|
|
41
|
-
|
42
|
-
bib = BibTeX.open(
|
43
|
-
#refute_nil(bib)
|
44
|
-
|
40
|
+
# def test_errors
|
41
|
+
# bib = BibTeX.open(Test.fixtures(:errors), :debug => false)
|
42
|
+
# #refute_nil(bib)
|
43
|
+
# end
|
45
44
|
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
assert_equal('2010-08-05 10:06:32 +0200', bib[:dragon]['date-modified'])
|
53
|
-
end
|
45
|
+
def test_bibdesk
|
46
|
+
bib = BibTeX::Bibliography.open(Test.fixtures(:bibdesk), :debug => false)
|
47
|
+
assert_equal 3, bib.length
|
48
|
+
assert_equal :rails, bib[0].key
|
49
|
+
assert_equal '2010-08-05 10:06:32 +0200', bib[:dragon]['date-modified']
|
50
|
+
end
|
54
51
|
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
assert_equal(1, bib.length)
|
61
|
-
assert_equal(file.gsub(/[\s]+/, ''), bib.to_s.gsub(/[\s]+/, ''))
|
62
|
-
end
|
52
|
+
def test_roundtrip
|
53
|
+
file = File.read(Test.fixtures(:roundtrip))
|
54
|
+
bib = BibTeX.parse(file, :debug => false)
|
55
|
+
assert_equal file.gsub(/[\s]+/, ''), bib.to_s.gsub(/[\s]+/, '')
|
56
|
+
end
|
63
57
|
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
58
|
+
def test_construct
|
59
|
+
file = File.read(Test.fixtures(:roundtrip))
|
60
|
+
bib = BibTeX::Bibliography.new
|
61
|
+
bib << BibTeX::Entry.new({
|
62
|
+
:type => :book,
|
63
|
+
:key => 'rails',
|
64
|
+
:address => 'Raleigh, North Carolina',
|
65
|
+
:author => 'Ruby, Sam and Thomas, Dave and Hansson Heinemeier, David',
|
66
|
+
:booktitle => 'Agile Web Development with Rails',
|
67
|
+
:edition => 'third',
|
68
|
+
:keywords => 'ruby, rails',
|
69
|
+
:publisher => 'The Pragmatic Bookshelf',
|
70
|
+
:series => 'The Facets of Ruby',
|
71
|
+
:title => 'Agile Web Development with Rails',
|
72
|
+
:year => '2009'
|
73
|
+
})
|
74
|
+
assert_equal(file.gsub(/[\s]+/, ''), bib.to_s.gsub(/[\s]+/, ''))
|
75
|
+
end
|
82
76
|
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
))
|
77
|
+
def test_parse
|
78
|
+
file = File.read(Test.fixtures(:roundtrip))
|
79
|
+
bib = BibTeX::Bibliography.new
|
80
|
+
bib.add(BibTeX::Element.parse(%q( @string{ pragprog = "The Pragmatic Booksehlf" } )))
|
81
|
+
bib.add(BibTeX::Element.parse(<<-END))
|
82
|
+
@book{rails,
|
83
|
+
address = {Raleigh, North Carolina},
|
84
|
+
author = {Ruby, Sam and Thomas, Dave and Hansson Heinemeier, David},
|
85
|
+
booktitle = {Agile Web Development with Rails},
|
86
|
+
edition = {third},
|
87
|
+
keywords = {ruby, rails},
|
88
|
+
publisher = {The Pragmatic Bookshelf},
|
89
|
+
series = {The Facets of Ruby},
|
90
|
+
title = {Agile Web Development with Rails},
|
91
|
+
year = {2009}
|
92
|
+
}
|
93
|
+
END
|
101
94
|
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
95
|
+
assert_equal(2, bib.length)
|
96
|
+
refute_nil(bib[:rails])
|
97
|
+
bib.replace_strings
|
98
|
+
assert_equal(file.gsub(/[\s]+/, ''), bib[:rails].to_s.gsub(/[\s]+/, ''))
|
99
|
+
end
|
106
100
|
end
|
107
|
-
end
|
108
101
|
|
102
|
+
end
|
data/test/test_export.rb
CHANGED
@@ -3,29 +3,25 @@ require 'helper.rb'
|
|
3
3
|
require 'yaml'
|
4
4
|
require 'json'
|
5
5
|
|
6
|
-
|
6
|
+
module BibTeX
|
7
|
+
class TestString < MiniTest::Unit::TestCase
|
7
8
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
yaml = YAML.load(bib.to_yaml)
|
17
|
-
refute_nil(yaml)
|
18
|
-
assert_equal(3, yaml.length)
|
19
|
-
assert_equal(['dragon', 'pickaxe', 'rails'], yaml.map { |y| y['key'] }.sort)
|
20
|
-
assert_equal('{The Facets of Ruby}', yaml[0]['series'])
|
21
|
-
end
|
9
|
+
def test_yaml
|
10
|
+
bib = BibTeX::Bibliography.open(Test.fixtures(:bibdesk), :debug => false)
|
11
|
+
yaml = YAML.load(bib.to_yaml)
|
12
|
+
refute_nil(yaml)
|
13
|
+
assert_equal(3, yaml.length)
|
14
|
+
assert_equal([:dragon, :pickaxe, :rails], yaml.map { |y| y[:key] }.sort)
|
15
|
+
assert_equal('{The Facets of Ruby}', yaml[0][:series])
|
16
|
+
end
|
22
17
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
18
|
+
def test_json
|
19
|
+
bib = BibTeX::Bibliography.open(Test.fixtures(:bibdesk), :debug => false)
|
20
|
+
json = JSON.parse(bib.to_json)
|
21
|
+
refute_nil(json)
|
22
|
+
assert_equal(3, json.length)
|
23
|
+
assert_equal(%w[ dragon pickaxe rails], json.map { |y| y['key'] }.sort)
|
24
|
+
assert_equal('{The Facets of Ruby}', json[0]['series'])
|
25
|
+
end
|
30
26
|
end
|
31
27
|
end
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: bibtex-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 1.
|
5
|
+
version: 1.3.0
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Sylvester Keil
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2011-
|
13
|
+
date: 2011-05-12 00:00:00 +02:00
|
14
14
|
default_executable:
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
@@ -21,32 +21,65 @@ dependencies:
|
|
21
21
|
requirements:
|
22
22
|
- - ">="
|
23
23
|
- !ruby/object:Gem::Version
|
24
|
-
version: 1.4
|
24
|
+
version: "1.4"
|
25
25
|
type: :development
|
26
26
|
version_requirements: *id001
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
|
-
name:
|
28
|
+
name: mini_shoulda
|
29
29
|
prerelease: false
|
30
30
|
requirement: &id002 !ruby/object:Gem::Requirement
|
31
31
|
none: false
|
32
32
|
requirements:
|
33
33
|
- - ">="
|
34
34
|
- !ruby/object:Gem::Version
|
35
|
-
version:
|
35
|
+
version: "0.3"
|
36
36
|
type: :development
|
37
37
|
version_requirements: *id002
|
38
38
|
- !ruby/object:Gem::Dependency
|
39
|
-
name:
|
39
|
+
name: mynyml-redgreen
|
40
40
|
prerelease: false
|
41
41
|
requirement: &id003 !ruby/object:Gem::Requirement
|
42
42
|
none: false
|
43
43
|
requirements:
|
44
44
|
- - ">="
|
45
45
|
- !ruby/object:Gem::Version
|
46
|
-
version:
|
46
|
+
version: "0.7"
|
47
47
|
type: :development
|
48
48
|
version_requirements: *id003
|
49
|
-
|
49
|
+
- !ruby/object:Gem::Dependency
|
50
|
+
name: autowatchr
|
51
|
+
prerelease: false
|
52
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
53
|
+
none: false
|
54
|
+
requirements:
|
55
|
+
- - ">="
|
56
|
+
- !ruby/object:Gem::Version
|
57
|
+
version: "0.1"
|
58
|
+
type: :development
|
59
|
+
version_requirements: *id004
|
60
|
+
- !ruby/object:Gem::Dependency
|
61
|
+
name: cucumber
|
62
|
+
prerelease: false
|
63
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
64
|
+
none: false
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: "0.10"
|
69
|
+
type: :development
|
70
|
+
version_requirements: *id005
|
71
|
+
- !ruby/object:Gem::Dependency
|
72
|
+
name: json
|
73
|
+
prerelease: false
|
74
|
+
requirement: &id006 !ruby/object:Gem::Requirement
|
75
|
+
none: false
|
76
|
+
requirements:
|
77
|
+
- - ">="
|
78
|
+
- !ruby/object:Gem::Version
|
79
|
+
version: "1.5"
|
80
|
+
type: :development
|
81
|
+
version_requirements: *id006
|
82
|
+
description: A (fairly complete) BibTeX library and parser written in Ruby. Includes a name parser and supports regular BibTeX entries, @comments, string replacement via @string. Allows for easy export/conversion to formats such as YAML, JSON, and XML.
|
50
83
|
email: http://sylvester.keil.or.at
|
51
84
|
executables: []
|
52
85
|
|
@@ -62,10 +95,22 @@ files:
|
|
62
95
|
- Manifest
|
63
96
|
- README.md
|
64
97
|
- Rakefile
|
98
|
+
- auto.watchr
|
65
99
|
- bibtex-ruby.gemspec
|
66
100
|
- examples/bib2html.rb
|
67
101
|
- examples/bib2yaml.rb
|
68
102
|
- examples/markdown.bib
|
103
|
+
- features/bibtex.feature
|
104
|
+
- features/entries.feature
|
105
|
+
- features/issues/slash_keys.feature
|
106
|
+
- features/names.feature
|
107
|
+
- features/preambles.feature
|
108
|
+
- features/query.feature
|
109
|
+
- features/replacement.feature
|
110
|
+
- features/step_definitions/bibtex_steps.rb
|
111
|
+
- features/step_definitions/name_steps.rb
|
112
|
+
- features/strings.feature
|
113
|
+
- features/support/env.rb
|
69
114
|
- lib/bibtex/bibliography.rb
|
70
115
|
- lib/bibtex/bibtex.y
|
71
116
|
- lib/bibtex/elements.rb
|
@@ -73,31 +118,38 @@ files:
|
|
73
118
|
- lib/bibtex/error.rb
|
74
119
|
- lib/bibtex/extensions.rb
|
75
120
|
- lib/bibtex/lexer.rb
|
121
|
+
- lib/bibtex/name_parser.output
|
122
|
+
- lib/bibtex/name_parser.rb
|
123
|
+
- lib/bibtex/names.rb
|
124
|
+
- lib/bibtex/names.y
|
76
125
|
- lib/bibtex/parser.output
|
77
126
|
- lib/bibtex/parser.rb
|
127
|
+
- lib/bibtex/replaceable.rb
|
78
128
|
- lib/bibtex/utilities.rb
|
129
|
+
- lib/bibtex/value.rb
|
79
130
|
- lib/bibtex/version.rb
|
80
131
|
- lib/bibtex.rb
|
81
|
-
- test/
|
82
|
-
- test/
|
83
|
-
- test/
|
84
|
-
- test/
|
85
|
-
- test/
|
86
|
-
- test/
|
87
|
-
- test/
|
88
|
-
- test/
|
89
|
-
- test/
|
90
|
-
- test/
|
91
|
-
- test/
|
92
|
-
- test/
|
132
|
+
- test/benchmark.rb
|
133
|
+
- test/bibtex/test_bibliography.rb
|
134
|
+
- test/bibtex/test_elements.rb
|
135
|
+
- test/bibtex/test_entry.rb
|
136
|
+
- test/bibtex/test_names.rb
|
137
|
+
- test/bibtex/test_parser.rb
|
138
|
+
- test/bibtex/test_string.rb
|
139
|
+
- test/bibtex/test_utilities.rb
|
140
|
+
- test/bibtex/test_value.rb
|
141
|
+
- test/fixtures/bibdesk.bib
|
142
|
+
- test/fixtures/comment.bib
|
143
|
+
- test/fixtures/decoret.bib
|
144
|
+
- test/fixtures/empty.bib
|
145
|
+
- test/fixtures/entry.bib
|
146
|
+
- test/fixtures/errors.bib
|
147
|
+
- test/fixtures/no_bibtex.bib
|
148
|
+
- test/fixtures/preamble.bib
|
149
|
+
- test/fixtures/roundtrip.bib
|
93
150
|
- test/helper.rb
|
94
151
|
- test/test_bibtex.rb
|
95
|
-
- test/test_comment.rb
|
96
|
-
- test/test_entry.rb
|
97
152
|
- test/test_export.rb
|
98
|
-
- test/test_preamble.rb
|
99
|
-
- test/test_string.rb
|
100
|
-
- test/test_utilities.rb
|
101
153
|
has_rdoc: true
|
102
154
|
homepage: http://inukshuk.github.com/bibtex-ruby
|
103
155
|
licenses: []
|
@@ -134,10 +186,13 @@ signing_key:
|
|
134
186
|
specification_version: 3
|
135
187
|
summary: A BibTeX parser and converter written in Ruby.
|
136
188
|
test_files:
|
189
|
+
- test/bibtex/test_bibliography.rb
|
190
|
+
- test/bibtex/test_elements.rb
|
191
|
+
- test/bibtex/test_entry.rb
|
192
|
+
- test/bibtex/test_names.rb
|
193
|
+
- test/bibtex/test_parser.rb
|
194
|
+
- test/bibtex/test_string.rb
|
195
|
+
- test/bibtex/test_utilities.rb
|
196
|
+
- test/bibtex/test_value.rb
|
137
197
|
- test/test_bibtex.rb
|
138
|
-
- test/test_comment.rb
|
139
|
-
- test/test_entry.rb
|
140
198
|
- test/test_export.rb
|
141
|
-
- test/test_preamble.rb
|
142
|
-
- test/test_string.rb
|
143
|
-
- test/test_utilities.rb
|