bibtex-ruby 5.1.1 → 5.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +1 -0
- data/lib/bibtex/entry/citeproc_converter.rb +12 -6
- data/lib/bibtex/version.rb +1 -1
- data/test/bibtex/test_entry.rb +32 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c9ac5e9768e0d7068c9283e81a5f678b57f5f5d0088050fd9568882277fe9a4f
|
4
|
+
data.tar.gz: 5cdbb72904fd9836db7479b5eecfb3e0d89410798fd286b63e7ffd32c2a6701b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 932db70949073cee21ee395c8b927b6e17fa065ffa90388f6092f69f758cf30580373ef039872221bb6aac933484850f9e734ced933a8c7699bceaa16d26b791
|
7
|
+
data.tar.gz: f1b94a673dd9bc16a195de943c21264c189a6b6623c7abc641e1af554216bdf5b06ac141ef85061221f2aba460f72d6b9a3b52f4207a8feec5ca44ffb6b731f9
|
data/Gemfile
CHANGED
@@ -56,6 +56,7 @@ class BibTeX::Entry::CiteProcConverter
|
|
56
56
|
|
57
57
|
def initialize(bibtex, options = {})
|
58
58
|
@bibtex = bibtex
|
59
|
+
@hash = {}
|
59
60
|
@options = { quotes: [] }.merge(options)
|
60
61
|
end
|
61
62
|
|
@@ -141,21 +142,26 @@ class BibTeX::Entry::CiteProcConverter
|
|
141
142
|
|
142
143
|
private
|
143
144
|
|
144
|
-
attr_reader :bibtex, :options
|
145
|
+
attr_reader :bibtex, :options, :hash
|
145
146
|
|
146
147
|
def convert(key, value)
|
147
148
|
return if BibTeX::Entry::DATE_FIELDS.include?(key)
|
149
|
+
return include_url(value) if howpublished_with_url?(key, value)
|
148
150
|
|
149
|
-
|
151
|
+
citeproc_key = CSL_FILTER[key].to_s
|
150
152
|
|
151
|
-
if hash.key?(
|
153
|
+
if hash.key?(citeproc_key)
|
152
154
|
hash[key] = value.to_citeproc(options)
|
153
155
|
else
|
154
|
-
hash[
|
156
|
+
hash[citeproc_key] = value.to_citeproc(options)
|
155
157
|
end
|
156
158
|
end
|
157
159
|
|
158
|
-
def
|
159
|
-
|
160
|
+
def howpublished_with_url?(key, value)
|
161
|
+
key == :howpublished && value.include?('url')
|
162
|
+
end
|
163
|
+
|
164
|
+
def include_url(value)
|
165
|
+
hash['URL'] = value.to_s[/url{?([^}]*)/, 1]
|
160
166
|
end
|
161
167
|
end
|
data/lib/bibtex/version.rb
CHANGED
data/test/bibtex/test_entry.rb
CHANGED
@@ -433,7 +433,7 @@ module BibTeX
|
|
433
433
|
end
|
434
434
|
end
|
435
435
|
|
436
|
-
describe '
|
436
|
+
describe '#to_citeproc' do
|
437
437
|
before do
|
438
438
|
@entry = Entry.new do |e|
|
439
439
|
e.type = :book
|
@@ -450,6 +450,37 @@ module BibTeX
|
|
450
450
|
it 'should accept option to use non-dropping-particle' do
|
451
451
|
assert_equal 'van', @entry.to_citeproc(particle: 'non-dropping-particle')['author'][0]['non-dropping-particle']
|
452
452
|
end
|
453
|
+
|
454
|
+
describe 'howpublished' do
|
455
|
+
it 'converts to "URL" when there is a url (without filters)' do
|
456
|
+
bibtex = <<-END
|
457
|
+
@book{noauthor_2017-xx,
|
458
|
+
title = "Google",
|
459
|
+
howpublished = "\\url{http://www.google.com/}"
|
460
|
+
}
|
461
|
+
END
|
462
|
+
bibliography = Bibliography.parse(bibtex)
|
463
|
+
|
464
|
+
citeproc = bibliography.to_citeproc
|
465
|
+
|
466
|
+
assert_equal('http://www.google.com/', citeproc[0]['URL'])
|
467
|
+
assert_nil(citeproc[0]['publisher'])
|
468
|
+
end
|
469
|
+
|
470
|
+
it 'converts to "URL" when there is a url (with latex)' do
|
471
|
+
bibtex = <<-END
|
472
|
+
@book{noauthor_2017-xx,
|
473
|
+
title = "Google",
|
474
|
+
howpublished = "\\url{http://www.google.com/}"
|
475
|
+
}
|
476
|
+
END
|
477
|
+
bibliography = Bibliography.parse(bibtex, filter: :latex)
|
478
|
+
|
479
|
+
citeproc = bibliography.to_citeproc
|
480
|
+
|
481
|
+
assert_equal('http://www.google.com/', citeproc[0]['URL'])
|
482
|
+
end
|
483
|
+
end
|
453
484
|
end
|
454
485
|
|
455
486
|
def test_simple
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bibtex-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 5.1.
|
4
|
+
version: 5.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sylvester Keil
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-02-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: latex-decode
|
@@ -157,8 +157,8 @@ test_files:
|
|
157
157
|
- test/bibtex/test_string.rb
|
158
158
|
- test/bibtex/test_utilities.rb
|
159
159
|
- test/bibtex/test_value.rb
|
160
|
-
- test/bibtex/test_entry.rb
|
161
160
|
- test/bibtex/test_filters.rb
|
162
161
|
- test/bibtex/test_bibliography.rb
|
162
|
+
- test/bibtex/test_entry.rb
|
163
163
|
- test/test_bibtex.rb
|
164
164
|
- test/test_export.rb
|