Commit 12a4cc1a authored by charlie-ablett's avatar charlie-ablett
Browse files

Vivliostyle step now uses shared shell

parent 630184bc
......@@ -10,7 +10,7 @@ GIT
PATH
remote: .
specs:
inkstep_coko_conversion (0.2.13)
inkstep_coko_conversion (0.2.14)
GEM
remote: https://rubygems.org/
......
......@@ -10,12 +10,7 @@ module InkStep
source_file_name = Pathname(source_file_path).sub_ext ''
output_file_path = File.join(working_directory, "#{source_file_name}.pdf")
set_xvfb_variable("DISPLAY", ":99.0")
sleep(1)
run_xvfb #if it's already running, hopefully it won't screw it up!
sleep(2)
run_vivliostyle_conversion(File.join(working_directory, source_file_path), output_file_path)
perform_conversion(source_file_path: source_file_path, output_file_path: output_file_path)
success! if File.exists?(output_file_path)
end
......@@ -29,27 +24,37 @@ module InkStep
private
def set_xvfb_variable(key, value)
def perform_conversion(source_file_path:, output_file_path:)
combined_command = [
set_xvfb_variable_command("DISPLAY", ":99.0"),
run_xvfb_command,
vivliostyle_command(File.join(working_directory, source_file_path), output_file_path)
].join("; ")
perform_command(command: combined_command)
end
def set_xvfb_variable_command(key, value)
command = "export #{key}='#{value}'"
perform_command(command: command, error_prefix: "error setting Xvfb variable")
# perform_command(command: command, error_prefix: "error setting Xvfb variable")
end
def run_xvfb
def run_xvfb_command
# Xvfb :99 -screen 0 1024x768x24 > /dev/null 2>&1 &
command = "Xvfb :99 -screen 0 1024x768x24 > /dev/null 2>&1 &"
command = "Xvfb :99 -screen 0 1024x768x24 > /dev/null 2>&1" #removed & to make it wait
perform_command(command: command, print_out: true, error_prefix: "error running Xvfb")
# perform_command(command: command, print_out: true, error_prefix: "error running Xvfb")
end
def run_vivliostyle_conversion(source_file_path, destination_file_path)
def vivliostyle_command(source_file_path, destination_file_path)
# see readme for more information about usage
# vivliostyle-electron input.html -o output.pdf
command = "vivliostyle-electron #{source_file_path} -o #{destination_file_path}"
perform_command(command: command, error_prefix: "Error running vivliostyle")
# perform_command(command: command, error_prefix: "Error running vivliostyle")
end
end
end
\ No newline at end of file
module CokoConversion
VERSION = '0.2.14'
VERSION = '0.2.15'
end
\ No newline at end of file
......@@ -29,13 +29,13 @@ describe InkStep::PandocEpubToIcmlStep do
context 'first file' do
let(:target_file_name) { "document_1.epub" }
specify do
test_file_conversion
test_file_conversion_with_target
end
end
xcontext 'second file' do
let(:target_file_name) { "document_2.icml" }
specify do
test_file_conversion(epub_file_2, expected_result_2)
test_file_conversion_with_target
end
end
end
......@@ -48,7 +48,7 @@ describe InkStep::PandocEpubToIcmlStep do
end
end
def test_file_conversion
def test_file_conversion_with_target
subject.perform_step
result = File.join(subject.send(:working_directory), target_file_name)
expect(File.exists?(result)).to be_truthy
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment