dblp 0.0.1 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +5 -0
- data/README.txt +9 -10
- data/bin/dblp +42 -1
- data/lib/dblp/version.rb +2 -2
- data/lib/dblp.rb +16 -2
- metadata +1 -1
data/History.txt
CHANGED
data/README.txt
CHANGED
@@ -1,26 +1,25 @@
|
|
1
1
|
= dblp
|
2
2
|
|
3
|
-
* FIX (url)
|
4
|
-
|
5
3
|
== DESCRIPTION:
|
6
4
|
|
7
|
-
|
5
|
+
DBLP is a command line tool to fetch required bibtex entries directly from the DBLP servers. The idea is, that you don't have to maintain all entries in your own file, but youse well known bibtex identifiers instead and then fetch them from DBLP.
|
6
|
+
|
8
7
|
|
9
|
-
== FEATURES/PROBLEMS:
|
10
8
|
|
11
|
-
* FIX (list of features or problems)
|
12
9
|
|
13
10
|
== SYNOPSIS:
|
14
11
|
|
15
|
-
|
12
|
+
The first step is to build your latex document, so that dblp can parse the aux file for your document. Now call
|
16
13
|
|
17
|
-
|
14
|
+
dblp my_tex_file[|.tex|.aux]
|
15
|
+
|
16
|
+
and this will scan for the citation commands in the aux file. The defined keys will be used to query DBLP. If an entry is available it is saved and as a result stored in the dblp.bib file. To use it in your Latex document just use \bibliography{my_own_file,..., dblp}
|
18
17
|
|
19
|
-
|
18
|
+
For more command line options see
|
20
19
|
|
21
|
-
|
20
|
+
dblp --help
|
21
|
+
|
22
22
|
|
23
|
-
* FIX (sudo gem install, anything else)
|
24
23
|
|
25
24
|
== LICENSE:
|
26
25
|
|
data/bin/dblp
CHANGED
@@ -10,7 +10,48 @@ rescue LoadError
|
|
10
10
|
end
|
11
11
|
|
12
12
|
require 'dblp'
|
13
|
+
require 'optparse'
|
14
|
+
require 'ostruct'
|
13
15
|
|
14
|
-
|
16
|
+
opt = OpenStruct.new
|
17
|
+
opt.output = "dblp.bib"
|
18
|
+
opt.bibtex = true
|
19
|
+
|
20
|
+
if ARGV.size == 0
|
21
|
+
ARGV << "-h"
|
22
|
+
end
|
23
|
+
|
24
|
+
unless ARGV[0] == "-h"
|
25
|
+
file_to_parse = ARGV.shift
|
26
|
+
end
|
27
|
+
|
28
|
+
OptionParser.new do |opts|
|
29
|
+
|
30
|
+
opts.banner = <<BANNER
|
31
|
+
DBLP is a command line tool to fetch required bibtex entries
|
32
|
+
directly from the DBLP servers. The idea is, that you don't
|
33
|
+
have to maintain all entries in your own file, but youse well
|
34
|
+
known bibtex identifiers instead and then fetch them from DBLP.
|
35
|
+
BANNER
|
36
|
+
|
37
|
+
opts.separator("")
|
38
|
+
opts.separator("Specific Options:")
|
39
|
+
|
40
|
+
opts.on("-o", "--output [FILENAME]", "Specify FILENAME for output instead of dblp.bib") do |fn|
|
41
|
+
opt.output = fn
|
42
|
+
end
|
43
|
+
|
44
|
+
opts.on("-b", "--[no-]bibtex", "Run Bibtex after fetching bib entries") do |b|
|
45
|
+
opt.bibtex = b
|
46
|
+
end
|
47
|
+
|
48
|
+
opts.on_tail("-h", "--help", "Show this message") do
|
49
|
+
puts opts
|
50
|
+
exit
|
51
|
+
end
|
52
|
+
end.parse!
|
53
|
+
|
54
|
+
|
55
|
+
Dblp::run(file_to_parse, opt)
|
15
56
|
|
16
57
|
# do stuff
|
data/lib/dblp/version.rb
CHANGED
data/lib/dblp.rb
CHANGED
@@ -8,16 +8,30 @@ module Dblp
|
|
8
8
|
|
9
9
|
class << self
|
10
10
|
|
11
|
-
def run(file,
|
11
|
+
def run(file, options)
|
12
|
+
|
13
|
+
# Clean file to parse
|
14
|
+
file = File.basename(file, File.extname(file)) + ".aux"
|
15
|
+
overall_size = 0
|
12
16
|
|
13
17
|
parser = Dblp::Parser.new(file)
|
14
18
|
grabber = Dblp::Grabber.new
|
15
|
-
File.open(
|
19
|
+
File.open(options.output, "w+") do |f|
|
16
20
|
f.puts parser.parse.inject({}) {|m, l|
|
17
21
|
m.merge!(grabber.grab(l))
|
22
|
+
overall_size = m.size
|
18
23
|
m
|
19
24
|
}.values.join("\n")
|
20
25
|
end
|
26
|
+
|
27
|
+
if options.bibtex
|
28
|
+
res = system("bibtex #{File.basename(file, File.extname(file))}")
|
29
|
+
puts res
|
30
|
+
end
|
31
|
+
|
32
|
+
# Output
|
33
|
+
puts "Stored #{overall_size} entries in #{options.output}"
|
34
|
+
|
21
35
|
end
|
22
36
|
|
23
37
|
end
|