roadie 5.0.1 → 5.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7ac28a4d983148b5e8c799804e754b81d9d7a04b4ef97f97bcc6592d37a74bed
4
- data.tar.gz: 9dbeb2fb1d41e301bf7d7c4049e476da22604bfc70047f6dc843ab6c1a489048
3
+ metadata.gz: d61e03043b7a3086eeccdb7ca1e804ca3eebb5b6dabcc96d09bd5a7daa06b845
4
+ data.tar.gz: d48918c67a5fe53b88e1b2607269fdf353457e8829cc7dba84bdab3f308426d3
5
5
  SHA512:
6
- metadata.gz: 5146cfb6152aad59b410670b792788bc84af5a9064c353628fae6cc1a1b2a2854703872990c47788c9369fef4469ee15b0040f192aeda1e32dcd8eef934e6327
7
- data.tar.gz: 80418199d7ea29608e7997ee4ccfb591dbe8bd1eb3c609b59e8fc857b0d056103fcc9e74fafab6cd32f041ea8051870c41a5e6807b24d4c233e46803ab498750
6
+ metadata.gz: 7e646c9a1864e7eb00fef92649583203721b551194ae9c5dd8f979200f8fae06f84b0298252dc3f851585f45047a66ae8f10c417dcdda776046cfc5c59267c0a
7
+ data.tar.gz: 0f01356119714952a4715ae0db43b96dc964168572943e7a9837cdbadadf493db56440484a6d6564fcccec6cbbc125076bf1cade4e588674ad9802dd7120d5a0
@@ -15,11 +15,11 @@ jobs:
15
15
  strategy:
16
16
  fail-fast: false
17
17
  matrix:
18
- ruby: ["2.6", "2.7", "3.0", "3.1"]
18
+ ruby: ["2.7", "3.0", "3.1", "3.2"]
19
19
 
20
20
  steps:
21
21
  - name: Checkout code
22
- uses: actions/checkout@v2
22
+ uses: actions/checkout@v3
23
23
 
24
24
  # This setup is not compatible with the way Travis CI was
25
25
  # setup, so the cache will only work for the root folder.
@@ -34,10 +34,19 @@ jobs:
34
34
 
35
35
  - uses: codecov/codecov-action@v2
36
36
 
37
- lint:
38
- runs-on: ubuntu-latest
39
- steps:
40
- - name: standardrb
41
- env:
42
- GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
43
- uses: amoeba/standardrb-action@v2
37
+ # Does not work. The action runs in Ruby 2.6, which is not compatible with
38
+ # the gem and fails to install.
39
+ # This is very strange considering that the source of the action uses a
40
+ # Dockerfile with Ruby 2.7. However, I don't want to spend time to fix this
41
+ # in a passively maintained gem.
42
+ #
43
+ # lint:
44
+ # runs-on: ubuntu-latest
45
+ # steps:
46
+ # - name: standardrb
47
+ # env:
48
+ # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
49
+ # uses: amoeba/standardrb-action@v2
50
+ # permissions:
51
+ # checks: write
52
+ # contents: read
data/.rubocop.yml CHANGED
@@ -1,5 +1,9 @@
1
- AllCops:
2
- DisabledByDefault: true
1
+ require:
2
+ - standard
3
+
4
+ inherit_gem:
5
+ standard: config/base.yml
3
6
 
4
- Style/FrozenStringLiteralComment:
5
- Enabled: true
7
+ AllCops:
8
+ SuggestExtensions: false
9
+ TargetRubyVersion: 2.7
data/.solargraph.yml CHANGED
@@ -8,9 +8,5 @@ exclude:
8
8
  - ".bundle/**/*"
9
9
  require: []
10
10
  domains: []
11
- plugins:
12
- - solargraph-standardrb
13
- reporters:
14
- - standardrb
15
11
  require_paths: []
16
12
  max_files: 5000
data/.standard.yml ADDED
@@ -0,0 +1 @@
1
+ ruby_version: 2.7
data/Changelog.md CHANGED
@@ -1,8 +1,21 @@
1
1
  ### dev
2
2
 
3
- [full changelog](https://github.com/Mange/roadie/compare/v5.0.1...master)
3
+ [full changelog](https://github.com/Mange/roadie/compare/v5.2.0...master)
4
4
 
5
- Nothing yet.
5
+ ### 5.2.0
6
+
7
+ [full changelog](https://github.com/Mange/roadie/compare/v5.1.0...v5.2.0)
8
+
9
+ * Upgrade to Nokogiri `~>` 1.15.
10
+ * Drop support for Ruby 2.6.
11
+ * Add official support for Ruby 3.2.
12
+
13
+ ### 5.1.0
14
+
15
+ [full changelog](https://github.com/Mange/roadie/compare/v5.0.1...v5.1.0)
16
+
17
+ * Support passing serialization options to Nokogiri with `serialization_options=` method -
18
+ [Dmytro Savochkin](https://github.com/dmytro-savochkin). (#171)
6
19
 
7
20
  ### 5.0.1
8
21
 
data/Gemfile CHANGED
@@ -8,3 +8,4 @@ gem "codecov", group: :test, require: false
8
8
  # Not actually required to run the tests for the gem, but a real convenience
9
9
  # for local development.
10
10
  gem "standard", group: [:test, :development], require: false
11
+ gem "solargraph", group: [:test, :development], require: false
data/README.md CHANGED
@@ -54,7 +54,7 @@ Install & Usage
54
54
  [Add this gem to your Gemfile as recommended by Rubygems](http://rubygems.org/gems/roadie) and run `bundle install`.
55
55
 
56
56
  ```ruby
57
- gem 'roadie', '~> 4.0'
57
+ gem 'roadie', '~> 5.2'
58
58
  ```
59
59
 
60
60
  You can then create a new instance of a Roadie document:
@@ -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
 
@@ -448,10 +450,10 @@ Build Status
448
450
 
449
451
  Tested with Github CI using:
450
452
 
451
- * MRI 2.6
452
453
  * MRI 2.7
453
454
  * MRI 3.0
454
455
  * MRI 3.1
456
+ * MRI 3.2
455
457
 
456
458
  Let me know if you want any other runtime supported officially.
457
459
 
@@ -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
@@ -8,6 +8,7 @@ module Roadie
8
8
  # should take place.
9
9
  class NullUrlRewriter
10
10
  def initialize(generator = nil)
11
+ # Intentionally left blank.
11
12
  end
12
13
 
13
14
  def transform_dom(dom)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Roadie
4
- VERSION = "5.0.1"
4
+ VERSION = "5.2.0"
5
5
  end
data/roadie.gemspec CHANGED
@@ -15,9 +15,9 @@ Gem::Specification.new do |s|
15
15
  s.description = "Roadie tries to make sending HTML emails a little less painful by inlining stylesheets and rewriting relative URLs for you."
16
16
  s.license = "MIT"
17
17
 
18
- s.required_ruby_version = ">= 2.6"
18
+ s.required_ruby_version = ">= 2.7"
19
19
 
20
- s.add_dependency "nokogiri", "~> 1.8"
20
+ s.add_dependency "nokogiri", "~> 1.15"
21
21
  s.add_dependency "css_parser", "~> 1.4"
22
22
 
23
23
  s.add_development_dependency "rake"
@@ -29,5 +29,4 @@ Gem::Specification.new do |s|
29
29
  s.require_paths = %w[lib]
30
30
 
31
31
  s.files = `git ls-files`.split("\n")
32
- s.test_files = `git ls-files -- spec/*`.split("\n")
33
32
  end
@@ -251,8 +251,7 @@ describe "Roadie functionality" do
251
251
  result = parse_html document.transform
252
252
 
253
253
  expect(result.at_css("a.one")["href"]).to eq("https://myapp.com/rails/app/about_us")
254
- # Nokogiri still treats the attribute as an URL and escapes it.
255
- expect(result.at_css("a.two")["href"]).to eq("%24UNSUBSCRIBE_URL")
254
+ expect(result.at_css("a.two")["href"]).to eq("$UNSUBSCRIBE_URL")
256
255
 
257
256
  expect(result).to have_styling("color" => "green").at_selector("a.one")
258
257
  expect(result).to have_styling("color" => "green").at_selector("a.two")
@@ -398,6 +397,38 @@ describe "Roadie functionality" do
398
397
  expect(actual_result).to eq(expected_result)
399
398
  end
400
399
 
400
+ it "adds XML declaration into XHTML with no serialization options prohibiting it" do
401
+ document = Roadie::Document.new <<-HTML
402
+ <html>
403
+ <head>
404
+ <title>Greetings</title>
405
+ </head>
406
+ </html>
407
+ HTML
408
+
409
+ document.mode = :xhtml
410
+ document.serialization_options = 0
411
+ result = document.transform
412
+
413
+ expect(result).to match(/\A<\?xml[^>]*?>/i)
414
+ end
415
+
416
+ it "does not add XML declaration into XHTML with serialization options prohibiting it" do
417
+ document = Roadie::Document.new <<-HTML
418
+ <html>
419
+ <head>
420
+ <title>Greetings</title>
421
+ </head>
422
+ </html>
423
+ HTML
424
+
425
+ document.mode = :xhtml
426
+ document.serialization_options = Nokogiri::XML::Node::SaveOptions::NO_DECLARATION
427
+ result = document.transform
428
+
429
+ expect(result).not_to match(/\A<\?xml[^>]*?>/i)
430
+ end
431
+
401
432
  describe "if merge_media_queries is set to false" do
402
433
  it "doesn't group non-inlineable media queries in the head" do
403
434
  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
@@ -39,7 +39,7 @@ module Roadie
39
39
  context "when one of media queries includes feature condition" do
40
40
  it "returns false" do
41
41
  selector = double "Selector", inlinable?: "maybe"
42
- expect(StyleBlock.new(selector, [], [:all, :'screen (min-width: 300px)']).inlinable?).to be(false)
42
+ expect(StyleBlock.new(selector, [], [:all, :"screen (min-width: 300px)"]).inlinable?).to be(false)
43
43
  end
44
44
  end
45
45
  end
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.1
4
+ version: 5.2.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-05-11 00:00:00.000000000 Z
11
+ date: 1980-01-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nokogiri
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '1.8'
19
+ version: '1.15'
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'
26
+ version: '1.15'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: css_parser
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -104,11 +104,11 @@ extra_rdoc_files:
104
104
  - README.md
105
105
  - Changelog.md
106
106
  files:
107
- - ".autotest"
108
107
  - ".github/workflows/main.yml"
109
108
  - ".gitignore"
110
109
  - ".rubocop.yml"
111
110
  - ".solargraph.yml"
111
+ - ".standard.yml"
112
112
  - ".yardopts"
113
113
  - Changelog.md
114
114
  - Gemfile
@@ -190,50 +190,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
190
190
  requirements:
191
191
  - - ">="
192
192
  - !ruby/object:Gem::Version
193
- version: '2.6'
193
+ version: '2.7'
194
194
  required_rubygems_version: !ruby/object:Gem::Requirement
195
195
  requirements:
196
196
  - - ">="
197
197
  - !ruby/object:Gem::Version
198
198
  version: '0'
199
199
  requirements: []
200
- rubygems_version: 3.0.9
200
+ rubygems_version: 3.4.17
201
201
  signing_key:
202
202
  specification_version: 4
203
203
  summary: Making HTML emails comfortable for the Ruby rockstars
204
- test_files:
205
- - spec/fixtures/big_em.css
206
- - spec/fixtures/stylesheets/green.css
207
- - spec/hash_as_cache_store_spec.rb
208
- - spec/integration_spec.rb
209
- - spec/lib/roadie/asset_scanner_spec.rb
210
- - spec/lib/roadie/cached_provider_spec.rb
211
- - spec/lib/roadie/css_not_found_spec.rb
212
- - spec/lib/roadie/deduplicator_spec.rb
213
- - spec/lib/roadie/document_spec.rb
214
- - spec/lib/roadie/filesystem_provider_spec.rb
215
- - spec/lib/roadie/inliner_spec.rb
216
- - spec/lib/roadie/markup_improver_spec.rb
217
- - spec/lib/roadie/net_http_provider_spec.rb
218
- - spec/lib/roadie/null_provider_spec.rb
219
- - spec/lib/roadie/null_url_rewriter_spec.rb
220
- - spec/lib/roadie/path_rewriter_provider_spec.rb
221
- - spec/lib/roadie/provider_list_spec.rb
222
- - spec/lib/roadie/selector_spec.rb
223
- - spec/lib/roadie/style_attribute_builder_spec.rb
224
- - spec/lib/roadie/style_block_spec.rb
225
- - spec/lib/roadie/style_property_spec.rb
226
- - spec/lib/roadie/stylesheet_spec.rb
227
- - spec/lib/roadie/test_provider_spec.rb
228
- - spec/lib/roadie/url_generator_spec.rb
229
- - spec/lib/roadie/url_rewriter_spec.rb
230
- - spec/lib/roadie/utils_spec.rb
231
- - spec/shared_examples/asset_provider.rb
232
- - spec/shared_examples/url_rewriter.rb
233
- - spec/spec_helper.rb
234
- - spec/support/have_attribute_matcher.rb
235
- - spec/support/have_node_matcher.rb
236
- - spec/support/have_selector_matcher.rb
237
- - spec/support/have_styling_matcher.rb
238
- - spec/support/have_xpath_matcher.rb
239
- - spec/support/test_provider.rb
204
+ test_files: []
data/.autotest DELETED
@@ -1,10 +0,0 @@
1
- # Override autotest default magic to rerun all tests every time a
2
- # change is detected on the file system.
3
- class Autotest
4
- def get_to_green
5
- begin
6
- rerun_all_tests
7
- wait_for_changes unless all_good
8
- end until all_good
9
- end
10
- end