roadie-rails 1.0.0.pre1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +19 -0
- data/.travis.yml +15 -0
- data/Changelog.md +9 -0
- data/Gemfile +17 -0
- data/Guardfile +16 -0
- data/LICENSE.txt +22 -0
- data/README.md +317 -0
- data/Rakefile +14 -0
- data/Upgrading.md +70 -0
- data/lib/roadie-rails.rb +1 -0
- data/lib/roadie/rails.rb +21 -0
- data/lib/roadie/rails/asset_pipeline_provider.rb +24 -0
- data/lib/roadie/rails/automatic.rb +16 -0
- data/lib/roadie/rails/document_builder.rb +18 -0
- data/lib/roadie/rails/inline_on_delivery.rb +17 -0
- data/lib/roadie/rails/mail_inliner.rb +26 -0
- data/lib/roadie/rails/mailer.rb +14 -0
- data/lib/roadie/rails/options.rb +101 -0
- data/lib/roadie/rails/railtie.rb +22 -0
- data/lib/roadie/rails/version.rb +5 -0
- data/roadie-rails.gemspec +29 -0
- data/setup.sh +62 -0
- data/spec/integration_spec.rb +119 -0
- data/spec/lib/roadie/rails/asset_pipeline_provider_spec.rb +47 -0
- data/spec/lib/roadie/rails/automatic_spec.rb +44 -0
- data/spec/lib/roadie/rails/document_builder_spec.rb +20 -0
- data/spec/lib/roadie/rails/mail_inliner_spec.rb +57 -0
- data/spec/lib/roadie/rails/mailer_spec.rb +57 -0
- data/spec/lib/roadie/rails/options_spec.rb +136 -0
- data/spec/lib/roadie/rails/railtie_spec.rb +48 -0
- data/spec/railsapps/README.md +69 -0
- data/spec/railsapps/rails_30/.gitignore +2 -0
- data/spec/railsapps/rails_30/Gemfile +7 -0
- data/spec/railsapps/rails_30/app/mailers/auto_mailer.rb +17 -0
- data/spec/railsapps/rails_30/app/mailers/mailer.rb +17 -0
- data/spec/railsapps/rails_30/app/views/auto_mailer/normal_email.html.erb +11 -0
- data/spec/railsapps/rails_30/app/views/auto_mailer/normal_email.text +1 -0
- data/spec/railsapps/rails_30/app/views/mailer/normal_email.html.erb +11 -0
- data/spec/railsapps/rails_30/app/views/mailer/normal_email.text +1 -0
- data/spec/railsapps/rails_30/config/application.rb +19 -0
- data/spec/railsapps/rails_30/config/boot.rb +6 -0
- data/spec/railsapps/rails_30/config/environment.rb +5 -0
- data/spec/railsapps/rails_30/config/environments/development.rb +10 -0
- data/spec/railsapps/rails_30/config/initializers/secret_token.rb +1 -0
- data/spec/railsapps/rails_30/config/initializers/session_store.rb +1 -0
- data/spec/railsapps/rails_30/config/routes.rb +2 -0
- data/spec/railsapps/rails_30/public/images/rails.png +0 -0
- data/spec/railsapps/rails_30/public/stylesheets/email.css +2 -0
- data/spec/railsapps/rails_30/script/rails +6 -0
- data/spec/railsapps/rails_31/.gitignore +2 -0
- data/spec/railsapps/rails_31/Gemfile +11 -0
- data/spec/railsapps/rails_31/app/assets/images/rails.png +0 -0
- data/spec/railsapps/rails_31/app/assets/stylesheets/email.css.scss +2 -0
- data/spec/railsapps/rails_31/app/mailers/auto_mailer.rb +17 -0
- data/spec/railsapps/rails_31/app/mailers/mailer.rb +17 -0
- data/spec/railsapps/rails_31/app/views/auto_mailer/normal_email.html.erb +11 -0
- data/spec/railsapps/rails_31/app/views/auto_mailer/normal_email.text +1 -0
- data/spec/railsapps/rails_31/app/views/mailer/normal_email.html.erb +11 -0
- data/spec/railsapps/rails_31/app/views/mailer/normal_email.text +1 -0
- data/spec/railsapps/rails_31/config/application.rb +22 -0
- data/spec/railsapps/rails_31/config/boot.rb +6 -0
- data/spec/railsapps/rails_31/config/environment.rb +5 -0
- data/spec/railsapps/rails_31/config/environments/development.rb +11 -0
- data/spec/railsapps/rails_31/config/initializers/secret_token.rb +1 -0
- data/spec/railsapps/rails_31/config/initializers/session_store.rb +1 -0
- data/spec/railsapps/rails_31/config/initializers/wrap_parameters.rb +4 -0
- data/spec/railsapps/rails_31/config/routes.rb +2 -0
- data/spec/railsapps/rails_31/script/rails +6 -0
- data/spec/railsapps/rails_32/.gitignore +2 -0
- data/spec/railsapps/rails_32/Gemfile +11 -0
- data/spec/railsapps/rails_32/app/assets/images/rails.png +0 -0
- data/spec/railsapps/rails_32/app/assets/stylesheets/email.css.scss +2 -0
- data/spec/railsapps/rails_32/app/mailers/auto_mailer.rb +17 -0
- data/spec/railsapps/rails_32/app/mailers/mailer.rb +17 -0
- data/spec/railsapps/rails_32/app/views/auto_mailer/normal_email.html.erb +11 -0
- data/spec/railsapps/rails_32/app/views/auto_mailer/normal_email.text +1 -0
- data/spec/railsapps/rails_32/app/views/mailer/normal_email.html.erb +11 -0
- data/spec/railsapps/rails_32/app/views/mailer/normal_email.text +1 -0
- data/spec/railsapps/rails_32/config/application.rb +22 -0
- data/spec/railsapps/rails_32/config/boot.rb +6 -0
- data/spec/railsapps/rails_32/config/environment.rb +5 -0
- data/spec/railsapps/rails_32/config/environments/development.rb +11 -0
- data/spec/railsapps/rails_32/config/initializers/secret_token.rb +1 -0
- data/spec/railsapps/rails_32/config/initializers/session_store.rb +1 -0
- data/spec/railsapps/rails_32/config/initializers/wrap_parameters.rb +4 -0
- data/spec/railsapps/rails_32/config/routes.rb +2 -0
- data/spec/railsapps/rails_32/script/rails +6 -0
- data/spec/railsapps/rails_40/Gemfile +9 -0
- data/spec/railsapps/rails_40/app/assets/images/rails.png +0 -0
- data/spec/railsapps/rails_40/app/assets/stylesheets/email.css.scss +2 -0
- data/spec/railsapps/rails_40/app/mailers/auto_mailer.rb +17 -0
- data/spec/railsapps/rails_40/app/mailers/mailer.rb +17 -0
- data/spec/railsapps/rails_40/app/views/auto_mailer/normal_email.html.erb +11 -0
- data/spec/railsapps/rails_40/app/views/auto_mailer/normal_email.text +1 -0
- data/spec/railsapps/rails_40/app/views/mailer/normal_email.html.erb +11 -0
- data/spec/railsapps/rails_40/app/views/mailer/normal_email.text +1 -0
- data/spec/railsapps/rails_40/bin/rails +4 -0
- data/spec/railsapps/rails_40/config/application.rb +18 -0
- data/spec/railsapps/rails_40/config/boot.rb +4 -0
- data/spec/railsapps/rails_40/config/environment.rb +5 -0
- data/spec/railsapps/rails_40/config/environments/development.rb +9 -0
- data/spec/railsapps/rails_40/config/initializers/secret_token.rb +1 -0
- data/spec/railsapps/rails_40/config/initializers/session_store.rb +1 -0
- data/spec/railsapps/rails_40/config/routes.rb +2 -0
- data/spec/railsapps/rails_40_no_pipeline/Gemfile +9 -0
- data/spec/railsapps/rails_40_no_pipeline/app/mailers/auto_mailer.rb +17 -0
- data/spec/railsapps/rails_40_no_pipeline/app/mailers/mailer.rb +17 -0
- data/spec/railsapps/rails_40_no_pipeline/app/views/auto_mailer/normal_email.html.erb +11 -0
- data/spec/railsapps/rails_40_no_pipeline/app/views/auto_mailer/normal_email.text +1 -0
- data/spec/railsapps/rails_40_no_pipeline/app/views/mailer/normal_email.html.erb +11 -0
- data/spec/railsapps/rails_40_no_pipeline/app/views/mailer/normal_email.text +1 -0
- data/spec/railsapps/rails_40_no_pipeline/bin/rails +4 -0
- data/spec/railsapps/rails_40_no_pipeline/config/application.rb +19 -0
- data/spec/railsapps/rails_40_no_pipeline/config/boot.rb +4 -0
- data/spec/railsapps/rails_40_no_pipeline/config/environment.rb +5 -0
- data/spec/railsapps/rails_40_no_pipeline/config/environments/development.rb +9 -0
- data/spec/railsapps/rails_40_no_pipeline/config/initializers/secret_token.rb +1 -0
- data/spec/railsapps/rails_40_no_pipeline/config/initializers/session_store.rb +1 -0
- data/spec/railsapps/rails_40_no_pipeline/config/routes.rb +2 -0
- data/spec/railsapps/rails_40_no_pipeline/log/dee +0 -0
- data/spec/railsapps/rails_40_no_pipeline/public/images/rails.png +0 -0
- data/spec/railsapps/rails_40_no_pipeline/public/stylesheets/email.css +2 -0
- data/spec/railsapps/rails_40_precompiled/Gemfile +9 -0
- data/spec/railsapps/rails_40_precompiled/Rakefile +6 -0
- data/spec/railsapps/rails_40_precompiled/app/assets/images/rails.png +0 -0
- data/spec/railsapps/rails_40_precompiled/app/assets/stylesheets/email.css.scss +2 -0
- data/spec/railsapps/rails_40_precompiled/app/mailers/mailer.rb +17 -0
- data/spec/railsapps/rails_40_precompiled/app/views/mailer/normal_email.html.erb +11 -0
- data/spec/railsapps/rails_40_precompiled/app/views/mailer/normal_email.text +1 -0
- data/spec/railsapps/rails_40_precompiled/bin/rails +4 -0
- data/spec/railsapps/rails_40_precompiled/config/application.rb +18 -0
- data/spec/railsapps/rails_40_precompiled/config/boot.rb +4 -0
- data/spec/railsapps/rails_40_precompiled/config/environment.rb +5 -0
- data/spec/railsapps/rails_40_precompiled/config/environments/development.rb +14 -0
- data/spec/railsapps/rails_40_precompiled/config/initializers/secret_token.rb +1 -0
- data/spec/railsapps/rails_40_precompiled/config/initializers/session_store.rb +1 -0
- data/spec/railsapps/rails_40_precompiled/config/routes.rb +2 -0
- data/spec/railsapps/rails_40_precompiled/public/assets/email-fad0c62b8f82e2835c1d0bdc19894257.css +5 -0
- data/spec/railsapps/rails_40_precompiled/public/assets/email-fad0c62b8f82e2835c1d0bdc19894257.css.gz +0 -0
- data/spec/railsapps/rails_40_precompiled/public/assets/manifest-8a3d16aeb2a40fe5057dd998c3edab10.json +1 -0
- data/spec/railsapps/rails_40_precompiled/public/assets/rails-231a680f23887d9dd70710ea5efd3c62.png +0 -0
- data/spec/railsapps/rails_41/.gitignore +16 -0
- data/spec/railsapps/rails_41/Gemfile +8 -0
- data/spec/railsapps/rails_41/app/assets/images/rails.png +0 -0
- data/spec/railsapps/rails_41/app/assets/stylesheets/email.css.scss +2 -0
- data/spec/railsapps/rails_41/app/mailers/auto_mailer.rb +17 -0
- data/spec/railsapps/rails_41/app/mailers/mailer.rb +17 -0
- data/spec/railsapps/rails_41/app/views/auto_mailer/normal_email.html.erb +11 -0
- data/spec/railsapps/rails_41/app/views/auto_mailer/normal_email.text +1 -0
- data/spec/railsapps/rails_41/app/views/mailer/normal_email.html.erb +11 -0
- data/spec/railsapps/rails_41/app/views/mailer/normal_email.text +1 -0
- data/spec/railsapps/rails_41/bin/rails +4 -0
- data/spec/railsapps/rails_41/config.ru +4 -0
- data/spec/railsapps/rails_41/config/application.rb +13 -0
- data/spec/railsapps/rails_41/config/boot.rb +4 -0
- data/spec/railsapps/rails_41/config/environment.rb +5 -0
- data/spec/railsapps/rails_41/config/environments/development.rb +9 -0
- data/spec/railsapps/rails_41/config/initializers/secret_token.rb +1 -0
- data/spec/railsapps/rails_41/config/initializers/session_store.rb +1 -0
- data/spec/railsapps/rails_41/config/routes.rb +2 -0
- data/spec/spec_helper.rb +14 -0
- data/spec/support/have_selector_matcher.rb +3 -0
- data/spec/support/have_styling_matcher.rb +63 -0
- data/spec/support/rails_app.rb +70 -0
- metadata +443 -0
data/Upgrading.md
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
# Upgrading from Roadie 2
|
|
2
|
+
|
|
3
|
+
## Project
|
|
4
|
+
|
|
5
|
+
Start by adding `roadie-rails` to your `Gemfile`. Remember to specify version requirements!
|
|
6
|
+
|
|
7
|
+
You'll need to change your configuration too. The main change is that Roadie now uses its own configuration for URL options:
|
|
8
|
+
|
|
9
|
+
```ruby
|
|
10
|
+
config.roadie.url_options = {host: "myapp.com"}
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Most other options should be easy to convert:
|
|
14
|
+
|
|
15
|
+
```ruby
|
|
16
|
+
config.roadie.enabled => Removed
|
|
17
|
+
# Override `#roadie_options` in the mailers to control enabling (if using Automatic) or do it manually (if using Mailer).
|
|
18
|
+
|
|
19
|
+
config.roadie.before_inlining => config.roadie.before_transformation
|
|
20
|
+
config.roadie.provider => config.roadie.asset_providers
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## Mailers
|
|
24
|
+
|
|
25
|
+
Next, find all mailers that you want to inline and include the `Roadie::Rails::Automatic` module:
|
|
26
|
+
|
|
27
|
+
```ruby
|
|
28
|
+
class MyMailer < ActionMailer::Base
|
|
29
|
+
include Roadie::Rails::Automatic
|
|
30
|
+
|
|
31
|
+
def cool_mail
|
|
32
|
+
mail(options)
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
You'll also need to remove any uses of the `:css` option to `mail` and `default_options`. Include CSS files by using `stylesheet_link_tag` instead.
|
|
38
|
+
|
|
39
|
+
**Before:**
|
|
40
|
+
|
|
41
|
+
```ruby
|
|
42
|
+
class MyMailer < ActionMailer::Base
|
|
43
|
+
defaults css: :email
|
|
44
|
+
|
|
45
|
+
def cool
|
|
46
|
+
mail(css: [:email, :cool])
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
** After:**
|
|
53
|
+
|
|
54
|
+
```erb
|
|
55
|
+
<head>
|
|
56
|
+
<%= stylesheet_link_tag :email, :cool %>
|
|
57
|
+
</head>
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
## Views
|
|
61
|
+
|
|
62
|
+
Search through your templates after uses of `data-immutable` and change them to `data-roadie-ignore`.
|
|
63
|
+
|
|
64
|
+
## Tests
|
|
65
|
+
|
|
66
|
+
If your tests relied on the styles being applied, they will fail unless you deliver the email. `Roadie::Rails::Automatic` does not inline stylesheets when you don't deliver the email. Either change how your tests work, or call `deliver` on the generated emails where you need it. If the problem is major, switch from `Roadie::Rails::Automatic` to `Roadie::Rails::Mailer` and follow the instructions in the documentation.
|
|
67
|
+
|
|
68
|
+
## Custom asset providers
|
|
69
|
+
|
|
70
|
+
The API has changed a bit. Read the new examples in the README and you should be able to convert without any great effort.
|
data/lib/roadie-rails.rb
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
require 'roadie/rails'
|
data/lib/roadie/rails.rb
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
module Roadie
|
|
2
|
+
module Rails
|
|
3
|
+
end
|
|
4
|
+
end
|
|
5
|
+
|
|
6
|
+
require "roadie"
|
|
7
|
+
|
|
8
|
+
require "roadie/rails/version"
|
|
9
|
+
require "roadie/rails/options"
|
|
10
|
+
|
|
11
|
+
require "roadie/rails/document_builder"
|
|
12
|
+
require "roadie/rails/mail_inliner"
|
|
13
|
+
|
|
14
|
+
require "roadie/rails/asset_pipeline_provider"
|
|
15
|
+
|
|
16
|
+
require "roadie/rails/mailer"
|
|
17
|
+
|
|
18
|
+
require "roadie/rails/automatic"
|
|
19
|
+
require "roadie/rails/inline_on_delivery"
|
|
20
|
+
|
|
21
|
+
require "roadie/rails/railtie"
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
module Roadie
|
|
2
|
+
module Rails
|
|
3
|
+
class AssetPipelineProvider
|
|
4
|
+
include Roadie::AssetProvider
|
|
5
|
+
attr_reader :pipeline
|
|
6
|
+
|
|
7
|
+
def initialize(pipeline)
|
|
8
|
+
super()
|
|
9
|
+
@pipeline = pipeline
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def find_stylesheet(name)
|
|
13
|
+
if (asset = @pipeline[normalize_asset_name name])
|
|
14
|
+
Stylesheet.new("#{asset.pathname} (live compiled)", asset.to_s)
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
private
|
|
19
|
+
def normalize_asset_name(href)
|
|
20
|
+
File.basename href.split('?').first
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
module Roadie
|
|
2
|
+
module Rails
|
|
3
|
+
module Automatic
|
|
4
|
+
def mail(*args, &block)
|
|
5
|
+
super.tap do |email|
|
|
6
|
+
email.extend InlineOnDelivery
|
|
7
|
+
email.roadie_options = roadie_options.dup
|
|
8
|
+
end
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def roadie_options
|
|
12
|
+
::Rails.application.config.roadie
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
module Roadie
|
|
2
|
+
module Rails
|
|
3
|
+
class DocumentBuilder
|
|
4
|
+
class << self
|
|
5
|
+
def build(html, options)
|
|
6
|
+
new.build(html, options)
|
|
7
|
+
end
|
|
8
|
+
private :new
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def build(html, options)
|
|
12
|
+
document = Document.new(html)
|
|
13
|
+
options.apply_to document
|
|
14
|
+
document
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
module Roadie
|
|
2
|
+
module Rails
|
|
3
|
+
# Extend instances of Mail with this to have it inlined automatically when
|
|
4
|
+
# delivered. You'll need to assign some #roadie_options for it to actually
|
|
5
|
+
# do anything.
|
|
6
|
+
module InlineOnDelivery
|
|
7
|
+
attr_accessor :roadie_options
|
|
8
|
+
|
|
9
|
+
def deliver
|
|
10
|
+
if (options = roadie_options)
|
|
11
|
+
MailInliner.new(self, options).execute
|
|
12
|
+
end
|
|
13
|
+
super
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
module Roadie
|
|
2
|
+
module Rails
|
|
3
|
+
class MailInliner
|
|
4
|
+
attr_reader :email, :options
|
|
5
|
+
|
|
6
|
+
def initialize(email, options)
|
|
7
|
+
@email = email
|
|
8
|
+
@options = options
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def execute
|
|
12
|
+
improve_html_part(email.html_part) if email.html_part
|
|
13
|
+
email
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
private
|
|
17
|
+
def improve_html_part(html_part)
|
|
18
|
+
html_part.body = make_new_html(html_part.body.decoded)
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def make_new_html(old_html)
|
|
22
|
+
DocumentBuilder.build(old_html, options).transform
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
module Roadie
|
|
2
|
+
module Rails
|
|
3
|
+
module Mailer
|
|
4
|
+
def roadie_mail(options = {}, &block)
|
|
5
|
+
email = mail(options, &block)
|
|
6
|
+
MailInliner.new(email, roadie_options).execute
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
def roadie_options
|
|
10
|
+
::Rails.application.config.roadie
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
end
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
module Roadie
|
|
2
|
+
module Rails
|
|
3
|
+
class Options
|
|
4
|
+
private
|
|
5
|
+
ATTRIBUTE_NAMES = [:url_options, :before_transformation, :after_transformation, :asset_providers]
|
|
6
|
+
|
|
7
|
+
public
|
|
8
|
+
attr_reader *ATTRIBUTE_NAMES
|
|
9
|
+
|
|
10
|
+
def initialize(options = {})
|
|
11
|
+
complain_about_unknown_keys options.keys
|
|
12
|
+
self.url_options = options[:url_options]
|
|
13
|
+
self.before_transformation = options[:before_transformation]
|
|
14
|
+
self.after_transformation = options[:after_transformation]
|
|
15
|
+
self.asset_providers = options[:asset_providers]
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def url_options=(options)
|
|
19
|
+
@url_options = options
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def before_transformation=(callback)
|
|
23
|
+
@before_transformation = callback
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def after_transformation=(callback)
|
|
27
|
+
@after_transformation = callback
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def asset_providers=(providers)
|
|
31
|
+
if providers
|
|
32
|
+
@asset_providers = ProviderList.wrap providers
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def apply_to(document)
|
|
37
|
+
document.url_options = url_options
|
|
38
|
+
document.before_transformation = before_transformation
|
|
39
|
+
document.after_transformation = after_transformation
|
|
40
|
+
document.asset_providers = asset_providers
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def merge(options)
|
|
44
|
+
dup.merge! options
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
def merge!(options)
|
|
48
|
+
[:url_options, :before_transformation, :after_transformation, :asset_providers].each do |attribute|
|
|
49
|
+
send "#{attribute}=", options.fetch(attribute, send(attribute))
|
|
50
|
+
end
|
|
51
|
+
self
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
def combine(options)
|
|
55
|
+
dup.combine! options
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
def combine!(options)
|
|
59
|
+
self.url_options = combine_hash url_options, options[:url_options]
|
|
60
|
+
self.before_transformation = combine_callable before_transformation, options[:before_transformation]
|
|
61
|
+
self.after_transformation = combine_callable after_transformation, options[:after_transformation]
|
|
62
|
+
self.asset_providers = combine_providers asset_providers, options[:asset_providers]
|
|
63
|
+
self
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
private
|
|
67
|
+
def combine_hash(first, second)
|
|
68
|
+
combine_nilable(first, second) do |a, b|
|
|
69
|
+
a.merge(b)
|
|
70
|
+
end
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
def combine_callable(first, second)
|
|
74
|
+
combine_nilable(first, second) do |a, b|
|
|
75
|
+
proc { |*args| a.call(*args); b.call(*args) }
|
|
76
|
+
end
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
def combine_providers(first, second)
|
|
80
|
+
combine_nilable(first, second) do |a, b|
|
|
81
|
+
ProviderList.new a.to_a + Array.wrap(b)
|
|
82
|
+
end
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
def combine_nilable(first, second)
|
|
86
|
+
if first && second
|
|
87
|
+
yield first, second
|
|
88
|
+
else
|
|
89
|
+
first ? first : second
|
|
90
|
+
end
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
def complain_about_unknown_keys(keys)
|
|
94
|
+
invalid_keys = keys - ATTRIBUTE_NAMES
|
|
95
|
+
if invalid_keys.size > 0
|
|
96
|
+
raise ArgumentError, "Unknown configuration parameters: #{invalid_keys}", caller(1)
|
|
97
|
+
end
|
|
98
|
+
end
|
|
99
|
+
end
|
|
100
|
+
end
|
|
101
|
+
end
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
require 'rails'
|
|
2
|
+
|
|
3
|
+
module Roadie
|
|
4
|
+
module Rails
|
|
5
|
+
class Railtie < ::Rails::Railtie
|
|
6
|
+
config.roadie = Roadie::Rails::Options.new
|
|
7
|
+
|
|
8
|
+
initializer "roadie-rails.setup" do |app|
|
|
9
|
+
config.roadie.asset_providers = [
|
|
10
|
+
Roadie::FilesystemProvider.new(::Rails.root.join("public").to_s),
|
|
11
|
+
]
|
|
12
|
+
|
|
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
|
|
17
|
+
config.roadie.asset_providers << AssetPipelineProvider.new(app.assets)
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
|
+
require 'roadie/rails/version'
|
|
5
|
+
|
|
6
|
+
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"
|
|
15
|
+
|
|
16
|
+
spec.files = `git ls-files`.split($/)
|
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
|
19
|
+
spec.extra_rdoc_files = %w[README.md Changelog.md LICENSE.txt]
|
|
20
|
+
spec.require_paths = ["lib"]
|
|
21
|
+
|
|
22
|
+
spec.add_dependency "roadie", "~> 3.0.0.pre1"
|
|
23
|
+
spec.add_dependency "rails", ">= 3.0", "< 4.2"
|
|
24
|
+
|
|
25
|
+
spec.add_development_dependency "bundler", "~> 1.6"
|
|
26
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
|
27
|
+
spec.add_development_dependency "rspec-rails"
|
|
28
|
+
spec.add_development_dependency "rspec-collection_matchers"
|
|
29
|
+
end
|
data/setup.sh
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
|
|
3
|
+
# This cannot be executed from within a Ruby-based environment (like Rake)
|
|
4
|
+
# since Bundler will affect the subshell environments.
|
|
5
|
+
|
|
6
|
+
set -e
|
|
7
|
+
|
|
8
|
+
function header() {
|
|
9
|
+
echo -e "\n$(tput setaf 5)$(tput smul)$1:$(tput sgr0)"
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
function green() {
|
|
13
|
+
echo $(tput setaf 2)$@$(tput sgr0)
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
function update() {
|
|
17
|
+
bundle update | grep -ve "^Using "
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
function install() {
|
|
21
|
+
bundle install --quiet && green " OK"
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
root=$(dirname $0)
|
|
25
|
+
|
|
26
|
+
# Set by Travis CI; interferes with the nested repos
|
|
27
|
+
unset BUNDLE_GEMFILE
|
|
28
|
+
|
|
29
|
+
if [[ $1 == "install" ]]; then
|
|
30
|
+
header "Installing gem dependencies"
|
|
31
|
+
install
|
|
32
|
+
|
|
33
|
+
for app_path in $root/spec/railsapps/rails_*; do
|
|
34
|
+
(
|
|
35
|
+
cd $app_path
|
|
36
|
+
header "Installing gems for $(basename $app_path)"
|
|
37
|
+
install
|
|
38
|
+
)
|
|
39
|
+
done
|
|
40
|
+
echo ""
|
|
41
|
+
|
|
42
|
+
elif [[ $1 == "update" ]]; then
|
|
43
|
+
header "Updating gem dependencies"
|
|
44
|
+
update
|
|
45
|
+
|
|
46
|
+
for app_path in $root/spec/railsapps/rails_*; do
|
|
47
|
+
(
|
|
48
|
+
cd $app_path
|
|
49
|
+
header "Updating $(basename $app_path)"
|
|
50
|
+
update
|
|
51
|
+
)
|
|
52
|
+
done
|
|
53
|
+
echo ""
|
|
54
|
+
|
|
55
|
+
else
|
|
56
|
+
echo "Usage: $0 [install|update]"
|
|
57
|
+
echo ""
|
|
58
|
+
echo " Install: Install all bundled updates."
|
|
59
|
+
echo " Update: Run bundle update on all bundles."
|
|
60
|
+
echo ""
|
|
61
|
+
exit 127
|
|
62
|
+
fi
|