roadie-rails 1.3.0 → 3.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: e4d5c326e544bd6b1009636f171a58e72d617d46
4
- data.tar.gz: 5dab77d31e9efae6d1a63846cd9a506501fcb407
2
+ SHA256:
3
+ metadata.gz: 3763b68398678ce8340c842702ed7321dce653b992c336c5d646e554696f2e83
4
+ data.tar.gz: a09a2aa1df722ddb5d13635ea1efaab6756c44f9a50258e27c2042b71e4dd8dc
5
5
  SHA512:
6
- metadata.gz: fb007edf188d872bd9143cf90ee974fed1d896d2ae849d14dc168be176c03aac868f911f5d289b94d911158e6588b9b6dce19a9eba65a682ee8369c75097195c
7
- data.tar.gz: cad9b361c937836cffab6bc74e27d61b5f5fe7dba0d84821d271c29a53565b794bb451d1c879c6fb2e19de9cb8633b60155724d397a425bbc18b4e2b2b53a6d3
6
+ metadata.gz: fb6f168beb438f59455e2b04ce07e6face9b4db9f226e5603bbe20bdaf0568ea2870ace9d6edde1884fbe0e09958d74f19b5a6c565d08b572459a60aee8ce203
7
+ data.tar.gz: e0b3f1146229dc609018db1d77d544ef4f9e9c3644e6a834b38dd7b00adcdafef02d79e248c914b24db1622beaacdffefbcc863383fd1b9005763bdab8ad3cd1
@@ -0,0 +1,43 @@
1
+ name: Main
2
+ on:
3
+ push:
4
+ branches:
5
+ - main
6
+ - master
7
+
8
+ pull_request:
9
+ types: [opened, synchronize, reopened]
10
+
11
+ jobs:
12
+ base:
13
+ name: Ruby ${{ matrix.ruby }}
14
+ runs-on: ubuntu-20.04
15
+ strategy:
16
+ fail-fast: false
17
+ matrix:
18
+ ruby: ["2.6", "2.7", "3.0", "3.1"]
19
+
20
+ steps:
21
+ - name: Checkout code
22
+ uses: actions/checkout@v2
23
+
24
+ # This setup is not compatible with the way Travis CI was
25
+ # setup, so the cache will only work for the root folder.
26
+ - name: Setup Ruby
27
+ uses: ruby/setup-ruby@v1
28
+ with:
29
+ ruby-version: ${{ matrix.ruby }}
30
+ bundler-cache: true
31
+
32
+ - name: Rake
33
+ run: rake
34
+
35
+ - uses: codecov/codecov-action@v2
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
data/.rubocop.yml ADDED
@@ -0,0 +1,71 @@
1
+ AllCops:
2
+ TargetRubyVersion: 2.5
3
+ Exclude:
4
+ - spec/railsapps/**/*
5
+
6
+ Naming/FileName:
7
+ Exclude:
8
+ # This is named intentionally this way (the gem name), in case someone
9
+ # includes it instead of "roadie/rails".
10
+ - lib/roadie-rails.rb
11
+
12
+ Style/StringLiterals:
13
+ EnforcedStyle: double_quotes
14
+
15
+ Style/TrailingCommaInHashLiteral:
16
+ EnforcedStyleForMultiline: comma
17
+
18
+ Style/TrailingCommaInArguments:
19
+ EnforcedStyleForMultiline: comma
20
+
21
+ Style/TrailingCommaInArrayLiteral:
22
+ EnforcedStyleForMultiline: consistent_comma
23
+
24
+ Layout/SpaceInsideHashLiteralBraces:
25
+ EnforcedStyle: no_space
26
+
27
+ Style/Documentation:
28
+ Enabled: false
29
+
30
+ Layout/FirstArrayElementIndentation:
31
+ EnforcedStyle: consistent
32
+
33
+ Layout/MultilineMethodCallIndentation:
34
+ EnforcedStyle: indented
35
+
36
+ Layout/EmptyLinesAroundAccessModifier:
37
+ Enabled: false
38
+
39
+ Style/GuardClause:
40
+ Enabled: false
41
+
42
+ Style/IfUnlessModifier:
43
+ Enabled: false
44
+
45
+ Style/SignalException:
46
+ Enabled: false
47
+
48
+ Style/BlockDelimiters:
49
+ Enabled: true
50
+ EnforcedStyle: braces_for_chaining
51
+ Exclude:
52
+ - 'spec/**/*'
53
+
54
+ Metrics/BlockLength:
55
+ ExcludedMethods:
56
+ - refine
57
+ - describe
58
+ - context
59
+ - shared_examples
60
+ Exclude:
61
+ - 'Rakefile'
62
+ - '**/*.rake'
63
+ - 'spec/*_spec.rb'
64
+ - 'spec/**/*_spec.rb'
65
+ - 'spec/shared_examples/*.rb'
66
+
67
+ Layout/LineLength:
68
+ IgnoredPatterns:
69
+ - '^\s*it\s' # Test names can be long
70
+ Exclude:
71
+ - roadie-rails.gemspec
data/.solargraph.yml ADDED
@@ -0,0 +1,16 @@
1
+ ---
2
+ include:
3
+ - "**/*.rb"
4
+ exclude:
5
+ - spec/**/*
6
+ - test/**/*
7
+ - vendor/**/*
8
+ - ".bundle/**/*"
9
+ require: []
10
+ domains: []
11
+ plugins:
12
+ - solargraph-standardrb
13
+ reporters:
14
+ - standardrb
15
+ require_paths: []
16
+ max_files: 5000
data/Changelog.md CHANGED
@@ -1,8 +1,57 @@
1
1
  ### development version
2
2
 
3
- [full changelog](https://github.com/Mange/roadie-rails/compare/v1.3.0...master)
3
+ [full changelog](https://github.com/Mange/roadie-rails/compare/v3.0.0...master)
4
4
 
5
- * Nothing yet.
5
+ ### 3.0.0
6
+
7
+ [full changelog](https://github.com/Mange/roadie-rails/compare/v2.3.0...v3.0.0)
8
+
9
+ * Drop support for Ruby versions < 2.6.
10
+ * Add support for Ruby 3.0 and 3.1.
11
+
12
+ Development changes:
13
+
14
+ * Replace Travis CI with Github CI.
15
+
16
+ ### 2.3.0
17
+
18
+ [full changelog](https://github.com/Mange/roadie-rails/compare/v2.2.0...v2.3.0)
19
+
20
+ * Support Rails 7.0 - [Sean Floyd (SeanLF)](https://github.com/SeanLF)
21
+ * Drop support for Ruby 2.5 (EoL).
22
+
23
+ ### 2.2.0
24
+
25
+ [full changelog](https://github.com/Mange/roadie-rails/compare/v2.1.1...v2.2.0)
26
+
27
+ * Support Rails 6.1 - [A. Fomera (afomera)](https://github.com/afomera)
28
+
29
+ ### 2.1.1
30
+
31
+ [full changelog](https://github.com/Mange/roadie-rails/compare/v2.1.0...v2.1.1)
32
+
33
+ * Relax Roadie dependency to allow v4.x
34
+
35
+ Development changes:
36
+
37
+ * Updated embedded Rails apps (used in tests) to work with new Sprockets 4.
38
+ * Updated Rubocop config to work with newer Rubocop versions.
39
+
40
+ ### 2.1.0
41
+
42
+ [full changelog](https://github.com/Mange/roadie-rails/compare/v2.0.0...v2.1.0)
43
+
44
+ * Rails 6 support (#88) - [Gleb Mazovetskiy (glebm)](https://github.com/glebm)
45
+
46
+ ### 2.0.0
47
+
48
+ [full changelog](https://github.com/Mange/roadie-rails/compare/v1.3.0...v2.0.0)
49
+
50
+ * Drop support for Ruby before 2.5.
51
+ * Drop support for Rails before 5.1.
52
+ * Add support for Ruby 2.5.
53
+ * Add support for Ruby 2.6.
54
+ * Fix arity of `Roadie::Rails::Mailer#roadie_mail` - [Adrian Lehmann (ownadi)](https://github.com/ownadi)
6
55
 
7
56
  ### 1.3.0
8
57
 
data/Gemfile CHANGED
@@ -1,14 +1,14 @@
1
- source 'https://rubygems.org'
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
2
4
 
3
5
  # Specify your gem's dependencies in roadie-rails.gemspec
4
6
  gemspec
5
7
 
6
- # Additional development dependencies I use but don't want to declare in the
7
- # gemfile since they aren't required to develop this codebase.
8
- group :development do
9
- gem 'guard'
10
- gem 'guard-rspec'
11
- end
12
-
13
8
  # Added here so it does not show up on the Gemspec; I only want it for CI builds
14
- gem 'codecov', group: :test, require: false
9
+ gem "simplecov", group: :test, require: false
10
+ gem "simplecov-cobertura", group: :test, require: false
11
+
12
+ # Not actually required to run the tests for the gem, but a real convenience
13
+ # for local development.
14
+ gem "standard", group: [:test, :development], require: false
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # roadie-rails
2
2
 
3
- [![Build history and status](https://secure.travis-ci.org/Mange/roadie-rails.png)](http://travis-ci.org/#!/Mange/roadie-rails)
3
+ [![Build history and status](https://github.com/Mange/roadie-rails/actions/workflows/main.yml/badge.svg)](https://github.com/Mange/roadie-rails/actions/workflows/main.yml)
4
4
  [![Code Climate](https://codeclimate.com/github/Mange/roadie-rails.png)](https://codeclimate.com/github/Mange/roadie-rails)
5
5
  [![Code coverage status](https://codecov.io/github/Mange/roadie-rails/coverage.svg?branch=master)](https://codecov.io/github/Mange/roadie-rails?branch=master)
6
6
  [![Gem](https://img.shields.io/gem/v/roadie-rails.svg)](https://rubygems.org/gems/roadie-rails)
@@ -20,7 +20,7 @@ This gem hooks up your Rails application with Roadie to help you generate HTML e
20
20
  [Add this gem to your Gemfile as recommended by Rubygems][gem] and run `bundle install`.
21
21
 
22
22
  ```ruby
23
- gem 'roadie-rails', '~> 0.0'
23
+ gem 'roadie-rails', '~> 3.0'
24
24
  ```
25
25
 
26
26
  ## Usage ##
@@ -190,7 +190,7 @@ class MyOtherMailer
190
190
  include Roadie::Rails::Mailer
191
191
 
192
192
  def some_mail(user)
193
- roadie_email {to: "foo@example.com"}, roadie_options_for(user)
193
+ roadie_mail {to: "foo@example.com"}, roadie_options_for(user)
194
194
  end
195
195
 
196
196
  private
@@ -278,18 +278,21 @@ end
278
278
 
279
279
  ## Build status ##
280
280
 
281
- Tested with [Travis CI](http://travis-ci.org) using [almost all combinations of](http://travis-ci.org/#!/Mange/roadie-rails):
281
+ Tested with Github Actions on multiple Ruby and Rails versions:
282
282
 
283
283
  * Ruby:
284
- * MRI 2.2
285
- * MRI 2.3
286
- * MRI 2.4
284
+ * MRI 2.6
285
+ * MRI 2.7
286
+ * MRI 3.0
287
+ * MRI 3.1
287
288
  * Rails
288
- * 4.2
289
- * 5.0
290
289
  * 5.1
291
290
  * 5.2
291
+ * 6.0
292
+ * 6.1
293
+ * 7.0
292
294
 
295
+ Please note that [all Rails-versions are not compatible with all Ruby-versions](https://www.fastruby.io/blog/ruby/rails/versions/compatibility-table.html).
293
296
  Let me know if you want any other combination supported officially.
294
297
 
295
298
  ### Versioning ###
@@ -316,7 +319,7 @@ After running `rake` for the first time and you want to keep running tests witho
316
319
 
317
320
  (The MIT License)
318
321
 
319
- Copyright © 2013-2018 [Magnus Bergmark](https://github.com/Mange) <magnus.bergmark@gmail.com>, et. al.
322
+ Copyright © 2013-2022 [Magnus Bergmark](https://github.com/Mange) <magnus.bergmark@gmail.com>, et. al.
320
323
 
321
324
  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the ‘Software’), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
322
325
 
data/Rakefile CHANGED
@@ -1,15 +1,17 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "bundler/gem_tasks"
2
4
 
3
5
  desc "Install gems for embedded Rails apps"
4
6
  task :install_gems do
5
- Bundler.with_clean_env do
7
+ Bundler.with_unbundled_env do
6
8
  sh "./setup.sh install"
7
9
  end
8
10
  end
9
11
 
10
12
  desc "Update gems for embedded Rails apps"
11
13
  task :update_gems do
12
- Bundler.with_clean_env do
14
+ Bundler.with_unbundled_env do
13
15
  sh "./setup.sh update"
14
16
  end
15
17
  end
@@ -20,4 +22,4 @@ task :spec do
20
22
  end
21
23
 
22
24
  desc "Default: Update gems and run specs"
23
- task :default => [:update_gems, :spec]
25
+ task default: %i[update_gems spec]
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Roadie
2
4
  module Rails
3
5
  class AssetPipelineProvider
@@ -5,7 +7,13 @@ module Roadie
5
7
  attr_reader :pipeline
6
8
 
7
9
  def initialize(pipeline)
8
- raise ArgumentError, "You need to pass a pipeline to initialize AssetPipelineProvider" unless pipeline
10
+ unless pipeline
11
+ raise(
12
+ ArgumentError,
13
+ "You need to pass a pipeline to initialize AssetPipelineProvider"
14
+ )
15
+ end
16
+
9
17
  super()
10
18
  @pipeline = pipeline
11
19
  end
@@ -17,6 +25,7 @@ module Roadie
17
25
  end
18
26
 
19
27
  private
28
+
20
29
  def filename(asset)
21
30
  if asset.respond_to?(:filename) # sprockets 4 or later
22
31
  asset.filename
@@ -27,11 +36,12 @@ module Roadie
27
36
 
28
37
  def find_asset_in_pipeline(name)
29
38
  normalized_name = normalize_asset_name(name)
30
- @pipeline[normalized_name] || @pipeline[remove_asset_digest(normalized_name)]
39
+ @pipeline[normalized_name] ||
40
+ @pipeline[remove_asset_digest(normalized_name)]
31
41
  end
32
42
 
33
43
  def normalize_asset_name(href)
34
- remove_asset_prefix(href.split('?').first)
44
+ remove_asset_prefix(href.split("?").first)
35
45
  end
36
46
 
37
47
  DIGEST_PATTERN = /
@@ -44,7 +54,7 @@ module Roadie
44
54
  /x.freeze
45
55
 
46
56
  def remove_asset_digest(path)
47
- path.gsub(DIGEST_PATTERN, '.')
57
+ path.gsub(DIGEST_PATTERN, ".")
48
58
  end
49
59
 
50
60
  def remove_asset_prefix(path)
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Roadie
2
4
  module Rails
3
5
  module Automatic
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Roadie
2
4
  module Rails
3
5
  class DocumentBuilder
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Roadie
2
4
  module Rails
3
5
  # Extend instances of Mail with this to have it inlined automatically when
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Roadie
2
4
  module Rails
3
5
  class MailInliner
@@ -10,13 +12,14 @@ module Roadie
10
12
 
11
13
  def execute
12
14
  if options
13
- improve_body if email.content_type =~ /^text\/html/
15
+ improve_body if %r{^text/html}.match?(email.content_type)
14
16
  improve_html_part(email.html_part) if email.html_part
15
17
  end
16
18
  email
17
19
  end
18
20
 
19
21
  private
22
+
20
23
  def improve_body
21
24
  email.body = transform_html(email.body.decoded)
22
25
  end
@@ -1,9 +1,17 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Roadie
2
4
  module Rails
3
5
  module Mailer
4
- def roadie_mail(options = {}, &block)
6
+ # Generate an email and run Roadie on it. Will use #roadie_options to get
7
+ # default options if not passed in.
8
+ def roadie_mail(
9
+ options = {},
10
+ final_roadie_options = roadie_options,
11
+ &block
12
+ )
5
13
  email = mail(options, &block)
6
- MailInliner.new(email, roadie_options).execute
14
+ MailInliner.new(email, final_roadie_options).execute
7
15
  end
8
16
 
9
17
  def roadie_options
@@ -1,58 +1,46 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Roadie
2
4
  module Rails
3
5
  class Options
4
- ATTRIBUTE_NAMES = [
5
- :after_transformation,
6
- :asset_providers,
7
- :before_transformation,
8
- :external_asset_providers,
9
- :keep_uninlinable_css,
10
- :url_options,
11
- ]
6
+ ATTRIBUTE_NAMES = %i[
7
+ after_transformation
8
+ asset_providers
9
+ before_transformation
10
+ external_asset_providers
11
+ keep_uninlinable_css
12
+ url_options
13
+ ].freeze
12
14
  private_constant :ATTRIBUTE_NAMES
15
+
13
16
  attr_reader(*ATTRIBUTE_NAMES)
17
+ attr_writer(
18
+ :url_options,
19
+ :before_transformation,
20
+ :after_transformation,
21
+ :keep_uninlinable_css
22
+ )
14
23
 
15
24
  def initialize(options = {})
16
25
  complain_about_unknown_keys options.keys
17
- self.after_transformation = options[:after_transformation]
18
- self.asset_providers = options[:asset_providers]
19
- self.before_transformation = options[:before_transformation]
20
- self.external_asset_providers = options[:external_asset_providers]
21
- self.keep_uninlinable_css = options[:keep_uninlinable_css]
22
- self.url_options = options[:url_options]
23
- end
24
-
25
- def url_options=(options)
26
- @url_options = options
27
- end
28
-
29
- def before_transformation=(callback)
30
- @before_transformation = callback
31
- end
32
-
33
- def after_transformation=(callback)
34
- @after_transformation = callback
35
- end
36
-
37
- def keep_uninlinable_css=(bool)
38
- @keep_uninlinable_css = bool
26
+ options.each_pair do |name, value|
27
+ self[name] = value
28
+ end
39
29
  end
40
30
 
41
31
  def asset_providers=(providers)
32
+ # TODO: Raise an error when setting to nil in order to make this not a
33
+ # silent error.
42
34
  if providers
43
35
  @asset_providers = ProviderList.wrap providers
44
- # TODO: Raise an error when setting to nil in order to make this not a silent error.
45
- # else
46
- # raise ArgumentError, "Cannot set asset_providers to nil. Set to Roadie::NullProvider if you want no external assets inlined."
47
36
  end
48
37
  end
49
38
 
50
39
  def external_asset_providers=(providers)
40
+ # TODO: Raise an error when setting to nil in order to make this not a
41
+ # silent error.
51
42
  if providers
52
43
  @external_asset_providers = ProviderList.wrap providers
53
- # TODO: Raise an error when setting to nil in order to make this not a silent error.
54
- # else
55
- # raise ArgumentError, "Cannot set asset_providers to nil. Set to Roadie::NullProvider if you want no external assets inlined."
56
44
  end
57
45
  end
58
46
 
@@ -62,9 +50,14 @@ module Roadie
62
50
  document.after_transformation = after_transformation
63
51
 
64
52
  document.asset_providers = asset_providers if asset_providers
65
- document.external_asset_providers = external_asset_providers if external_asset_providers
66
53
 
67
- document.keep_uninlinable_css = keep_uninlinable_css unless keep_uninlinable_css.nil?
54
+ if external_asset_providers
55
+ document.external_asset_providers = external_asset_providers
56
+ end
57
+
58
+ unless keep_uninlinable_css.nil?
59
+ document.keep_uninlinable_css = keep_uninlinable_css
60
+ end
68
61
  end
69
62
 
70
63
  def merge(options)
@@ -73,7 +66,7 @@ module Roadie
73
66
 
74
67
  def merge!(options)
75
68
  ATTRIBUTE_NAMES.each do |attribute|
76
- send "#{attribute}=", options.fetch(attribute, send(attribute))
69
+ self[attribute] = options.fetch(attribute, self[attribute])
77
70
  end
78
71
  self
79
72
  end
@@ -83,63 +76,52 @@ module Roadie
83
76
  end
84
77
 
85
78
  def combine!(options)
86
- self.after_transformation = combine_callable(
87
- after_transformation, options[:after_transformation]
88
- )
89
-
90
- self.asset_providers = combine_providers(
91
- asset_providers, options[:asset_providers]
92
- )
93
-
94
- self.before_transformation = combine_callable(
95
- before_transformation, options[:before_transformation]
96
- )
79
+ %i[after_transformation before_transformation].each do |name|
80
+ self[name] = Utils.combine_callable(self[name], options[name])
81
+ end
97
82
 
98
- self.external_asset_providers = combine_providers(
99
- external_asset_providers, options[:external_asset_providers]
100
- )
83
+ %i[asset_providers external_asset_providers].each do |name|
84
+ self[name] = Utils.combine_providers(self[name], options[name])
85
+ end
101
86
 
102
- self.keep_uninlinable_css =
103
- options[:keep_uninlinable_css] if options.has_key?(:keep_uninlinable_css)
87
+ if options.key?(:keep_uninlinable_css)
88
+ self.keep_uninlinable_css = options[:keep_uninlinable_css]
89
+ end
104
90
 
105
- self.url_options = combine_hash(
106
- url_options, options[:url_options]
91
+ self.url_options = Utils.combine_hash(
92
+ url_options,
93
+ options[:url_options]
107
94
  )
108
95
 
109
96
  self
110
97
  end
111
98
 
112
- private
113
- def combine_hash(first, second)
114
- combine_nilable(first, second) do |a, b|
115
- a.merge(b)
116
- end
117
- end
118
-
119
- def combine_callable(first, second)
120
- combine_nilable(first, second) do |a, b|
121
- proc { |*args| a.call(*args); b.call(*args) }
122
- end
123
- end
124
-
125
- def combine_providers(first, second)
126
- combine_nilable(first, second) do |a, b|
127
- ProviderList.new(a.to_a + Array.wrap(b))
99
+ def [](option)
100
+ if ATTRIBUTE_NAMES.include?(option)
101
+ public_send(option)
102
+ else
103
+ raise ArgumentError, "#{option.inspect} is not a valid option"
128
104
  end
129
105
  end
130
106
 
131
- def combine_nilable(first, second)
132
- if first && second
133
- yield first, second
107
+ def []=(option, value)
108
+ if ATTRIBUTE_NAMES.include?(option)
109
+ public_send("#{option}=", value)
134
110
  else
135
- first ? first : second
111
+ raise ArgumentError, "#{option.inspect} is not a valid option"
136
112
  end
137
113
  end
138
114
 
115
+ private
116
+
139
117
  def complain_about_unknown_keys(keys)
140
118
  invalid_keys = keys - ATTRIBUTE_NAMES
141
- if invalid_keys.size > 0
142
- raise ArgumentError, "Unknown configuration parameters: #{invalid_keys}", caller(1)
119
+ unless invalid_keys.empty?
120
+ raise(
121
+ ArgumentError,
122
+ "Unknown configuration parameters: #{invalid_keys}",
123
+ caller(1)
124
+ )
143
125
  end
144
126
  end
145
127
  end
@@ -1,4 +1,6 @@
1
- require 'rails'
1
+ # frozen_string_literal: true
2
+
3
+ require "rails"
2
4
 
3
5
  module Roadie
4
6
  module Rails
@@ -7,18 +9,17 @@ module Roadie
7
9
 
8
10
  initializer "roadie-rails.setup" do |app|
9
11
  config.roadie.asset_providers = [
10
- Roadie::FilesystemProvider.new(::Rails.root.join("public").to_s),
12
+ Roadie::FilesystemProvider.new(::Rails.root.join("public").to_s)
11
13
  ]
12
14
 
13
- # Saying config.assets.enabled here does not work in Rails 3.1-3.2, but
14
- # APP.config.assets work. There is a difference between "config" and
15
- # "app.config" on those versions.
16
- if app.config.respond_to?(:assets) && app.config.assets.enabled != false
15
+ if app.config.respond_to?(:assets) && app.config.assets
17
16
  if app.assets
18
- config.roadie.asset_providers << AssetPipelineProvider.new(app.assets)
17
+ config.roadie.asset_providers <<
18
+ AssetPipelineProvider.new(app.assets)
19
19
  else
20
20
  app.config.assets.configure do |env|
21
- config.roadie.asset_providers << AssetPipelineProvider.new(env)
21
+ config.roadie.asset_providers <<
22
+ AssetPipelineProvider.new(env)
22
23
  end
23
24
  end
24
25
  end
@@ -0,0 +1,62 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Roadie
4
+ module Rails
5
+ module Utils
6
+ module_function
7
+
8
+ # Combine two hashes, or return the non-nil hash if either is nil.
9
+ # Returns nil if both are nil.
10
+ def combine_hash(first, second)
11
+ combine_nilable(first, second) do |a, b|
12
+ a.merge(b)
13
+ end
14
+ end
15
+
16
+ # Return a callable that will call both inputs. If either is nil, then
17
+ # just return the other.
18
+ #
19
+ # The result from the second one will be the result of the combined
20
+ # callable.
21
+ #
22
+ # ```ruby
23
+ # combine_callable(-> { 1 }, -> { 2 }).call # => 2
24
+ # combine_callable(-> { 1 }, nil).call # => 1
25
+ # combine_callable(nil, nil).nil? # => true
26
+ # ```
27
+ def combine_callable(first, second)
28
+ combine_nilable(first, second) do |a, b|
29
+ lambda do |*args|
30
+ a.call(*args)
31
+ b.call(*args)
32
+ end
33
+ end
34
+ end
35
+
36
+ # Combine two Provider ducks into a ProviderList. If either is nil, pick
37
+ # the non-nil value instead.
38
+ def combine_providers(first, second)
39
+ combine_nilable(first, second) do |a, b|
40
+ ProviderList.new(a.to_a + Array.wrap(b))
41
+ end
42
+ end
43
+
44
+ # Discard the nil value. If neither is nil, then yield both and return
45
+ # the result from the block.
46
+ #
47
+ # ```ruby
48
+ # combine_nilable(nil, 5) { |a, b| a+b } # => 5
49
+ # combine_nilable(7, nil) { |a, b| a+b } # => 7
50
+ # combine_nilable(nil, nil) { |a, b| a+b } # => nil
51
+ # combine_nilable(7, 5) { |a, b| a+b } # => 12
52
+ # ```
53
+ def combine_nilable(first, second)
54
+ if first && second
55
+ yield first, second
56
+ else
57
+ first || second
58
+ end
59
+ end
60
+ end
61
+ end
62
+ end
@@ -1,5 +1,7 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Roadie
2
4
  module Rails
3
- VERSION = "1.3.0"
5
+ VERSION = "3.0.0"
4
6
  end
5
7
  end
data/lib/roadie/rails.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Roadie
2
4
  module Rails
3
5
  end
@@ -6,6 +8,7 @@ end
6
8
  require "roadie"
7
9
 
8
10
  require "roadie/rails/version"
11
+ require "roadie/rails/utils"
9
12
  require "roadie/rails/options"
10
13
 
11
14
  require "roadie/rails/document_builder"
data/lib/roadie-rails.rb CHANGED
@@ -1 +1,3 @@
1
- require 'roadie/rails'
1
+ # frozen_string_literal: true
2
+
3
+ require "roadie/rails"
data/roadie-rails.gemspec CHANGED
@@ -1,32 +1,33 @@
1
- # coding: utf-8
2
- lib = File.expand_path('../lib', __FILE__)
1
+ # frozen_string_literal: true
2
+
3
+ lib = File.expand_path("lib", __dir__)
3
4
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require 'roadie/rails/version'
5
+ require "roadie/rails/version"
5
6
 
6
7
  Gem::Specification.new do |spec|
7
- spec.name = "roadie-rails"
8
- spec.version = Roadie::Rails::VERSION
9
- spec.authors = ["Magnus Bergmark"]
10
- spec.email = ["magnus.bergmark@gmail.com"]
11
- spec.homepage = 'http://github.com/Mange/roadie-rails'
12
- spec.summary = %q{Making HTML emails comfortable for the Rails rockstars}
13
- spec.description = %q{Hooks Roadie into your Rails application to help with email generation.}
14
- spec.license = "MIT"
8
+ spec.name = "roadie-rails"
9
+ spec.version = Roadie::Rails::VERSION
10
+ spec.authors = ["Magnus Bergmark"]
11
+ spec.email = ["magnus.bergmark@gmail.com"]
12
+ spec.homepage = "http://github.com/Mange/roadie-rails"
13
+ spec.summary = "Making HTML emails comfortable for the Rails rockstars"
14
+ spec.description = "Hooks Roadie into your Rails application to help with email generation."
15
+ spec.license = "MIT"
15
16
 
16
- spec.required_ruby_version = ">= 2.2"
17
+ spec.required_ruby_version = ">= 2.6"
17
18
 
18
- spec.files = `git ls-files | grep -v ^spec`.split($/)
19
- spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
20
- spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.files = `git ls-files | grep -v ^spec`.split($INPUT_RECORD_SEPARATOR)
20
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
21
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
21
22
  spec.extra_rdoc_files = %w[README.md Changelog.md LICENSE.txt]
22
23
  spec.require_paths = ["lib"]
23
24
 
24
- spec.add_dependency "roadie", "~> 3.1"
25
- spec.add_dependency "railties", ">= 3.0", "< 5.3"
25
+ spec.add_dependency "railties", ">= 5.1", "< 7.1"
26
+ spec.add_dependency "roadie", "~> 5.0"
26
27
 
27
- spec.add_development_dependency "rails", ">= 4.2", "< 5.3"
28
- spec.add_development_dependency "bundler", "~> 1.6"
29
- spec.add_development_dependency "rspec", "~> 3.0"
30
- spec.add_development_dependency "rspec-rails"
28
+ spec.add_development_dependency "bundler", "~> 2.2"
29
+ spec.add_development_dependency "rails", ">= 5.1", "< 7.1"
30
+ spec.add_development_dependency "rspec", "~> 3.10"
31
31
  spec.add_development_dependency "rspec-collection_matchers"
32
+ spec.add_development_dependency "rspec-rails"
32
33
  end
data/setup.sh CHANGED
@@ -10,7 +10,7 @@ function header() {
10
10
  }
11
11
 
12
12
  function green() {
13
- echo $(tput setaf 2)$@$(tput sgr0)
13
+ echo "$(tput setaf 2)$*$(tput sgr0)"
14
14
  }
15
15
 
16
16
  function update() {
@@ -23,20 +23,21 @@ function install() {
23
23
  }
24
24
 
25
25
 
26
- root=$(dirname $0)
26
+ root=$(dirname "$0")
27
27
 
28
- # Set by Travis CI; interferes with the nested repos
28
+ # Previously needed by Travis CI; might still be needed at Github Actions
29
+ # due to nested repos
29
30
  unset BUNDLE_GEMFILE
30
31
 
31
32
  if [[ $1 == "install" ]]; then
32
33
  header "Installing gem dependencies"
33
34
  install
34
35
 
35
- for app_path in $root/spec/railsapps/rails_*; do
36
+ for app_path in "$root"/spec/railsapps/rails_*; do
36
37
  (
37
- header "Rails app $(basename $app_path)"
38
- cd $app_path
39
- echo "Installing gems for $(basename $app_path)"
38
+ header "Rails app $(basename "$app_path")"
39
+ cd "$app_path"
40
+ echo -n "Installing gems for $(basename "$app_path")"
40
41
  install
41
42
  )
42
43
  done
@@ -46,10 +47,10 @@ elif [[ $1 == "update" ]]; then
46
47
  header "Updating gem dependencies"
47
48
  update
48
49
 
49
- for app_path in $root/spec/railsapps/rails_*; do
50
+ for app_path in "$root"/spec/railsapps/rails_*; do
50
51
  (
51
- cd $app_path
52
- header "Updating $(basename $app_path)"
52
+ cd "$app_path"
53
+ header "Updating $(basename "$app_path")"
53
54
  update
54
55
  )
55
56
  done
metadata CHANGED
@@ -1,99 +1,99 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: roadie-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.0
4
+ version: 3.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Magnus Bergmark
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-04-04 00:00:00.000000000 Z
11
+ date: 2022-02-02 00:00:00.000000000 Z
12
12
  dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: roadie
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - "~>"
18
- - !ruby/object:Gem::Version
19
- version: '3.1'
20
- type: :runtime
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - "~>"
25
- - !ruby/object:Gem::Version
26
- version: '3.1'
27
13
  - !ruby/object:Gem::Dependency
28
14
  name: railties
29
15
  requirement: !ruby/object:Gem::Requirement
30
16
  requirements:
31
17
  - - ">="
32
18
  - !ruby/object:Gem::Version
33
- version: '3.0'
19
+ version: '5.1'
34
20
  - - "<"
35
21
  - !ruby/object:Gem::Version
36
- version: '5.3'
22
+ version: '7.1'
37
23
  type: :runtime
38
24
  prerelease: false
39
25
  version_requirements: !ruby/object:Gem::Requirement
40
26
  requirements:
41
27
  - - ">="
42
28
  - !ruby/object:Gem::Version
43
- version: '3.0'
29
+ version: '5.1'
44
30
  - - "<"
45
31
  - !ruby/object:Gem::Version
46
- version: '5.3'
32
+ version: '7.1'
47
33
  - !ruby/object:Gem::Dependency
48
- name: rails
34
+ name: roadie
49
35
  requirement: !ruby/object:Gem::Requirement
50
36
  requirements:
51
- - - ">="
52
- - !ruby/object:Gem::Version
53
- version: '4.2'
54
- - - "<"
37
+ - - "~>"
55
38
  - !ruby/object:Gem::Version
56
- version: '5.3'
57
- type: :development
39
+ version: '5.0'
40
+ type: :runtime
58
41
  prerelease: false
59
42
  version_requirements: !ruby/object:Gem::Requirement
60
43
  requirements:
61
- - - ">="
62
- - !ruby/object:Gem::Version
63
- version: '4.2'
64
- - - "<"
44
+ - - "~>"
65
45
  - !ruby/object:Gem::Version
66
- version: '5.3'
46
+ version: '5.0'
67
47
  - !ruby/object:Gem::Dependency
68
48
  name: bundler
69
49
  requirement: !ruby/object:Gem::Requirement
70
50
  requirements:
71
51
  - - "~>"
72
52
  - !ruby/object:Gem::Version
73
- version: '1.6'
53
+ version: '2.2'
74
54
  type: :development
75
55
  prerelease: false
76
56
  version_requirements: !ruby/object:Gem::Requirement
77
57
  requirements:
78
58
  - - "~>"
79
59
  - !ruby/object:Gem::Version
80
- version: '1.6'
60
+ version: '2.2'
61
+ - !ruby/object:Gem::Dependency
62
+ name: rails
63
+ requirement: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - ">="
66
+ - !ruby/object:Gem::Version
67
+ version: '5.1'
68
+ - - "<"
69
+ - !ruby/object:Gem::Version
70
+ version: '7.1'
71
+ type: :development
72
+ prerelease: false
73
+ version_requirements: !ruby/object:Gem::Requirement
74
+ requirements:
75
+ - - ">="
76
+ - !ruby/object:Gem::Version
77
+ version: '5.1'
78
+ - - "<"
79
+ - !ruby/object:Gem::Version
80
+ version: '7.1'
81
81
  - !ruby/object:Gem::Dependency
82
82
  name: rspec
83
83
  requirement: !ruby/object:Gem::Requirement
84
84
  requirements:
85
85
  - - "~>"
86
86
  - !ruby/object:Gem::Version
87
- version: '3.0'
87
+ version: '3.10'
88
88
  type: :development
89
89
  prerelease: false
90
90
  version_requirements: !ruby/object:Gem::Requirement
91
91
  requirements:
92
92
  - - "~>"
93
93
  - !ruby/object:Gem::Version
94
- version: '3.0'
94
+ version: '3.10'
95
95
  - !ruby/object:Gem::Dependency
96
- name: rspec-rails
96
+ name: rspec-collection_matchers
97
97
  requirement: !ruby/object:Gem::Requirement
98
98
  requirements:
99
99
  - - ">="
@@ -107,7 +107,7 @@ dependencies:
107
107
  - !ruby/object:Gem::Version
108
108
  version: '0'
109
109
  - !ruby/object:Gem::Dependency
110
- name: rspec-collection_matchers
110
+ name: rspec-rails
111
111
  requirement: !ruby/object:Gem::Requirement
112
112
  requirements:
113
113
  - - ">="
@@ -130,11 +130,12 @@ extra_rdoc_files:
130
130
  - Changelog.md
131
131
  - LICENSE.txt
132
132
  files:
133
+ - ".github/workflows/main.yml"
133
134
  - ".gitignore"
134
- - ".travis.yml"
135
+ - ".rubocop.yml"
136
+ - ".solargraph.yml"
135
137
  - Changelog.md
136
138
  - Gemfile
137
- - Guardfile
138
139
  - LICENSE.txt
139
140
  - README.md
140
141
  - Rakefile
@@ -150,6 +151,7 @@ files:
150
151
  - lib/roadie/rails/mailer.rb
151
152
  - lib/roadie/rails/options.rb
152
153
  - lib/roadie/rails/railtie.rb
154
+ - lib/roadie/rails/utils.rb
153
155
  - lib/roadie/rails/version.rb
154
156
  - roadie-rails.gemspec
155
157
  - setup.sh
@@ -157,7 +159,7 @@ homepage: http://github.com/Mange/roadie-rails
157
159
  licenses:
158
160
  - MIT
159
161
  metadata: {}
160
- post_install_message:
162
+ post_install_message:
161
163
  rdoc_options: []
162
164
  require_paths:
163
165
  - lib
@@ -165,16 +167,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
165
167
  requirements:
166
168
  - - ">="
167
169
  - !ruby/object:Gem::Version
168
- version: '2.2'
170
+ version: '2.6'
169
171
  required_rubygems_version: !ruby/object:Gem::Requirement
170
172
  requirements:
171
173
  - - ">="
172
174
  - !ruby/object:Gem::Version
173
175
  version: '0'
174
176
  requirements: []
175
- rubyforge_project:
176
- rubygems_version: 2.6.14
177
- signing_key:
177
+ rubygems_version: 3.0.9
178
+ signing_key:
178
179
  specification_version: 4
179
180
  summary: Making HTML emails comfortable for the Rails rockstars
180
181
  test_files: []
data/.travis.yml DELETED
@@ -1,20 +0,0 @@
1
- sudo: false
2
- language: ruby
3
- rvm:
4
- - 2.2
5
- - 2.3
6
- - 2.4
7
-
8
- matrix:
9
- fast_finish: true
10
-
11
- cache:
12
- directories:
13
- - .bundle
14
- - spec/railsapps/rails_42/.bundle
15
- - spec/railsapps/rails_42_sprockets_rails_3/.bundle
16
- - spec/railsapps/rails_50/.bundle
17
- - spec/railsapps/rails_51/.bundle
18
- - spec/railsapps/rails_52/.bundle
19
- bundler_args: --without guard --path=.bundle
20
- script: "rake"
data/Guardfile DELETED
@@ -1,16 +0,0 @@
1
- rspec_options = {
2
- cmd: 'rspec -f documentation',
3
- fail_mode: :keep,
4
- all_after_pass: true,
5
- all_on_start: true,
6
- run_all: {cmd: 'rspec -f progress'}
7
- }
8
-
9
- guard :rspec, rspec_options do
10
- watch(%r{^spec/.+_spec\.rb$})
11
- watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
12
-
13
- watch('spec/spec_helper.rb') { "spec" }
14
- watch(%r{^spec/support/.+\.rb$}) { "spec" }
15
- end
16
-