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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e1220f03462fd20dc2547ad2d690860f971e3ae6d73374d76071e78d62438eee
4
- data.tar.gz: c518a5179f6325c0ac3a2cba62107e3e6be6b7fe8c40a5b0c02f8ef38dea56fe
3
+ metadata.gz: c9ac5e9768e0d7068c9283e81a5f678b57f5f5d0088050fd9568882277fe9a4f
4
+ data.tar.gz: 5cdbb72904fd9836db7479b5eecfb3e0d89410798fd286b63e7ffd32c2a6701b
5
5
  SHA512:
6
- metadata.gz: d0d1816bd6913c7723b8ac6d77d42ea4e87cd1a76451c8075a890e802846402b4c27de8293ff842702a210305758279465da47541798b6cd20359a0fa0691e4e
7
- data.tar.gz: 67dba827e0ea514f6182fd82fb489034a7551b4704061539e1e316094e32be8ab7a31ac36753f299f96031543bf4e390c88dfacda4b472242e366daac0a9ef93
6
+ metadata.gz: 932db70949073cee21ee395c8b927b6e17fa065ffa90388f6092f69f758cf30580373ef039872221bb6aac933484850f9e734ced933a8c7699bceaa16d26b791
7
+ data.tar.gz: f1b94a673dd9bc16a195de943c21264c189a6b6623c7abc641e1af554216bdf5b06ac141ef85061221f2aba460f72d6b9a3b52f4207a8feec5ca44ffb6b731f9
data/Gemfile CHANGED
@@ -33,6 +33,7 @@ end
33
33
 
34
34
  group :development do
35
35
  gem 'iconv', platforms: [:ruby]
36
+ gem 'racc'
36
37
  gem 'rake'
37
38
  gem 'rubocop', require: false
38
39
  gem 'yard'
@@ -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
- cp_key = CSL_FILTER[key].to_s
151
+ citeproc_key = CSL_FILTER[key].to_s
150
152
 
151
- if hash.key?(cp_key)
153
+ if hash.key?(citeproc_key)
152
154
  hash[key] = value.to_citeproc(options)
153
155
  else
154
- hash[cp_key] = value.to_citeproc(options)
156
+ hash[citeproc_key] = value.to_citeproc(options)
155
157
  end
156
158
  end
157
159
 
158
- def hash
159
- @hash ||= {}
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
@@ -20,7 +20,7 @@ module BibTeX
20
20
  module Version
21
21
  MAJOR = 5
22
22
  MINOR = 1
23
- PATCH = 1
23
+ PATCH = 2
24
24
  BUILD = nil
25
25
 
26
26
  STRING = [MAJOR, MINOR, PATCH, BUILD].compact.join('.').freeze
@@ -433,7 +433,7 @@ module BibTeX
433
433
  end
434
434
  end
435
435
 
436
- describe 'citeproc export' do
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.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-01-17 00:00:00.000000000 Z
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