Module: WkHtml::CommonSettings
- Defined in:
- lib/wkhtml/common_settings.rb
Constant Summary collapse
- TRUE =
'true'
- FALSE =
'false'
- STDIN =
STDOUT = '-'
- PDF =
'pdf'
- JPG =
'jpg'
- PNG =
'png'
- BMP =
'bmp'
- SVG =
'svg'
- REGEXP_URI =
/\A#{URI.regexp(['http', 'https'])}/
Class Method Summary collapse
Class Method Details
.cleanup_path(path) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/wkhtml/common_settings.rb', line 18 def cleanup_path(path) path = path.path if path.is_a?(File) || path.is_a?(Tempfile) if path == STDIN || path == STDOUT path elsif path =~ REGEXP_URI URI.parse(path).to_s() else File.(path) end end |
.readable?(path) ⇒ Boolean
30 31 32 33 34 35 36 |
# File 'lib/wkhtml/common_settings.rb', line 30 def readable?(path) unless path =~ REGEXP_URI File.exists?(path) && File.readable?(path) else true end end |
.writable?(path) ⇒ Boolean
38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/wkhtml/common_settings.rb', line 38 def writable?(path) unless File.writable?(path) begin FileUtils.touch(path) true rescue false end else true end end |