Class: LNCS::Proceedings

Inherits:
Object
  • Object
show all
Defined in:
lib/lncs/proceedings.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#manifestObject

Returns the value of attribute manifest.



5
6
7
# File 'lib/lncs/proceedings.rb', line 5

def manifest
  @manifest
end

Instance Method Details

#add_papers_to_manifestObject



50
51
52
53
54
55
# File 'lib/lncs/proceedings.rb', line 50

def add_papers_to_manifest
  new_papers = sections.reduce({}) { |data, section| data.merge(section.paper_data_for_manifest(papers)) }
  new_manifest = manifest.dup
  new_manifest["papers"] = new_papers
  actions.create_file("manifest.json", JSON.pretty_generate(new_manifest))
end

#copy_to(dst) ⇒ Object



46
47
48
# File 'lib/lncs/proceedings.rb', line 46

def copy_to(dst)
  sections.each { |section| section.copy_to(dst) }
end

#generate_body_to(dst) ⇒ Object



57
58
59
60
61
62
# File 'lib/lncs/proceedings.rb', line 57

def generate_body_to(dst)
  start_page = 1
  sections.each do |s|
    start_page = s.generate_body_to(dst, volume_number, start_page)
  end
end

#generate_titles_to(dst) ⇒ Object



64
65
66
67
68
69
70
71
# File 'lib/lncs/proceedings.rb', line 64

def generate_titles_to(dst)
  actions.remove_file("#{dst}/index.tex")
  actions.create_file("#{dst}/index.tex")
  start_page = 1
  sections.each do |s|
    start_page = s.generate_titles_to(dst, start_page)
  end
end

#paper_file_name_for(paper_id) ⇒ Object



19
20
21
22
23
# File 'lib/lncs/proceedings.rb', line 19

def paper_file_name_for(paper_id)
  Dir.chdir(source_directory) do
    Dir.glob("*_#{paper_id}.{pdf,zip}")[0]
  end
end

#paper_manifest_for(paper_id) ⇒ Object



31
32
33
34
35
# File 'lib/lncs/proceedings.rb', line 31

def paper_manifest_for(paper_id)
  paper_manifest = papers.fetch(paper_id.to_s, {})
  paper_manifest["pdf"] = paper_file_name_for(paper_id) unless paper_manifest["pdf"]
  paper_manifest
end

#paper_path_for(paper_id) ⇒ Object



25
26
27
28
29
# File 'lib/lncs/proceedings.rb', line 25

def paper_path_for(paper_id)
  filename = paper_file_name_for(paper_id)
  raise "Error: no file with name ending '#{paper_id}.pdf' or '#{paper_id}.zip' found at path '#{source_directory}'" unless filename
  File.join(source_directory, filename)
end

#papersObject



15
16
17
# File 'lib/lncs/proceedings.rb', line 15

def papers
  manifest["papers"] || {}
end

#reportObject



73
74
75
# File 'lib/lncs/proceedings.rb', line 73

def report
  sections.each { |s| s.report }
end

#sectionsObject



37
38
39
40
41
42
43
44
# File 'lib/lncs/proceedings.rb', line 37

def sections
  manifest["sections"].map do |section|
    Section.new.tap do |s|
      s.manifest = section
      s.proceedings = self
    end
  end
end

#source_directoryObject



11
12
13
# File 'lib/lncs/proceedings.rb', line 11

def source_directory
  manifest["sources"]
end

#volume_numberObject



7
8
9
# File 'lib/lncs/proceedings.rb', line 7

def volume_number
  manifest["volume_number"]
end