Module: Dblp

Defined in:
lib/dblp/version.rb,
lib/dblp.rb,
lib/dblp/parser.rb,
lib/dblp/grabber.rb

Overview

:nodoc:

Defined Under Namespace

Modules: VERSION Classes: CiteseerGrabber, Grabber, Parser

Class Method Summary collapse

Class Method Details

.run(file, options) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/dblp.rb', line 8

def run(file, options)

  if !file || !File.exists?(file)
    puts "You need to specify a filename"
    exit
  end
  
  # Clean file to parse
  file = File.basename(file, File.extname(file)) + ".aux"
  overall_size = 0
  
  parser = Dblp::Parser.new(file)
  grabber = Dblp::Grabber.new(options)
  File.open(options.output, "w+") do |f|
    f.puts parser.parse.inject([]) {|m, l| 
        m << grabber.grab(l)
        overall_size = m.size
        m
      }.uniq.join("\n")
  end
  
  if options.bibtex
    res = system("bibtex #{File.basename(file, File.extname(file))}")
    puts res
  end
  
  # Output
  puts "Stored #{overall_size} entries in #{options.output}"
  
end