dblpbib 0.1.6 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -1
- data/.rubocop.yml +19 -0
- data/.travis.yml +7 -2
- data/Rakefile +3 -3
- data/bin/console +4 -4
- data/dblpbib.gemspec +25 -20
- data/exe/dblpbib +28 -27
- data/lib/dblpbib.rb +21 -2
- data/lib/dblpbib/version.rb +3 -2
- metadata +27 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1f2fc3c8c6c1ce8bc1b2ac7d3fff7faf1692b2ec
|
4
|
+
data.tar.gz: 2a2505420e97e7c148ad1be58079424da4ce863a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f19341d7b2d3743d37ad983136fc9614b19e9afde241a11ae0cd9137a51bcf94ecbd562d3e0ff06e4e6b0b65c12907d13c652738a0e406cbd03090b1ade9c2e6
|
7
|
+
data.tar.gz: 1392b30cfec220967a26debb1c7c3e699608a15bc7cf54a6dc64bdcaed219c0c0d264cdf8aade66247e8e70d846553a6b71fe6a444cef4b0654c339afb8d0a7b
|
data/.gitignore
CHANGED
data/.rubocop.yml
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
# Plain wrong :)
|
2
|
+
Layout/Tab:
|
3
|
+
Enabled: false
|
4
|
+
Layout/IndentationWidth:
|
5
|
+
Width: 1
|
6
|
+
|
7
|
+
# Just annoying
|
8
|
+
Metrics/AbcSize:
|
9
|
+
Enabled: false
|
10
|
+
Metrics/AbcSize:
|
11
|
+
Enabled: false
|
12
|
+
Metrics/BlockLength:
|
13
|
+
Enabled: false
|
14
|
+
Metrics/MethodLength:
|
15
|
+
Enabled: false
|
16
|
+
|
17
|
+
# Multiline regexes
|
18
|
+
Style/RegexpLiteral:
|
19
|
+
Enabled: false
|
data/.travis.yml
CHANGED
data/Rakefile
CHANGED
data/bin/console
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
-
require
|
4
|
-
require
|
3
|
+
require 'bundler/setup'
|
4
|
+
require 'dblpbib'
|
5
5
|
|
6
6
|
# You can add fixtures and/or initialization code here to make experimenting
|
7
7
|
# with your gem easier. You can also use a different console, if you like.
|
8
8
|
|
9
9
|
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
-
# require
|
10
|
+
# require 'pry'
|
11
11
|
# Pry.start
|
12
12
|
|
13
|
-
require
|
13
|
+
require 'irb'
|
14
14
|
IRB.start
|
data/dblpbib.gemspec
CHANGED
@@ -1,29 +1,34 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
lib = File.expand_path('lib', __dir__)
|
2
|
+
|
3
3
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
4
|
require 'dblpbib/version'
|
5
5
|
|
6
6
|
Gem::Specification.new do |spec|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
7
|
+
spec.name = 'dblpbib'
|
8
|
+
spec.version = Dblpbib::VERSION
|
9
|
+
spec.authors = ['PJK']
|
10
|
+
spec.email = ['me@pavelkalvoda.com']
|
11
11
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
12
|
+
spec.summary = Dblpbib::DESCRIPTION
|
13
|
+
spec.description = 'Automatically create bibliographies for BibTeX DBLP
|
14
|
+
references. This utility is meant to be invoked during LaTeX build. It scans
|
15
|
+
the documents for DBLP references and compiles a cached .bib file. Correctly
|
16
|
+
handles crosslinking. Entries can be overridden. Other bibliography sources
|
17
|
+
can still be included.'
|
18
|
+
spec.homepage = 'https://github.com/PJK/dblpbib'
|
19
|
+
spec.license = 'MIT'
|
16
20
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
21
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
22
|
+
f.match(%r{^(test|spec|features)/})
|
23
|
+
end
|
24
|
+
spec.bindir = 'exe'
|
25
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
26
|
+
spec.require_paths = ['lib']
|
23
27
|
|
24
|
-
|
25
|
-
|
26
|
-
|
28
|
+
spec.add_development_dependency 'bundler', '~> 1.16'
|
29
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
30
|
+
spec.add_development_dependency 'rspec', '~> 3'
|
31
|
+
spec.add_development_dependency 'rubocop', '~> 0.57'
|
27
32
|
|
28
|
-
|
33
|
+
spec.add_dependency 'commander'
|
29
34
|
end
|
data/exe/dblpbib
CHANGED
@@ -8,12 +8,21 @@ require 'open-uri'
|
|
8
8
|
|
9
9
|
require 'dblpbib/version'
|
10
10
|
|
11
|
+
# Top-level CLI app
|
11
12
|
class DBLPCLI
|
12
13
|
include Commander::Methods
|
13
14
|
|
14
15
|
def shared_options(command)
|
15
|
-
command.option
|
16
|
-
|
16
|
+
command.option(
|
17
|
+
'--cache CACHE_DIR',
|
18
|
+
String,
|
19
|
+
'Cache directory. Single .bib entries are stored here'
|
20
|
+
)
|
21
|
+
command.option(
|
22
|
+
'--output OUTPUT.bib',
|
23
|
+
String,
|
24
|
+
'Output bibliography. \'dblp.bib\' by default'
|
25
|
+
)
|
17
26
|
end
|
18
27
|
|
19
28
|
def default_options(options)
|
@@ -21,18 +30,6 @@ class DBLPCLI
|
|
21
30
|
options.default output: 'dblp.bib'
|
22
31
|
end
|
23
32
|
|
24
|
-
def get_keys(file)
|
25
|
-
IO.read(file)
|
26
|
-
.gsub(/(?<!\\)%.*$/, '')
|
27
|
-
.scan(/\\cite(\[[^\]]+\])?\{([^\}]+)\}/)
|
28
|
-
.map(&:pop)
|
29
|
-
.flat_map { |keyset| keyset.split(',') }
|
30
|
-
.map(&:strip)
|
31
|
-
.uniq
|
32
|
-
.keep_if { |key| key.start_with?('DBLP:') }
|
33
|
-
.map { |key| key.sub('DBLP:', '') }
|
34
|
-
end
|
35
|
-
|
36
33
|
def bib_path(cache, key)
|
37
34
|
File.join(cache, key + '.bib')
|
38
35
|
end
|
@@ -51,25 +48,29 @@ class DBLPCLI
|
|
51
48
|
default_options(options)
|
52
49
|
FileUtils.mkdir_p(options.cache)
|
53
50
|
|
54
|
-
keys =
|
51
|
+
keys = Dblpbib.scan_keys(IO.read(args[0]))
|
55
52
|
|
56
53
|
keys.each do |key|
|
57
54
|
path = bib_path(options.cache, key)
|
58
55
|
|
59
|
-
|
60
|
-
puts "Fetching #{key}"
|
56
|
+
next if File.exist?(path)
|
61
57
|
|
62
|
-
|
58
|
+
puts "Fetching #{key}"
|
59
|
+
FileUtils.mkdir_p(File.dirname(path))
|
63
60
|
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
61
|
+
begin
|
62
|
+
File.write(
|
63
|
+
path,
|
64
|
+
open("http://dblp.uni-trier.de/rec/bib1/#{key}.bib").read
|
65
|
+
)
|
66
|
+
rescue OpenURI::HTTPError => e
|
67
|
+
puts "Failed to fetch key #{key} (#{e}) -- " \
|
68
|
+
"perhaps it is misspelled or doesn't exist?"
|
69
|
+
exit 1
|
72
70
|
end
|
71
|
+
|
72
|
+
# TODO: crossrefs! When I got here I actually realized the 'standard'
|
73
|
+
# output is perfectly OK for most situations...
|
73
74
|
end
|
74
75
|
|
75
76
|
File.open(options.output, 'w') do |output|
|
@@ -90,4 +91,4 @@ class DBLPCLI
|
|
90
91
|
end
|
91
92
|
end
|
92
93
|
|
93
|
-
DBLPCLI.new.run
|
94
|
+
DBLPCLI.new.run
|
data/lib/dblpbib.rb
CHANGED
@@ -1,5 +1,24 @@
|
|
1
|
-
require
|
1
|
+
require 'dblpbib/version'
|
2
2
|
|
3
|
+
# Bits of logic
|
3
4
|
module Dblpbib
|
4
|
-
|
5
|
+
def self.scan_keys(document)
|
6
|
+
# TODO: Extract the allowed command names, possible make them configurable
|
7
|
+
document
|
8
|
+
.gsub(/(?<!\\)%.*$/, '')
|
9
|
+
.scan(%r{
|
10
|
+
# Command
|
11
|
+
\\(text|auto)?cite(|(al)?[pt]\*?|year(par|\*)?|par\*?|author\*?|text|)
|
12
|
+
# Optionally options
|
13
|
+
(\[[^\]]+\])?
|
14
|
+
# Parameters
|
15
|
+
\{([^\}]+)\}
|
16
|
+
}x)
|
17
|
+
.map(&:pop)
|
18
|
+
.flat_map { |keyset| keyset.split(',') }
|
19
|
+
.map(&:strip)
|
20
|
+
.keep_if { |key| key.start_with?('DBLP:') }
|
21
|
+
.map { |key| key.sub('DBLP:', '') }
|
22
|
+
.uniq
|
23
|
+
end
|
5
24
|
end
|
data/lib/dblpbib/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dblpbib
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- PJK
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-06-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '1.
|
19
|
+
version: '1.16'
|
20
20
|
type: :development
|
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: '1.
|
26
|
+
version: '1.16'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -44,14 +44,28 @@ dependencies:
|
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '3
|
47
|
+
version: '3'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: '3
|
54
|
+
version: '3'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rubocop
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0.57'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0.57'
|
55
69
|
- !ruby/object:Gem::Dependency
|
56
70
|
name: commander
|
57
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -66,10 +80,12 @@ dependencies:
|
|
66
80
|
- - ">="
|
67
81
|
- !ruby/object:Gem::Version
|
68
82
|
version: '0'
|
69
|
-
description:
|
70
|
-
|
71
|
-
references
|
72
|
-
|
83
|
+
description: |-
|
84
|
+
Automatically create bibliographies for BibTeX DBLP
|
85
|
+
references. This utility is meant to be invoked during LaTeX build. It scans
|
86
|
+
the documents for DBLP references and compiles a cached .bib file. Correctly
|
87
|
+
handles crosslinking. Entries can be overridden. Other bibliography sources
|
88
|
+
can still be included.
|
73
89
|
email:
|
74
90
|
- me@pavelkalvoda.com
|
75
91
|
executables:
|
@@ -78,8 +94,8 @@ extensions: []
|
|
78
94
|
extra_rdoc_files: []
|
79
95
|
files:
|
80
96
|
- ".gitignore"
|
81
|
-
- ".idea/vcs.xml"
|
82
97
|
- ".rspec"
|
98
|
+
- ".rubocop.yml"
|
83
99
|
- ".travis.yml"
|
84
100
|
- Gemfile
|
85
101
|
- LICENSE.txt
|