bibtex-ruby 5.1.3 → 5.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/bibtex/entry/citeproc_converter.rb +16 -0
- data/lib/bibtex/value.rb +6 -1
- data/lib/bibtex/version.rb +1 -1
- data/test/bibtex/test_entry.rb +9 -4
- metadata +11 -11
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 980c5b47dd86c02f33fa428d64a71b1743912452b464b71d4f9eda7a9960fbc7
|
|
4
|
+
data.tar.gz: 60bddbfcaf99d248a5ee893495a63106ead7712fe861b13137ef7e34aaedc584
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
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
|
data/lib/bibtex/value.rb
CHANGED
|
@@ -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
|
-
|
|
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])
|
data/lib/bibtex/version.rb
CHANGED
data/test/bibtex/test_entry.rb
CHANGED
|
@@ -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 = "
|
|
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,
|
|
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
|
-
|
|
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(
|
|
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.
|
|
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-
|
|
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.
|
|
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
|