bibtex-ruby 3.0.1 → 3.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.
- checksums.yaml +4 -4
- data/Gemfile +29 -17
- data/History.txt +5 -0
- data/Manifest +8 -0
- data/README.md +33 -31
- data/bibtex-ruby.gemspec +2 -3
- data/features/issues/non_ascii_default_keys.feature +3 -3
- data/features/support/env.rb +12 -10
- data/lib/bibtex.rb +14 -4
- data/lib/bibtex/bibliography.rb +10 -12
- data/lib/bibtex/bibliography/rdf_converter.rb +27 -0
- data/lib/bibtex/compatibility.rb +1 -1
- data/lib/bibtex/elements.rb +2 -2
- data/lib/bibtex/entry.rb +9 -233
- data/lib/bibtex/entry/bibtexml_converter.rb +44 -0
- data/lib/bibtex/entry/citeproc_converter.rb +110 -0
- data/lib/bibtex/entry/rdf_converter.rb +543 -0
- data/lib/bibtex/lexer.rb +1 -1
- data/lib/bibtex/names.rb +2 -2
- data/lib/bibtex/value.rb +1 -1
- data/lib/bibtex/version.rb +7 -7
- data/test/bibtex/entry/test_rdf_converter.rb +317 -0
- data/test/bibtex/test_bibliography.rb +1 -1
- data/test/bibtex/test_entry.rb +2 -1
- data/test/bibtex/test_names.rb +1 -1
- data/test/bibtex/test_utilities.rb +8 -8
- data/test/helper.rb +16 -8
- data/test/test_bibtex.rb +1 -1
- data/test/test_export.rb +5 -5
- metadata +20 -28
data/lib/bibtex/lexer.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
#--
|
2
2
|
# BibTeX-Ruby
|
3
|
-
# Copyright (C) 2010-
|
3
|
+
# Copyright (C) 2010-2014 Sylvester Keil <http://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
|
data/lib/bibtex/names.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
#--
|
2
2
|
# BibTeX-Ruby
|
3
|
-
# Copyright (C) 2010-
|
3
|
+
# Copyright (C) 2010-2014 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
|
@@ -297,4 +297,4 @@ module BibTeX
|
|
297
297
|
alias von= prefix=
|
298
298
|
|
299
299
|
end
|
300
|
-
end
|
300
|
+
end
|
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-2014 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,26 +1,26 @@
|
|
1
1
|
#--
|
2
2
|
# BibTeX-Ruby
|
3
|
-
# Copyright (C) 2010-
|
4
|
-
#
|
3
|
+
# Copyright (C) 2010-2014 Sylvester Keil <sylvester.keil.or.at>
|
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
|
7
7
|
# the Free Software Foundation, either version 3 of the License, or
|
8
8
|
# (at your option) any later version.
|
9
|
-
#
|
9
|
+
#
|
10
10
|
# This program is distributed in the hope that it will be useful,
|
11
11
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12
12
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
13
13
|
# GNU General Public License for more details.
|
14
|
-
#
|
14
|
+
#
|
15
15
|
# You should have received a copy of the GNU General Public License
|
16
16
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
17
17
|
#++
|
18
18
|
|
19
19
|
module BibTeX
|
20
|
-
module Version
|
20
|
+
module Version
|
21
21
|
MAJOR = 3
|
22
|
-
MINOR =
|
23
|
-
PATCH =
|
22
|
+
MINOR = 1
|
23
|
+
PATCH = 0
|
24
24
|
BUILD = nil
|
25
25
|
|
26
26
|
STRING = [MAJOR, MINOR, PATCH, BUILD].compact.join('.').freeze
|
@@ -0,0 +1,317 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
|
3
|
+
require 'helper.rb'
|
4
|
+
|
5
|
+
module BibTeX
|
6
|
+
class RDFConverterTest < Minitest::Spec
|
7
|
+
subject { BibTeX::Entry::RDFConverter.new(entry) }
|
8
|
+
let(:entry) { Entry.new }
|
9
|
+
|
10
|
+
before do
|
11
|
+
entry.parse_names
|
12
|
+
entry.parse_month
|
13
|
+
end
|
14
|
+
|
15
|
+
describe '#abstract' do
|
16
|
+
let(:entry) { Entry.new(abstract: 'foo') }
|
17
|
+
|
18
|
+
it 'should run successfully' do
|
19
|
+
subject.abstract
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
describe '#author' do
|
24
|
+
let(:entry) { Entry.new(author: 'Gustav Gans and Donald Duck') }
|
25
|
+
|
26
|
+
it 'should run successfully' do
|
27
|
+
subject.author
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
describe '#booktitle' do
|
32
|
+
let(:entry) { Entry.new(booktitle: 'Entenhausen brennt!') }
|
33
|
+
|
34
|
+
it 'should run successfully' do
|
35
|
+
subject.booktitle
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
describe '#chapter' do
|
40
|
+
let(:entry) { Entry.new(chapter: '4') }
|
41
|
+
|
42
|
+
it 'should run successfully' do
|
43
|
+
subject.chapter
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
describe '#children' do
|
48
|
+
it 'should run successfully'
|
49
|
+
end
|
50
|
+
|
51
|
+
describe '#copyright' do
|
52
|
+
let(:entry) { Entry.new(copyright: 'King Kong') }
|
53
|
+
|
54
|
+
it 'should run successfully' do
|
55
|
+
subject.copyright
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
describe '#date_added' do
|
60
|
+
let(:entry) { Entry.new(:'date-added' => '2014-01-20') }
|
61
|
+
|
62
|
+
it 'should run successfully' do
|
63
|
+
subject.date_added
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
describe '#doi' do
|
68
|
+
let(:entry) { Entry.new(doi: '10.1000/182') }
|
69
|
+
|
70
|
+
it 'should run successfully' do
|
71
|
+
subject.doi
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
describe '#edition' do
|
76
|
+
let(:entry) { Entry.new(edition: 'fifth edition') }
|
77
|
+
|
78
|
+
it 'should run successfully' do
|
79
|
+
subject.edition
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
describe '#editor' do
|
84
|
+
let(:entry) { Entry.new(editor: 'Dagobert Duck') }
|
85
|
+
|
86
|
+
it 'should run successfully' do
|
87
|
+
subject.editor
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
describe '#fallback_default' do
|
92
|
+
it 'should run successfully' do
|
93
|
+
subject.fallback_default
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
describe '#howpublished' do
|
98
|
+
let(:entry) { Entry.new(howpublished: 'http://www.example.com') }
|
99
|
+
|
100
|
+
it 'should run successfully' do
|
101
|
+
subject.howpublished
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
|
+
describe '#institution' do
|
106
|
+
let(:entry) { Entry.new(institution: 'University of Duckberg') }
|
107
|
+
|
108
|
+
it 'should run successfully' do
|
109
|
+
subject.institution
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
113
|
+
describe '#isbn' do
|
114
|
+
let(:entry) { Entry.new(isbn: '978-3-935322-14-0') }
|
115
|
+
|
116
|
+
it 'should run successfully' do
|
117
|
+
subject.isbn
|
118
|
+
end
|
119
|
+
end
|
120
|
+
|
121
|
+
describe '#issn' do
|
122
|
+
let(:entry) { Entry.new(issn: '978-3-935322-14-0') }
|
123
|
+
|
124
|
+
it 'should run successfully' do
|
125
|
+
subject.issn
|
126
|
+
end
|
127
|
+
end
|
128
|
+
|
129
|
+
describe '#journal_dc_source' do
|
130
|
+
let(:entry) { Entry.new(journal: 'Lustiges Taschenbuch') }
|
131
|
+
|
132
|
+
it 'should run successfully' do
|
133
|
+
subject.journal_dc_source
|
134
|
+
end
|
135
|
+
end
|
136
|
+
|
137
|
+
describe '#journal_dc_part_of' do
|
138
|
+
let(:entry) { Entry.new(journal: 'Lustiges Taschenbuch') }
|
139
|
+
|
140
|
+
it 'should run successfully' do
|
141
|
+
subject.journal_dc_part_of
|
142
|
+
end
|
143
|
+
end
|
144
|
+
|
145
|
+
describe '#key' do
|
146
|
+
let(:entry) { Entry.new(key: 'pickaxe') }
|
147
|
+
|
148
|
+
it 'should run successfully' do
|
149
|
+
subject.key
|
150
|
+
end
|
151
|
+
end
|
152
|
+
|
153
|
+
describe '#keywords' do
|
154
|
+
let(:entry) { Entry.new(keywords: 'Ruby, RDF, Fun') }
|
155
|
+
|
156
|
+
it 'should run successfully' do
|
157
|
+
subject.keywords
|
158
|
+
end
|
159
|
+
end
|
160
|
+
|
161
|
+
describe '#language' do
|
162
|
+
let(:entry) { Entry.new(language: 'french') }
|
163
|
+
|
164
|
+
it 'should run successfully' do
|
165
|
+
subject.language
|
166
|
+
end
|
167
|
+
end
|
168
|
+
|
169
|
+
describe '#location' do
|
170
|
+
let(:entry) { Entry.new(location: 'Duckberg') }
|
171
|
+
|
172
|
+
it 'should run successfully' do
|
173
|
+
subject.location
|
174
|
+
end
|
175
|
+
end
|
176
|
+
|
177
|
+
describe '#lccn' do
|
178
|
+
let(:entry) { Entry.new(lccn: '1234') }
|
179
|
+
|
180
|
+
it 'should run successfully' do
|
181
|
+
subject.lccn
|
182
|
+
end
|
183
|
+
end
|
184
|
+
|
185
|
+
describe '#note' do
|
186
|
+
let(:entry) { Entry.new(note: 'Never gonna give you up!') }
|
187
|
+
|
188
|
+
it 'should run successfully' do
|
189
|
+
subject.note
|
190
|
+
end
|
191
|
+
end
|
192
|
+
|
193
|
+
describe '#number' do
|
194
|
+
let(:entry) { Entry.new(number: '2') }
|
195
|
+
|
196
|
+
it 'should run successfully' do
|
197
|
+
subject.number
|
198
|
+
end
|
199
|
+
end
|
200
|
+
|
201
|
+
describe '#organization' do
|
202
|
+
let(:entry) { Entry.new(organization: 'Azkaban Prison') }
|
203
|
+
|
204
|
+
it 'should run successfully' do
|
205
|
+
subject.organization
|
206
|
+
end
|
207
|
+
end
|
208
|
+
|
209
|
+
describe '#pages' do
|
210
|
+
let(:entry) { Entry.new(pages: '1--12') }
|
211
|
+
|
212
|
+
it 'should run successfully' do
|
213
|
+
subject.pages
|
214
|
+
end
|
215
|
+
end
|
216
|
+
|
217
|
+
describe '#pagetotal' do
|
218
|
+
let(:entry) { Entry.new(pagetotal: '12') }
|
219
|
+
|
220
|
+
it 'should run successfully' do
|
221
|
+
subject.pagetotal
|
222
|
+
end
|
223
|
+
end
|
224
|
+
|
225
|
+
describe '#parent' do
|
226
|
+
it 'should run successfully'
|
227
|
+
end
|
228
|
+
|
229
|
+
describe '#publisher' do
|
230
|
+
let(:entry) { Entry.new(publisher: 'Neustaedter Zeitung') }
|
231
|
+
|
232
|
+
it 'should run successfully' do
|
233
|
+
subject.publisher
|
234
|
+
end
|
235
|
+
end
|
236
|
+
|
237
|
+
describe '#school' do
|
238
|
+
let(:entry) { Entry.new(school: 'Hogwarts School of Witchcraft and Wizardry') }
|
239
|
+
|
240
|
+
it 'should run successfully' do
|
241
|
+
subject.school
|
242
|
+
end
|
243
|
+
end
|
244
|
+
|
245
|
+
describe '#series' do
|
246
|
+
let(:entry) { Entry.new(series: 'Harry Potter') }
|
247
|
+
|
248
|
+
it 'should run successfully' do
|
249
|
+
subject.series
|
250
|
+
end
|
251
|
+
end
|
252
|
+
|
253
|
+
describe '#thesis_degree' do
|
254
|
+
let(:entry) { Entry.new(type: :thesis) }
|
255
|
+
|
256
|
+
it 'should run successfully' do
|
257
|
+
subject.thesis_degree
|
258
|
+
end
|
259
|
+
end
|
260
|
+
|
261
|
+
describe '#title' do
|
262
|
+
let(:entry) { Entry.new(title: 'My Title') }
|
263
|
+
|
264
|
+
it 'should run successfully' do
|
265
|
+
subject.title
|
266
|
+
end
|
267
|
+
end
|
268
|
+
|
269
|
+
describe '#translator' do
|
270
|
+
let(:entry) { Entry.new(translator: 'Jon Doe') }
|
271
|
+
|
272
|
+
it 'should run successfully' do
|
273
|
+
subject.translator
|
274
|
+
end
|
275
|
+
end
|
276
|
+
|
277
|
+
describe '#type' do
|
278
|
+
let(:entry) { Entry.new(type: :proceedings) }
|
279
|
+
|
280
|
+
it 'should run successfully' do
|
281
|
+
subject.type
|
282
|
+
end
|
283
|
+
end
|
284
|
+
|
285
|
+
describe '#url' do
|
286
|
+
let(:entry) { Entry.new(url: 'http://www.example.com') }
|
287
|
+
|
288
|
+
it 'should run successfully' do
|
289
|
+
subject.url
|
290
|
+
end
|
291
|
+
end
|
292
|
+
|
293
|
+
describe '#volume' do
|
294
|
+
let(:entry) { Entry.new(volume: '4') }
|
295
|
+
|
296
|
+
it 'should run successfully' do
|
297
|
+
subject.volume
|
298
|
+
end
|
299
|
+
end
|
300
|
+
|
301
|
+
describe '#volumes' do
|
302
|
+
let(:entry) { Entry.new(volumes: '7') }
|
303
|
+
|
304
|
+
it 'should run successfully' do
|
305
|
+
subject.volumes
|
306
|
+
end
|
307
|
+
end
|
308
|
+
|
309
|
+
describe '#year' do
|
310
|
+
let(:entry) { Entry.new(year: '1977', month: 'jan') }
|
311
|
+
|
312
|
+
it 'should run successfully' do
|
313
|
+
subject.year
|
314
|
+
end
|
315
|
+
end
|
316
|
+
end
|
317
|
+
end
|
data/test/bibtex/test_entry.rb
CHANGED
@@ -271,7 +271,8 @@ module BibTeX
|
|
271
271
|
|
272
272
|
it 'support literal dates in citeproc export' do
|
273
273
|
@entry.year = 'Test'
|
274
|
-
|
274
|
+
e = @entry.to_citeproc
|
275
|
+
assert_equal({ 'literal' => 'Test' }, e['issued'])
|
275
276
|
end
|
276
277
|
|
277
278
|
describe 'given a filter object or a filter name' do
|
data/test/bibtex/test_names.rb
CHANGED
@@ -1,34 +1,34 @@
|
|
1
1
|
require 'helper.rb'
|
2
2
|
|
3
3
|
module BibTeX
|
4
|
-
|
4
|
+
|
5
5
|
class TestBibtex < Minitest::Unit::TestCase
|
6
|
-
|
6
|
+
|
7
7
|
def test_empty?
|
8
8
|
assert BibTeX.open(Test.fixtures(:empty)).empty?
|
9
9
|
refute BibTeX.open(Test.fixtures(:bibdesk)).empty?
|
10
10
|
end
|
11
|
-
|
11
|
+
|
12
12
|
def test_parse
|
13
13
|
bib = BibTeX.parse %q[ @book{ id, author = {Poe, Edgar Allen}, title = "Ligeia" } ]
|
14
14
|
assert_equal 1, bib.length
|
15
15
|
assert_equal 'Ligeia', bib[:id].title
|
16
16
|
assert_equal 'Poe, Edgar Allen', bib[:id].author.to_s
|
17
17
|
end
|
18
|
-
|
18
|
+
|
19
19
|
def test_validation
|
20
20
|
log_level = BibTeX.log.level
|
21
21
|
BibTeX.log.level = Logger::ERROR
|
22
|
-
|
22
|
+
|
23
23
|
refute BibTeX.parse(%q[ @book{ id, author = {Poe, Edgar Allen}, title = "Ligeia" } ]).valid?
|
24
24
|
assert BibTeX.parse(%q[ @book{ id, author = {Poe, Edgar Allen}, title = "Ligeia", publisher = "Penguin", year = 1996 } ]).valid?
|
25
25
|
assert BibTeX.parse(%q[ @book{ id, editor = {Poe, Edgar Allen}, title = "Ligeia", publisher = "Penguin", year = 1996 } ]).valid?
|
26
26
|
refute BibTeX.parse(%q[ @book{ id, xxxxxx = {Poe, Edgar Allen}, title = "Ligeia", publisher = "Penguin", year = 1996 } ]).valid?
|
27
27
|
refute BibTeX.parse(%q[ @book{ id, author = {Poe, Edgar Allen}, title = "Lig"eia", publisher = "Penguin", year = 1996 } ]).valid?
|
28
28
|
assert BibTeX.valid?(Test.fixtures(:bibdesk))
|
29
|
-
|
29
|
+
|
30
30
|
BibTeX.log.level = log_level
|
31
31
|
end
|
32
32
|
end
|
33
|
-
|
34
|
-
end
|
33
|
+
|
34
|
+
end
|