bibtex-ruby 2.0.12 → 2.1.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.
- data/Gemfile +20 -7
- data/Gemfile.lock +55 -46
- data/Guardfile +20 -0
- data/History.txt +5 -2
- data/Manifest +1 -1
- data/README.md +64 -69
- data/Rakefile +32 -18
- data/bibtex-ruby.gemspec +3 -9
- data/features/query.feature +39 -1
- data/features/support/env.rb +13 -1
- data/lib/bibtex.rb +5 -2
- data/lib/bibtex/bibliography.rb +1 -1
- data/lib/bibtex/compatibility.rb +9 -1
- data/lib/bibtex/elements.rb +94 -69
- data/lib/bibtex/entry.rb +33 -12
- data/lib/bibtex/name_parser.rb +2 -3
- data/lib/bibtex/names.rb +1 -1
- data/lib/bibtex/names.y +2 -3
- data/lib/bibtex/value.rb +1 -1
- data/lib/bibtex/version.rb +8 -3
- data/test/bibtex/test_elements.rb +23 -23
- data/test/bibtex/test_entry.rb +2 -2
- data/test/helper.rb +12 -1
- metadata +35 -60
- data/auto.watchr +0 -6
data/lib/bibtex/entry.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
#--
|
2
2
|
# BibTeX-Ruby
|
3
|
-
# Copyright (C) 2010-
|
3
|
+
# Copyright (C) 2010-2012 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
|
@@ -161,7 +161,28 @@ module BibTeX
|
|
161
161
|
|
162
162
|
add(other.fields)
|
163
163
|
end
|
164
|
-
|
164
|
+
|
165
|
+
|
166
|
+
# Generate Accessors for required fields (#52)
|
167
|
+
|
168
|
+
REQUIRED_FIELDS.values.flatten.uniq.each do |name|
|
169
|
+
|
170
|
+
define_method(name) do
|
171
|
+
case
|
172
|
+
when fields.has_key?(name)
|
173
|
+
fields[name]
|
174
|
+
when has_parent? && parent.provides?(name)
|
175
|
+
parent.provide(name)
|
176
|
+
else
|
177
|
+
nil
|
178
|
+
end
|
179
|
+
end
|
180
|
+
|
181
|
+
define_method("#{name}=") do |value|
|
182
|
+
add name, value
|
183
|
+
end
|
184
|
+
end
|
185
|
+
|
165
186
|
# call-seq:
|
166
187
|
# entry.each { |key, value| block } -> entry
|
167
188
|
# entry.each_pair { |key, value| block } -> entry
|
@@ -379,15 +400,15 @@ module BibTeX
|
|
379
400
|
end
|
380
401
|
|
381
402
|
|
403
|
+
# call-seq:
|
404
|
+
# add(:author, "Edgar A. Poe")
|
405
|
+
# add(:author, "Edgar A. Poe", :title, "The Raven")
|
406
|
+
# add([:author, "Edgar A. Poe", :title, "The Raven"])
|
407
|
+
# add(:author => "Edgar A. Poe", :title => "The Raven")
|
408
|
+
# add(:author => Names.new(Name.new(:first => 'Edgar A.', :last => 'Poe')))
|
409
|
+
#
|
382
410
|
# Adds a new field (name-value pair) or multiple fields to the entry.
|
383
411
|
# Returns the entry for chainability.
|
384
|
-
#
|
385
|
-
# call-seq:
|
386
|
-
# add(:author, "Edgar A. Poe")
|
387
|
-
# add(:author, "Edgar A. Poe", :title, "The Raven")
|
388
|
-
# add([:author, "Edgar A. Poe", :title, "The Raven"])
|
389
|
-
# add(:author => "Edgar A. Poe", :title => "The Raven")
|
390
|
-
# add(:author => Names.new(Name.new(:first => 'Edgar A.', :last => 'Poe')))
|
391
412
|
def add(*arguments)
|
392
413
|
Hash[*arguments.flatten].each_pair do |name, value|
|
393
414
|
fields[name.to_sym] = Value.create(value)
|
@@ -440,9 +461,9 @@ module BibTeX
|
|
440
461
|
end
|
441
462
|
|
442
463
|
if bibliography.options.has_key?(:filter)
|
443
|
-
|
444
|
-
|
445
|
-
|
464
|
+
[*bibliography.options[:filter]].each do |filter|
|
465
|
+
convert!(filter)
|
466
|
+
end
|
446
467
|
end
|
447
468
|
|
448
469
|
self
|
data/lib/bibtex/name_parser.rb
CHANGED
@@ -13,19 +13,18 @@ module BibTeX
|
|
13
13
|
|
14
14
|
module_eval(<<'...end names.y/module_eval...', 'names.y', 94)
|
15
15
|
|
16
|
-
# Patterns Cache (#37: MacRuby does not cache regular expressions)
|
17
16
|
@patterns = {
|
18
17
|
:and => /,?\s+and\s+/io,
|
19
18
|
:space => /[\t\r\n\s]+/o,
|
20
19
|
:comma => /,/o,
|
21
20
|
:lower => /[[:lower:]][^\t\r\n\s\{\}\d\\,]*/o,
|
22
|
-
:upper => /[[:upper:]][^\t\r\n\s\{\}\d\\,]*/
|
21
|
+
:upper => /[[:upper:]][^\t\r\n\s\{\}\d\\,]*/uo,
|
23
22
|
:symbols => /(\d|\\.)+/o,
|
24
23
|
:lbrace => /\{/o,
|
25
24
|
:rbrace => /\}/o,
|
26
25
|
:period => /./o,
|
27
26
|
:braces => /[\{\}]/o
|
28
|
-
}
|
27
|
+
}
|
29
28
|
|
30
29
|
class << self
|
31
30
|
attr_reader :patterns
|
data/lib/bibtex/names.rb
CHANGED
@@ -279,7 +279,7 @@ module BibTeX
|
|
279
279
|
hash['family'] = family unless family.nil?
|
280
280
|
hash['given'] = given unless given.nil?
|
281
281
|
hash['suffix'] = suffix unless suffix.nil?
|
282
|
-
hash[options[:particle] || 'dropping-particle'] = prefix unless prefix.nil?
|
282
|
+
hash[options[:particle] || 'non-dropping-particle'] = prefix unless prefix.nil?
|
283
283
|
hash
|
284
284
|
end
|
285
285
|
|
data/lib/bibtex/names.y
CHANGED
@@ -92,19 +92,18 @@ require 'strscan'
|
|
92
92
|
|
93
93
|
---- inner
|
94
94
|
|
95
|
-
# Patterns Cache (#37: MacRuby does not cache regular expressions)
|
96
95
|
@patterns = {
|
97
96
|
:and => /,?\s+and\s+/io,
|
98
97
|
:space => /[\t\r\n\s]+/o,
|
99
98
|
:comma => /,/o,
|
100
99
|
:lower => /[[:lower:]][^\t\r\n\s\{\}\d\\,]*/o,
|
101
|
-
:upper => /[[:upper:]][^\t\r\n\s\{\}\d\\,]*/
|
100
|
+
:upper => /[[:upper:]][^\t\r\n\s\{\}\d\\,]*/uo,
|
102
101
|
:symbols => /(\d|\\.)+/o,
|
103
102
|
:lbrace => /\{/o,
|
104
103
|
:rbrace => /\}/o,
|
105
104
|
:period => /./o,
|
106
105
|
:braces => /[\{\}]/o
|
107
|
-
}
|
106
|
+
}
|
108
107
|
|
109
108
|
class << self
|
110
109
|
attr_reader :patterns
|
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-2012 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-2012 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
|
@@ -17,7 +17,12 @@
|
|
17
17
|
#++
|
18
18
|
|
19
19
|
module BibTeX
|
20
|
-
module Version
|
21
|
-
|
20
|
+
module Version
|
21
|
+
MAJOR = 2
|
22
|
+
MINOR = 1
|
23
|
+
PATCH = 0
|
24
|
+
BUILD = nil
|
25
|
+
|
26
|
+
STRING = [MAJOR, MINOR, PATCH, BUILD].compact.join('.').freeze
|
22
27
|
end
|
23
28
|
end
|
@@ -2,29 +2,29 @@ require 'helper'
|
|
2
2
|
|
3
3
|
module BibTeX
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
5
|
+
class ElementTest < MiniTest::Spec
|
6
|
+
|
7
|
+
describe '.parse' do
|
8
|
+
|
9
|
+
it 'accepts a BibTeX string' do
|
10
|
+
Element.parse('@misc{x,},@misc{y,}').length.must_be :==, 2
|
11
|
+
end
|
12
|
+
|
13
|
+
it 'accepts an Element' do
|
14
|
+
Element.parse(Comment.new('blah')).length.must_be :==, 1
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'accepts a Hash and returns an Entry' do
|
18
|
+
Element.parse({ :type => :book })[0].type.must_be :==, :book
|
19
|
+
end
|
20
|
+
|
21
|
+
it 'accepts an array of hashes' do
|
22
|
+
Element.parse([{ :type => :book }, { :type => :misc }])[1].type.must_be :==, :misc
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
28
28
|
|
29
29
|
class PreambleTest < MiniTest::Spec
|
30
30
|
|
data/test/bibtex/test_entry.rb
CHANGED
@@ -310,8 +310,8 @@ module BibTeX
|
|
310
310
|
end
|
311
311
|
end
|
312
312
|
|
313
|
-
it 'should use dropping-particle by default' do
|
314
|
-
assert_equal 'van', @entry.to_citeproc['author'][0]['dropping-particle']
|
313
|
+
it 'should use non-dropping-particle by default' do
|
314
|
+
assert_equal 'van', @entry.to_citeproc['author'][0]['non-dropping-particle']
|
315
315
|
end
|
316
316
|
|
317
317
|
it 'should accept option to use non-dropping-particle' do
|
data/test/helper.rb
CHANGED
@@ -1,6 +1,17 @@
|
|
1
|
+
begin
|
2
|
+
if RUBY_VERSION > '1.8'
|
3
|
+
require 'debugger'
|
4
|
+
require 'simplecov'
|
5
|
+
else
|
6
|
+
require 'ruby-debug'
|
7
|
+
Debugger.start
|
8
|
+
end
|
9
|
+
rescue LoadError
|
10
|
+
# ignore
|
11
|
+
end
|
1
12
|
|
2
13
|
require 'minitest/autorun'
|
3
|
-
require '
|
14
|
+
require 'minitest/colorize'
|
4
15
|
require 'tempfile'
|
5
16
|
|
6
17
|
require 'bibtex'
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bibtex-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0
|
4
|
+
version: 2.1.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-08-31 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: latex-decode
|
16
|
-
requirement: &
|
16
|
+
requirement: &70168050368080 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: 0.0.6
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70168050368080
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: multi_json
|
27
|
-
requirement: &
|
27
|
+
requirement: &70168050367300 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ~>
|
@@ -32,63 +32,39 @@ dependencies:
|
|
32
32
|
version: '1.3'
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
36
|
-
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
version: '1.4'
|
55
|
-
type: :development
|
56
|
-
prerelease: false
|
57
|
-
version_requirements: *70280979735280
|
58
|
-
- !ruby/object:Gem::Dependency
|
59
|
-
name: rdoc
|
60
|
-
requirement: &70280979734680 !ruby/object:Gem::Requirement
|
61
|
-
none: false
|
62
|
-
requirements:
|
63
|
-
- - ~>
|
64
|
-
- !ruby/object:Gem::Version
|
65
|
-
version: '3.9'
|
66
|
-
type: :development
|
67
|
-
prerelease: false
|
68
|
-
version_requirements: *70280979734680
|
69
|
-
description: ! "\t\tBibTeX-Ruby is the Rubyist's swiss-army-knife for all things BibTeX.
|
70
|
-
It\n includes a parser for all common BibTeX objects (@string, @preamble,\n @comment
|
71
|
-
and regular entries) and a sophisticated name parser that\n tokenizes correctly
|
72
|
-
formatted names; BibTeX-Ruby recognizes BibTeX string\n replacements, joins values
|
73
|
-
containing multiple strings or variables,\n supports cross-references, and decodes
|
74
|
-
common LaTeX formatting\n instructions to unicode; if you are in a hurry, it
|
75
|
-
also allows for easy\n export/conversion to formats such as YAML, JSON, CSL,
|
76
|
-
and XML (BibTeXML).\n"
|
35
|
+
version_requirements: *70168050367300
|
36
|
+
description: ! 'BibTeX-Ruby is the Rubyist''s swiss-army-knife for all things BibTeX.
|
37
|
+
It
|
38
|
+
|
39
|
+
includes a parser for all common BibTeX objects (@string, @preamble,
|
40
|
+
|
41
|
+
@comment and regular entries) and a sophisticated name parser that
|
42
|
+
|
43
|
+
tokenizes correctly formatted names; BibTeX-Ruby recognizes BibTeX string
|
44
|
+
|
45
|
+
replacements, joins values containing multiple strings or variables,
|
46
|
+
|
47
|
+
supports cross-references, and decodes common LaTeX formatting
|
48
|
+
|
49
|
+
instructions to unicode; if you are in a hurry, it also allows for easy
|
50
|
+
|
51
|
+
export/conversion to formats such as YAML, JSON, CSL, and XML (BibTeXML).
|
52
|
+
|
53
|
+
'
|
77
54
|
email:
|
78
|
-
-
|
55
|
+
- sylvester@keil.or.at
|
79
56
|
executables: []
|
80
57
|
extensions: []
|
81
|
-
extra_rdoc_files:
|
82
|
-
- README.md
|
58
|
+
extra_rdoc_files: []
|
83
59
|
files:
|
84
60
|
- Gemfile
|
85
61
|
- Gemfile.lock
|
62
|
+
- Guardfile
|
86
63
|
- History.txt
|
87
64
|
- LICENSE
|
88
65
|
- Manifest
|
89
66
|
- README.md
|
90
67
|
- Rakefile
|
91
|
-
- auto.watchr
|
92
68
|
- bibtex-ruby.gemspec
|
93
69
|
- examples/bib2html.rb
|
94
70
|
- examples/bib2yaml.rb
|
@@ -164,14 +140,7 @@ homepage: http://inukshuk.github.com/bibtex-ruby
|
|
164
140
|
licenses:
|
165
141
|
- GPL-3
|
166
142
|
post_install_message:
|
167
|
-
rdoc_options:
|
168
|
-
- --line-numbers
|
169
|
-
- --inline-source
|
170
|
-
- --title
|
171
|
-
- ! '"BibTeX-Ruby Documentation"'
|
172
|
-
- --main
|
173
|
-
- README.md
|
174
|
-
- --webcvs=http://github.com/inukshuk/bibtex-ruby/tree/master/
|
143
|
+
rdoc_options: []
|
175
144
|
require_paths:
|
176
145
|
- lib
|
177
146
|
required_ruby_version: !ruby/object:Gem::Requirement
|
@@ -180,12 +149,18 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
180
149
|
- - ! '>='
|
181
150
|
- !ruby/object:Gem::Version
|
182
151
|
version: '0'
|
152
|
+
segments:
|
153
|
+
- 0
|
154
|
+
hash: 769369451757676187
|
183
155
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
184
156
|
none: false
|
185
157
|
requirements:
|
186
158
|
- - ! '>='
|
187
159
|
- !ruby/object:Gem::Version
|
188
160
|
version: '0'
|
161
|
+
segments:
|
162
|
+
- 0
|
163
|
+
hash: 769369451757676187
|
189
164
|
requirements: []
|
190
165
|
rubyforge_project:
|
191
166
|
rubygems_version: 1.8.10
|
@@ -206,4 +181,4 @@ test_files:
|
|
206
181
|
- test/bibtex/test_value.rb
|
207
182
|
- test/test_bibtex.rb
|
208
183
|
- test/test_export.rb
|
209
|
-
has_rdoc:
|
184
|
+
has_rdoc: yard
|