roadie 5.0.1 → 5.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/main.yml +3 -0
- data/Changelog.md +7 -2
- data/README.md +2 -0
- data/lib/roadie/document.rb +15 -7
- data/lib/roadie/version.rb +1 -1
- data/spec/integration_spec.rb +32 -0
- data/spec/lib/roadie/document_spec.rb +10 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 39c01590157057fcedad04740a1594a45f18150d74c7e8fe071dd3aea6908e1f
|
4
|
+
data.tar.gz: 490cc578b42057ca635ce613d8e50b05401b0a07597761f70423467aa99aa673
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d71f85f1aba91c711351972b65074835f690f62d0cd4a0feb663f67df89a86d8acddc855fe7be4e23601fe3b0508c1558f6c18cc260c69c1ad5b1b1857ad04e2
|
7
|
+
data.tar.gz: 1d708c10a62800d44efbe825601546a8713b953f81a2549d91a23e74e26048839adc418d38c38bbd08bd885bc6504a3a07c5cca46f94d3ad147d347f3086ffaa
|
data/.github/workflows/main.yml
CHANGED
data/Changelog.md
CHANGED
@@ -1,8 +1,13 @@
|
|
1
1
|
### dev
|
2
2
|
|
3
|
-
[full changelog](https://github.com/Mange/roadie/compare/v5.0
|
3
|
+
[full changelog](https://github.com/Mange/roadie/compare/v5.1.0...master)
|
4
4
|
|
5
|
-
|
5
|
+
### 5.1.0
|
6
|
+
|
7
|
+
[full changelog](https://github.com/Mange/roadie/compare/v5.0.1...v5.1.0)
|
8
|
+
|
9
|
+
* Support passing serialization options to Nokogiri with `serialization_options=` method -
|
10
|
+
[Dmytro Savochkin](https://github.com/dmytro-savochkin). (#171)
|
6
11
|
|
7
12
|
### 5.0.1
|
8
13
|
|
data/README.md
CHANGED
@@ -94,6 +94,8 @@ Your document instance can be configured with several options:
|
|
94
94
|
* `external_asset_providers` - A list of asset providers that are invoked when absolute CSS URLs are referenced. See below.
|
95
95
|
* `before_transformation` - A callback run before transformation starts.
|
96
96
|
* `after_transformation` - A callback run after transformation is completed.
|
97
|
+
* `serialization_options` - An integer bitmap of options passed along to Nokogiri during serialization.
|
98
|
+
By default it's `Nokogiri::XML::Node::SaveOptions::NO_DECLARATION | Nokogiri::XML::Node::SaveOptions::NO_EMPTY_TAGS`.
|
97
99
|
|
98
100
|
### Making URLs absolute ###
|
99
101
|
|
data/lib/roadie/document.rb
CHANGED
@@ -42,6 +42,10 @@ module Roadie
|
|
42
42
|
# which would change the styling on the page
|
43
43
|
attr_accessor :merge_media_queries
|
44
44
|
|
45
|
+
# Integer representing a bitmap set of options used by Nokogiri during serialization.
|
46
|
+
# For the complete set of available options look into +Nokogiri::XML::Node::SaveOptions+.
|
47
|
+
attr_reader :serialization_options
|
48
|
+
|
45
49
|
# The mode to generate markup in. Valid values are `:html` (default) and `:xhtml`.
|
46
50
|
attr_reader :mode
|
47
51
|
|
@@ -49,6 +53,9 @@ module Roadie
|
|
49
53
|
def initialize(html)
|
50
54
|
@keep_uninlinable_css = true
|
51
55
|
@merge_media_queries = true
|
56
|
+
@serialization_options =
|
57
|
+
Nokogiri::XML::Node::SaveOptions::NO_DECLARATION |
|
58
|
+
Nokogiri::XML::Node::SaveOptions::NO_EMPTY_TAGS
|
52
59
|
@html = html
|
53
60
|
@asset_providers = ProviderList.wrap(FilesystemProvider.new)
|
54
61
|
@external_asset_providers = ProviderList.empty
|
@@ -137,6 +144,13 @@ module Roadie
|
|
137
144
|
@external_asset_providers = ProviderList.wrap(list)
|
138
145
|
end
|
139
146
|
|
147
|
+
# Integer representing a bitmap set of options used by Nokogiri during serialization.
|
148
|
+
# For the complete set of available options look into +Nokogiri::XML::Node::SaveOptions+.
|
149
|
+
# (To change the mode in which the document is generated use {#mode=} however.)
|
150
|
+
def serialization_options=(options)
|
151
|
+
@serialization_options = options || 0
|
152
|
+
end
|
153
|
+
|
140
154
|
# Change the mode. The mode affects how the resulting markup is generated.
|
141
155
|
#
|
142
156
|
# Valid modes:
|
@@ -187,13 +201,7 @@ module Roadie
|
|
187
201
|
xml: save_options::AS_XML
|
188
202
|
}.fetch(mode)
|
189
203
|
|
190
|
-
dom.dup.to_html(
|
191
|
-
save_with: (
|
192
|
-
save_options::NO_DECLARATION |
|
193
|
-
save_options::NO_EMPTY_TAGS |
|
194
|
-
format
|
195
|
-
)
|
196
|
-
)
|
204
|
+
dom.dup.to_html(save_with: (serialization_options | format))
|
197
205
|
end
|
198
206
|
|
199
207
|
def make_url_rewriter
|
data/lib/roadie/version.rb
CHANGED
data/spec/integration_spec.rb
CHANGED
@@ -398,6 +398,38 @@ describe "Roadie functionality" do
|
|
398
398
|
expect(actual_result).to eq(expected_result)
|
399
399
|
end
|
400
400
|
|
401
|
+
it "adds XML declaration into XHTML with no serialization options prohibiting it" do
|
402
|
+
document = Roadie::Document.new <<-HTML
|
403
|
+
<html>
|
404
|
+
<head>
|
405
|
+
<title>Greetings</title>
|
406
|
+
</head>
|
407
|
+
</html>
|
408
|
+
HTML
|
409
|
+
|
410
|
+
document.mode = :xhtml
|
411
|
+
document.serialization_options = 0
|
412
|
+
result = document.transform
|
413
|
+
|
414
|
+
expect(result).to match(/\A<\?xml[^>]*?>/i)
|
415
|
+
end
|
416
|
+
|
417
|
+
it "does not add XML declaration into XHTML with serialization options prohibiting it" do
|
418
|
+
document = Roadie::Document.new <<-HTML
|
419
|
+
<html>
|
420
|
+
<head>
|
421
|
+
<title>Greetings</title>
|
422
|
+
</head>
|
423
|
+
</html>
|
424
|
+
HTML
|
425
|
+
|
426
|
+
document.mode = :xhtml
|
427
|
+
document.serialization_options = Nokogiri::XML::Node::SaveOptions::NO_DECLARATION
|
428
|
+
result = document.transform
|
429
|
+
|
430
|
+
expect(result).not_to match(/\A<\?xml[^>]*?>/i)
|
431
|
+
end
|
432
|
+
|
401
433
|
describe "if merge_media_queries is set to false" do
|
402
434
|
it "doesn't group non-inlineable media queries in the head" do
|
403
435
|
document = Roadie::Document.new <<-HTML
|
@@ -17,6 +17,16 @@ module Roadie
|
|
17
17
|
expect(document.url_options).to eq({host: "foo.bar"})
|
18
18
|
end
|
19
19
|
|
20
|
+
it "has an accessor for serialization options" do
|
21
|
+
serialization_options = Nokogiri::XML::Node::SaveOptions::FORMAT |
|
22
|
+
Nokogiri::XML::Node::SaveOptions::NO_EMPTY_TAGS
|
23
|
+
document.serialization_options = serialization_options
|
24
|
+
expect(document.serialization_options).to eq(serialization_options)
|
25
|
+
|
26
|
+
document.serialization_options = nil
|
27
|
+
expect(document.serialization_options).to eq(0)
|
28
|
+
end
|
29
|
+
|
20
30
|
it "has a setting for keeping uninlinable styles" do
|
21
31
|
expect(document.keep_uninlinable_css).to be true
|
22
32
|
document.keep_uninlinable_css = false
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: roadie
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 5.0
|
4
|
+
version: 5.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Magnus Bergmark
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-11-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: nokogiri
|
@@ -197,7 +197,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
197
197
|
- !ruby/object:Gem::Version
|
198
198
|
version: '0'
|
199
199
|
requirements: []
|
200
|
-
rubygems_version: 3.
|
200
|
+
rubygems_version: 3.3.7
|
201
201
|
signing_key:
|
202
202
|
specification_version: 4
|
203
203
|
summary: Making HTML emails comfortable for the Ruby rockstars
|