bibtex-ruby 3.1.1 → 3.1.2
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.
Potentially problematic release.
This version of bibtex-ruby might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/Gemfile +3 -2
- data/History.txt +5 -0
- data/README.md +1 -0
- data/Rakefile +5 -0
- data/bibtex-ruby.gemspec +1 -1
- data/features/support/env.rb +1 -0
- data/lib/bibtex/entry/citeproc_converter.rb +44 -15
- data/lib/bibtex/version.rb +1 -1
- data/test/bibtex/test_entry.rb +62 -14
- data/test/helper.rb +1 -0
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c042ba0b1e7763904a6e41fa5c0d3de2df2c1963
|
4
|
+
data.tar.gz: 8bbe22f8178cd6e3072093d2b3bb83fc03145061
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 296d227e81b7e250bf4bad9385d4a6e6cdc1183385ec4074faac0328824f9718446990b95f7adba20272c930b7ace932a61dddcb5bb68349900c2d0a4a4d3ad6
|
7
|
+
data.tar.gz: f15dfaff08f2883c5b304b164e01f0cb39f7ef8e0c267ecfad3d43260e1e6a295adb21c0df1592915534fcccc27e4d3fd956dd8ada0817e55ca007b42f33cfbd
|
data/Gemfile
CHANGED
@@ -19,6 +19,9 @@ group :test do
|
|
19
19
|
gem 'minitest-ansi'
|
20
20
|
gem 'cucumber', '~>1.3'
|
21
21
|
gem 'unicode', '~>0.4', :platforms => [:rbx, :mswin, :mingw, :mri_19, :mri_20, :mri_21]
|
22
|
+
gem 'simplecov', '~>0.8', :require => false, :platforms => [:ruby_21, :ruby_20]
|
23
|
+
gem 'rubinius-coverage', :require => false, :platforms => :rbx
|
24
|
+
gem 'coveralls', '~>0.7', :require => false
|
22
25
|
end
|
23
26
|
|
24
27
|
group :extra do
|
@@ -34,8 +37,6 @@ end
|
|
34
37
|
group :profile do
|
35
38
|
gem 'ruby-prof', '~>0.14', :platforms => [:mri_19, :mri_20, :mri_21]
|
36
39
|
gem 'gnuplot', '~>2.4', :platforms => [:mri_19, :mri_20, :mri_21]
|
37
|
-
gem 'simplecov', '~>0.8', :require => false, :platforms => [:ruby_21, :ruby_20]
|
38
|
-
gem 'rubinius-coverage', :require => false, :platforms => :rbx
|
39
40
|
end
|
40
41
|
|
41
42
|
group :development do
|
data/History.txt
CHANGED
data/README.md
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
BibTeX-Ruby
|
2
2
|
===========
|
3
3
|
[](http://travis-ci.org/inukshuk/bibtex-ruby)
|
4
|
+
[](https://coveralls.io/r/inukshuk/bibtex-ruby)
|
4
5
|
|
5
6
|
BibTeX-Ruby is the Rubyist's swiss-army-knife for all things BibTeX. It
|
6
7
|
includes a parser for all common BibTeX objects (@string, @preamble, @comment
|
data/Rakefile
CHANGED
@@ -38,6 +38,9 @@ rescue LoadError
|
|
38
38
|
end
|
39
39
|
end
|
40
40
|
|
41
|
+
require 'coveralls/rake/task'
|
42
|
+
Coveralls::RakeTask.new
|
43
|
+
task :test_with_coveralls => [:test, :features, 'coveralls:push']
|
41
44
|
|
42
45
|
task :default => [:test, :features]
|
43
46
|
|
@@ -82,6 +85,8 @@ end
|
|
82
85
|
|
83
86
|
|
84
87
|
desc 'Updates the Manifest file'
|
88
|
+
require 'coveralls' if ENV['CI']
|
89
|
+
require 'coveralls' if ENV['CI']
|
85
90
|
task :manifest => ['clean', 'racc'] do
|
86
91
|
m = File.open('Manifest', 'w')
|
87
92
|
m.print FileList['**/*'].reject{ |f|
|
data/bibtex-ruby.gemspec
CHANGED
@@ -25,7 +25,7 @@ Gem::Specification.new do |s|
|
|
25
25
|
export/conversion to formats such as YAML, JSON, CSL, and XML (BibTeXML).
|
26
26
|
END_DESCRIPTION
|
27
27
|
|
28
|
-
s.add_runtime_dependency('latex-decode', ['
|
28
|
+
s.add_runtime_dependency('latex-decode', ['~>0.0'])
|
29
29
|
|
30
30
|
s.files = File.open('Manifest').readlines.map(&:chomp)
|
31
31
|
s.test_files = Dir.glob('test/**/test*.rb')
|
data/features/support/env.rb
CHANGED
@@ -1,17 +1,21 @@
|
|
1
1
|
class BibTeX::Entry::CiteProcConverter
|
2
2
|
CSL_FILTER = Hash.new { |h, k| k }.merge(Hash[*%w{
|
3
|
-
date
|
4
|
-
isbn
|
5
|
-
booktitle
|
6
|
-
journal
|
7
|
-
series
|
8
|
-
address
|
9
|
-
pages
|
10
|
-
number
|
11
|
-
url
|
12
|
-
doi
|
13
|
-
year
|
14
|
-
type
|
3
|
+
date issued
|
4
|
+
isbn ISBN
|
5
|
+
booktitle container-title
|
6
|
+
journal container-title
|
7
|
+
series collection-title
|
8
|
+
address publisher-place
|
9
|
+
pages page
|
10
|
+
number issue
|
11
|
+
url URL
|
12
|
+
doi DOI
|
13
|
+
year issued
|
14
|
+
type genre
|
15
|
+
school publisher
|
16
|
+
institution publisher
|
17
|
+
organization publisher
|
18
|
+
howpublished publisher
|
15
19
|
}.map(&:intern)]).freeze
|
16
20
|
|
17
21
|
CSL_FIELDS = %w{
|
@@ -35,9 +39,8 @@ class BibTeX::Entry::CiteProcConverter
|
|
35
39
|
inproceedings paper-conference
|
36
40
|
manual book
|
37
41
|
mastersthesis thesis
|
38
|
-
misc article
|
39
42
|
phdthesis thesis
|
40
|
-
proceedings
|
43
|
+
proceedings book
|
41
44
|
techreport report
|
42
45
|
unpublished manuscript
|
43
46
|
article article-journal
|
@@ -57,7 +60,15 @@ class BibTeX::Entry::CiteProcConverter
|
|
57
60
|
bibtex.parse_month
|
58
61
|
|
59
62
|
bibtex.each_pair do |key, value|
|
60
|
-
|
63
|
+
unless BibTeX::Entry::DATE_FIELDS.include?(key)
|
64
|
+
cp_key = CSL_FILTER[key].to_s
|
65
|
+
|
66
|
+
if hash.key?(cp_key)
|
67
|
+
hash[key] = value.to_citeproc(options)
|
68
|
+
else
|
69
|
+
hash[cp_key] = value.to_citeproc(options)
|
70
|
+
end
|
71
|
+
end
|
61
72
|
end
|
62
73
|
|
63
74
|
methods = self.class.instance_methods(false) - [:convert!]
|
@@ -66,6 +77,24 @@ class BibTeX::Entry::CiteProcConverter
|
|
66
77
|
hash
|
67
78
|
end
|
68
79
|
|
80
|
+
def conferences
|
81
|
+
return unless [:conference, :proceedings, :inproceedings].include?(bibtex.type)
|
82
|
+
|
83
|
+
if bibtex.field?(:organization) && bibtex.field?(:publisher)
|
84
|
+
hash['authority'] = bibtex[:organization]
|
85
|
+
hash['publisher'] = bibtex[:publisher]
|
86
|
+
end
|
87
|
+
|
88
|
+
if bibtex.field? :address
|
89
|
+
hash['event-place'] = bibtex[:address]
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
def techreport
|
94
|
+
return unless bibtex.type == :techreport
|
95
|
+
hash['number'] = bibtex[:number].to_s if bibtex.field? :number
|
96
|
+
end
|
97
|
+
|
69
98
|
def date
|
70
99
|
return unless bibtex.field?(:year)
|
71
100
|
|
data/lib/bibtex/version.rb
CHANGED
data/test/bibtex/test_entry.rb
CHANGED
@@ -259,27 +259,75 @@ module BibTeX
|
|
259
259
|
assert_equal 'Moby Dick', e[:foo]
|
260
260
|
end
|
261
261
|
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
262
|
+
describe 'citeproc export' do
|
263
|
+
it 'supports citeproc export' do
|
264
|
+
e = @entry.to_citeproc
|
265
|
+
assert_equal 'book', e['type']
|
266
|
+
assert_equal 'New York', e['publisher-place']
|
267
|
+
assert_equal [1993,11], e['issued']['date-parts'][0]
|
268
|
+
assert_equal 1, e['author'].length
|
269
|
+
assert_equal 'Herman', e['author'][0]['given']
|
270
|
+
assert_equal 'Melville', e['author'][0]['family']
|
271
|
+
end
|
272
|
+
|
273
|
+
it 'sets both issue and number in techreports' do
|
274
|
+
report = Entry.new { |r|
|
275
|
+
r.type = :techreport
|
276
|
+
r.number = 1
|
277
|
+
}.to_citeproc
|
278
|
+
|
279
|
+
assert_equal '1', report['number']
|
280
|
+
assert_equal '1', report['issue']
|
281
|
+
end
|
282
|
+
|
283
|
+
it 'uses authority and publisher for proceedings' do
|
284
|
+
proceedings = Entry.new { |p|
|
285
|
+
p.type = :inproceedings
|
286
|
+
p.publisher = 'Publisher'
|
287
|
+
p.organization = 'Organization'
|
288
|
+
}.to_citeproc
|
289
|
+
|
290
|
+
assert_equal 'Publisher', proceedings['publisher']
|
291
|
+
assert_equal 'Organization', proceedings['authority']
|
292
|
+
|
293
|
+
proceedings = Entry.new { |p|
|
294
|
+
p.type = :inproceedings
|
295
|
+
p.organization = 'Organization'
|
296
|
+
}.to_citeproc
|
297
|
+
|
298
|
+
assert_equal 'Organization', proceedings['publisher']
|
299
|
+
refute proceedings.key?('authority')
|
271
300
|
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
301
|
+
proceedings = Entry.new { |p|
|
302
|
+
p.type = :inproceedings
|
303
|
+
p.publisher = 'Publisher'
|
304
|
+
}.to_citeproc
|
305
|
+
|
306
|
+
assert_equal 'Publisher', proceedings['publisher']
|
307
|
+
refute proceedings.key?('authority')
|
308
|
+
end
|
309
|
+
|
310
|
+
it 'uses event_place for conferences' do
|
311
|
+
conference = Entry.new { |p|
|
312
|
+
p.type = :conference
|
313
|
+
p.address = 'Place'
|
314
|
+
}.to_citeproc
|
315
|
+
|
316
|
+
assert_equal 'Place', conference['event-place']
|
317
|
+
end
|
318
|
+
|
319
|
+
it 'support literal dates in citeproc export' do
|
320
|
+
@entry.year = 'Test'
|
321
|
+
e = @entry.to_citeproc
|
322
|
+
assert_equal({ 'literal' => 'Test' }, e['issued'])
|
323
|
+
end
|
276
324
|
end
|
277
325
|
|
278
326
|
describe 'given a filter object or a filter name' do
|
279
327
|
before do
|
280
328
|
@filter = Object.new
|
281
329
|
def @filter.apply (value); value.is_a?(::String) ? value.upcase : value; end
|
282
|
-
|
330
|
+
|
283
331
|
class SuffixB < BibTeX::Filter
|
284
332
|
def apply(value)
|
285
333
|
value.is_a?(::String) ? "#{value}b" : value
|
data/test/helper.rb
CHANGED
metadata
CHANGED
@@ -1,29 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bibtex-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.1.
|
4
|
+
version: 3.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: 2014-01-
|
11
|
+
date: 2014-01-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: latex-decode
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 0.0
|
19
|
+
version: '0.0'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - "
|
24
|
+
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 0.0
|
26
|
+
version: '0.0'
|
27
27
|
description: |
|
28
28
|
BibTeX-Ruby is the Rubyist's swiss-army-knife for all things BibTeX. It
|
29
29
|
includes a parser for all common BibTeX objects (@string, @preamble,
|