Class: MagicShelf::KindleGenWrapper
- Inherits:
-
Object
- Object
- MagicShelf::KindleGenWrapper
- Defined in:
- lib/magicshelf/kindlegenwrapper.rb
Instance Attribute Summary collapse
-
#inputfile ⇒ Object
Returns the value of attribute inputfile.
-
#outputfile ⇒ Object
Returns the value of attribute outputfile.
Instance Method Summary collapse
Instance Attribute Details
#inputfile ⇒ Object
Returns the value of attribute inputfile.
8 9 10 |
# File 'lib/magicshelf/kindlegenwrapper.rb', line 8 def inputfile @inputfile end |
#outputfile ⇒ Object
Returns the value of attribute outputfile.
8 9 10 |
# File 'lib/magicshelf/kindlegenwrapper.rb', line 8 def outputfile @outputfile end |
Instance Method Details
#enter ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/magicshelf/kindlegenwrapper.rb', line 10 def enter() MagicShelf.logger.debug('enter KindleGenWrapper') # check parameters raise MagicShelf::KindleGenWrapperError.new("inputfile is not set") if @inputfile == nil raise MagicShelf::KindleGenWrapperError.new("outputfile is not set") if @outputfile == nil out, err, status = Open3.capture3("which kindlegen") if status.exitstatus != 0 raise MagicShelf::KindleGenWrapperError.new("cannot execute kindlegen, is it on your PATH?") end yield end |
#process ⇒ Object
24 25 26 27 28 29 |
# File 'lib/magicshelf/kindlegenwrapper.rb', line 24 def process() out, err, status = Open3.capture3("kindlegen #{@inputfile} -o #{@outputfile}") if status.exitstatus != 0 raise MagicShelf::KindleGenWrapperError.new("kindlegen exited with #{status.exitstatus}: \n" + out + "\n" + err) end end |