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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f0b1ac4d5fc56686d55aa46a802c393e8458fd93
4
- data.tar.gz: f5f24d27564b772b333e9a4103d0f212ad15c0e0
3
+ metadata.gz: 21fdefff2c21b5341c4d824e0fd2b1a497f23636
4
+ data.tar.gz: 423949075eecb0abd2ba0ac9fa77493fa7131861
5
5
  SHA512:
6
- metadata.gz: 021426b86e6e7c2bf1b44f93f5d5b98953266c8e66be9731ddae6d08191240c16f26fce04eccbb705ede46bbe0f53592b53c17a083d6bc3c4bde0d5d07ee2090
7
- data.tar.gz: 9db725e6bdb5d2616a9700b131de4c9e81b9e808ec0a48494650d50e3a7358af49c7bad1af8f5c58c58f3e555ece656926f79803e13785cc8ad1ebd2e7858f15
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 = @options.dup
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
@@ -83,6 +83,7 @@ class Grover
83
83
 
84
84
  def path_without_extension
85
85
  return @path_without_extension if defined? @path_without_extension
86
+
86
87
  path = @request.path.sub(PDF_REGEX, '')
87
88
  @path_without_extension = path.sub(@request.script_name, '')
88
89
  end
@@ -1,3 +1,3 @@
1
1
  class Grover
2
- VERSION = '0.4.3'.freeze
2
+ VERSION = '0.4.4'.freeze
3
3
  end
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.3
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.8.4
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.8.4
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: A Ruby gem to transform HTML into PDFs using Google Puppeteer/Chromium
153
+ description: Transform HTML into PDFs using Google Puppeteer/Chromium
154
154
  email:
155
155
  - abromwich@studiosity.com
156
156
  executables: []