grover 0.4.3 → 0.4.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/grover.rb +42 -37
- data/lib/grover/middleware.rb +1 -0
- data/lib/grover/version.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 21fdefff2c21b5341c4d824e0fd2b1a497f23636
|
4
|
+
data.tar.gz: 423949075eecb0abd2ba0ac9fa77493fa7131861
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a5a62083e5deabebf8728033b0519d1ffadc7cd08683a5d1ad85e25fe490d83113d41db34db24bde1f4b89c0c709e0b46e424ee02ca23d96ff82f8fe79911e6d
|
7
|
+
data.tar.gz: 6fad9c43307155729a8425d1553953ae1ce22e75a2a12f7f6d6aa7c755e18339130205b36e9dbe3f379ac0a0e0b3bb1ff1c2e8b63ead6867669b9c64332cd789
|
data/lib/grover.rb
CHANGED
@@ -114,47 +114,12 @@ class Grover
|
|
114
114
|
end
|
115
115
|
|
116
116
|
def base_options
|
117
|
-
options =
|
117
|
+
options = {}
|
118
|
+
@options.each { |k, v| options[k.to_s] = v }
|
118
119
|
options.merge! meta_options unless url_source?
|
119
120
|
options
|
120
121
|
end
|
121
122
|
|
122
|
-
def options_with_template_fix
|
123
|
-
options = base_options
|
124
|
-
display_url = options.delete :display_url
|
125
|
-
if display_url
|
126
|
-
options[:footer_template] ||= DEFAULT_FOOTER_TEMPLATE
|
127
|
-
|
128
|
-
%i[header_template footer_template].each do |key|
|
129
|
-
next unless options[key].is_a? String
|
130
|
-
options[key] = options[key].gsub(DISPLAY_URL_PLACEHOLDER, display_url)
|
131
|
-
end
|
132
|
-
end
|
133
|
-
options
|
134
|
-
end
|
135
|
-
|
136
|
-
def normalized_options(path)
|
137
|
-
options = Utils.normalize_object options_with_template_fix
|
138
|
-
fix_boolean_options! options
|
139
|
-
fix_numeric_options! options
|
140
|
-
options['path'] = path if path
|
141
|
-
options
|
142
|
-
end
|
143
|
-
|
144
|
-
def fix_boolean_options!(options)
|
145
|
-
%w[displayHeaderFooter printBackground landscape preferCSSPageSize].each do |opt|
|
146
|
-
next unless options.key? opt
|
147
|
-
options[opt] = !FALSE_VALUES.include?(options[opt])
|
148
|
-
end
|
149
|
-
end
|
150
|
-
|
151
|
-
FALSE_VALUES = [nil, false, 0, '0', 'f', 'F', 'false', 'FALSE', 'off', 'OFF'].freeze
|
152
|
-
|
153
|
-
def fix_numeric_options!(options)
|
154
|
-
return unless options.key? 'scale'
|
155
|
-
options['scale'] = options['scale'].to_f
|
156
|
-
end
|
157
|
-
|
158
123
|
#
|
159
124
|
# Extract out options from meta tags in the source - based on code from PDFKit project
|
160
125
|
#
|
@@ -178,4 +143,44 @@ class Grover
|
|
178
143
|
def url_source?
|
179
144
|
@url.match(/^http/i)
|
180
145
|
end
|
146
|
+
|
147
|
+
def normalized_options(path)
|
148
|
+
options = base_options
|
149
|
+
|
150
|
+
fix_templates! options
|
151
|
+
fix_boolean_options! options
|
152
|
+
fix_numeric_options! options
|
153
|
+
options['path'] = path if path
|
154
|
+
|
155
|
+
Utils.normalize_object options
|
156
|
+
end
|
157
|
+
|
158
|
+
def fix_templates!(options)
|
159
|
+
display_url = options.delete 'display_url'
|
160
|
+
return unless display_url
|
161
|
+
|
162
|
+
options['footer_template'] ||= DEFAULT_FOOTER_TEMPLATE
|
163
|
+
|
164
|
+
%w[header_template footer_template].each do |key|
|
165
|
+
next unless options[key].is_a? String
|
166
|
+
|
167
|
+
options[key] = options[key].gsub(DISPLAY_URL_PLACEHOLDER, display_url)
|
168
|
+
end
|
169
|
+
end
|
170
|
+
|
171
|
+
def fix_boolean_options!(options)
|
172
|
+
%w[display_header_footer print_background landscape prefer_css_page_size].each do |opt|
|
173
|
+
next unless options.key? opt
|
174
|
+
|
175
|
+
options[opt] = !FALSE_VALUES.include?(options[opt])
|
176
|
+
end
|
177
|
+
end
|
178
|
+
|
179
|
+
FALSE_VALUES = [nil, false, 0, '0', 'f', 'F', 'false', 'FALSE', 'off', 'OFF'].freeze
|
180
|
+
|
181
|
+
def fix_numeric_options!(options)
|
182
|
+
return unless options.key? 'scale'
|
183
|
+
|
184
|
+
options['scale'] = options['scale'].to_f
|
185
|
+
end
|
181
186
|
end
|
data/lib/grover/middleware.rb
CHANGED
data/lib/grover/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: grover
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew Bromwich
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 1.
|
19
|
+
version: '1.0'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 1.
|
26
|
+
version: '1.0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: schmooze
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -150,7 +150,7 @@ dependencies:
|
|
150
150
|
- - "~>"
|
151
151
|
- !ruby/object:Gem::Version
|
152
152
|
version: '0.15'
|
153
|
-
description:
|
153
|
+
description: Transform HTML into PDFs using Google Puppeteer/Chromium
|
154
154
|
email:
|
155
155
|
- abromwich@studiosity.com
|
156
156
|
executables: []
|