Browse files

Normalize options after finding configuration in

meta tags. Options in meta tags in spec should be 
underscored as to merge in with default options.
  • Loading branch information...
1 parent 108357e commit a7d9b66ebb63a2da8166600719c2c6d4e1b500b7 @jstewart committed Jul 22, 2010
Showing with 12 additions and 3 deletions.
  1. +2 −1 lib/pdfkit/pdfkit.rb
  2. +10 −2 spec/pdfkit_spec.rb
View
3 lib/pdfkit/pdfkit.rb
@@ -22,8 +22,9 @@ def initialize(url_file_or_html, options = {})
@stylesheets = []
- @options = normalize_options(PDFKit.configuration.default_options.merge(options))
+ @options = PDFKit.configuration.default_options.merge(options)
@options.merge! find_options_in_meta(url_file_or_html) unless source.url?
+ @options = normalize_options(@options)
raise NoExecutableError.new unless File.exists?(PDFKit.configuration.wkhtmltopdf)
end
View
12 spec/pdfkit_spec.rb
@@ -77,9 +77,17 @@
end
it "should detect special pdfkit meta tags" do
- body = %{<html><head><meta name="pdfkit-page-size" content="Letter"/></head></html>}
+ body = %{
+ <html>
+ <head>
+ <meta name="pdfkit-page_size" content="Legal"/>
+ <meta name="pdfkit-orientation" content="Landscape"/>
+ </head>
+ </html>
+ }
pdfkit = PDFKit.new(body)
- pdfkit.command[pdfkit.command.index('--page-size') + 1].should == 'Letter'
+ pdfkit.command[pdfkit.command.index('--page-size') + 1].should == 'Legal'
+ pdfkit.command[pdfkit.command.index('--orientation') + 1].should == 'Landscape'
end
end

0 comments on commit a7d9b66

Please sign in to comment.