diff -Nru ruby-roadie-4.0.0/Changelog.md ruby-roadie-5.0.0/Changelog.md --- ruby-roadie-4.0.0/Changelog.md 2019-10-13 19:17:45.000000000 +0000 +++ ruby-roadie-5.0.0/Changelog.md 2022-02-05 05:54:20.000000000 +0000 @@ -1,9 +1,21 @@ ### dev -[full changelog](https://github.com/Mange/roadie/compare/v4.0.0...master) +[full changelog](https://github.com/Mange/roadie/compare/v5.0.0...master) Nothing yet. +### 5.0.0 + +[full changelog](https://github.com/Mange/roadie/compare/v4.0.0...v5.0.0) + +* Drop support for Ruby 2.4 and Ruby 2.5 +* Drop support for JRuby and Rubinius +* Test with Ruby 2.7 - [aried3r (Anton Rieder)](https://github.com/aried3r) (#167) +* Test with Ruby 3.0 and Ruby 3.1 +* Add standardrb as code formatter +* Drop support for callbacks that accepts only a single argument. +* Change signature of `Roadie::CssNotFound` and `Roadie::ProvidersFailed`. + ### 4.0.0 [full changelog](https://github.com/Mange/roadie/compare/v3.5.1...v4.0.0) @@ -387,4 +399,3 @@ * + some other enhancements * Deprecations: * Removed support for Rails 2.x - diff -Nru ruby-roadie-4.0.0/debian/changelog ruby-roadie-5.0.0/debian/changelog --- ruby-roadie-4.0.0/debian/changelog 2019-10-31 22:55:30.000000000 +0000 +++ ruby-roadie-5.0.0/debian/changelog 2022-02-05 06:28:44.000000000 +0000 @@ -1,3 +1,22 @@ +ruby-roadie (5.0.0-1) unstable; urgency=medium + + [ Debian Janitor ] + * Set upstream metadata fields: Bug-Database, Bug-Submit, Repository, + Repository-Browse. + * Update standards version to 4.5.0, no changes needed. + * Update watch file format version to 4. + + [ Unit 193 ] + * New upstream version 5.0.0. + - Bump DH compat to 13, remove old version constraints. + - Replace 'ruby | ruby-interpreter' depend with ${ruby:Depends}. + - Update my email address. + * d/u/metadata: Add 'Archive' and 'Changelog' fields. + * d/rules: Install upstream changelog. + * Update Standards-Version to 4.6.0. + + -- Unit 193 Sat, 05 Feb 2022 01:28:44 -0500 + ruby-roadie (4.0.0-1) unstable; urgency=medium * New upstream version 4.0.0 diff -Nru ruby-roadie-4.0.0/debian/control ruby-roadie-5.0.0/debian/control --- ruby-roadie-4.0.0/debian/control 2019-10-31 22:55:15.000000000 +0000 +++ ruby-roadie-5.0.0/debian/control 2022-02-05 06:26:07.000000000 +0000 @@ -1,32 +1,31 @@ Source: ruby-roadie Section: ruby Priority: optional -Maintainer: Debian Ruby Extras Maintainers -Uploaders: Unit 193 -Build-Depends: debhelper-compat (= 12), +Maintainer: Debian Ruby Team +Uploaders: Unit 193 +Build-Depends: debhelper-compat (= 13), gem2deb, rake, - ruby-css-parser (>= 1.4), - ruby-nokogiri (>= 1.8), + ruby-css-parser, + ruby-nokogiri, ruby-rspec, ruby-rspec-collection-matchers, ruby-webmock -Standards-Version: 4.4.1 +Rules-Requires-Root: no +Standards-Version: 4.6.0 Vcs-Git: https://salsa.debian.org/ruby-team/ruby-roadie.git Vcs-Browser: https://salsa.debian.org/ruby-team/ruby-roadie Homepage: https://github.com/Mange/roadie -Rules-Requires-Root: no Testsuite: autopkgtest-pkg-ruby XS-Ruby-Versions: all Package: ruby-roadie Architecture: all XB-Ruby-Versions: ${ruby:Versions} -Depends: ruby | ruby-interpreter, - ruby-css-parser (>= 1.4), - ruby-nokogiri (>= 1.8), - ${misc:Depends}, - ${shlibs:Depends} +Depends: ${misc:Depends}, + ${ruby:Depends}, + ruby-css-parser, + ruby-nokogiri, Description: library for composing HTML email Email clients have bad support for stylesheets, and some of them blocks stylesheets from downloading. The easiest way to handle this is to work with diff -Nru ruby-roadie-4.0.0/debian/rules ruby-roadie-5.0.0/debian/rules --- ruby-roadie-4.0.0/debian/rules 2019-10-31 22:53:35.000000000 +0000 +++ ruby-roadie-5.0.0/debian/rules 2022-02-05 06:27:01.000000000 +0000 @@ -4,3 +4,6 @@ %: dh $@ --buildsystem=ruby --with ruby + +override_dh_installchangelogs: + dh_installchangelogs Changelog.md diff -Nru ruby-roadie-4.0.0/debian/upstream/metadata ruby-roadie-5.0.0/debian/upstream/metadata --- ruby-roadie-4.0.0/debian/upstream/metadata 1970-01-01 00:00:00.000000000 +0000 +++ ruby-roadie-5.0.0/debian/upstream/metadata 2022-02-05 06:25:07.000000000 +0000 @@ -0,0 +1,7 @@ +--- +Archive: GitHub +Bug-Database: https://github.com/Mange/roadie/issues +Bug-Submit: https://github.com/Mange/roadie/issues/new +Changelog: https://github.com/Mange/roadie/blob/master/Changelog.md +Repository: https://github.com/Mange/roadie.git +Repository-Browse: https://github.com/Mange/roadie diff -Nru ruby-roadie-4.0.0/debian/watch ruby-roadie-5.0.0/debian/watch --- ruby-roadie-4.0.0/debian/watch 2019-10-31 22:53:35.000000000 +0000 +++ ruby-roadie-5.0.0/debian/watch 2022-02-05 05:04:29.000000000 +0000 @@ -1,2 +1,2 @@ -version=3 +version=4 https://gemwatch.debian.net/roadie .*/roadie-(.*).tar.gz diff -Nru ruby-roadie-4.0.0/Gemfile ruby-roadie-5.0.0/Gemfile --- ruby-roadie-4.0.0/Gemfile 2019-10-13 19:17:45.000000000 +0000 +++ ruby-roadie-5.0.0/Gemfile 2022-02-05 05:54:20.000000000 +0000 @@ -1,7 +1,10 @@ # frozen_string_literal: true -source 'https://rubygems.org' +source "https://rubygems.org" gemspec # Added here so it does not show up on the Gemspec; I only want it for CI builds -gem 'codecov', group: :test, require: false +gem "codecov", group: :test, require: false +# Not actually required to run the tests for the gem, but a real convenience +# for local development. +gem "standard", group: [:test, :development], require: false diff -Nru ruby-roadie-4.0.0/.github/workflows/main.yml ruby-roadie-5.0.0/.github/workflows/main.yml --- ruby-roadie-4.0.0/.github/workflows/main.yml 1970-01-01 00:00:00.000000000 +0000 +++ ruby-roadie-5.0.0/.github/workflows/main.yml 2022-02-05 05:54:20.000000000 +0000 @@ -0,0 +1,43 @@ +name: Main +on: + push: + branches: + - main + - master + + pull_request: + types: [opened, synchronize, reopened] + +jobs: + base: + name: Ruby ${{ matrix.ruby }} + runs-on: ubuntu-20.04 + strategy: + fail-fast: false + matrix: + ruby: ["2.6", "2.7", "3.0", "3.1"] + + steps: + - name: Checkout code + uses: actions/checkout@v2 + + # This setup is not compatible with the way Travis CI was + # setup, so the cache will only work for the root folder. + - name: Setup Ruby + uses: ruby/setup-ruby@v1 + with: + ruby-version: ${{ matrix.ruby }} + bundler-cache: true + + - name: Rake + run: bundle exec rake + + - uses: codecov/codecov-action@v2 + + lint: + runs-on: ubuntu-latest + steps: + - name: standardrb + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + uses: amoeba/standardrb-action@v2 diff -Nru ruby-roadie-4.0.0/lib/roadie/asset_provider.rb ruby-roadie-5.0.0/lib/roadie/asset_provider.rb --- ruby-roadie-4.0.0/lib/roadie/asset_provider.rb 2019-10-13 19:17:45.000000000 +0000 +++ ruby-roadie-5.0.0/lib/roadie/asset_provider.rb 2022-02-05 05:54:20.000000000 +0000 @@ -7,7 +7,9 @@ # It helps you by declaring {#find_stylesheet!} in the terms of #find_stylesheet in your own class. module AssetProvider def find_stylesheet!(name) - find_stylesheet(name) or raise CssNotFound.new(name, nil, self) + find_stylesheet(name) or raise( + CssNotFound.new(css_name: name, provider: self) + ) end end end diff -Nru ruby-roadie-4.0.0/lib/roadie/asset_scanner.rb ruby-roadie-5.0.0/lib/roadie/asset_scanner.rb --- ruby-roadie-4.0.0/lib/roadie/asset_scanner.rb 2019-10-13 19:17:45.000000000 +0000 +++ ruby-roadie-5.0.0/lib/roadie/asset_scanner.rb 2022-02-05 05:54:20.000000000 +0000 @@ -43,15 +43,15 @@ # @see #find_css # @return [Enumerable] every extracted stylesheet def extract_css - stylesheets = @dom.css(STYLE_ELEMENT_QUERY).map { |element| + @dom.css(STYLE_ELEMENT_QUERY).map { |element| stylesheet = read_stylesheet(element) element.remove if stylesheet stylesheet }.compact - stylesheets end private + STYLE_ELEMENT_QUERY = ( "style:not([data-roadie-ignore]), " + # TODO: When using Nokogiri 1.6.1 and later; we may use a double :not here @@ -75,7 +75,7 @@ def read_stylesheet(element) if element.name == "style" read_style_element element - elsif element.name == "link" && element['media'] != "print" && element["href"] + elsif element.name == "link" && element["media"] != "print" && element["href"] read_link_element element end end @@ -86,14 +86,14 @@ def read_link_element(element) if Utils.path_is_absolute?(element["href"]) - external_asset_provider.find_stylesheet! element['href'] if should_find_external? + external_asset_provider.find_stylesheet! element["href"] if should_find_external? else - normal_asset_provider.find_stylesheet! element['href'] + normal_asset_provider.find_stylesheet! element["href"] end end def clean_css(css) - css.gsub(CLEANING_MATCHER, '') + css.gsub(CLEANING_MATCHER, "") end def should_find_external? diff -Nru ruby-roadie-4.0.0/lib/roadie/cached_provider.rb ruby-roadie-5.0.0/lib/roadie/cached_provider.rb --- ruby-roadie-4.0.0/lib/roadie/cached_provider.rb 2019-10-13 19:17:45.000000000 +0000 +++ ruby-roadie-5.0.0/lib/roadie/cached_provider.rb 2022-02-05 05:54:20.000000000 +0000 @@ -69,6 +69,7 @@ end private + def cache_fetch(name) cache[name] || cache[name] = yield rescue CssNotFound diff -Nru ruby-roadie-4.0.0/lib/roadie/deduplicator.rb ruby-roadie-5.0.0/lib/roadie/deduplicator.rb --- ruby-roadie-4.0.0/lib/roadie/deduplicator.rb 2019-10-13 19:17:45.000000000 +0000 +++ ruby-roadie-5.0.0/lib/roadie/deduplicator.rb 2022-02-05 05:54:20.000000000 +0000 @@ -26,6 +26,7 @@ end private + attr_reader :input, :latest_occurance def has_duplicates? diff -Nru ruby-roadie-4.0.0/lib/roadie/document.rb ruby-roadie-5.0.0/lib/roadie/document.rb --- ruby-roadie-4.0.0/lib/roadie/document.rb 2019-10-13 19:17:45.000000000 +0000 +++ ruby-roadie-5.0.0/lib/roadie/document.rb 2022-02-05 05:54:20.000000000 +0000 @@ -142,6 +142,7 @@ # Valid modes: # `:html` (default) # `:xhtml` + # `:xml` def mode=(mode) if VALID_MODES.include?(mode) @mode = mode @@ -151,7 +152,8 @@ end private - VALID_MODES = %i[html xhtml].freeze + + VALID_MODES = %i[html xhtml xml].freeze private_constant :VALID_MODES def stylesheet @@ -168,7 +170,7 @@ Inliner.new(dom_stylesheets + [stylesheet], dom).inline( keep_uninlinable_css: keep_uninlinable_css, keep_uninlinable_in: keep_uninlinable_in, - merge_media_queries: merge_media_queries, + merge_media_queries: merge_media_queries ) end @@ -182,6 +184,7 @@ format = { html: save_options::AS_HTML, xhtml: save_options::AS_XHTML, + xml: save_options::AS_XML }.fetch(mode) dom.dup.to_html( @@ -189,7 +192,7 @@ save_options::NO_DECLARATION | save_options::NO_EMPTY_TAGS | format - ), + ) ) end @@ -203,13 +206,7 @@ def callback(callable, dom) if callable.respond_to?(:call) - # Arity checking is to support the API without bumping a major version. - # TODO: Remove on next major version (v4.0) - if !callable.respond_to?(:parameters) || callable.parameters.size == 1 - callable.(dom) - else - callable.(dom, self) - end + callable.call(dom, self) end end diff -Nru ruby-roadie-4.0.0/lib/roadie/errors.rb ruby-roadie-5.0.0/lib/roadie/errors.rb --- ruby-roadie-4.0.0/lib/roadie/errors.rb 2019-10-13 19:17:45.000000000 +0000 +++ ruby-roadie-5.0.0/lib/roadie/errors.rb 2022-02-05 05:54:20.000000000 +0000 @@ -18,10 +18,10 @@ def initialize(given_path, cause = nil) @cause = cause - if cause - cause_message = " Caused by: #{cause}" + cause_message = if cause + " Caused by: #{cause}" else - cause_message = "" + "" end super "Cannot use path \"#{given_path}\" in URL generation.#{cause_message}" end @@ -43,23 +43,22 @@ # Extra message attr_reader :extra_message - # TODO: Change signature in the next major version of Roadie. - def initialize(css_name, extra_message = nil, provider = nil) + def initialize(css_name:, message: nil, provider: nil) @css_name = css_name @provider = provider - @extra_message = extra_message - super build_message(extra_message) + @extra_message = message + super build_message end protected + def error_row - "#{provider || "Unknown provider"}: #{extra_message || message}" + "#{provider || "Unknown provider"}: #{extra_message}" end private - # Redundant method argument is to keep API compatability without major version bump. - # TODO: Remove argument on version 4.0. - def build_message(extra_message = @extra_message) + + def build_message message = +%(Could not find stylesheet "#{css_name}") message << ": #{extra_message}" if extra_message message << "\nUsed provider:\n#{provider}" if provider @@ -70,13 +69,18 @@ class ProvidersFailed < CssNotFound attr_reader :errors - def initialize(css_name, provider_list, errors) + def initialize(css_name:, providers:, errors:) @errors = errors - super(css_name, "All providers failed", provider_list) + super( + css_name: css_name, + message: "All providers failed", + provider: providers + ) end private - def build_message(extra_message) + + def build_message message = +%(Could not find stylesheet "#{css_name}": #{extra_message}\nUsed providers:\n) each_error_row(errors) do |row| message << "\t" << row << "\n" diff -Nru ruby-roadie-4.0.0/lib/roadie/filesystem_provider.rb ruby-roadie-5.0.0/lib/roadie/filesystem_provider.rb --- ruby-roadie-4.0.0/lib/roadie/filesystem_provider.rb 2019-10-13 19:17:45.000000000 +0000 +++ ruby-roadie-5.0.0/lib/roadie/filesystem_provider.rb 2022-02-05 05:54:20.000000000 +0000 @@ -32,14 +32,24 @@ Stylesheet.new file_path, File.read(file_path) else basename = File.basename file_path - raise CssNotFound.new(basename, %{#{file_path} does not exist. (Original name was "#{name}")}, self) + raise CssNotFound.new( + css_name: basename, + message: %{#{file_path} does not exist. (Original name was "#{name}")}, + provider: self + ) end end - def to_s() inspect end - def inspect() "#<#{self.class} #@path>" end + def to_s + inspect + end + + def inspect + "#<#{self.class} #{@path}>" + end private + def build_file_path(name) raise InsecurePathError, name if name.include?("..") File.join(@path, name[/^([^?]+)/]) diff -Nru ruby-roadie-4.0.0/lib/roadie/inliner.rb ruby-roadie-5.0.0/lib/roadie/inliner.rb --- ruby-roadie-4.0.0/lib/roadie/inliner.rb 2019-10-13 19:17:45.000000000 +0000 +++ ruby-roadie-5.0.0/lib/roadie/inliner.rb 2022-02-05 05:54:20.000000000 +0000 @@ -1,21 +1,28 @@ # frozen_string_literal: true -require 'set' -require 'nokogiri' -require 'uri' -require 'css_parser' +require "set" +require "nokogiri" +require "uri" +require "css_parser" module Roadie # @api private # The Inliner inlines stylesheets to the elements of the DOM. # # Inlining means that {StyleBlock}s and a DOM tree are combined: - # a { color: red; } # StyleBlock - # # DOM + # + # ```css + # a { color: red; } # StyleBlock + # ``` + # ```html + # # DOM + # ``` # # becomes # - # + # ```html + # + # ``` class Inliner # @param [Array] stylesheets the stylesheets to use in the inlining # @param [Nokogiri::HTML::Document] dom @@ -47,9 +54,11 @@ end protected + attr_reader :stylesheets, :dom private + def consume_stylesheets style_map = StyleMap.new extra_blocks = [] @@ -91,12 +100,18 @@ # with having to rescue errors. # Pseudo selectors that are known to be bad are skipped automatically but # this will catch the rest. - rescue Nokogiri::XML::XPath::SyntaxError, Nokogiri::CSS::SyntaxError => error - Utils.warn "Cannot inline #{selector.inspect} from \"#{stylesheet.name}\" stylesheet. If this is valid CSS, please report a bug." + rescue Nokogiri::XML::XPath::SyntaxError, Nokogiri::CSS::SyntaxError + Utils.warn( + "Cannot inline #{selector.inspect} from \"#{stylesheet.name}\" " \ + "stylesheet. If this is valid CSS, please report a bug." + ) nil rescue => error - Utils.warn "Got error when looking for #{selector.inspect} (from \"#{stylesheet.name}\" stylesheet): #{error}" - raise unless error.message.include?('XPath') + Utils.warn( + "Got error when looking for #{selector.inspect} " \ + "(from \"#{stylesheet.name}\" stylesheet): #{error}" + ) + raise unless error.message.include?("XPath") nil end @@ -122,12 +137,12 @@ end def find_head - dom.at_xpath('html/head') + dom.at_xpath("html/head") end def create_style_element(style_blocks, parent, merge_media_queries) return unless parent - element = Nokogiri::XML::Node.new('style', parent.document) + element = Nokogiri::XML::Node.new("style", parent.document) element.content = if merge_media_queries @@ -141,17 +156,23 @@ # For performance reasons, we should group styles with the same media types within # one media query instead of creating thousands of media queries. # https://github.com/artifex404/media-queries-benchmark - # Example result: ["@media(max-width: 600px) { .col-12 { display: block; } }"] + # + # Example result: + # + # ```ruby + # ["@media(max-width: 600px) { .col-12 { display: block; } }"] + # ``` + # # @param {Array} style_blocks Style blocks that could not be inlined # @return {Array} def styles_in_shared_media_queries(style_blocks) style_blocks.group_by(&:media).map do |media_types, blocks| css_rules = blocks.map(&:to_s).join("\n") - if media_types == ['all'] + if media_types == ["all"] css_rules else - "@media #{media_types.join(', ')} {\n#{css_rules}\n}" + "@media #{media_types.join(", ")} {\n#{css_rules}\n}" end end end @@ -159,27 +180,36 @@ # Some users might prefer to not group rules within media queries because # it will result in rules getting reordered. # e.g. + # + # ```css # @media(max-width: 600px) { .col-6 { display: block; } } # @media(max-width: 400px) { .col-12 { display: inline-block; } } # @media(max-width: 600px) { .col-12 { display: block; } } + # ```` + # # will become + # + # ```css # @media(max-width: 600px) { .col-6 { display: block; } .col-12 { display: block; } } # @media(max-width: 400px) { .col-12 { display: inline-block; } } + # ``` + # + # # which would change the styling on the page # (before it would've yielded display: block; for .col-12 at max-width: 600px # and now it yields inline-block;) # # If merge_media_queries is set to false, - # we will generate #{style_blocks.size} media queries, potentially + # we will generate `style_blocks.size` media queries, potentially # causing performance issues. # @param {Array} style_blocks All style blocks # @return {Array} def styles_in_individual_media_queries(style_blocks) style_blocks.map do |css_rule| - if css_rule.media == ['all'] + if css_rule.media == ["all"] css_rule else - "@media #{css_rule.media.join(', ')} {\n#{css_rule}\n}" + "@media #{css_rule.media.join(", ")} {\n#{css_rule}\n}" end end end diff -Nru ruby-roadie-4.0.0/lib/roadie/markup_improver.rb ruby-roadie-5.0.0/lib/roadie/markup_improver.rb --- ruby-roadie-4.0.0/lib/roadie/markup_improver.rb 2019-10-13 19:17:45.000000000 +0000 +++ ruby-roadie-5.0.0/lib/roadie/markup_improver.rb 2022-02-05 05:54:20.000000000 +0000 @@ -7,13 +7,10 @@ # This class will improve the following aspects of the DOM: # * A HTML5 doctype will be added if missing, other doctypes will be left as-is. # * Basic HTML elements will be added if missing. - # * ++ - # * ++ - # * ++ - # * ++ declaring charset and content-type (text/html) - # - # @note Due to a Nokogiri bug, the HTML5 doctype cannot be added under JRuby. No doctype is outputted under JRuby. - # See https://github.com/sparklemotion/nokogiri/issues/984 + # * `` + # * `` + # * `` + # * `` declaring charset and content-type (text/html) class MarkupImprover # The original HTML must also be passed in in order to handle the doctypes # since a +Nokogiri::HTML::Document+ will always have a doctype, no matter if @@ -33,45 +30,39 @@ end protected + attr_reader :dom private + def ensure_doctype_present - return if uses_buggy_jruby? - return if @html.include?('" end + def to_s + inspect + end + + def inspect + "#<#{self.class} whitelist: #{whitelist.inspect}>" + end private + def host_set(hosts) hosts.each { |host| validate_host(host) }.to_set end @@ -63,7 +73,11 @@ if access_granted_to?(uri.host) get_response(uri) else - raise CssNotFound.new(url, "#{uri.host} is not part of whitelist!", self) + raise CssNotFound.new( + css_name: url, + message: "#{uri.host} is not part of whitelist!", + provider: self + ) end end @@ -71,7 +85,7 @@ if RUBY_VERSION >= "2.0.0" Net::HTTP.get_response(uri) else - Net::HTTP.start(uri.host, uri.port, use_ssl: (uri.scheme == 'https')) do |http| + Net::HTTP.start(uri.host, uri.port, use_ssl: (uri.scheme == "https")) do |http| http.request(Net::HTTP::Get.new(uri.request_uri)) end end @@ -92,7 +106,7 @@ def response_body(response) # Make sure we respect encoding because Net:HTTP will encode body as ASCII by default # which will break if the response is not compatible. - supplied_charset = response.type_params['charset'] + supplied_charset = response.type_params["charset"] body = response.body if supplied_charset diff -Nru ruby-roadie-4.0.0/lib/roadie/null_provider.rb ruby-roadie-5.0.0/lib/roadie/null_provider.rb --- ruby-roadie-4.0.0/lib/roadie/null_provider.rb 2019-10-13 19:17:45.000000000 +0000 +++ ruby-roadie-5.0.0/lib/roadie/null_provider.rb 2022-02-05 05:54:20.000000000 +0000 @@ -6,13 +6,26 @@ # Use it to ignore missing assets or in your tests when you need a provider # but you do not care what it contains or that it is even referenced at all. class NullProvider - def find_stylesheet(name) empty_stylesheet end - def find_stylesheet!(name) empty_stylesheet end + def find_stylesheet(name) + empty_stylesheet + end - def to_s() inspect end - def inspect() "#<#{self.class}>" end + def find_stylesheet!(name) + empty_stylesheet + end + + def to_s + inspect + end + + def inspect + "#<#{self.class}>" + end private - def empty_stylesheet() Stylesheet.new "(null)", "" end + + def empty_stylesheet + Stylesheet.new "(null)", "" + end end end diff -Nru ruby-roadie-4.0.0/lib/roadie/null_url_rewriter.rb ruby-roadie-5.0.0/lib/roadie/null_url_rewriter.rb --- ruby-roadie-4.0.0/lib/roadie/null_url_rewriter.rb 2019-10-13 19:17:45.000000000 +0000 +++ ruby-roadie-5.0.0/lib/roadie/null_url_rewriter.rb 2022-02-05 05:54:20.000000000 +0000 @@ -7,8 +7,12 @@ # Used whenever client does not pass any URL options and no URL rewriting # should take place. class NullUrlRewriter - def initialize(generator = nil) end - def transform_dom(dom) end + def initialize(generator = nil) + end + + def transform_dom(dom) + end + def transform_css(css) css end diff -Nru ruby-roadie-4.0.0/lib/roadie/path_rewriter_provider.rb ruby-roadie-5.0.0/lib/roadie/path_rewriter_provider.rb --- ruby-roadie-4.0.0/lib/roadie/path_rewriter_provider.rb 2019-10-13 19:17:45.000000000 +0000 +++ ruby-roadie-5.0.0/lib/roadie/path_rewriter_provider.rb 2022-02-05 05:54:20.000000000 +0000 @@ -59,7 +59,10 @@ if new_path provider.find_stylesheet!(new_path) else - raise CssNotFound, "Filter returned #{new_path.inspect}" + raise CssNotFound.new( + css_name: path, + message: "Filter returned #{new_path.inspect}" + ) end end end diff -Nru ruby-roadie-4.0.0/lib/roadie/provider_list.rb ruby-roadie-5.0.0/lib/roadie/provider_list.rb --- ruby-roadie-4.0.0/lib/roadie/provider_list.rb 2019-10-13 19:17:45.000000000 +0000 +++ ruby-roadie-5.0.0/lib/roadie/provider_list.rb 2022-02-05 05:54:20.000000000 +0000 @@ -1,6 +1,6 @@ # frozen_string_literal: true -require 'forwardable' +require "forwardable" module Roadie # An asset provider that just composes a list of other asset providers. @@ -25,7 +25,7 @@ # @overload wrap(provider1, provider2, ...) # @return a new {ProviderList} with all the passed providers in it. def self.wrap(*providers) - if providers.size == 1 && providers.first.class == self + if providers.size == 1 && providers.first.instance_of?(self) providers.first else new(providers.flatten) @@ -33,7 +33,9 @@ end # Returns a new empty list. - def self.empty() new([]) end + def self.empty + new([]) + end def initialize(providers) @providers = providers @@ -55,13 +57,13 @@ def find_stylesheet!(name) errors = [] @providers.each do |provider| - begin - return provider.find_stylesheet!(name) - rescue CssNotFound => error - errors << error - end + return provider.find_stylesheet!(name) + rescue CssNotFound => error + errors << error end - raise ProvidersFailed.new(name, self, errors) + raise ProvidersFailed.new( + css_name: name, providers: self, errors: errors + ) end def to_s @@ -69,12 +71,14 @@ # Indent every line one level provider.to_s.split("\n").join("\n\t") } - "ProviderList: [\n\t#{list.join(",\n\t")}\n]" + "ProviderList: [\n\t#{list.join(",\n\t")}\n]\n" end # ProviderList can be coerced to an array. This makes Array#flatten work # with it, among other things. - def to_ary() to_a end + def to_ary + to_a + end # @!method each # @see Array#each diff -Nru ruby-roadie-4.0.0/lib/roadie/rspec/asset_provider.rb ruby-roadie-5.0.0/lib/roadie/rspec/asset_provider.rb --- ruby-roadie-4.0.0/lib/roadie/rspec/asset_provider.rb 2019-10-13 19:17:45.000000000 +0000 +++ ruby-roadie-5.0.0/lib/roadie/rspec/asset_provider.rb 2022-02-05 05:54:20.000000000 +0000 @@ -45,7 +45,10 @@ it "raises Roadie::CssNotFound on invalid stylesheets" do expect { subject.find_stylesheet!(invalid_name) - }.to raise_error Roadie::CssNotFound, Regexp.new(Regexp.quote(invalid_name)) + }.to raise_error( + Roadie::CssNotFound, + Regexp.new(Regexp.quote(invalid_name)) + ) end end end diff -Nru ruby-roadie-4.0.0/lib/roadie/rspec.rb ruby-roadie-5.0.0/lib/roadie/rspec.rb --- ruby-roadie-4.0.0/lib/roadie/rspec.rb 2019-10-13 19:17:45.000000000 +0000 +++ ruby-roadie-5.0.0/lib/roadie/rspec.rb 2022-02-05 05:54:20.000000000 +0000 @@ -1,4 +1,4 @@ # frozen_string_literal: true -require 'roadie/rspec/asset_provider' -require 'roadie/rspec/cache_store' +require "roadie/rspec/asset_provider" +require "roadie/rspec/cache_store" diff -Nru ruby-roadie-4.0.0/lib/roadie/selector.rb ruby-roadie-5.0.0/lib/roadie/selector.rb --- ruby-roadie-4.0.0/lib/roadie/selector.rb 2019-10-13 19:17:45.000000000 +0000 +++ ruby-roadie-5.0.0/lib/roadie/selector.rb 2022-02-05 05:54:20.000000000 +0000 @@ -37,9 +37,17 @@ !(pseudo_element? || at_rule? || pseudo_function?) end - def to_s() selector end - def to_str() to_s end - def inspect() selector.inspect end + def to_s + selector + end + + def to_str + to_s + end + + def inspect + selector.inspect + end # {Selector}s are equal to other {Selector}s if, and only if, their string # representations are equal. @@ -52,9 +60,11 @@ end protected + attr_reader :selector private + BAD_PSEUDO_FUNCTIONS = %w[ :active :focus :hover :link :target :visited :-ms-input-placeholder :-moz-placeholder @@ -63,11 +73,11 @@ ].freeze def pseudo_element? - selector.include? '::' + selector.include? "::" end def at_rule? - selector[0, 1] == '@' + selector[0, 1] == "@" end def pseudo_function? diff -Nru ruby-roadie-4.0.0/lib/roadie/style_attribute_builder.rb ruby-roadie-5.0.0/lib/roadie/style_attribute_builder.rb --- ruby-roadie-4.0.0/lib/roadie/style_attribute_builder.rb 2019-10-13 19:17:45.000000000 +0000 +++ ruby-roadie-5.0.0/lib/roadie/style_attribute_builder.rb 2022-02-05 05:54:20.000000000 +0000 @@ -11,10 +11,11 @@ end def attribute_string - Deduplicator.apply(stable_sort(@styles).map(&:to_s)).join(';') + Deduplicator.apply(stable_sort(@styles).map(&:to_s)).join(";") end private + def stable_sort(list) # Ruby's sort is unstable for performance reasons. We need it to be # stable, e.g. to preserve order of elements that are compared equal in diff -Nru ruby-roadie-4.0.0/lib/roadie/style_block.rb ruby-roadie-5.0.0/lib/roadie/style_block.rb --- ruby-roadie-4.0.0/lib/roadie/style_block.rb 2019-10-13 19:17:45.000000000 +0000 +++ ruby-roadie-5.0.0/lib/roadie/style_block.rb 2022-02-05 05:54:20.000000000 +0000 @@ -1,6 +1,6 @@ # frozen_string_literal: true -require 'forwardable' +require "forwardable" module Roadie # @api private @@ -39,7 +39,7 @@ # @return {String} def to_s # NB - leave off redundant final semicolon - see https://www.w3.org/TR/CSS2/syndata.html#declaration - "#{selector}{#{properties.map(&:to_s).join(';')}}" + "#{selector}{#{properties.map(&:to_s).join(";")}}" end private @@ -49,7 +49,7 @@ # @media only screen and (max-width: 600px) {...} cannot be inlined # @return {Boolean} def inlinable_media? - @media.none? { |media_query| media_query.include? '(' } + @media.none? { |media_query| media_query.include? "(" } end end end diff -Nru ruby-roadie-4.0.0/lib/roadie/style_property.rb ruby-roadie-5.0.0/lib/roadie/style_property.rb --- ruby-roadie-4.0.0/lib/roadie/style_property.rb 2019-10-13 19:17:45.000000000 +0000 +++ ruby-roadie-5.0.0/lib/roadie/style_property.rb 2022-02-05 05:54:20.000000000 +0000 @@ -38,14 +38,15 @@ end def to_s - [property, value_with_important].join(':') + [property, value_with_important].join(":") end def inspect - "#{to_s} (#{specificity})" + "#{self} (#{specificity})" end private + def value_with_important if important "#{value} !important" diff -Nru ruby-roadie-4.0.0/lib/roadie/stylesheet.rb ruby-roadie-5.0.0/lib/roadie/stylesheet.rb --- ruby-roadie-4.0.0/lib/roadie/stylesheet.rb 2019-10-13 19:17:45.000000000 +0000 +++ ruby-roadie-5.0.0/lib/roadie/stylesheet.rb 2022-02-05 05:54:20.000000000 +0000 @@ -8,7 +8,7 @@ # @attr_reader [String] name the name of the stylesheet ("stylesheets/main.css", "Admin user styles", etc.). The name of the stylesheet will be visible if any errors occur. # @attr_reader [Array] blocks class Stylesheet - BOM = (+"\xEF\xBB\xBF").force_encoding('UTF-8').freeze + BOM = (+"\xEF\xBB\xBF").force_encoding("UTF-8").freeze attr_reader :name, :blocks @@ -26,6 +26,7 @@ end private + def inlinable_blocks blocks.select(&:inlinable?) end diff -Nru ruby-roadie-4.0.0/lib/roadie/url_generator.rb ruby-roadie-5.0.0/lib/roadie/url_generator.rb --- ruby-roadie-4.0.0/lib/roadie/url_generator.rb 2019-10-13 19:17:45.000000000 +0000 +++ ruby-roadie-5.0.0/lib/roadie/url_generator.rb 2022-02-05 05:54:20.000000000 +0000 @@ -1,6 +1,6 @@ # frozen_string_literal: true -require 'set' +require "set" module Roadie # @api private @@ -23,8 +23,15 @@ # @option url_options [String] :scheme URL scheme ("http" is default) # @option url_options [String] :protocol alias for :scheme def initialize(url_options) - raise ArgumentError, "No URL options were specified" unless url_options - raise ArgumentError, "No :host was specified; options are: #{url_options.inspect}" unless url_options[:host] + unless url_options + raise ArgumentError, "No URL options were specified" + end + + unless url_options[:host] + raise ArgumentError, + "No :host was specified; options were: #{url_options.inspect}" + end + validate_options url_options @url_options = url_options @@ -58,7 +65,7 @@ # @param [String] base The base which the relative path comes from # @return [String] an absolute URL def generate_url(path, base = "/") - return root_uri.to_s if path.nil? or path.empty? + return root_uri.to_s if path.nil? || path.empty? return path if path_is_anchor?(path) return add_scheme(path) if path_is_schemeless?(path) return path if Utils.path_is_absolute?(path) @@ -67,13 +74,20 @@ end protected + attr_reader :root_uri, :scheme private + def build_root_uri path = make_absolute url_options[:path] port = parse_port url_options[:port] - URI::Generic.build(scheme: scheme, host: url_options[:host], port: port, path: path) + URI::Generic.build( + scheme: scheme, + host: url_options[:host], + port: port, + path: path + ) end def add_scheme(path) @@ -98,7 +112,7 @@ # Strip :// from any scheme, if present def normalize_scheme(scheme) - return 'http' unless scheme + return "http" unless scheme scheme.to_s[/^\w+/] end @@ -119,7 +133,7 @@ end def path_is_anchor?(path) - path.start_with? '#' + path.start_with? "#" end VALID_OPTIONS = Set[:host, :port, :path, :protocol, :scheme].freeze @@ -127,7 +141,9 @@ def validate_options(options) keys = Set.new(options.keys) unless keys.subset? VALID_OPTIONS - raise ArgumentError, "Passed invalid options: #{(keys - VALID_OPTIONS).to_a}, valid options are: #{VALID_OPTIONS.to_a}" + raise ArgumentError, + "Passed invalid options: #{(keys - VALID_OPTIONS).to_a}, " \ + "valid options are: #{VALID_OPTIONS.to_a}" end end end diff -Nru ruby-roadie-4.0.0/lib/roadie/url_rewriter.rb ruby-roadie-5.0.0/lib/roadie/url_rewriter.rb --- ruby-roadie-4.0.0/lib/roadie/url_rewriter.rb 2019-10-13 19:17:45.000000000 +0000 +++ ruby-roadie-5.0.0/lib/roadie/url_rewriter.rb 2022-02-05 05:54:20.000000000 +0000 @@ -25,9 +25,9 @@ dom.css( "a[href]:not([data-roadie-ignore]), " \ "img[src]:not([data-roadie-ignore]), " \ - "*[style]:not([data-roadie-ignore])", + "*[style]:not([data-roadie-ignore])" ).each do |element| - transform_element_style element if element.has_attribute?('style') + transform_element_style element if element.has_attribute?("style") transform_element element end nil @@ -49,7 +49,10 @@ end private - def generate_url(*args) @generator.generate_url(*args) end + + def generate_url(*args) + @generator.generate_url(*args) + end # Regexp matching all the url() declarations in CSS # diff -Nru ruby-roadie-4.0.0/lib/roadie/utils.rb ruby-roadie-5.0.0/lib/roadie/utils.rb --- ruby-roadie-4.0.0/lib/roadie/utils.rb 2019-10-13 19:17:45.000000000 +0000 +++ ruby-roadie-5.0.0/lib/roadie/utils.rb 2022-02-05 05:54:20.000000000 +0000 @@ -10,7 +10,7 @@ # # URLs that start with double slashes (//css/app.css) are also absolute # in modern browsers, but most email clients do not understand them. - return true if path =~ %r{^(\w+:|//)} + return true if %r{^(\w+:|//)}.match?(path) begin !URI.parse(path).relative? diff -Nru ruby-roadie-4.0.0/lib/roadie/version.rb ruby-roadie-5.0.0/lib/roadie/version.rb --- ruby-roadie-4.0.0/lib/roadie/version.rb 2019-10-13 19:17:45.000000000 +0000 +++ ruby-roadie-5.0.0/lib/roadie/version.rb 2022-02-05 05:54:20.000000000 +0000 @@ -1,6 +1,5 @@ # frozen_string_literal: true - module Roadie - VERSION = "4.0.0" + VERSION = "5.0.0" end diff -Nru ruby-roadie-4.0.0/lib/roadie.rb ruby-roadie-5.0.0/lib/roadie.rb --- ruby-roadie-4.0.0/lib/roadie.rb 2019-10-13 19:17:45.000000000 +0000 +++ ruby-roadie-5.0.0/lib/roadie.rb 2022-02-05 05:54:20.000000000 +0000 @@ -3,30 +3,30 @@ module Roadie end -require 'roadie/version' -require 'roadie/errors' +require "roadie/version" +require "roadie/errors" -require 'roadie/utils' -require 'roadie/deduplicator' +require "roadie/utils" +require "roadie/deduplicator" -require 'roadie/stylesheet' -require 'roadie/selector' -require 'roadie/style_property' -require 'roadie/style_attribute_builder' -require 'roadie/style_block' +require "roadie/stylesheet" +require "roadie/selector" +require "roadie/style_property" +require "roadie/style_attribute_builder" +require "roadie/style_block" -require 'roadie/asset_provider' -require 'roadie/provider_list' -require 'roadie/filesystem_provider' -require 'roadie/null_provider' -require 'roadie/net_http_provider' -require 'roadie/cached_provider' -require 'roadie/path_rewriter_provider' +require "roadie/asset_provider" +require "roadie/provider_list" +require "roadie/filesystem_provider" +require "roadie/null_provider" +require "roadie/net_http_provider" +require "roadie/cached_provider" +require "roadie/path_rewriter_provider" -require 'roadie/asset_scanner' -require 'roadie/markup_improver' -require 'roadie/url_generator' -require 'roadie/url_rewriter' -require 'roadie/null_url_rewriter' -require 'roadie/inliner' -require 'roadie/document' +require "roadie/asset_scanner" +require "roadie/markup_improver" +require "roadie/url_generator" +require "roadie/url_rewriter" +require "roadie/null_url_rewriter" +require "roadie/inliner" +require "roadie/document" diff -Nru ruby-roadie-4.0.0/Rakefile ruby-roadie-5.0.0/Rakefile --- ruby-roadie-4.0.0/Rakefile 2019-10-13 19:17:45.000000000 +0000 +++ ruby-roadie-5.0.0/Rakefile 2022-02-05 05:54:20.000000000 +0000 @@ -1,6 +1,6 @@ # frozen_string_literal: true -require 'bundler/setup' +require "bundler/setup" Bundler::GemHelper.install_tasks @@ -10,4 +10,4 @@ end desc "Default: Run specs" -task :default => :spec +task default: :spec diff -Nru ruby-roadie-4.0.0/README.md ruby-roadie-5.0.0/README.md --- ruby-roadie-4.0.0/README.md 2019-10-13 19:17:45.000000000 +0000 +++ ruby-roadie-5.0.0/README.md 2022-02-05 05:54:20.000000000 +0000 @@ -1,7 +1,6 @@ Roadie ====== -[![Build history and status](https://travis-ci.org/Mange/roadie.svg?branch=master)](http://travis-ci.org/#!/Mange/roadie) [![Code Climate](https://codeclimate.com/github/Mange/roadie.png)](https://codeclimate.com/github/Mange/roadie) [![Code coverage status](https://codecov.io/github/Mange/roadie/coverage.svg?branch=master)](https://codecov.io/github/Mange/roadie?branch=master) [![Gem](https://img.shields.io/gem/v/roadie.svg)](https://rubygems.org/gems/roadie) @@ -333,7 +332,10 @@ end def find_stylesheet!(name) - find_stylesheet(name) or raise Roadie::CssNotFound.new(name, "does not match a user stylesheet", self) + find_stylesheet(name) or + raise Roadie::CssNotFound.new( + css_name: name, message: "does not match a user stylesheet", provider: self + ) end # Instead of implementing #find_stylesheet!, you could also: @@ -444,18 +446,14 @@ Build Status ------------ -Tested with [Travis CI](http://travis-ci.org) using: +Tested with Github CI using: -* MRI 2.1 -* MRI 2.2 -* MRI 2.3 -* MRI 2.4 -* JRuby (latest) -* Rubinius (failures on Rubinius will not fail the build due to a long history of instability in `rbx`) +* MRI 2.6 +* MRI 2.7 +* MRI 3.0 +* MRI 3.1 -[(Build status)](http://travis-ci.org/#!/Mange/roadie) - -Let me know if you want any other VM supported officially. +Let me know if you want any other runtime supported officially. ### Versioning ### @@ -565,7 +563,7 @@ (The MIT License) -Copyright (c) 2009-2018 Magnus Bergmark, Jim Neath / Purify, and contributors. +Copyright (c) 2009-2022 Magnus Bergmark, Jim Neath / Purify, and contributors. * [Magnus Bergmark](https://github.com/Mange) diff -Nru ruby-roadie-4.0.0/roadie.gemspec ruby-roadie-5.0.0/roadie.gemspec --- ruby-roadie-4.0.0/roadie.gemspec 2019-10-13 19:17:45.000000000 +0000 +++ ruby-roadie-5.0.0/roadie.gemspec 2022-02-05 05:54:20.000000000 +0000 @@ -1,35 +1,33 @@ -# frozen_string_literal: true # roadie.gemspec -# -*- encoding: utf-8 -*- +# frozen_string_literal: true $:.push File.expand_path("../lib", __FILE__) -require 'roadie/version' +require "roadie/version" Gem::Specification.new do |s| - s.name = 'roadie' - s.version = Roadie::VERSION - s.platform = Gem::Platform::RUBY - s.authors = ['Magnus Bergmark'] - s.email = ['magnus.bergmark@gmail.com'] - s.homepage = 'http://github.com/Mange/roadie' - s.summary = %q{Making HTML emails comfortable for the Ruby rockstars} - s.description = %q{Roadie tries to make sending HTML emails a little less painful by inlining stylesheets and rewriting relative URLs for you.} - s.license = "MIT" - - s.required_ruby_version = ">= 2.4" - - s.add_dependency 'nokogiri', '~> 1.8' - s.add_dependency 'css_parser', '~> 1.4' - - s.add_development_dependency 'rspec', '~> 3.0' - s.add_development_dependency 'rspec-collection_matchers', '~> 1.0' - s.add_development_dependency 'rubocop', '0.75.0' - s.add_development_dependency 'webmock', '~> 3.0' + s.name = "roadie" + s.version = Roadie::VERSION + s.platform = Gem::Platform::RUBY + s.authors = ["Magnus Bergmark"] + s.email = ["magnus.bergmark@gmail.com"] + s.homepage = "http://github.com/Mange/roadie" + s.summary = "Making HTML emails comfortable for the Ruby rockstars" + s.description = "Roadie tries to make sending HTML emails a little less painful by inlining stylesheets and rewriting relative URLs for you." + s.license = "MIT" + + s.required_ruby_version = ">= 2.6" + + s.add_dependency "nokogiri", "~> 1.8" + s.add_dependency "css_parser", "~> 1.4" + + s.add_development_dependency "rake" + s.add_development_dependency "rspec", "~> 3.0" + s.add_development_dependency "rspec-collection_matchers", "~> 1.0" + s.add_development_dependency "webmock", "~> 3.0" s.extra_rdoc_files = %w[README.md Changelog.md] s.require_paths = %w[lib] - s.files = `git ls-files`.split("\n") - s.test_files = `git ls-files -- spec/*`.split("\n") + s.files = `git ls-files`.split("\n") + s.test_files = `git ls-files -- spec/*`.split("\n") end - diff -Nru ruby-roadie-4.0.0/.solargraph.yml ruby-roadie-5.0.0/.solargraph.yml --- ruby-roadie-4.0.0/.solargraph.yml 1970-01-01 00:00:00.000000000 +0000 +++ ruby-roadie-5.0.0/.solargraph.yml 2022-02-05 05:54:20.000000000 +0000 @@ -0,0 +1,16 @@ +--- +include: + - "**/*.rb" +exclude: + - spec/**/* + - test/**/* + - vendor/**/* + - ".bundle/**/*" +require: [] +domains: [] +plugins: + - solargraph-standardrb +reporters: + - standardrb +require_paths: [] +max_files: 5000 diff -Nru ruby-roadie-4.0.0/spec/hash_as_cache_store_spec.rb ruby-roadie-5.0.0/spec/hash_as_cache_store_spec.rb --- ruby-roadie-4.0.0/spec/hash_as_cache_store_spec.rb 2019-10-13 19:17:45.000000000 +0000 +++ ruby-roadie-5.0.0/spec/hash_as_cache_store_spec.rb 2022-02-05 05:54:20.000000000 +0000 @@ -4,6 +4,6 @@ require "roadie/rspec" describe "Using Hash as a cache store" do - subject(:hash) { Hash.new } + subject(:hash) { {} } it_behaves_like "roadie cache store" end diff -Nru ruby-roadie-4.0.0/spec/integration_spec.rb ruby-roadie-5.0.0/spec/integration_spec.rb --- ruby-roadie-4.0.0/spec/integration_spec.rb 2019-10-13 19:17:45.000000000 +0000 +++ ruby-roadie-5.0.0/spec/integration_spec.rb 2022-02-05 05:54:20.000000000 +0000 @@ -1,6 +1,6 @@ # frozen_string_literal: true -require 'spec_helper' +require "spec_helper" describe "Roadie functionality" do describe "on full documents" do @@ -13,14 +13,7 @@ document = Roadie::Document.new(html) result = document.transform - unless defined?(JRuby) - # JRuby has a bug that makes DTD manipulation impossible - # See Nokogiri bugs #984 and #985 - # https://github.com/sparklemotion/nokogiri/issues/984 - # https://github.com/sparklemotion/nokogiri/issues/985 - expect(result).to include("") - end - + expect(result).to include("") expect(result).to include("") expect(result).to include("") expect(result).to include("") @@ -47,8 +40,8 @@ CSS result = parse_html document.transform - expect(result).to have_styling('text-align' => 'center').at_selector('h1') - expect(result).to have_styling('color' => 'red').at_selector('p > em') + expect(result).to have_styling("text-align" => "center").at_selector("h1") + expect(result).to have_styling("color" => "red").at_selector("p > em") end it "stores styles that cannot be inlined in the " do @@ -112,7 +105,7 @@ HTML result = parse_html document.transform - expect(result).to have_styling('font-size' => '200%').at_selector('p > em') + expect(result).to have_styling("font-size" => "200%").at_selector("p > em") end it "crashes when stylesheets cannot be found, unless using NullProvider" do @@ -127,7 +120,9 @@ HTML - expect { document.transform }.to raise_error(Roadie::CssNotFound, /does_not_exist\.css/) + expect { + document.transform + }.to raise_error(Roadie::CssNotFound, /does_not_exist\.css/) document.asset_providers << Roadie::NullProvider.new expect { document.transform }.to_not raise_error @@ -151,8 +146,8 @@ document.external_asset_providers = [] result = parse_html document.transform - expect(result).to have_selector('head > link') - expect(result).to have_styling([]).at_selector('p > em') + expect(result).to have_selector("head > link") + expect(result).to have_styling([]).at_selector("p > em") end it "inlines external css if configured" do @@ -175,8 +170,8 @@ ) result = parse_html document.transform - expect(result).to have_styling('font-size' => '200%').at_selector('p > em') - expect(result).to_not have_selector('head > link') + expect(result).to have_styling("font-size" => "200%").at_selector("p > em") + expect(result).to_not have_selector("head > link") end it "does not inline the same properties several times" do @@ -197,8 +192,8 @@ result = parse_html document.transform expect(result).to have_styling([ - ['color', 'red'] - ]).at_selector('p') + ["color", "red"] + ]).at_selector("p") end it "makes URLs absolute" do @@ -232,7 +227,7 @@ ).at_selector("body") expect(result).to have_styling( - "background" => 'url(https://myapp.com/rails/app/assets/link-abcdef1234567890.png)' + "background" => "url(https://myapp.com/rails/app/assets/link-abcdef1234567890.png)" ).at_selector("a") end @@ -324,10 +319,10 @@ ) result = parse_html document.transform - expect(result).to have_styling('color' => 'green').at_selector('.colorful') + expect(result).to have_styling("color" => "green").at_selector(".colorful") end - it 'puts non-inlineable media queries in the head' do + it "puts non-inlineable media queries in the head" do document = Roadie::Document.new <<-HTML @@ -353,18 +348,18 @@ result = parse_html document.transform - styles = result.at_css('html > head > style').text + styles = result.at_css("html > head > style").text expected_result = <<-CSS @media screen and (max-width 800px) { .colorful{color:blue} } @media screen, print and (max-width 800px) { .colorful{color:blue} } CSS - expected_result = expected_result.gsub(/[\s]+/, ' ').strip - actual_result = styles.gsub(/[\s]+/, ' ').strip + expected_result = expected_result.gsub(/\s+/, " ").strip + actual_result = styles.gsub(/\s+/, " ").strip expect(actual_result).to eq(expected_result) end - it 'groups non-inlineable media queries in the head by default' do + it "groups non-inlineable media queries in the head by default" do document = Roadie::Document.new <<-HTML @@ -390,20 +385,20 @@ result = parse_html document.transform - styles = result.at_css('html > head > style').text + styles = result.at_css("html > head > style").text expected_result = <<-CSS @media screen and (max-width 600px) { .colorful{color:red;width:600px} .colorful-2{color:red;width:600px} } CSS - expected_result = expected_result.gsub(/[\s]+/, ' ').strip - actual_result = styles.gsub(/[\s]+/, ' ').strip + expected_result = expected_result.gsub(/\s+/, " ").strip + actual_result = styles.gsub(/\s+/, " ").strip expect(actual_result).to eq(expected_result) end - describe 'if merge_media_queries is set to false' do + describe "if merge_media_queries is set to false" do it "doesn't group non-inlineable media queries in the head" do document = Roadie::Document.new <<-HTML @@ -432,7 +427,7 @@ result = parse_html document.transform - styles = result.at_css('html > head > style').text + styles = result.at_css("html > head > style").text expected_result = <<-CSS @media screen and (max-width 600px) { .colorful{color:red;width:600px} @@ -441,8 +436,8 @@ .colorful-2{color:red;width:600px} } CSS - expected_result = expected_result.gsub(/[\s]+/, ' ').strip - actual_result = styles.gsub(/[\s]+/, ' ').strip + expected_result = expected_result.gsub(/\s+/, " ").strip + actual_result = styles.gsub(/\s+/, " ").strip expect(actual_result).to eq(expected_result) end @@ -474,8 +469,8 @@ CSS result = parse_html document.transform_partial - expect(result).to have_styling('text-align' => 'center').at_selector('h1') - expect(result).to have_styling('color' => 'red').at_selector('p > em') + expect(result).to have_styling("text-align" => "center").at_selector("h1") + expect(result).to have_styling("color" => "red").at_selector("p > em") end it "stores styles that cannot be inlined in a new