bibtex-ruby 1.3.8 → 1.3.9
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.
- data/Gemfile.lock +12 -8
- data/History.txt +4 -0
- data/Manifest +1 -0
- data/README.md +28 -0
- data/bibtex-ruby.gemspec +2 -0
- data/features/issues/latex_filter.feature +18 -0
- data/features/step_definitions/bibtex_steps.rb +7 -0
- data/lib/bibtex/bibliography.rb +1 -0
- data/lib/bibtex/filters/latex.rb +13 -13
- data/lib/bibtex/version.rb +1 -1
- metadata +34 -22
data/Gemfile.lock
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
bibtex-ruby (1.3.
|
|
4
|
+
bibtex-ruby (1.3.9)
|
|
5
|
+
latex-decode (>= 0.0.1)
|
|
5
6
|
|
|
6
7
|
GEM
|
|
7
8
|
remote: http://rubygems.org/
|
|
@@ -10,19 +11,21 @@ GEM
|
|
|
10
11
|
autowatchr (0.1.5)
|
|
11
12
|
watchr
|
|
12
13
|
builder (3.0.0)
|
|
13
|
-
columnize (0.3.
|
|
14
|
-
cucumber (0.
|
|
14
|
+
columnize (0.3.3)
|
|
15
|
+
cucumber (1.0.0)
|
|
15
16
|
builder (>= 2.1.2)
|
|
16
17
|
diff-lcs (>= 1.1.2)
|
|
17
|
-
gherkin (~> 2.4.
|
|
18
|
+
gherkin (~> 2.4.1)
|
|
18
19
|
json (>= 1.4.6)
|
|
19
20
|
term-ansicolor (>= 1.0.5)
|
|
20
21
|
diff-lcs (1.1.2)
|
|
21
|
-
gherkin (2.4.
|
|
22
|
+
gherkin (2.4.1)
|
|
22
23
|
json (>= 1.4.6)
|
|
23
24
|
gnuplot (2.3.6)
|
|
24
|
-
json (1.5.
|
|
25
|
-
|
|
25
|
+
json (1.5.3)
|
|
26
|
+
latex-decode (0.0.1)
|
|
27
|
+
linecache (0.46)
|
|
28
|
+
rbx-require-relative (> 0.0.4)
|
|
26
29
|
linecache19 (0.5.12)
|
|
27
30
|
ruby_core_source (>= 0.1.4)
|
|
28
31
|
mini_shoulda (0.3.0)
|
|
@@ -32,7 +35,8 @@ GEM
|
|
|
32
35
|
term-ansicolor (>= 1.0.4)
|
|
33
36
|
racc (1.4.6)
|
|
34
37
|
rake (0.9.2)
|
|
35
|
-
|
|
38
|
+
rbx-require-relative (0.0.5)
|
|
39
|
+
rdoc (3.8)
|
|
36
40
|
ruby-debug (0.10.4)
|
|
37
41
|
columnize (>= 0.1)
|
|
38
42
|
ruby-debug-base (~> 0.10.4.0)
|
data/History.txt
CHANGED
data/Manifest
CHANGED
|
@@ -17,6 +17,7 @@ features/bibtex.feature
|
|
|
17
17
|
features/entries.feature
|
|
18
18
|
features/issues
|
|
19
19
|
features/issues/braced_strings.feature
|
|
20
|
+
features/issues/latex_filter.feature
|
|
20
21
|
features/issues/number_keys.feature
|
|
21
22
|
features/issues/parse_months.feature
|
|
22
23
|
features/issues/slash_keys.feature
|
data/README.md
CHANGED
|
@@ -256,6 +256,34 @@ are parsed and can easily be mapped to their last names:
|
|
|
256
256
|
END
|
|
257
257
|
=> ["Hawthorne", "Melville"]
|
|
258
258
|
|
|
259
|
+
### Filters
|
|
260
|
+
|
|
261
|
+
Since version 1.3.8 BibTeX-Ruby comes with a plugin framework for input
|
|
262
|
+
filters. You can use the methods `convert` and `convert!` methods if `Value`,
|
|
263
|
+
`Entry` and `Bibliography` instances to easily convert string values according
|
|
264
|
+
to a given filter. Starting with version 1.3.9 BibTeX-Ruby includes a
|
|
265
|
+
LaTeX filter that depends on the
|
|
266
|
+
[latex-decode gem](http://rubygems.org/gems/latex-decode). Example:
|
|
267
|
+
|
|
268
|
+
>> faust = '@book{faust, title = {Faust: Der Trag\"odie Erster Teil}}'
|
|
269
|
+
>> BibTeX.parse(faust).convert(:latex)[:faust].title
|
|
270
|
+
=> "Faust: Der Tragödie Erster Teil"
|
|
271
|
+
|
|
272
|
+
Conditional conversions are also supported:
|
|
273
|
+
|
|
274
|
+
>> faust1 = '@book{faust1, title = {Faust: Der Trag\"odie Erster Teil}}'
|
|
275
|
+
>> faust2 = '@book{faust2, title = {Faust: Der Trag\"odie Zweiter Teil}}'
|
|
276
|
+
>> p BibTeX.parse(faust1 + faust2).convert(:latex) { |e| e.key == :faust2 }.to_s
|
|
277
|
+
@book{faust1,
|
|
278
|
+
title = {Faust: Der Trag\"odie Erster Teil}
|
|
279
|
+
}
|
|
280
|
+
@book{faust2,
|
|
281
|
+
title = {Faust: Der Tragödie Zweiter Teil}
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
If you need to express a condition on the basis of individual fields, use the
|
|
285
|
+
conversion methods of BibTeX::Entry with a block instead (the block will be
|
|
286
|
+
passed the key and value of each field prior to conversion).
|
|
259
287
|
|
|
260
288
|
### Conversions
|
|
261
289
|
|
data/bibtex-ruby.gemspec
CHANGED
|
@@ -18,6 +18,8 @@ Gem::Specification.new do |s|
|
|
|
18
18
|
s.required_rubygems_version = '>= 1.3.6'
|
|
19
19
|
s.rubyforge_project = s.name
|
|
20
20
|
|
|
21
|
+
s.add_runtime_dependency('latex-decode', ['>= 0.0.1'])
|
|
22
|
+
|
|
21
23
|
s.add_development_dependency('rake', ['>= 0.8'])
|
|
22
24
|
s.add_development_dependency('racc', ['>= 1.4'])
|
|
23
25
|
s.add_development_dependency('mini_shoulda', ['>= 0.3'])
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
Feature: Parse BibTeX files and convert LaTeX to Unicode
|
|
2
|
+
As a hacker who works with bibliographies
|
|
3
|
+
I want to be able to parse BibTeX files containing LaTeX strings and
|
|
4
|
+
convert them to Unicode
|
|
5
|
+
|
|
6
|
+
@latex
|
|
7
|
+
Scenario: A BibTeX file containing a LaTeX umlaut
|
|
8
|
+
When I parse the following file:
|
|
9
|
+
"""
|
|
10
|
+
@misc{issue16,
|
|
11
|
+
author = {rbq},
|
|
12
|
+
title = {An umlaut: \"u!},
|
|
13
|
+
year = 2011,
|
|
14
|
+
}
|
|
15
|
+
"""
|
|
16
|
+
Then my bibliography should contain an entry with key "issue16"
|
|
17
|
+
When I convert all entries using the filter "latex"
|
|
18
|
+
Then the entry with key "issue16" should have a field "title" with the value "An umlaut: ü!"
|
|
@@ -26,6 +26,9 @@ When /^I replace and join all strings(?: in my bibliography)$/ do
|
|
|
26
26
|
@bibliography.replace_strings.join_strings
|
|
27
27
|
end
|
|
28
28
|
|
|
29
|
+
When /^I convert all entries using the filter "([^"]*)"$/ do |filter|
|
|
30
|
+
@bibliography.convert(filter)
|
|
31
|
+
end
|
|
29
32
|
|
|
30
33
|
|
|
31
34
|
Then /^my bibliography should contain the following objects:$/ do |table|
|
|
@@ -85,4 +88,8 @@ end
|
|
|
85
88
|
|
|
86
89
|
Then /^the string "([^"]*)" should be "([^"]*)"$/ do |key, value|
|
|
87
90
|
assert_equal value, @bibliography.strings[key.to_sym].v.to_s
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
Then /^the entry with key "([^"]*)" should have a field "([^"]*)" with the value "([^"]*)"$/ do |key, field, value|
|
|
94
|
+
assert_equal value, @bibliography[key.to_sym][field.to_sym].to_s
|
|
88
95
|
end
|
data/lib/bibtex/bibliography.rb
CHANGED
data/lib/bibtex/filters/latex.rb
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
1
|
+
require 'latex/decode'
|
|
2
|
+
|
|
3
|
+
module BibTeX
|
|
4
|
+
module Filters
|
|
5
|
+
|
|
6
|
+
class LaTeX < Filter
|
|
7
|
+
def apply (value)
|
|
8
|
+
::LaTeX.decode(value)
|
|
9
|
+
end
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
end
|
|
13
|
+
end
|
data/lib/bibtex/version.rb
CHANGED
metadata
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
name: bibtex-ruby
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
4
|
prerelease:
|
|
5
|
-
version: 1.3.
|
|
5
|
+
version: 1.3.9
|
|
6
6
|
platform: ruby
|
|
7
7
|
authors:
|
|
8
8
|
- Sylvester Keil
|
|
@@ -14,8 +14,19 @@ date: 2011-07-05 00:00:00 +02:00
|
|
|
14
14
|
default_executable:
|
|
15
15
|
dependencies:
|
|
16
16
|
- !ruby/object:Gem::Dependency
|
|
17
|
-
name:
|
|
17
|
+
name: latex-decode
|
|
18
18
|
requirement: &id001 !ruby/object:Gem::Requirement
|
|
19
|
+
none: false
|
|
20
|
+
requirements:
|
|
21
|
+
- - ">="
|
|
22
|
+
- !ruby/object:Gem::Version
|
|
23
|
+
version: 0.0.1
|
|
24
|
+
type: :runtime
|
|
25
|
+
prerelease: false
|
|
26
|
+
version_requirements: *id001
|
|
27
|
+
- !ruby/object:Gem::Dependency
|
|
28
|
+
name: rake
|
|
29
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
|
19
30
|
none: false
|
|
20
31
|
requirements:
|
|
21
32
|
- - ">="
|
|
@@ -23,10 +34,10 @@ dependencies:
|
|
|
23
34
|
version: "0.8"
|
|
24
35
|
type: :development
|
|
25
36
|
prerelease: false
|
|
26
|
-
version_requirements: *
|
|
37
|
+
version_requirements: *id002
|
|
27
38
|
- !ruby/object:Gem::Dependency
|
|
28
39
|
name: racc
|
|
29
|
-
requirement: &
|
|
40
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
|
30
41
|
none: false
|
|
31
42
|
requirements:
|
|
32
43
|
- - ">="
|
|
@@ -34,10 +45,10 @@ dependencies:
|
|
|
34
45
|
version: "1.4"
|
|
35
46
|
type: :development
|
|
36
47
|
prerelease: false
|
|
37
|
-
version_requirements: *
|
|
48
|
+
version_requirements: *id003
|
|
38
49
|
- !ruby/object:Gem::Dependency
|
|
39
50
|
name: mini_shoulda
|
|
40
|
-
requirement: &
|
|
51
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
|
41
52
|
none: false
|
|
42
53
|
requirements:
|
|
43
54
|
- - ">="
|
|
@@ -45,10 +56,10 @@ dependencies:
|
|
|
45
56
|
version: "0.3"
|
|
46
57
|
type: :development
|
|
47
58
|
prerelease: false
|
|
48
|
-
version_requirements: *
|
|
59
|
+
version_requirements: *id004
|
|
49
60
|
- !ruby/object:Gem::Dependency
|
|
50
61
|
name: mynyml-redgreen
|
|
51
|
-
requirement: &
|
|
62
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
|
52
63
|
none: false
|
|
53
64
|
requirements:
|
|
54
65
|
- - ">="
|
|
@@ -56,10 +67,10 @@ dependencies:
|
|
|
56
67
|
version: "0.7"
|
|
57
68
|
type: :development
|
|
58
69
|
prerelease: false
|
|
59
|
-
version_requirements: *
|
|
70
|
+
version_requirements: *id005
|
|
60
71
|
- !ruby/object:Gem::Dependency
|
|
61
72
|
name: autowatchr
|
|
62
|
-
requirement: &
|
|
73
|
+
requirement: &id006 !ruby/object:Gem::Requirement
|
|
63
74
|
none: false
|
|
64
75
|
requirements:
|
|
65
76
|
- - ">="
|
|
@@ -67,10 +78,10 @@ dependencies:
|
|
|
67
78
|
version: "0.1"
|
|
68
79
|
type: :development
|
|
69
80
|
prerelease: false
|
|
70
|
-
version_requirements: *
|
|
81
|
+
version_requirements: *id006
|
|
71
82
|
- !ruby/object:Gem::Dependency
|
|
72
83
|
name: cucumber
|
|
73
|
-
requirement: &
|
|
84
|
+
requirement: &id007 !ruby/object:Gem::Requirement
|
|
74
85
|
none: false
|
|
75
86
|
requirements:
|
|
76
87
|
- - ">="
|
|
@@ -78,10 +89,10 @@ dependencies:
|
|
|
78
89
|
version: "0.10"
|
|
79
90
|
type: :development
|
|
80
91
|
prerelease: false
|
|
81
|
-
version_requirements: *
|
|
92
|
+
version_requirements: *id007
|
|
82
93
|
- !ruby/object:Gem::Dependency
|
|
83
94
|
name: json
|
|
84
|
-
requirement: &
|
|
95
|
+
requirement: &id008 !ruby/object:Gem::Requirement
|
|
85
96
|
none: false
|
|
86
97
|
requirements:
|
|
87
98
|
- - ">="
|
|
@@ -89,10 +100,10 @@ dependencies:
|
|
|
89
100
|
version: "1.5"
|
|
90
101
|
type: :development
|
|
91
102
|
prerelease: false
|
|
92
|
-
version_requirements: *
|
|
103
|
+
version_requirements: *id008
|
|
93
104
|
- !ruby/object:Gem::Dependency
|
|
94
105
|
name: ruby-prof
|
|
95
|
-
requirement: &
|
|
106
|
+
requirement: &id009 !ruby/object:Gem::Requirement
|
|
96
107
|
none: false
|
|
97
108
|
requirements:
|
|
98
109
|
- - ">="
|
|
@@ -100,10 +111,10 @@ dependencies:
|
|
|
100
111
|
version: "0.10"
|
|
101
112
|
type: :development
|
|
102
113
|
prerelease: false
|
|
103
|
-
version_requirements: *
|
|
114
|
+
version_requirements: *id009
|
|
104
115
|
- !ruby/object:Gem::Dependency
|
|
105
116
|
name: gnuplot
|
|
106
|
-
requirement: &
|
|
117
|
+
requirement: &id010 !ruby/object:Gem::Requirement
|
|
107
118
|
none: false
|
|
108
119
|
requirements:
|
|
109
120
|
- - ">="
|
|
@@ -111,10 +122,10 @@ dependencies:
|
|
|
111
122
|
version: "2.3"
|
|
112
123
|
type: :development
|
|
113
124
|
prerelease: false
|
|
114
|
-
version_requirements: *
|
|
125
|
+
version_requirements: *id010
|
|
115
126
|
- !ruby/object:Gem::Dependency
|
|
116
127
|
name: rdoc
|
|
117
|
-
requirement: &
|
|
128
|
+
requirement: &id011 !ruby/object:Gem::Requirement
|
|
118
129
|
none: false
|
|
119
130
|
requirements:
|
|
120
131
|
- - ">="
|
|
@@ -122,7 +133,7 @@ dependencies:
|
|
|
122
133
|
version: "3.6"
|
|
123
134
|
type: :development
|
|
124
135
|
prerelease: false
|
|
125
|
-
version_requirements: *
|
|
136
|
+
version_requirements: *id011
|
|
126
137
|
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.
|
|
127
138
|
email: http://sylvester.keil.or.at
|
|
128
139
|
executables: []
|
|
@@ -147,6 +158,7 @@ files:
|
|
|
147
158
|
- features/bibtex.feature
|
|
148
159
|
- features/entries.feature
|
|
149
160
|
- features/issues/braced_strings.feature
|
|
161
|
+
- features/issues/latex_filter.feature
|
|
150
162
|
- features/issues/number_keys.feature
|
|
151
163
|
- features/issues/parse_months.feature
|
|
152
164
|
- features/issues/slash_keys.feature
|
|
@@ -227,7 +239,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
227
239
|
requirements:
|
|
228
240
|
- - ">="
|
|
229
241
|
- !ruby/object:Gem::Version
|
|
230
|
-
hash:
|
|
242
|
+
hash: 2367743903630420638
|
|
231
243
|
segments:
|
|
232
244
|
- 0
|
|
233
245
|
version: "0"
|