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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8579fc07e8437d733ae2593adedd2e9b9a53cdc6
4
- data.tar.gz: 8bc0cb71db6ce4b2e80fe1385251e8f261cc6b8b
3
+ metadata.gz: 4ebc35f0ed6cd31025b806b1dd863c89b345c88e
4
+ data.tar.gz: 9d238e137990f200ea53b92e19ddf96dd147a5df
5
5
  SHA512:
6
- metadata.gz: 5fc0d42f2a46852bb5d3c9f837ae9870a6c0a12511da63157d9f6955fd86dc95ebf1ab67b6c8df355754d2c54f97b75934e1135573865b0066871f14d23a2354
7
- data.tar.gz: 08560e71aae34c126709a9ea6ba7cb016702c246201948af8952ad81ea8e56370532d932fbc836d20a6950d1da7b0841b540f3835e1a5d11efd494552c56adbe
6
+ metadata.gz: f5ea802c71afacd7749595702d997e0da04d03dad30e70366765d384fa14a81f8dc7191e8de159fde6f51b755e880068a43cae403b1d43b8b715bc6baf94dd60
7
+ data.tar.gz: 0baa93fb426d8c8ceeca8f902fb6db70203ebff5bd37be53023b5e3b7abf4fa2f6f928445faaf265ba11d53e9707b63615b4c1af9aa26c27822d2db316220b3d
data/History.txt CHANGED
@@ -1,3 +1,8 @@
1
+ 3.1.1 / 2014-01-20
2
+ ==================
3
+
4
+ * RDF Export improvements (@tmaier)
5
+
1
6
  3.1.0 / 2014-01-20
2
7
  ==================
3
8
 
data/Rakefile CHANGED
@@ -63,7 +63,7 @@ task :console, [:script] do |t,args|
63
63
 
64
64
  require 'irb'
65
65
  require 'bibtex'
66
-
66
+
67
67
  IRB.conf[:SCRIPT] = args.script
68
68
  IRB.start
69
69
  end
@@ -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*,\s*/).each do |keyword|
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) || bibtex.field?(:organization) || bibtex.field?(:school)
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
- graph << [entry, bibo[:degree], degree] unless degree.nil?
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].join(': ')
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
@@ -20,7 +20,7 @@ module BibTeX
20
20
  module Version
21
21
  MAJOR = 3
22
22
  MINOR = 1
23
- PATCH = 0
23
+ PATCH = 1
24
24
  BUILD = nil
25
25
 
26
26
  STRING = [MAJOR, MINOR, PATCH, BUILD].compact.join('.').freeze
@@ -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
 
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: 3.1.0
4
+ version: 3.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sylvester Keil