Class: DocverterServer::Runner::Base
- Inherits:
-
Object
- Object
- DocverterServer::Runner::Base
- Defined in:
- lib/docverter-server/runner/base.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#directory ⇒ Object
readonly
Returns the value of attribute directory.
-
#input_filename ⇒ Object
readonly
Returns the value of attribute input_filename.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
- #generate_output_filename(extension) ⇒ Object
-
#initialize(directory, input_filename = nil, options = {}) ⇒ Base
constructor
A new instance of Base.
- #run ⇒ Object
- #run_command(options) ⇒ Object
- #with_manifest ⇒ Object
Constructor Details
#initialize(directory, input_filename = nil, options = {}) ⇒ Base
Returns a new instance of Base.
9 10 11 12 13 |
# File 'lib/docverter-server/runner/base.rb', line 9 def initialize(directory, input_filename=nil, ={}) @directory = directory @input_filename = input_filename @options = end |
Instance Attribute Details
#directory ⇒ Object (readonly)
Returns the value of attribute directory.
7 8 9 |
# File 'lib/docverter-server/runner/base.rb', line 7 def directory @directory end |
#input_filename ⇒ Object (readonly)
Returns the value of attribute input_filename.
7 8 9 |
# File 'lib/docverter-server/runner/base.rb', line 7 def input_filename @input_filename end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
7 8 9 |
# File 'lib/docverter-server/runner/base.rb', line 7 def @options end |
Instance Method Details
#generate_output_filename(extension) ⇒ Object
19 20 21 |
# File 'lib/docverter-server/runner/base.rb', line 19 def generate_output_filename(extension) "output.#{SecureRandom.hex(10)}.#{extension}" end |
#run ⇒ Object
15 16 17 |
# File 'lib/docverter-server/runner/base.rb', line 15 def run raise "implement in subclass" end |
#run_command(options) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/docverter-server/runner/base.rb', line 23 def run_command() p output = "" cmd = Shellwords.join() + " 2>&1" p cmd IO.popen(cmd) do |io| output = io.read end if $?.exitstatus != 0 raise DocverterServer::CommandError.new(output) end end |
#with_manifest ⇒ Object
36 37 38 39 40 |
# File 'lib/docverter-server/runner/base.rb', line 36 def with_manifest Dir.chdir(directory) do yield DocverterServer::Manifest.load_file("manifest.yml") end end |