bibtex-ruby 3.1.0 → 3.1.1
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/History.txt +5 -0
- data/Rakefile +1 -1
- data/lib/bibtex/entry/rdf_converter.rb +44 -7
- data/lib/bibtex/version.rb +1 -1
- data/test/bibtex/entry/test_rdf_converter.rb +24 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4ebc35f0ed6cd31025b806b1dd863c89b345c88e
|
4
|
+
data.tar.gz: 9d238e137990f200ea53b92e19ddf96dd147a5df
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f5ea802c71afacd7749595702d997e0da04d03dad30e70366765d384fa14a81f8dc7191e8de159fde6f51b755e880068a43cae403b1d43b8b715bc6baf94dd60
|
7
|
+
data.tar.gz: 0baa93fb426d8c8ceeca8f902fb6db70203ebff5bd37be53023b5e3b7abf4fa2f6f928445faaf265ba11d53e9707b63615b4c1af9aa26c27822d2db316220b3d
|
data/History.txt
CHANGED
data/Rakefile
CHANGED
@@ -2,10 +2,10 @@ require 'uri/common'
|
|
2
2
|
|
3
3
|
class BibTeX::Entry::RDFConverter
|
4
4
|
DEFAULT_REMOVE_FROM_FALLBACK = %w(
|
5
|
-
date-modified
|
6
5
|
bdsk-file-1
|
7
6
|
bdsk-file-2
|
8
7
|
bdsk-file-3
|
8
|
+
bdsk-file-4
|
9
9
|
).map(&:intern).freeze
|
10
10
|
|
11
11
|
BIBO_TYPES = Hash[*%w{
|
@@ -66,6 +66,17 @@ class BibTeX::Entry::RDFConverter
|
|
66
66
|
graph << [entry, bibo[:abstract], bibtex[:abstract].to_s]
|
67
67
|
end
|
68
68
|
|
69
|
+
def annote
|
70
|
+
return unless bibtex.field?(:annote)
|
71
|
+
remove_from_fallback(:annote)
|
72
|
+
|
73
|
+
pub = RDF::Node.new
|
74
|
+
graph << [pub, RDF.type, bibo[:Note]]
|
75
|
+
graph << [pub, bibo[:content], bibtex[:annote]]
|
76
|
+
|
77
|
+
graph << [entry, bibo[:annotates], pub]
|
78
|
+
end
|
79
|
+
|
69
80
|
def author
|
70
81
|
return unless bibtex.field?(:author)
|
71
82
|
remove_from_fallback(:author)
|
@@ -83,6 +94,17 @@ class BibTeX::Entry::RDFConverter
|
|
83
94
|
end
|
84
95
|
end
|
85
96
|
|
97
|
+
def bdsk_url
|
98
|
+
count = 1
|
99
|
+
while bibtex.field?("bdsk-url-#{count}".to_sym) do
|
100
|
+
field = "bdsk-url-#{count}".to_sym
|
101
|
+
remove_from_fallback(field)
|
102
|
+
graph << [entry, RDF::DC.URI, bibtex[field].to_s]
|
103
|
+
graph << [entry, bibo[:uri], bibtex[field].to_s]
|
104
|
+
count += 1
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
86
108
|
def booktitle
|
87
109
|
return unless bibtex.field?(:booktitle)
|
88
110
|
remove_from_fallback(:booktitle)
|
@@ -132,6 +154,13 @@ class BibTeX::Entry::RDFConverter
|
|
132
154
|
graph << [entry, RDF::DC.created, bibtex[:'date-added'].to_s]
|
133
155
|
end
|
134
156
|
|
157
|
+
def date_modified
|
158
|
+
return unless bibtex.field?(:'date-modified')
|
159
|
+
remove_from_fallback(:'date-modified')
|
160
|
+
|
161
|
+
graph << [entry, RDF::DC.modified, bibtex[:'date-modified'].to_s]
|
162
|
+
end
|
163
|
+
|
135
164
|
def doi
|
136
165
|
return unless bibtex.field?(:doi)
|
137
166
|
remove_from_fallback(:doi)
|
@@ -244,7 +273,7 @@ class BibTeX::Entry::RDFConverter
|
|
244
273
|
return unless bibtex.field?(:keywords)
|
245
274
|
remove_from_fallback(:keywords)
|
246
275
|
|
247
|
-
bibtex[:keywords].to_s.split(/\s
|
276
|
+
bibtex[:keywords].to_s.split(/\s*[,;]\s*/).each do |keyword|
|
248
277
|
graph << [entry, RDF::DC.subject, keyword]
|
249
278
|
end
|
250
279
|
end
|
@@ -338,7 +367,7 @@ class BibTeX::Entry::RDFConverter
|
|
338
367
|
end
|
339
368
|
|
340
369
|
def publisher
|
341
|
-
return unless bibtex.field?(:publisher
|
370
|
+
return unless bibtex.field?(:publisher, :organization, :school, :institution)
|
342
371
|
remove_from_fallback(:publisher, :address)
|
343
372
|
|
344
373
|
org =
|
@@ -349,6 +378,8 @@ class BibTeX::Entry::RDFConverter
|
|
349
378
|
agent(bibtex[:organization].to_s) { create_agent(bibtex[:organization].to_s, :Organization) }
|
350
379
|
when bibtex.field?(:school)
|
351
380
|
agent(bibtex[:school].to_s) { create_agent(bibtex[:school].to_s, :Organization) }
|
381
|
+
when bibtex.field?(:institution)
|
382
|
+
agent(bibtex[:institution].to_s) { create_agent(bibtex[:institution].to_s, :Organization) }
|
352
383
|
end
|
353
384
|
|
354
385
|
if bibtex.field?(:address)
|
@@ -398,20 +429,26 @@ class BibTeX::Entry::RDFConverter
|
|
398
429
|
case bibtex[:type]
|
399
430
|
when 'mathesis' then bibo['degrees/ma']
|
400
431
|
when 'phdthesis' then bibo['degrees/phd']
|
432
|
+
when /Dissertation/i then bibo['degrees/phd']
|
401
433
|
when /Bachelor['s]{0,2} Thesis/i then "Bachelor's Thesis"
|
402
434
|
when /Diplomarbeit/i then bibo['degrees/ms']
|
403
435
|
when /Magisterarbeit/i then bibo['degrees/ma']
|
404
436
|
else degree
|
405
437
|
end
|
406
438
|
|
407
|
-
|
439
|
+
unless degree.nil?
|
440
|
+
remove_from_fallback(:type)
|
441
|
+
graph << [entry, bibo[:degree], degree]
|
442
|
+
end
|
408
443
|
end
|
409
444
|
|
410
445
|
def title
|
411
446
|
return unless bibtex.field?(:title)
|
412
447
|
remove_from_fallback(:title)
|
413
448
|
|
414
|
-
title = [bibtex[:title].to_s, bibtex[:subtitle].to_s]
|
449
|
+
title = [bibtex[:title].to_s, bibtex[:subtitle].to_s]
|
450
|
+
.reject { |t| t.nil? || t.empty? }
|
451
|
+
.join(': ')
|
415
452
|
graph << [entry, RDF::DC.title, title]
|
416
453
|
graph << [entry, bibo[:shortTitle], bibtex[:title].to_s] if bibtex.field?(:subtitle)
|
417
454
|
end
|
@@ -429,7 +466,7 @@ class BibTeX::Entry::RDFConverter
|
|
429
466
|
end
|
430
467
|
|
431
468
|
def type
|
432
|
-
graph << [entry, RDF.type, bibo_class]
|
469
|
+
graph << [entry, RDF.type, bibo[bibo_class]]
|
433
470
|
|
434
471
|
case bibtex.type
|
435
472
|
when :proceedings, :journal
|
@@ -470,7 +507,7 @@ class BibTeX::Entry::RDFConverter
|
|
470
507
|
month = BibTeX::Entry::MONTHS.find_index(bibtex[:month].to_s.intern)
|
471
508
|
month += 1 unless month.nil?
|
472
509
|
end
|
473
|
-
date = [year, month].join('-')
|
510
|
+
date = month.nil? ? year : [year, month].join('-')
|
474
511
|
|
475
512
|
graph << [entry, RDF::DC.issued, date]
|
476
513
|
end
|
data/lib/bibtex/version.rb
CHANGED
@@ -20,6 +20,14 @@ module BibTeX
|
|
20
20
|
end
|
21
21
|
end
|
22
22
|
|
23
|
+
describe '#annote' do
|
24
|
+
let(:entry) { Entry.new(annote: 'foo') }
|
25
|
+
|
26
|
+
it 'should run successfully' do
|
27
|
+
subject.annote
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
23
31
|
describe '#author' do
|
24
32
|
let(:entry) { Entry.new(author: 'Gustav Gans and Donald Duck') }
|
25
33
|
|
@@ -28,6 +36,14 @@ module BibTeX
|
|
28
36
|
end
|
29
37
|
end
|
30
38
|
|
39
|
+
describe '#bdsk_url' do
|
40
|
+
let(:entry) { Entry.new(:'bdsk-url-1' => 'http://www.example.com') }
|
41
|
+
|
42
|
+
it 'should run successfully' do
|
43
|
+
subject.bdsk_url
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
31
47
|
describe '#booktitle' do
|
32
48
|
let(:entry) { Entry.new(booktitle: 'Entenhausen brennt!') }
|
33
49
|
|
@@ -64,6 +80,14 @@ module BibTeX
|
|
64
80
|
end
|
65
81
|
end
|
66
82
|
|
83
|
+
describe '#date_modified' do
|
84
|
+
let(:entry) { Entry.new(:'date-modified' => '2014-01-20') }
|
85
|
+
|
86
|
+
it 'should run successfully' do
|
87
|
+
subject.date_modified
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
67
91
|
describe '#doi' do
|
68
92
|
let(:entry) { Entry.new(doi: '10.1000/182') }
|
69
93
|
|