Class: Grover
- Defined in:
- lib/grover.rb,
lib/grover/utils.rb,
lib/grover/version.rb,
lib/grover/middleware.rb,
lib/grover/configuration.rb,
lib/grover/html_preprocessor.rb
Overview
Grover interface for converting HTML to PDF
Defined Under Namespace
Modules: HTMLPreprocessor Classes: Configuration, Middleware, Utils
Constant Summary collapse
- DEFAULT_HEADER_TEMPLATE =
"<div class='date text left'></div><div class='title text center'></div>".freeze
- DEFAULT_FOOTER_TEMPLATE =
Utils.strip_heredoc(" <div class='url text left grow'></div>\n <div class='text right'><span class='pageNumber'></span>/<span class='totalPages'></span></div>\n").freeze
- VERSION =
'0.6.1'.freeze
Instance Attribute Summary collapse
-
#back_cover_path ⇒ Object
readonly
Returns the value of attribute back_cover_path.
-
#front_cover_path ⇒ Object
readonly
Returns the value of attribute front_cover_path.
Class Method Summary collapse
-
.configuration ⇒ Object
Configuration for the conversion.
- .configure {|configuration| ... } ⇒ Object
Instance Method Summary collapse
-
#initialize(url, options = {}) ⇒ Grover
constructor
A new instance of Grover.
-
#inspect ⇒ Object
Instance inspection.
-
#show_back_cover? ⇒ Boolean
Returns whether a back cover (request) path has been specified in the options.
-
#show_front_cover? ⇒ Boolean
Returns whether a front cover (request) path has been specified in the options.
-
#to_pdf(path = nil) ⇒ String
Request URL with provided options and create PDF.
Constructor Details
#initialize(url, options = {}) ⇒ Grover
97 98 99 100 101 102 103 104 |
# File 'lib/grover.rb', line 97 def initialize(url, = {}) @url = url = @root_path = .delete 'root_path' @front_cover_path = .delete 'front_cover_path' @back_cover_path = .delete 'back_cover_path' end |
Instance Attribute Details
#back_cover_path ⇒ Object (readonly)
Returns the value of attribute back_cover_path.
90 91 92 |
# File 'lib/grover.rb', line 90 def back_cover_path @back_cover_path end |
#front_cover_path ⇒ Object (readonly)
Returns the value of attribute front_cover_path.
90 91 92 |
# File 'lib/grover.rb', line 90 def front_cover_path @front_cover_path end |
Class Method Details
.configuration ⇒ Object
Configuration for the conversion
152 153 154 |
# File 'lib/grover.rb', line 152 def self.configuration @configuration ||= Configuration.new end |
.configure {|configuration| ... } ⇒ Object
156 157 158 |
# File 'lib/grover.rb', line 156 def self.configure yield(configuration) end |
Instance Method Details
#inspect ⇒ Object
Instance inspection
140 141 142 143 144 145 146 147 |
# File 'lib/grover.rb', line 140 def inspect format( '#<%<class_name>s:0x%<object_id>p @url="%<url>s">', class_name: self.class.name, object_id: object_id, url: @url ) end |
#show_back_cover? ⇒ Boolean
Returns whether a back cover (request) path has been specified in the options
133 134 135 |
# File 'lib/grover.rb', line 133 def show_back_cover? back_cover_path.is_a?(::String) && back_cover_path.start_with?('/') end |
#show_front_cover? ⇒ Boolean
Returns whether a front cover (request) path has been specified in the options
124 125 126 |
# File 'lib/grover.rb', line 124 def show_front_cover? front_cover_path.is_a?(::String) && front_cover_path.start_with?('/') end |
#to_pdf(path = nil) ⇒ String
Request URL with provided options and create PDF
112 113 114 115 116 117 |
# File 'lib/grover.rb', line 112 def to_pdf(path = nil) = Utils.normalize_object ['path'] = path if path.is_a? ::String result = processor.convert_pdf @url, result['data'].pack('c*') end |