bibtex-ruby 1.2.1 → 1.3.0

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.

Files changed (67) hide show
  1. data/Gemfile +6 -1
  2. data/Gemfile.lock +48 -5
  3. data/History.txt +16 -1
  4. data/Manifest +43 -19
  5. data/README.md +178 -167
  6. data/Rakefile +26 -5
  7. data/auto.watchr +6 -0
  8. data/bibtex-ruby.gemspec +8 -5
  9. data/examples/bib2html.rb +28 -18
  10. data/features/bibtex.feature +96 -0
  11. data/features/entries.feature +67 -0
  12. data/features/issues/slash_keys.feature +21 -0
  13. data/features/names.feature +72 -0
  14. data/features/preambles.feature +27 -0
  15. data/features/query.feature +56 -0
  16. data/features/replacement.feature +68 -0
  17. data/features/step_definitions/bibtex_steps.rb +74 -0
  18. data/features/step_definitions/name_steps.rb +13 -0
  19. data/features/strings.feature +52 -0
  20. data/features/support/env.rb +7 -0
  21. data/lib/bibtex.rb +5 -1
  22. data/lib/bibtex/bibliography.rb +218 -95
  23. data/lib/bibtex/bibtex.y +18 -15
  24. data/lib/bibtex/elements.rb +130 -136
  25. data/lib/bibtex/entry.rb +133 -69
  26. data/lib/bibtex/extensions.rb +0 -35
  27. data/lib/bibtex/lexer.rb +9 -9
  28. data/lib/bibtex/name_parser.output +464 -0
  29. data/lib/bibtex/name_parser.rb +490 -0
  30. data/lib/bibtex/names.rb +162 -0
  31. data/lib/bibtex/names.y +196 -0
  32. data/lib/bibtex/parser.output +5 -5
  33. data/lib/bibtex/parser.rb +19 -16
  34. data/lib/bibtex/replaceable.rb +52 -0
  35. data/lib/bibtex/utilities.rb +23 -5
  36. data/lib/bibtex/value.rb +201 -0
  37. data/lib/bibtex/version.rb +1 -1
  38. data/test/benchmark.rb +52 -0
  39. data/test/bibtex/test_bibliography.rb +141 -0
  40. data/test/bibtex/test_elements.rb +40 -0
  41. data/test/bibtex/test_entry.rb +99 -0
  42. data/test/bibtex/test_names.rb +23 -0
  43. data/test/bibtex/test_parser.rb +79 -0
  44. data/test/bibtex/test_string.rb +83 -0
  45. data/test/bibtex/test_utilities.rb +34 -0
  46. data/test/bibtex/test_value.rb +70 -0
  47. data/test/{bib/10_bibdesk.bib → fixtures/bibdesk.bib} +1 -1
  48. data/test/{bib/05_comment.bib → fixtures/comment.bib} +0 -0
  49. data/test/{bib/08_decoret.bib → fixtures/decoret.bib} +0 -0
  50. data/test/{bib/00_empty.bib → fixtures/empty.bib} +0 -0
  51. data/test/{bib/07_entry.bib → fixtures/entry.bib} +0 -0
  52. data/test/{bib/09_errors.bib → fixtures/errors.bib} +0 -0
  53. data/test/{bib/01_no_bibtex.bib → fixtures/no_bibtex.bib} +0 -0
  54. data/test/{bib/06_preamble.bib → fixtures/preamble.bib} +1 -1
  55. data/test/{bib/11_roundtrip.bib → fixtures/roundtrip.bib} +1 -1
  56. data/test/helper.rb +17 -2
  57. data/test/test_bibtex.rb +87 -93
  58. data/test/test_export.rb +18 -22
  59. metadata +85 -30
  60. data/test/bib/02_string.bib +0 -1
  61. data/test/bib/03_string.bib +0 -25
  62. data/test/bib/04_string_replacement.bib +0 -16
  63. data/test/test_comment.rb +0 -21
  64. data/test/test_entry.rb +0 -98
  65. data/test/test_preamble.rb +0 -39
  66. data/test/test_string.rb +0 -97
  67. data/test/test_utilities.rb +0 -36
@@ -2,7 +2,7 @@
2
2
  %% This is a valid BibTeX File
3
3
  %%
4
4
 
5
- % Testing @preamble statements
5
+ % Testing preamble statements
6
6
 
7
7
  @preamble{"This bibliography was created \today"}
8
8
  @preamble { "Bib\TeX" }
@@ -1,6 +1,6 @@
1
1
  @book{rails,
2
2
  address = {Raleigh, North Carolina},
3
- author = {Ruby, Sam, and Thomas, Dave, and Hansson, David Heinemeier},
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},
@@ -1,4 +1,19 @@
1
1
  require File.expand_path('../../lib/bibtex.rb', __FILE__)
2
- require 'rubygems'
3
- require 'minitest/unit'
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
@@ -1,108 +1,102 @@
1
1
  require 'helper.rb'
2
2
 
3
- class TestBibtex < MiniTest::Unit::TestCase
3
+ module BibTeX
4
+ class TestBibtex < MiniTest::Unit::TestCase
4
5
 
5
- def setup
6
- end
6
+ def setup
7
+ end
7
8
 
8
- def teardown
9
- end
9
+ def teardown
10
+ end
10
11
 
11
- def test_empty
12
- bib = BibTeX::Bibliography.open('test/bib/00_empty.bib', :debug => true)
13
- refute_nil(bib)
14
- assert_equal(BibTeX::Bibliography, bib.class)
15
- assert(bib.empty?)
16
- end
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
- def test_no_bibtex
19
- bib = BibTeX::Bibliography.open('test/bib/01_no_bibtex.bib', :debug => true)
20
- refute_nil(bib)
21
- assert_equal(BibTeX::Bibliography, bib.class)
22
- assert(bib.empty?)
23
- end
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
- def test_decoret
26
- bib = BibTeX::Bibliography.open('test/bib/08_decoret.bib', :debug => true)
27
- refute_nil(bib)
28
- assert_equal(BibTeX::Bibliography, bib.class)
29
- assert_equal(15, bib.length)
30
- assert_equal([BibTeX::Entry,BibTeX::Comment,BibTeX::String,BibTeX::Preamble], bib.data.map(&:class).uniq)
31
- assert_equal('py03', bib.data[0].key)
32
- assert_equal(:article, bib['py03'].type)
33
- assert_equal("Xavier D\\'ecoret", bib['py03'][:author])
34
- assert_equal('PyBiTex', bib['py03'][:title])
35
- assert_equal('2003', bib['py03'][:year])
36
- assert_equal(:article, bib['key03'].type)
37
- assert_equal('A {bunch {of} braces {in}} title', bib['key03'][:title])
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
- def test_errors
42
- bib = BibTeX.open('test/bib/09_errors.bib', :debug => true)
43
- #refute_nil(bib)
44
- end
40
+ # def test_errors
41
+ # bib = BibTeX.open(Test.fixtures(:errors), :debug => false)
42
+ # #refute_nil(bib)
43
+ # end
45
44
 
46
- def test_bibdesk
47
- bib = BibTeX::Bibliography.open('test/bib/10_bibdesk.bib', :debug => true)
48
- refute_nil(bib)
49
- assert_equal(BibTeX::Bibliography, bib.class)
50
- assert_equal(3, bib.length)
51
- assert_equal('rails', bib.data[0].key)
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
- 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
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
- 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
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
- 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
- ))
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
- 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]+/, ''))
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
@@ -3,29 +3,25 @@ require 'helper.rb'
3
3
  require 'yaml'
4
4
  require 'json'
5
5
 
6
- class TestString < MiniTest::Unit::TestCase
6
+ module BibTeX
7
+ class TestString < MiniTest::Unit::TestCase
7
8
 
8
- def setup
9
- end
10
-
11
- def teardown
12
- end
13
-
14
- def test_yaml
15
- bib = BibTeX::Bibliography.open('test/bib/10_bibdesk.bib', :debug => true)
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
- def test_json
24
- bib = BibTeX::Bibliography.open('test/bib/10_bibdesk.bib', :debug => true)
25
- json = JSON.parse(bib.to_json)
26
- refute_nil(json)
27
- assert_equal(3, json.length)
28
- assert_equal(['dragon', 'pickaxe', 'rails'], json.map { |y| y['key'] }.sort)
29
- assert_equal('{The Facets of Ruby}', json[0]['series'])
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.2.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-04-06 00:00:00 +02:00
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.6
24
+ version: "1.4"
25
25
  type: :development
26
26
  version_requirements: *id001
27
27
  - !ruby/object:Gem::Dependency
28
- name: minitest
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: 2.0.2
35
+ version: "0.3"
36
36
  type: :development
37
37
  version_requirements: *id002
38
38
  - !ruby/object:Gem::Dependency
39
- name: json
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: 1.5.0
46
+ version: "0.7"
47
47
  type: :development
48
48
  version_requirements: *id003
49
- description: A (fairly complete) BibTeX parser written in Ruby. Supports regular BibTeX entries, @comments, string replacement via @string. Allows for easy export/conversion to formats such as YAML, JSON, and XML.
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/bib/00_empty.bib
82
- - test/bib/01_no_bibtex.bib
83
- - test/bib/02_string.bib
84
- - test/bib/03_string.bib
85
- - test/bib/04_string_replacement.bib
86
- - test/bib/05_comment.bib
87
- - test/bib/06_preamble.bib
88
- - test/bib/07_entry.bib
89
- - test/bib/08_decoret.bib
90
- - test/bib/09_errors.bib
91
- - test/bib/10_bibdesk.bib
92
- - test/bib/11_roundtrip.bib
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