Class: LNCS::Paper
- Inherits:
-
Object
- Object
- LNCS::Paper
- Defined in:
- lib/lncs/paper.rb
Instance Attribute Summary collapse
-
#manifest ⇒ Object
Returns the value of attribute manifest.
-
#path ⇒ Object
Returns the value of attribute path.
-
#proceedings ⇒ Object
Returns the value of attribute proceedings.
Instance Method Summary collapse
- #authors ⇒ Object
- #copy_to(dst) ⇒ Object
- #data_for_manifest(existing_data) ⇒ Object
- #generate_title_to(dst, start_page) ⇒ Object
- #id ⇒ Object
- #name ⇒ Object
- #page_count ⇒ Object
- #pdf ⇒ Object
- #title ⇒ Object
- #type ⇒ Object
Instance Attribute Details
#manifest ⇒ Object
Returns the value of attribute manifest.
8 9 10 |
# File 'lib/lncs/paper.rb', line 8 def manifest @manifest end |
#path ⇒ Object
Returns the value of attribute path.
8 9 10 |
# File 'lib/lncs/paper.rb', line 8 def path @path end |
#proceedings ⇒ Object
Returns the value of attribute proceedings.
8 9 10 |
# File 'lib/lncs/paper.rb', line 8 def proceedings @proceedings end |
Instance Method Details
#authors ⇒ Object
18 19 20 |
# File 'lib/lncs/paper.rb', line 18 def manifest["authors"] end |
#copy_to(dst) ⇒ Object
50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/lncs/paper.rb', line 50 def copy_to(dst) FileUtils.mkdir_p(dst) if type == "zip" Zip::ZipFile.open(path) do |zipfile| zipfile.select { |file| zipfile.get_entry(file).file? }.each do |file| actions.create_file(File.join(dst, file.name), zipfile.read(file)) end end else actions.copy_file(path, File.join(dst, name)) end end |
#data_for_manifest(existing_data) ⇒ Object
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 |
# File 'lib/lncs/paper.rb', line 64 def data_for_manifest(existing_data) if existing_data.key?(id) { id => existing_data[id] } elsif type == "zip" data = { pdf: paths_to_pdfs } case data[:pdf].size when 1 data[:pdf] = data[:pdf].first when 0 data[:FIXME] = "Change the PDF key to the path (relative, within the ZIP) of the compiled PDF." else data[:FIXME] = "Reduce the PDF key from an array to a single value which corresponds to the compiled PDF." end { id => data } else {} end end |
#generate_title_to(dst, start_page) ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/lncs/paper.rb', line 34 def generate_title_to(dst, start_page) check_pdf_exists captured = title_page_from_manifest_or_latex captured += "\n" + .map do |a| a.gsub!(/(?<forename>\S*) (?<surname>.*)/, '\k<surname>, \k<forename>') if a "\\index{#{a}}" end.join("\n") + "\n" captured += "\\maketitle\n" captured += "\\clearpage\n" captured += "\\setcounter{page}{#{start_page + page_count}}" actions.create_file(dst, captured) end |
#id ⇒ Object
26 27 28 |
# File 'lib/lncs/paper.rb', line 26 def id name.match(/(\d+).(pdf|zip)/)[1] end |
#name ⇒ Object
22 23 24 |
# File 'lib/lncs/paper.rb', line 22 def name File.basename(path) end |
#page_count ⇒ Object
87 88 89 90 91 |
# File 'lib/lncs/paper.rb', line 87 def page_count check_pdf_exists PDF::Reader.new(open_pdf).page_count end |
#pdf ⇒ Object
10 11 12 |
# File 'lib/lncs/paper.rb', line 10 def pdf manifest["pdf"] end |
#title ⇒ Object
14 15 16 |
# File 'lib/lncs/paper.rb', line 14 def title manifest["title"] end |
#type ⇒ Object
30 31 32 |
# File 'lib/lncs/paper.rb', line 30 def type name.match(/(pdf|zip)/)[1] end |