Module: MagicShelf::MobiTask
- Defined in:
- lib/magicshelf/mobitask.rb
Class Method Summary collapse
-
.perform(params) ⇒ Object
- Runs a subprocess and applies handlers for stdout and stderr TODO make this function to a redis task and run it background Params:
inputfile
- must be fullpath to the input file
title
- book title
booktype
- book type: must be one of [“comic”, “novelimage”, “novel”, “ltr”]
outputfile
-
must be fullpath to the output file.
- book type: must be one of [“comic”, “novelimage”, “novel”, “ltr”]
- book title
- must be fullpath to the input file
- Runs a subprocess and applies handlers for stdout and stderr TODO make this function to a redis task and run it background Params:
Class Method Details
.perform(params) ⇒ Object
Runs a subprocess and applies handlers for stdout and stderr TODO make this function to a redis task and run it background Params:
inputfile
-
must be fullpath to the input file
title
-
book title
booktype
-
book type: must be one of [“comic”, “novelimage”, “novel”, “ltr”]
outputfile
-
must be fullpath to the output file
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/magicshelf/mobitask.rb', line 17 def self.perform(params) inputfile = params['inputfile'] title = params['title'] = params['author'] booktype = params['booktype'] outputfile = params['outputfile'] MagicShelf.logger.info("generate_mobi with params: #{params}") MagicShelf::ExecutionPipe.new.enter { |params,&block| Dir.mktmpdir("magicshelf") do |dir| params[:workdir] = dir block.call end }.pipe(MagicShelf::FileExtractor.new,:workdir => [:destdir]) { |this| this.inputfile = File.(inputfile) }.enter(:destdir => [:workdir]) {|params, &block| Dir.chdir(params[:workdir]) do block.call end }.pipe(MagicShelf::DirRenamer.new, :workdir => [:workdir]) { |this| }.pipe(MagicShelf::FileNameValidator.new, :workdir => [:workdir]) { |this| }.pipe(MagicShelf::MakeItVertical.new, :workdir => [:workdir]) { |this| }.pipe(MagicShelf::EpubGenerator.new, :workdir => [:workdir]) { |this| this.title = title this.creator = this.book_type = booktype this.outputfile = 'test.epub' }.pipe(MagicShelf::KindleGenWrapper.new, :outputfile => [:inputfile]) { |this| this.outputfile = 'test.mobi' }.process(:inputfile => [:file,:inputfile], :outputfile => [:outputfile]) { |params| FileUtils.remove(params[:file]) }.pipe(MagicShelf::KindleStripper.new, :outputfile => [:inputfile]) { |this| this.outputfile = File.('test_strip.mobi') }.pipe(MagicShelf::FileCleaner.new, :inputfile => [:file], :outputfile => [:outputfile]) { |this| }.pipe(MagicShelf::FileMover.new, :outputfile => [:inputfile]) { |this| this.outputfile = File.(outputfile) }.execute end |