bibtex-ruby 5.1.3 → 5.1.4

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: 31cdff476cee38ead2161b578b907daa073320391523659cc14d35e8fae5c052
4
- data.tar.gz: e7e2a2c9ef27f881a3a8fc85897e4d3f3419759e35ad533a0bb47520ff88cb9e
3
+ metadata.gz: 980c5b47dd86c02f33fa428d64a71b1743912452b464b71d4f9eda7a9960fbc7
4
+ data.tar.gz: 60bddbfcaf99d248a5ee893495a63106ead7712fe861b13137ef7e34aaedc584
5
5
  SHA512:
6
- metadata.gz: 95b3fb3bd7dc0475202faf023971c3b6f89c12670dcc1cad00794e61af94cbeb3f348656f8a4c3d5f0ba9fed1c716b439588922ed84f68fb7dbf9f98cbf4e0a8
7
- data.tar.gz: 74c852d9a65c060c10da882efcc192f8ec912b5dd95fa249678350a9bd82e9678e2cc052580dbe4ae712f065f6542480c4cb0705b387dda716c95d9d1e5545f5
6
+ metadata.gz: 4fdcba9e792dbe07ba3787b356858e5b75f3a5c8fcc0fb716f33ba4868637efc3a574edffe7ca59445c0e5dc71e8d5a1ec718d5fec642ac66cbcb0e973e44781
7
+ data.tar.gz: 63eb1cd74717a63df3772ade0d2526cfd1e14a9e87aa98f628cb247208a139c80c467dee7e981561228e50eaa8483937b94f52c74cd5162c39e86da2d547cc20
@@ -20,6 +20,7 @@ class BibTeX::Entry::CiteProcConverter
20
20
  organization publisher
21
21
  howpublished publisher
22
22
  type genre
23
+ urldate accessed
23
24
  ].map(&:intern)]).freeze
24
25
 
25
26
  CSL_FIELDS = %w[
@@ -123,6 +124,21 @@ class BibTeX::Entry::CiteProcConverter
123
124
  end
124
125
  end
125
126
 
127
+ def accessed
128
+ return unless hash.key? 'accessed'
129
+
130
+ hash['accessed'] =
131
+ case hash['accessed']
132
+ when %r{^[\d/\s-]+$}
133
+ {
134
+ 'date-parts' =>
135
+ hash['accessed'].split('/').map { |pt| pt.split('-').map(&:to_i) }
136
+ }
137
+ else
138
+ { 'literal' => hash['accessed'] }
139
+ end
140
+ end
141
+
126
142
  def key
127
143
  hash['id'] = bibtex.key.to_s
128
144
  end
@@ -180,7 +180,12 @@ module BibTeX
180
180
  # If the option :filter is given, the Value will be converted using
181
181
  # the filter(s) specified.
182
182
  def to_s(options = {})
183
- return convert(options[:filter]).to_s(options.reject { |k,| k == :filter || (k == :quotes && (!atomic? || symbol?)) }) if options.key?(:filter)
183
+ if options.key?(:filter)
184
+ return convert(options[:filter]).to_s(
185
+ options.reject { |k,| k == :filter || (k == :quotes && (!atomic? || symbol?)) }
186
+ )
187
+ end
188
+
184
189
  return value.to_s unless options.key?(:quotes) && atomic? && !symbol?
185
190
 
186
191
  q = Array(options[:quotes])
@@ -20,7 +20,7 @@ module BibTeX
20
20
  module Version
21
21
  MAJOR = 5
22
22
  MINOR = 1
23
- PATCH = 3
23
+ PATCH = 4
24
24
  BUILD = nil
25
25
 
26
26
  STRING = [MAJOR, MINOR, PATCH, BUILD].compact.join('.').freeze
@@ -31,7 +31,8 @@ module BibTeX
31
31
  @bib = Bibliography.parse <<-END
32
32
  @book{a, editor = "A", title = "A"}
33
33
  @incollection{a1, crossref = "a"}
34
- @incollection{b1, crossref = "b"}
34
+ @incollection{b1, crossref = "b2"}
35
+ @book{b, author = "B", title = "B", date = "2020", urldate = "2020"}
35
36
  END
36
37
  end
37
38
 
@@ -124,6 +125,10 @@ module BibTeX
124
125
  it 'includes inherited values' do
125
126
  @bib['a1'].to_citeproc['container-title'].must_be :==, @bib['a'].title.to_s
126
127
  end
128
+
129
+ it 'converts urldate' do
130
+ @bib['b'].to_citeproc['accessed'].must_be :==, 'date-parts' => [[2020]]
131
+ end
127
132
  end
128
133
 
129
134
  describe '#save_inherited_fields' do
@@ -485,7 +490,7 @@ module BibTeX
485
490
 
486
491
  describe '#to_s' do
487
492
  before do
488
- @bib = Bibliography.parse(<<-BIBINPUT, { :parse_months => false })
493
+ @bib = Bibliography.parse(<<-BIBINPUT, parse_months: false)
489
494
  @misc{foo,
490
495
  title = {A
491
496
  title},
@@ -493,14 +498,14 @@ module BibTeX
493
498
  series},
494
499
  month = dec
495
500
  }
496
- BIBINPUT
501
+ BIBINPUT
497
502
  end
498
503
  it 'applies filters when converting to strings' do
499
504
  assert_equal "@misc{foo,\n"\
500
505
  " title = {A title},\n"\
501
506
  " series = {A series},\n"\
502
507
  " month = dec\n"\
503
- "}\n", @bib['foo'].to_s({ filter: :linebreaks })
508
+ "}\n", @bib['foo'].to_s(filter: :linebreaks)
504
509
  end
505
510
  end
506
511
 
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.3
4
+ version: 5.1.4
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-04-06 00:00:00.000000000 Z
11
+ date: 2020-04-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: latex-decode
@@ -143,22 +143,22 @@ required_rubygems_version: !ruby/object:Gem::Requirement
143
143
  - !ruby/object:Gem::Version
144
144
  version: '0'
145
145
  requirements: []
146
- rubygems_version: 3.1.2
146
+ rubygems_version: 3.0.3
147
147
  signing_key:
148
148
  specification_version: 4
149
149
  summary: A BibTeX parser, converter and API for Ruby.
150
150
  test_files:
151
+ - test/test_export.rb
152
+ - test/bibtex/test_filters.rb
151
153
  - test/bibtex/entry/test_rdf_converter.rb
152
- - test/bibtex/test_elements.rb
153
- - test/bibtex/test_lexer.rb
154
154
  - test/bibtex/test_name_parser.rb
155
- - test/bibtex/test_names.rb
156
- - test/bibtex/test_parser.rb
157
- - test/bibtex/test_string.rb
158
155
  - test/bibtex/test_utilities.rb
159
- - test/bibtex/test_value.rb
160
- - test/bibtex/test_filters.rb
161
156
  - test/bibtex/test_bibliography.rb
157
+ - test/bibtex/test_string.rb
158
+ - test/bibtex/test_value.rb
162
159
  - test/bibtex/test_entry.rb
160
+ - test/bibtex/test_lexer.rb
161
+ - test/bibtex/test_names.rb
162
+ - test/bibtex/test_elements.rb
163
+ - test/bibtex/test_parser.rb
163
164
  - test/test_bibtex.rb
164
- - test/test_export.rb