roadie-rails 1.3.0 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.rubocop.yml +71 -0
- data/.travis.yml +12 -7
- data/Changelog.md +12 -2
- data/Gemfile +4 -9
- data/README.md +4 -7
- data/Rakefile +3 -1
- data/lib/roadie-rails.rb +3 -1
- data/lib/roadie/rails.rb +3 -0
- data/lib/roadie/rails/asset_pipeline_provider.rb +13 -4
- data/lib/roadie/rails/automatic.rb +2 -0
- data/lib/roadie/rails/document_builder.rb +2 -0
- data/lib/roadie/rails/inline_on_delivery.rb +2 -0
- data/lib/roadie/rails/mail_inliner.rb +3 -1
- data/lib/roadie/rails/mailer.rb +10 -2
- data/lib/roadie/rails/options.rb +61 -80
- data/lib/roadie/rails/railtie.rb +8 -7
- data/lib/roadie/rails/utils.rb +61 -0
- data/lib/roadie/rails/version.rb +3 -1
- data/roadie-rails.gemspec +14 -13
- data/setup.sh +8 -8
- metadata +38 -37
- data/Guardfile +0 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: b598ab302972326c1a3be3f3b036abe8cb1ea5a5662e10754b19914e37dd1250
|
4
|
+
data.tar.gz: 5deb626d2d7c474391653e3bcc0bb27687c90454ee204ae048f2026df974c5fa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b67ed7362896c5569f3d34baef59b999356af250bcc72c0e53460dc76929db87ca94035bcc66623544690832e2b151197a4532a08ebf2e626520a4c616015ed4
|
7
|
+
data.tar.gz: 3d98816b7c20d85d2b82c1d2ee5e9dbbcb704f1a70297d4c9eaa95fb209deea07a338de644a9e1bdf2d9c480830ebc64b00b5bccc125c7ad6706dbca5f64876c
|
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/IndentArray:
|
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
|
+
Metrics/LineLength:
|
68
|
+
IgnoredPatterns:
|
69
|
+
- '^\s*it\s' # Test names can be long
|
70
|
+
Exclude:
|
71
|
+
- roadie-rails.gemspec
|
data/.travis.yml
CHANGED
@@ -1,20 +1,25 @@
|
|
1
1
|
sudo: false
|
2
2
|
language: ruby
|
3
3
|
rvm:
|
4
|
-
- 2.
|
5
|
-
- 2.
|
6
|
-
- 2.4
|
4
|
+
- 2.5
|
5
|
+
- 2.6
|
7
6
|
|
8
7
|
matrix:
|
9
8
|
fast_finish: true
|
10
9
|
|
10
|
+
before_install:
|
11
|
+
# Ruby 2.6.0 does not work with Bundler 2 unless the gem system is updated
|
12
|
+
# first.
|
13
|
+
# https://github.com/bundler/bundler/issues/6784
|
14
|
+
- gem update --system
|
15
|
+
# Install latest bundler; Travis has an old version that Rails 5+ don't like.
|
16
|
+
# (2019-02-09; has 1.16.2, needs ~> 2.0)
|
17
|
+
- gem install bundler
|
18
|
+
|
11
19
|
cache:
|
12
20
|
directories:
|
13
21
|
- .bundle
|
14
|
-
- spec/railsapps/rails_42/.bundle
|
15
|
-
- spec/railsapps/rails_42_sprockets_rails_3/.bundle
|
16
|
-
- spec/railsapps/rails_50/.bundle
|
17
22
|
- spec/railsapps/rails_51/.bundle
|
18
23
|
- spec/railsapps/rails_52/.bundle
|
19
|
-
bundler_args: --
|
24
|
+
bundler_args: --path=.bundle
|
20
25
|
script: "rake"
|
data/Changelog.md
CHANGED
@@ -1,8 +1,18 @@
|
|
1
1
|
### development version
|
2
2
|
|
3
|
-
[full changelog](https://github.com/Mange/roadie-rails/compare/
|
3
|
+
[full changelog](https://github.com/Mange/roadie-rails/compare/v2.0.0...master)
|
4
4
|
|
5
|
-
|
5
|
+
Nothing yet.
|
6
|
+
|
7
|
+
### 2.0.0
|
8
|
+
|
9
|
+
[full changelog](https://github.com/Mange/roadie-rails/compare/v1.3.0...v2.0.0)
|
10
|
+
|
11
|
+
* Drop support for Ruby before 2.5.
|
12
|
+
* Drop support for Rails before 5.1.
|
13
|
+
* Add support for Ruby 2.5.
|
14
|
+
* Add support for Ruby 2.6.
|
15
|
+
* Fix arity of `Roadie::Rails::Mailer#roadie_mail` - [Adrian Lehmann (ownadi)](https://github.com/ownadi)
|
6
16
|
|
7
17
|
### 1.3.0
|
8
18
|
|
data/Gemfile
CHANGED
@@ -1,14 +1,9 @@
|
|
1
|
-
|
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
|
9
|
+
gem "codecov", group: :test, require: false
|
data/README.md
CHANGED
@@ -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', '~>
|
23
|
+
gem 'roadie-rails', '~> 2.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
|
-
|
193
|
+
roadie_mail {to: "foo@example.com"}, roadie_options_for(user)
|
194
194
|
end
|
195
195
|
|
196
196
|
private
|
@@ -281,12 +281,9 @@ end
|
|
281
281
|
Tested with [Travis CI](http://travis-ci.org) using [almost all combinations of](http://travis-ci.org/#!/Mange/roadie-rails):
|
282
282
|
|
283
283
|
* Ruby:
|
284
|
-
* MRI 2.
|
285
|
-
* MRI 2.
|
286
|
-
* MRI 2.4
|
284
|
+
* MRI 2.5
|
285
|
+
* MRI 2.6
|
287
286
|
* Rails
|
288
|
-
* 4.2
|
289
|
-
* 5.0
|
290
287
|
* 5.1
|
291
288
|
* 5.2
|
292
289
|
|
data/Rakefile
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require "bundler/gem_tasks"
|
2
4
|
|
3
5
|
desc "Install gems for embedded Rails apps"
|
@@ -20,4 +22,4 @@ task :spec do
|
|
20
22
|
end
|
21
23
|
|
22
24
|
desc "Default: Update gems and run specs"
|
23
|
-
task :
|
25
|
+
task default: %i[update_gems spec]
|
data/lib/roadie-rails.rb
CHANGED
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
|
class AssetPipelineProvider
|
@@ -5,7 +7,13 @@ module Roadie
|
|
5
7
|
attr_reader :pipeline
|
6
8
|
|
7
9
|
def initialize(pipeline)
|
8
|
-
|
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
|
@@ -27,11 +35,12 @@ module Roadie
|
|
27
35
|
|
28
36
|
def find_asset_in_pipeline(name)
|
29
37
|
normalized_name = normalize_asset_name(name)
|
30
|
-
@pipeline[normalized_name] ||
|
38
|
+
@pipeline[normalized_name] ||
|
39
|
+
@pipeline[remove_asset_digest(normalized_name)]
|
31
40
|
end
|
32
41
|
|
33
42
|
def normalize_asset_name(href)
|
34
|
-
remove_asset_prefix(href.split(
|
43
|
+
remove_asset_prefix(href.split("?").first)
|
35
44
|
end
|
36
45
|
|
37
46
|
DIGEST_PATTERN = /
|
@@ -44,7 +53,7 @@ module Roadie
|
|
44
53
|
/x.freeze
|
45
54
|
|
46
55
|
def remove_asset_digest(path)
|
47
|
-
path.gsub(DIGEST_PATTERN,
|
56
|
+
path.gsub(DIGEST_PATTERN, ".")
|
48
57
|
end
|
49
58
|
|
50
59
|
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
|
class MailInliner
|
@@ -10,7 +12,7 @@ module Roadie
|
|
10
12
|
|
11
13
|
def execute
|
12
14
|
if options
|
13
|
-
improve_body if email.content_type =~
|
15
|
+
improve_body if email.content_type =~ %r{^text/html}
|
14
16
|
improve_html_part(email.html_part) if email.html_part
|
15
17
|
end
|
16
18
|
email
|
data/lib/roadie/rails/mailer.rb
CHANGED
@@ -1,9 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Roadie
|
2
4
|
module Rails
|
3
5
|
module Mailer
|
4
|
-
|
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,
|
14
|
+
MailInliner.new(email, final_roadie_options).execute
|
7
15
|
end
|
8
16
|
|
9
17
|
def roadie_options
|
data/lib/roadie/rails/options.rb
CHANGED
@@ -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
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
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
|
-
|
18
|
-
|
19
|
-
|
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
|
-
|
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
|
-
|
69
|
+
self[attribute] = options.fetch(attribute, self[attribute])
|
77
70
|
end
|
78
71
|
self
|
79
72
|
end
|
@@ -82,64 +75,52 @@ module Roadie
|
|
82
75
|
dup.combine! options
|
83
76
|
end
|
84
77
|
|
85
|
-
def combine!(options)
|
86
|
-
|
87
|
-
|
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
|
-
)
|
78
|
+
def combine!(options) # rubocop:disable Metrics/MethodLength
|
79
|
+
%i[after_transformation before_transformation].each do |name|
|
80
|
+
self[name] = Utils.combine_callable(self[name], options[name])
|
81
|
+
end
|
97
82
|
|
98
|
-
|
99
|
-
|
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
|
-
|
103
|
-
|
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,
|
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
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
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
|
132
|
-
if
|
133
|
-
|
107
|
+
def []=(option, value)
|
108
|
+
if ATTRIBUTE_NAMES.include?(option)
|
109
|
+
public_send("#{option}=", value)
|
134
110
|
else
|
135
|
-
|
111
|
+
raise ArgumentError, "#{option.inspect} is not a valid option"
|
136
112
|
end
|
137
113
|
end
|
138
114
|
|
115
|
+
private
|
139
116
|
def complain_about_unknown_keys(keys)
|
140
117
|
invalid_keys = keys - ATTRIBUTE_NAMES
|
141
|
-
|
142
|
-
raise
|
118
|
+
unless invalid_keys.empty?
|
119
|
+
raise(
|
120
|
+
ArgumentError,
|
121
|
+
"Unknown configuration parameters: #{invalid_keys}",
|
122
|
+
caller(1),
|
123
|
+
)
|
143
124
|
end
|
144
125
|
end
|
145
126
|
end
|
data/lib/roadie/rails/railtie.rb
CHANGED
@@ -1,4 +1,6 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "rails"
|
2
4
|
|
3
5
|
module Roadie
|
4
6
|
module Rails
|
@@ -10,15 +12,14 @@ module Roadie
|
|
10
12
|
Roadie::FilesystemProvider.new(::Rails.root.join("public").to_s),
|
11
13
|
]
|
12
14
|
|
13
|
-
|
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 <<
|
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 <<
|
21
|
+
config.roadie.asset_providers <<
|
22
|
+
AssetPipelineProvider.new(env)
|
22
23
|
end
|
23
24
|
end
|
24
25
|
end
|
@@ -0,0 +1,61 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Roadie
|
4
|
+
module Rails
|
5
|
+
module Utils
|
6
|
+
module_function
|
7
|
+
# Combine two hashes, or return the non-nil hash if either is nil.
|
8
|
+
# Returns nil if both are nil.
|
9
|
+
def combine_hash(first, second)
|
10
|
+
combine_nilable(first, second) do |a, b|
|
11
|
+
a.merge(b)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
# Return a callable that will call both inputs. If either is nil, then
|
16
|
+
# just return the other.
|
17
|
+
#
|
18
|
+
# The result from the second one will be the result of the combined
|
19
|
+
# callable.
|
20
|
+
#
|
21
|
+
# ```ruby
|
22
|
+
# combine_callable(-> { 1 }, -> { 2 }).call # => 2
|
23
|
+
# combine_callable(-> { 1 }, nil).call # => 1
|
24
|
+
# combine_callable(nil, nil).nil? # => true
|
25
|
+
# ```
|
26
|
+
def combine_callable(first, second)
|
27
|
+
combine_nilable(first, second) do |a, b|
|
28
|
+
lambda do |*args|
|
29
|
+
a.call(*args)
|
30
|
+
b.call(*args)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
# Combine two Provider ducks into a ProviderList. If either is nil, pick
|
36
|
+
# the non-nil value instead.
|
37
|
+
def combine_providers(first, second)
|
38
|
+
combine_nilable(first, second) do |a, b|
|
39
|
+
ProviderList.new(a.to_a + Array.wrap(b))
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
# Discard the nil value. If neither is nil, then yield both and return
|
44
|
+
# the result from the block.
|
45
|
+
#
|
46
|
+
# ```ruby
|
47
|
+
# combine_nilable(nil, 5) { |a, b| a+b } # => 5
|
48
|
+
# combine_nilable(7, nil) { |a, b| a+b } # => 7
|
49
|
+
# combine_nilable(nil, nil) { |a, b| a+b } # => nil
|
50
|
+
# combine_nilable(7, 5) { |a, b| a+b } # => 12
|
51
|
+
# ```
|
52
|
+
def combine_nilable(first, second)
|
53
|
+
if first && second
|
54
|
+
yield first, second
|
55
|
+
else
|
56
|
+
first || second
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
data/lib/roadie/rails/version.rb
CHANGED
data/roadie-rails.gemspec
CHANGED
@@ -1,32 +1,33 @@
|
|
1
|
-
#
|
2
|
-
|
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
|
5
|
+
require "roadie/rails/version"
|
5
6
|
|
6
7
|
Gem::Specification.new do |spec|
|
7
8
|
spec.name = "roadie-rails"
|
8
9
|
spec.version = Roadie::Rails::VERSION
|
9
10
|
spec.authors = ["Magnus Bergmark"]
|
10
11
|
spec.email = ["magnus.bergmark@gmail.com"]
|
11
|
-
spec.homepage =
|
12
|
-
spec.summary =
|
13
|
-
spec.description =
|
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."
|
14
15
|
spec.license = "MIT"
|
15
16
|
|
16
|
-
spec.required_ruby_version = ">= 2.
|
17
|
+
spec.required_ruby_version = ">= 2.5"
|
17
18
|
|
18
|
-
spec.files = `git ls-files | grep -v ^spec`.split(
|
19
|
+
spec.files = `git ls-files | grep -v ^spec`.split($INPUT_RECORD_SEPARATOR)
|
19
20
|
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
20
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
|
|
25
|
+
spec.add_dependency "railties", ">= 5.1", "< 5.3"
|
24
26
|
spec.add_dependency "roadie", "~> 3.1"
|
25
|
-
spec.add_dependency "railties", ">= 3.0", "< 5.3"
|
26
27
|
|
27
|
-
spec.add_development_dependency "
|
28
|
-
spec.add_development_dependency "
|
29
|
-
spec.add_development_dependency "rspec", "~> 3.
|
30
|
-
spec.add_development_dependency "rspec-rails"
|
28
|
+
spec.add_development_dependency "bundler", "~> 2.0"
|
29
|
+
spec.add_development_dependency "rails", ">= 5.1", "< 5.3"
|
30
|
+
spec.add_development_dependency "rspec", "~> 3.8"
|
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)
|
13
|
+
echo "$(tput setaf 2)$*$(tput sgr0)"
|
14
14
|
}
|
15
15
|
|
16
16
|
function update() {
|
@@ -32,11 +32,11 @@ if [[ $1 == "install" ]]; then
|
|
32
32
|
header "Installing gem dependencies"
|
33
33
|
install
|
34
34
|
|
35
|
-
for app_path in $root/spec/railsapps/rails_*; do
|
35
|
+
for app_path in "$root"/spec/railsapps/rails_*; do
|
36
36
|
(
|
37
|
-
header "Rails app $(basename $app_path)"
|
38
|
-
cd $app_path
|
39
|
-
echo "Installing gems for $(basename $app_path)"
|
37
|
+
header "Rails app $(basename "$app_path")"
|
38
|
+
cd "$app_path"
|
39
|
+
echo "Installing gems for $(basename "$app_path")"
|
40
40
|
install
|
41
41
|
)
|
42
42
|
done
|
@@ -46,10 +46,10 @@ elif [[ $1 == "update" ]]; then
|
|
46
46
|
header "Updating gem dependencies"
|
47
47
|
update
|
48
48
|
|
49
|
-
for app_path in $root/spec/railsapps/rails_*; do
|
49
|
+
for app_path in "$root"/spec/railsapps/rails_*; do
|
50
50
|
(
|
51
|
-
cd $app_path
|
52
|
-
header "Updating $(basename $app_path)"
|
51
|
+
cd "$app_path"
|
52
|
+
header "Updating $(basename "$app_path")"
|
53
53
|
update
|
54
54
|
)
|
55
55
|
done
|
metadata
CHANGED
@@ -1,15 +1,35 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: roadie-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.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:
|
11
|
+
date: 2019-02-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: railties
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '5.1'
|
20
|
+
- - "<"
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: '5.3'
|
23
|
+
type: :runtime
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
requirements:
|
27
|
+
- - ">="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '5.1'
|
30
|
+
- - "<"
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '5.3'
|
13
33
|
- !ruby/object:Gem::Dependency
|
14
34
|
name: roadie
|
15
35
|
requirement: !ruby/object:Gem::Requirement
|
@@ -25,32 +45,26 @@ dependencies:
|
|
25
45
|
- !ruby/object:Gem::Version
|
26
46
|
version: '3.1'
|
27
47
|
- !ruby/object:Gem::Dependency
|
28
|
-
name:
|
48
|
+
name: bundler
|
29
49
|
requirement: !ruby/object:Gem::Requirement
|
30
50
|
requirements:
|
31
|
-
- - "
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: '3.0'
|
34
|
-
- - "<"
|
51
|
+
- - "~>"
|
35
52
|
- !ruby/object:Gem::Version
|
36
|
-
version: '
|
37
|
-
type: :
|
53
|
+
version: '2.0'
|
54
|
+
type: :development
|
38
55
|
prerelease: false
|
39
56
|
version_requirements: !ruby/object:Gem::Requirement
|
40
57
|
requirements:
|
41
|
-
- - "
|
42
|
-
- !ruby/object:Gem::Version
|
43
|
-
version: '3.0'
|
44
|
-
- - "<"
|
58
|
+
- - "~>"
|
45
59
|
- !ruby/object:Gem::Version
|
46
|
-
version: '
|
60
|
+
version: '2.0'
|
47
61
|
- !ruby/object:Gem::Dependency
|
48
62
|
name: rails
|
49
63
|
requirement: !ruby/object:Gem::Requirement
|
50
64
|
requirements:
|
51
65
|
- - ">="
|
52
66
|
- !ruby/object:Gem::Version
|
53
|
-
version: '
|
67
|
+
version: '5.1'
|
54
68
|
- - "<"
|
55
69
|
- !ruby/object:Gem::Version
|
56
70
|
version: '5.3'
|
@@ -60,40 +74,26 @@ dependencies:
|
|
60
74
|
requirements:
|
61
75
|
- - ">="
|
62
76
|
- !ruby/object:Gem::Version
|
63
|
-
version: '
|
77
|
+
version: '5.1'
|
64
78
|
- - "<"
|
65
79
|
- !ruby/object:Gem::Version
|
66
80
|
version: '5.3'
|
67
|
-
- !ruby/object:Gem::Dependency
|
68
|
-
name: bundler
|
69
|
-
requirement: !ruby/object:Gem::Requirement
|
70
|
-
requirements:
|
71
|
-
- - "~>"
|
72
|
-
- !ruby/object:Gem::Version
|
73
|
-
version: '1.6'
|
74
|
-
type: :development
|
75
|
-
prerelease: false
|
76
|
-
version_requirements: !ruby/object:Gem::Requirement
|
77
|
-
requirements:
|
78
|
-
- - "~>"
|
79
|
-
- !ruby/object:Gem::Version
|
80
|
-
version: '1.6'
|
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.
|
87
|
+
version: '3.8'
|
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.
|
94
|
+
version: '3.8'
|
95
95
|
- !ruby/object:Gem::Dependency
|
96
|
-
name: rspec-
|
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-
|
110
|
+
name: rspec-rails
|
111
111
|
requirement: !ruby/object:Gem::Requirement
|
112
112
|
requirements:
|
113
113
|
- - ">="
|
@@ -131,10 +131,10 @@ extra_rdoc_files:
|
|
131
131
|
- LICENSE.txt
|
132
132
|
files:
|
133
133
|
- ".gitignore"
|
134
|
+
- ".rubocop.yml"
|
134
135
|
- ".travis.yml"
|
135
136
|
- Changelog.md
|
136
137
|
- Gemfile
|
137
|
-
- Guardfile
|
138
138
|
- LICENSE.txt
|
139
139
|
- README.md
|
140
140
|
- Rakefile
|
@@ -150,6 +150,7 @@ files:
|
|
150
150
|
- lib/roadie/rails/mailer.rb
|
151
151
|
- lib/roadie/rails/options.rb
|
152
152
|
- lib/roadie/rails/railtie.rb
|
153
|
+
- lib/roadie/rails/utils.rb
|
153
154
|
- lib/roadie/rails/version.rb
|
154
155
|
- roadie-rails.gemspec
|
155
156
|
- setup.sh
|
@@ -165,7 +166,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
165
166
|
requirements:
|
166
167
|
- - ">="
|
167
168
|
- !ruby/object:Gem::Version
|
168
|
-
version: '2.
|
169
|
+
version: '2.5'
|
169
170
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
170
171
|
requirements:
|
171
172
|
- - ">="
|
@@ -173,7 +174,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
173
174
|
version: '0'
|
174
175
|
requirements: []
|
175
176
|
rubyforge_project:
|
176
|
-
rubygems_version: 2.
|
177
|
+
rubygems_version: 2.7.3
|
177
178
|
signing_key:
|
178
179
|
specification_version: 4
|
179
180
|
summary: Making HTML emails comfortable for the Rails rockstars
|
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
|
-
|