roadie 3.5.1 → 4.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (69) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +5 -0
  3. data/.travis.yml +1 -3
  4. data/Changelog.md +9 -3
  5. data/Gemfile +2 -0
  6. data/README.md +1 -1
  7. data/Rakefile +2 -1
  8. data/lib/roadie.rb +2 -0
  9. data/lib/roadie/asset_provider.rb +2 -0
  10. data/lib/roadie/asset_scanner.rb +2 -0
  11. data/lib/roadie/cached_provider.rb +2 -0
  12. data/lib/roadie/deduplicator.rb +2 -0
  13. data/lib/roadie/document.rb +3 -1
  14. data/lib/roadie/errors.rb +4 -2
  15. data/lib/roadie/filesystem_provider.rb +2 -0
  16. data/lib/roadie/inliner.rb +2 -0
  17. data/lib/roadie/markup_improver.rb +2 -0
  18. data/lib/roadie/net_http_provider.rb +2 -1
  19. data/lib/roadie/null_provider.rb +2 -0
  20. data/lib/roadie/null_url_rewriter.rb +5 -1
  21. data/lib/roadie/path_rewriter_provider.rb +2 -0
  22. data/lib/roadie/provider_list.rb +2 -0
  23. data/lib/roadie/rspec.rb +2 -0
  24. data/lib/roadie/rspec/asset_provider.rb +2 -0
  25. data/lib/roadie/rspec/cache_store.rb +2 -0
  26. data/lib/roadie/selector.rb +2 -0
  27. data/lib/roadie/style_attribute_builder.rb +2 -0
  28. data/lib/roadie/style_block.rb +2 -0
  29. data/lib/roadie/style_property.rb +2 -0
  30. data/lib/roadie/stylesheet.rb +3 -1
  31. data/lib/roadie/url_generator.rb +2 -0
  32. data/lib/roadie/url_rewriter.rb +6 -6
  33. data/lib/roadie/utils.rb +2 -0
  34. data/lib/roadie/version.rb +2 -1
  35. data/roadie.gemspec +3 -1
  36. data/spec/hash_as_cache_store_spec.rb +2 -0
  37. data/spec/integration_spec.rb +2 -0
  38. data/spec/lib/roadie/asset_scanner_spec.rb +2 -1
  39. data/spec/lib/roadie/cached_provider_spec.rb +2 -0
  40. data/spec/lib/roadie/css_not_found_spec.rb +2 -0
  41. data/spec/lib/roadie/deduplicator_spec.rb +2 -0
  42. data/spec/lib/roadie/document_spec.rb +2 -1
  43. data/spec/lib/roadie/filesystem_provider_spec.rb +2 -1
  44. data/spec/lib/roadie/inliner_spec.rb +2 -1
  45. data/spec/lib/roadie/markup_improver_spec.rb +2 -1
  46. data/spec/lib/roadie/net_http_provider_spec.rb +9 -7
  47. data/spec/lib/roadie/null_provider_spec.rb +2 -1
  48. data/spec/lib/roadie/null_url_rewriter_spec.rb +2 -1
  49. data/spec/lib/roadie/path_rewriter_provider_spec.rb +2 -0
  50. data/spec/lib/roadie/provider_list_spec.rb +2 -1
  51. data/spec/lib/roadie/selector_spec.rb +2 -1
  52. data/spec/lib/roadie/style_attribute_builder_spec.rb +2 -0
  53. data/spec/lib/roadie/style_block_spec.rb +2 -1
  54. data/spec/lib/roadie/style_property_spec.rb +2 -0
  55. data/spec/lib/roadie/stylesheet_spec.rb +2 -1
  56. data/spec/lib/roadie/test_provider_spec.rb +2 -0
  57. data/spec/lib/roadie/url_generator_spec.rb +2 -1
  58. data/spec/lib/roadie/url_rewriter_spec.rb +4 -3
  59. data/spec/lib/roadie/utils_spec.rb +2 -0
  60. data/spec/shared_examples/asset_provider.rb +2 -0
  61. data/spec/shared_examples/url_rewriter.rb +5 -3
  62. data/spec/spec_helper.rb +2 -0
  63. data/spec/support/have_attribute_matcher.rb +2 -0
  64. data/spec/support/have_node_matcher.rb +2 -0
  65. data/spec/support/have_selector_matcher.rb +2 -0
  66. data/spec/support/have_styling_matcher.rb +2 -0
  67. data/spec/support/have_xpath_matcher.rb +2 -0
  68. data/spec/support/test_provider.rb +2 -0
  69. metadata +18 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 19c2bb2df5f06249e20336bee272088f2224749fcb20741c411647428221e20e
4
- data.tar.gz: cd7e290f724bf71fd8b56d8f013ebc2dd246b5594fc730d5899639d1dbdada38
3
+ metadata.gz: 17f87e779aab695788d0361a733cd56f81b74d4d89bc9c82eb1949f9bdec1796
4
+ data.tar.gz: 608a6d3a482a827123818c45acaf9709f4dd214328809e43d327fd860ce0d455
5
5
  SHA512:
6
- metadata.gz: 8767e97ed3592ff69e969d646537775b9a0c571d62f54bb02555e102f5acedf5813435d0f4b1b58b52adb4187608cfe33020a7019c98aebd8ad5077ef3e3b4e8
7
- data.tar.gz: 220fdd872e42acea4e4aebe9dc04f34d3a9e996254d5135af4663d98534362ade3b0d1c21368afd6c046282814b4f0d061f8e20f14451d295fb511f0c4888366
6
+ metadata.gz: d512b9c8568ec0514161689fa8cb678d3c975b11ec9b6d9b7b1f31c09ad166788c88e195161b7b101256d229de36dec6abcc77f420dfddd6b663ce82233cdfcd
7
+ data.tar.gz: c94e1245d485c0824057868010d849b24b37faf6fd69ab59989a3f6bae0bf02284255550fa67fef79c0355c95a149d1ad34ec9e22b0ecc8b8c1eec6888ae0545
@@ -0,0 +1,5 @@
1
+ AllCops:
2
+ DisabledByDefault: true
3
+
4
+ Style/FrozenStringLiteralComment:
5
+ Enabled: true
@@ -1,11 +1,9 @@
1
1
  sudo: false
2
2
  language: ruby
3
3
  rvm:
4
- - 2.1
5
- - 2.2
6
- - 2.3
7
4
  - 2.4
8
5
  - 2.5
6
+ - 2.6
9
7
  - jruby
10
8
  - rbx
11
9
  before_install:
@@ -1,10 +1,16 @@
1
1
  ### dev
2
2
 
3
- ### dev
3
+ [full changelog](https://github.com/Mange/roadie/compare/v4.0.0...master)
4
+
5
+ Nothing yet.
6
+
7
+ ### 4.0.0
4
8
 
5
- [full changelog](https://github.com/Mange/roadie/compare/v3.5.1...master)
9
+ [full changelog](https://github.com/Mange/roadie/compare/v3.5.1...v4.0.0)
6
10
 
7
- * Nothing yet.
11
+ * Drop support for Ruby 2.1, 2.2, and 2.3 and
12
+ add support for frozen string literals and Ruby 2.6 - [adamkiczula (Adam
13
+ Kiczula)](https://github.com/adamkiczula) (#164)
8
14
 
9
15
  ### 3.5.1
10
16
 
data/Gemfile CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  source 'https://rubygems.org'
2
4
  gemspec
3
5
 
data/README.md CHANGED
@@ -55,7 +55,7 @@ Install & Usage
55
55
  [Add this gem to your Gemfile as recommended by Rubygems](http://rubygems.org/gems/roadie) and run `bundle install`.
56
56
 
57
57
  ```ruby
58
- gem 'roadie', '~> 3.5'
58
+ gem 'roadie', '~> 4.0'
59
59
  ```
60
60
 
61
61
  You can then create a new instance of a Roadie document:
data/Rakefile CHANGED
@@ -1,4 +1,5 @@
1
- # encoding: utf-8
1
+ # frozen_string_literal: true
2
+
2
3
  require 'bundler/setup'
3
4
 
4
5
  Bundler::GemHelper.install_tasks
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Roadie
2
4
  end
3
5
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Roadie
2
4
  # This module can be included in your own code to help you implement the
3
5
  # standard behavior for asset providers.
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Roadie
2
4
  # @api private
3
5
  #
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Roadie
2
4
  # @api public
3
5
  # The {CachedProvider} wraps another provider (or {ProviderList}) and caches
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Roadie
2
4
  class Deduplicator
3
5
  def self.apply(input)
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Roadie
2
4
  # The main entry point for Roadie. A document represents a working unit and
3
5
  # is built with the input HTML and the configuration options you need.
@@ -50,7 +52,7 @@ module Roadie
50
52
  @html = html
51
53
  @asset_providers = ProviderList.wrap(FilesystemProvider.new)
52
54
  @external_asset_providers = ProviderList.empty
53
- @css = ""
55
+ @css = +""
54
56
  @mode = :html
55
57
  end
56
58
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Roadie
2
4
  # Base class for all Roadie errors. Rescue this if you want to catch errors
3
5
  # from Roadie.
@@ -58,7 +60,7 @@ module Roadie
58
60
  # Redundant method argument is to keep API compatability without major version bump.
59
61
  # TODO: Remove argument on version 4.0.
60
62
  def build_message(extra_message = @extra_message)
61
- message = %(Could not find stylesheet "#{css_name}")
63
+ message = +%(Could not find stylesheet "#{css_name}")
62
64
  message << ": #{extra_message}" if extra_message
63
65
  message << "\nUsed provider:\n#{provider}" if provider
64
66
  message
@@ -75,7 +77,7 @@ module Roadie
75
77
 
76
78
  private
77
79
  def build_message(extra_message)
78
- message = %(Could not find stylesheet "#{css_name}": #{extra_message}\nUsed providers:\n)
80
+ message = +%(Could not find stylesheet "#{css_name}": #{extra_message}\nUsed providers:\n)
79
81
  each_error_row(errors) do |row|
80
82
  message << "\t" << row << "\n"
81
83
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Roadie
2
4
  # Asset provider that looks for files on your local filesystem.
3
5
  #
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'set'
2
4
  require 'nokogiri'
3
5
  require 'uri'
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Roadie
2
4
  # @api private
3
5
  # Class that improves the markup of a HTML DOM tree
@@ -1,4 +1,5 @@
1
- # encoding: UTF-8
1
+ # frozen_string_literal: true
2
+
2
3
  require 'set'
3
4
  require 'uri'
4
5
  require 'net/http'
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Roadie
2
4
  # An asset provider that returns empty stylesheets for any name.
3
5
  #
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Roadie
2
4
  # @api private
3
5
  # Null Object for the URL rewriter role.
@@ -7,6 +9,8 @@ module Roadie
7
9
  class NullUrlRewriter
8
10
  def initialize(generator = nil) end
9
11
  def transform_dom(dom) end
10
- def transform_css(css) end
12
+ def transform_css(css)
13
+ css
14
+ end
11
15
  end
12
16
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Roadie
2
4
  # @api public
3
5
  # This provider acts a bit like a pipeline in normal UNIX parlour by enabling
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'forwardable'
2
4
 
3
5
  module Roadie
@@ -1,2 +1,4 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'roadie/rspec/asset_provider'
2
4
  require 'roadie/rspec/cache_store'
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  shared_examples_for "roadie asset provider" do |options|
2
4
  valid_name = options[:valid_name] or raise "You must provide a :valid_name option to the shared examples"
3
5
  invalid_name = options[:invalid_name] or raise "You must provide an :invalid_name option to the shared examples"
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  shared_examples_for "roadie cache store" do
2
4
  it "allows storing Stylesheets" do
3
5
  stylesheet = Roadie::Stylesheet.new("foo.css", "body { color: green; }")
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Roadie
2
4
  # @api private
3
5
  #
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Roadie
2
4
  class StyleAttributeBuilder
3
5
  def initialize
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'forwardable'
2
4
 
3
5
  module Roadie
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Roadie
2
4
  # @api private
3
5
  # Domain object for a CSS property such as "color: red !important".
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Roadie
2
4
  # Domain object that represents a stylesheet (from disc, perhaps).
3
5
  #
@@ -6,7 +8,7 @@ module Roadie
6
8
  # @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.
7
9
  # @attr_reader [Array<StyleBlock>] blocks
8
10
  class Stylesheet
9
- BOM = "\xEF\xBB\xBF".force_encoding('UTF-8').freeze
11
+ BOM = (+"\xEF\xBB\xBF").force_encoding('UTF-8').freeze
10
12
 
11
13
  attr_reader :name, :blocks
12
14
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'set'
2
4
 
3
5
  module Roadie
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Roadie
2
4
  # @api private
3
5
  #
@@ -35,13 +37,12 @@ module Roadie
35
37
  #
36
38
  # This will make all URLs inside url() absolute.
37
39
  #
38
- # [nil] is returned so no one can misunderstand that this method mutates
39
- # the passed string.
40
+ # Copy of CSS that is mutated is returned, passed string is not mutated.
40
41
  #
41
42
  # @param [String] css the css to mutate
42
- # @return [nil] css is mutated
43
+ # @return [String] copy of css that is mutated
43
44
  def transform_css(css)
44
- css.gsub!(CSS_URL_REGEXP) do
45
+ css.gsub(CSS_URL_REGEXP) do
45
46
  matches = Regexp.last_match
46
47
  "url(#{matches[:quote]}#{generate_url(matches[:url])}#{matches[:quote]})"
47
48
  end
@@ -81,8 +82,7 @@ module Roadie
81
82
  # We need to use a setter for Nokogiri to detect the string mutation.
82
83
  # If nokogiri used "dumber" data structures, this would all be redundant.
83
84
  css = element["style"]
84
- transform_css css
85
- element["style"] = css
85
+ element["style"] = transform_css(css)
86
86
  end
87
87
  end
88
88
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Roadie
2
4
  module Utils
3
5
  # @api private
@@ -1,5 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+
3
4
  module Roadie
4
- VERSION = "3.5.1"
5
+ VERSION = "4.0.0"
5
6
  end
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  # roadie.gemspec
2
3
  # -*- encoding: utf-8 -*-
3
4
 
@@ -15,13 +16,14 @@ Gem::Specification.new do |s|
15
16
  s.description = %q{Roadie tries to make sending HTML emails a little less painful by inlining stylesheets and rewriting relative URLs for you.}
16
17
  s.license = "MIT"
17
18
 
18
- s.required_ruby_version = ">= 1.9"
19
+ s.required_ruby_version = ">= 2.4"
19
20
 
20
21
  s.add_dependency 'nokogiri', '~> 1.8'
21
22
  s.add_dependency 'css_parser', '~> 1.4'
22
23
 
23
24
  s.add_development_dependency 'rspec', '~> 3.0'
24
25
  s.add_development_dependency 'rspec-collection_matchers', '~> 1.0'
26
+ s.add_development_dependency 'rubocop', '0.75.0'
25
27
  s.add_development_dependency 'webmock', '~> 3.0'
26
28
 
27
29
  s.extra_rdoc_files = %w[README.md Changelog.md]
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "spec_helper"
2
4
  require "roadie/rspec"
3
5
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe "Roadie functionality" do
@@ -1,4 +1,5 @@
1
- # encoding: UTF-8
1
+ # frozen_string_literal: true
2
+
2
3
  require 'spec_helper'
3
4
 
4
5
  module Roadie
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
  require 'roadie/rspec'
3
5
  require 'shared_examples/asset_provider'
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  module Roadie
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "spec_helper"
2
4
 
3
5
  module Roadie
@@ -1,4 +1,5 @@
1
- # encoding: UTF-8
1
+ # frozen_string_literal: true
2
+
2
3
  require 'spec_helper'
3
4
 
4
5
  module Roadie
@@ -1,4 +1,5 @@
1
- # encoding: UTF-8
1
+ # frozen_string_literal: true
2
+
2
3
  require 'spec_helper'
3
4
  require 'roadie/rspec'
4
5
  require 'shared_examples/asset_provider'
@@ -1,4 +1,5 @@
1
- # encoding: UTF-8
1
+ # frozen_string_literal: true
2
+
2
3
  require 'spec_helper'
3
4
 
4
5
  module Roadie
@@ -1,4 +1,5 @@
1
- # encoding: UTF-8
1
+ # frozen_string_literal: true
2
+
2
3
  require 'spec_helper'
3
4
 
4
5
  module Roadie
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
  require 'roadie/rspec'
3
5
  require 'shared_examples/asset_provider'
@@ -18,13 +20,13 @@ module Roadie
18
20
  invalid_name: "http://example.com/red.css"
19
21
  ) do
20
22
  before do
21
- stub_request(:get, "http://example.com/green.css").and_return(body: "p { color: green; }")
23
+ stub_request(:get, "http://example.com/green.css").and_return(body: +"p { color: green; }")
22
24
  stub_request(:get, "http://example.com/red.css").and_return(status: 404, body: "Not here!")
23
25
  end
24
26
  end
25
27
 
26
28
  it "can download over HTTPS" do
27
- stub_request(:get, "https://example.com/style.css").and_return(body: "p { color: green; }")
29
+ stub_request(:get, "https://example.com/style.css").and_return(body: +"p { color: green; }")
28
30
  expect {
29
31
  NetHttpProvider.new.find_stylesheet!("https://example.com/style.css")
30
32
  }.to_not raise_error
@@ -37,7 +39,7 @@ module Roadie
37
39
  # asset inlining, but the scheme-less URL implies that there should exist
38
40
  # both a HTTP and a HTTPS endpoint. Let's take the secure one in that
39
41
  # case!
40
- stub_request(:get, "https://example.com/style.css").and_return(body: "p { color: green; }")
42
+ stub_request(:get, "https://example.com/style.css").and_return(body: +"p { color: green; }")
41
43
  expect {
42
44
  NetHttpProvider.new.find_stylesheet!("//example.com/style.css")
43
45
  }.to_not raise_error
@@ -48,7 +50,7 @@ module Roadie
48
50
  # (US-ASCII). The headers will indicate what charset the client should
49
51
  # use when trying to make sense of these bytes.
50
52
  stub_request(:get, url).and_return(
51
- body: %(p::before { content: "l\xF6ve" }).force_encoding("US-ASCII"),
53
+ body: (+%(p::before { content: "l\xF6ve" })).force_encoding("US-ASCII"),
52
54
  headers: {"Content-Type" => "text/css;charset=ISO-8859-1"},
53
55
  )
54
56
 
@@ -64,7 +66,7 @@ module Roadie
64
66
 
65
67
  it "assumes UTF-8 encoding if server headers do not specify a charset" do
66
68
  stub_request(:get, url).and_return(
67
- body: %(p::before { content: "Åh nej" }).force_encoding("US-ASCII"),
69
+ body: (+%(p::before { content: "Åh nej" })).force_encoding("US-ASCII"),
68
70
  headers: {"Content-Type" => "text/css"},
69
71
  )
70
72
 
@@ -119,8 +121,8 @@ module Roadie
119
121
  whitelisted_url = "http://whitelisted.example.com/style.css"
120
122
  other_url = "http://www.example.com/style.css"
121
123
 
122
- whitelisted_request = stub_request(:get, whitelisted_url).and_return(body: "x")
123
- other_request = stub_request(:get, other_url).and_return(body: "x")
124
+ whitelisted_request = stub_request(:get, whitelisted_url).and_return(body: +"x")
125
+ other_request = stub_request(:get, other_url).and_return(body: +"x")
124
126
 
125
127
  expect(provider.find_stylesheet(other_url)).to be_nil
126
128
  expect {
@@ -1,4 +1,5 @@
1
- # encoding: UTF-8
1
+ # frozen_string_literal: true
2
+
2
3
  require 'spec_helper'
3
4
  require 'shared_examples/asset_provider'
4
5
 
@@ -1,4 +1,5 @@
1
- # encoding: UTF-8
1
+ # frozen_string_literal: true
2
+
2
3
  require 'spec_helper'
3
4
  require 'shared_examples/url_rewriter'
4
5
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
  require 'roadie/rspec'
3
5
  require 'shared_examples/asset_provider'
@@ -1,4 +1,5 @@
1
- # encoding: UTF-8
1
+ # frozen_string_literal: true
2
+
2
3
  require 'spec_helper'
3
4
  require 'roadie/rspec'
4
5
 
@@ -1,4 +1,5 @@
1
- # encoding: UTF-8
1
+ # frozen_string_literal: true
2
+
2
3
  require 'spec_helper'
3
4
 
4
5
  module Roadie
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  module Roadie
@@ -1,4 +1,5 @@
1
- # encoding: UTF-8
1
+ # frozen_string_literal: true
2
+
2
3
  require 'spec_helper'
3
4
 
4
5
  module Roadie
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  module Roadie
@@ -1,4 +1,5 @@
1
- # encoding: UTF-8
1
+ # frozen_string_literal: true
2
+
2
3
  require 'spec_helper'
3
4
 
4
5
  module Roadie
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
  require 'roadie/rspec'
3
5
 
@@ -1,4 +1,5 @@
1
- # encoding: UTF-8
1
+ # frozen_string_literal: true
2
+
2
3
  require 'spec_helper'
3
4
 
4
5
  module Roadie
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
  require 'shared_examples/url_rewriter'
3
5
 
@@ -71,9 +73,8 @@ module Roadie
71
73
  it "rewrites all url() directives" do
72
74
  expect(generator).to receive(:generate_url).with("some/path.jpg").and_return "http://foo.com/image.jpg"
73
75
  css = "body { background: top url(some/path.jpg) #eee; }"
74
- expect {
75
- rewriter.transform_css css
76
- }.to change { css }.to "body { background: top url(http://foo.com/image.jpg) #eee; }"
76
+ transformed_css = rewriter.transform_css css
77
+ expect(transformed_css).to eq "body { background: top url(http://foo.com/image.jpg) #eee; }"
77
78
  end
78
79
 
79
80
  it "correctly identifies URLs with single quotes" do
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "spec_helper"
2
4
 
3
5
  module Roadie
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  shared_examples_for "asset provider role" do
2
4
  it "responds to #find_stylesheet" do
3
5
  expect(subject).to respond_to(:find_stylesheet)
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  shared_examples_for "url rewriter" do
2
4
  it "is constructed with a generator" do
3
5
  generator = double "URL generator"
@@ -6,7 +8,7 @@ shared_examples_for "url rewriter" do
6
8
  }.to_not raise_error
7
9
  end
8
10
 
9
- it "has a #transform_dom(dom) method that returns nil" do
11
+ it "has a #transform_dom(dom) method that returns the modified string" do
10
12
  expect(subject).to respond_to(:transform_dom)
11
13
  expect(subject.method(:transform_dom).arity).to eq(1)
12
14
 
@@ -14,10 +16,10 @@ shared_examples_for "url rewriter" do
14
16
  expect(subject.transform_dom(dom)).to be_nil
15
17
  end
16
18
 
17
- it "has a #transform_css(css) method that returns nil" do
19
+ it "has a #transform_css(css) method that returns the modified string" do
18
20
  expect(subject).to respond_to(:transform_css)
19
21
  expect(subject.method(:transform_css).arity).to eq(1)
20
22
 
21
- expect(subject.transform_css("")).to be_nil
23
+ expect(subject.transform_css("")).to eq("")
22
24
  end
23
25
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'rspec/collection_matchers'
2
4
  require 'webmock/rspec'
3
5
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  RSpec::Matchers.define :have_attribute do |attribute|
2
4
  @selector = 'body > *:first'
3
5
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  RSpec::Matchers.define :have_node do |selector|
2
4
  chain(:with_attributes) { |attributes| @attributes = attributes }
3
5
  match do |document|
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  RSpec::Matchers.define :have_selector do |selector|
2
4
  match { |document| !document.css(selector).empty? }
3
5
  failure_message { "expected document to have selector #{selector.inspect}"}
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  RSpec::Matchers.define :have_styling do |rules|
2
4
  normalized_rules = StylingExpectation.new(rules)
3
5
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  RSpec::Matchers.define :have_xpath do |xpath|
2
4
  match { |document| !document.xpath(xpath).empty? }
3
5
  failure_message { "expected document to have xpath #{xpath.inspect}"}
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class TestProvider
2
4
  include Roadie::AssetProvider
3
5
 
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: 3.5.1
4
+ version: 4.0.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: 2019-10-02 00:00:00.000000000 Z
11
+ date: 2019-10-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nokogiri
@@ -66,6 +66,20 @@ dependencies:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
68
  version: '1.0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rubocop
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - '='
74
+ - !ruby/object:Gem::Version
75
+ version: 0.75.0
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - '='
81
+ - !ruby/object:Gem::Version
82
+ version: 0.75.0
69
83
  - !ruby/object:Gem::Dependency
70
84
  name: webmock
71
85
  requirement: !ruby/object:Gem::Requirement
@@ -92,6 +106,7 @@ extra_rdoc_files:
92
106
  files:
93
107
  - ".autotest"
94
108
  - ".gitignore"
109
+ - ".rubocop.yml"
95
110
  - ".travis.yml"
96
111
  - ".yardopts"
97
112
  - Changelog.md
@@ -174,7 +189,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
174
189
  requirements:
175
190
  - - ">="
176
191
  - !ruby/object:Gem::Version
177
- version: '1.9'
192
+ version: '2.4'
178
193
  required_rubygems_version: !ruby/object:Gem::Requirement
179
194
  requirements:
180
195
  - - ">="