Skip to content

Commit

Permalink
mbleigh#63 add custom executable options
Browse files Browse the repository at this point in the history
  • Loading branch information
mustmodify committed Oct 18, 2019
1 parent 559f374 commit d4c012a
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ The defaults for the render options are as follows:
server_flag: true
javascript_flag: false
timeout: none
exe_options: none

## Contributors

Expand Down
5 changes: 4 additions & 1 deletion lib/princely/pdf.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ def initialize(options={})
:logger => nil,
:server_flag => true,
:media => nil,
:javascript_flag => false
:javascript_flag => false,
:exe_options => []
}.merge(options)
@executable = options[:path] ? Princely::Executable.new(options[:path]) : options[:executable]
@style_sheets = ''
Expand All @@ -24,6 +25,7 @@ def initialize(options={})
@media = options[:media]
@javascript_flag = options[:javascript_flag]
@timeout = options[:timeout]
@custom_exe_options = options[:exe_options]
end

# Returns the instance logger or Princely default logger
Expand Down Expand Up @@ -58,6 +60,7 @@ def executable_options
options << "--media=#{media}" if media
options << "--javascript" if @javascript_flag
options << @style_sheets
options += @custom_exe_options
options
end

Expand Down
11 changes: 11 additions & 0 deletions spec/princely/pdf_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,17 @@
end
end

describe "exe_options with array" do
before(:each) do
allow(prince).to receive(:log_file).and_return('/tmp/test_log')
end

let(:prince) { Princely::Pdf.new(:exe_options => ['--xml-external-entities']) }
it 'adds them to the other options' do
expect(prince.executable_options).to include('--xml-external-entities')
end
end

describe "exe_path" do
let(:prince) { Princely::Pdf.new(:path => '/tmp/fake') }

Expand Down

0 comments on commit d4c012a

Please sign in to comment.