Module: QuickCite

Included in:
Main
Defined in:
lib/quickcite.rb,
lib/quickcite/dblp.rb,
lib/quickcite/version.rb,
lib/quickcite/citeulike.rb

Defined Under Namespace

Classes: CiteULike, DBLP, Main, Result

Constant Summary collapse

CITE_REGEX =
/\\cite[tp]?\{([^\}]+)\}/
SPLIT_REGEX =
/([A-Z]+[a-z]+|[0-9]+|[^\\p]+)/
VERSION =
"1.0.4"

Class Method Summary collapse

Class Method Details

.ask_user(cite, result_list) ⇒ Object

Query the user for a result from the result list to use for this citation reference.

Returns the selected reference or nil if no match was selected.



40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/quickcite.rb', line 40

def self.ask_user(cite, result_list)
  if result_list.empty? then
    return nil
  end
  
  puts "Result to use for \{#{cite}\}: "
  puts "  (0) Skip this citation"
  result_list.each_with_index do |r, idx|
    puts "  (#{idx + 1}) #{r.title} (#{r.date})"
    puts "      Authors: #{r.authors.join(', ')}"
    puts "      Venue: #{r.venue}"
  end
  
  c = HighLine::SystemExtensions::get_character.chr.to_i
  if c > 0 && c <= result_list.length then
    return result_list[c - 1]
  end
end

.cite_to_query(cite) ⇒ Object

Convert a citation reference (e.g “PowerPiccolo2008”) into a list of strings appropriate for submission to a search engine.

By default the citation is split on lowercase->uppercase transitions.



31
32
33
# File 'lib/quickcite.rb', line 31

def self.cite_to_query(cite)
  cite.scan(SPLIT_REGEX).map { |w| w[0] }
end

.run(latex_files, bibtex_file) ⇒ Object



23
24
25
# File 'lib/quickcite.rb', line 23

def self.run(latex_files, bibtex_file)
  Main.new(latex_files, bibtex_file)
end