Module: ODDB::FiPDF

Includes:
DRb::DRbUndumped
Defined in:
ext/fipdf/src/rules.rb,
ext/fipdf/src/fipdf.rb,
ext/fipdf/src/format.rb,
ext/fipdf/test/rules_test.rb,
ext/fipdf/test/format_test.rb,
ext/fipdf/src/chapter_wrapper.rb,
ext/fipdf/src/fachinfo_writer.rb,
ext/fipdf/src/section_wrapper.rb,
ext/fipdf/src/substance_index.rb,
ext/fipdf/src/fachinfo_wrapper.rb,
ext/fipdf/src/paragraph_wrapper.rb,
ext/fipdf/test/chapter_wrapper_test.rb,
ext/fipdf/test/fachinfo_writer_test.rb,
ext/fipdf/test/substance_index_test.rb,
ext/fipdf/test/section_wrapper_test.rb,
ext/fipdf/test/fachinfo_wrapper_test.rb,
ext/fipdf/test/paragraph_wrapper_test.rb

Defined Under Namespace

Classes: ChapterWrapper, FachinfoProxy, FachinfoRule, FachinfoWrapper, FachinfoWriter, FachinfoWriterProxy, Format, OrphanRule, ParagraphWrapper, Rule, SectionWrapper, StubRegistration, SubstanceIndex, TestChapterWrapper, TestFachinfoWrapper, TestFormat, TestParagraphWrapper, TestSectionWrapper, TestSubstanceIndex, WidowRule

Constant Summary

DATA_DIR =
File.expand_path('../data', File.dirname(__FILE__))
PDF_PATH =
File.expand_path('downloads', DATA_DIR)

Instance Method Summary (collapse)

Instance Method Details

- (Object) dictionary(language)



84
85
86
87
# File 'ext/fipdf/src/fipdf.rb', line 84

def dictionary(language)
  require 'text/hyphen'
  ::Text::Hyphen.new(:language => language.to_s)
end

- (Object) document(filename, language, &block)



88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
# File 'ext/fipdf/src/fipdf.rb', line 88

def document(filename, language, &block)
  begin
    writer = FachinfoWriter.new :language => language
    writer.hyphenator = dictionary(language)
    pdf = FachinfoWriterProxy.new(writer)
    block.call(pdf)
    writer.save_as filename
    $stdout.flush
  rescue Exception => e
    puts e
    puts e.backtrace
  ensure
    # Cache-Files are only being deleted when their corresponding 
    # instance is Garbage-Collected:
    GC.start
  end
  ''
end

- (Object) write_pdf(fachinfo_ids, language, path)



106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
# File 'ext/fipdf/src/fipdf.rb', line 106

def write_pdf(fachinfo_ids, language, path)
  fachinfos = fachinfo_ids.collect do |id| ODBA.cache.fetch id end
  fachinfos = fachinfos.sort_by { |fachinfo|
    ODDB.search_term(fachinfo.send(language).name).downcase
  }
  total = fachinfos.size
  puts "Total: #{total} fachinfos to write"
  document(path, language) { |document|
    start_time = Time.new
    fachinfos.each_with_index { |fachinfo, idx|
      puts "checking Fachinfo: (#{idx}/#{total})"
      if(fachinfo.registrations.any? { |reg| reg.public_package_count > 0 })
        puts "writing Fachinfo: (#{idx}/#{total})"
        proxy = FachinfoProxy.new(fachinfo, language)
        document.write_fachinfo(proxy) if(proxy.first_chapter)
        puts "done"
      end
    }
    end_time = Time.new
    document.write_substance_index
    puts "Fachinfos took #{end_time - start_time} seconds or #{(end_time - start_time) / 60} minutes"
    puts "closing writer"
  }
  puts "written all pdfs"
end