roadie-rails 1.0.0.pre1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (166) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +19 -0
  3. data/.travis.yml +15 -0
  4. data/Changelog.md +9 -0
  5. data/Gemfile +17 -0
  6. data/Guardfile +16 -0
  7. data/LICENSE.txt +22 -0
  8. data/README.md +317 -0
  9. data/Rakefile +14 -0
  10. data/Upgrading.md +70 -0
  11. data/lib/roadie-rails.rb +1 -0
  12. data/lib/roadie/rails.rb +21 -0
  13. data/lib/roadie/rails/asset_pipeline_provider.rb +24 -0
  14. data/lib/roadie/rails/automatic.rb +16 -0
  15. data/lib/roadie/rails/document_builder.rb +18 -0
  16. data/lib/roadie/rails/inline_on_delivery.rb +17 -0
  17. data/lib/roadie/rails/mail_inliner.rb +26 -0
  18. data/lib/roadie/rails/mailer.rb +14 -0
  19. data/lib/roadie/rails/options.rb +101 -0
  20. data/lib/roadie/rails/railtie.rb +22 -0
  21. data/lib/roadie/rails/version.rb +5 -0
  22. data/roadie-rails.gemspec +29 -0
  23. data/setup.sh +62 -0
  24. data/spec/integration_spec.rb +119 -0
  25. data/spec/lib/roadie/rails/asset_pipeline_provider_spec.rb +47 -0
  26. data/spec/lib/roadie/rails/automatic_spec.rb +44 -0
  27. data/spec/lib/roadie/rails/document_builder_spec.rb +20 -0
  28. data/spec/lib/roadie/rails/mail_inliner_spec.rb +57 -0
  29. data/spec/lib/roadie/rails/mailer_spec.rb +57 -0
  30. data/spec/lib/roadie/rails/options_spec.rb +136 -0
  31. data/spec/lib/roadie/rails/railtie_spec.rb +48 -0
  32. data/spec/railsapps/README.md +69 -0
  33. data/spec/railsapps/rails_30/.gitignore +2 -0
  34. data/spec/railsapps/rails_30/Gemfile +7 -0
  35. data/spec/railsapps/rails_30/app/mailers/auto_mailer.rb +17 -0
  36. data/spec/railsapps/rails_30/app/mailers/mailer.rb +17 -0
  37. data/spec/railsapps/rails_30/app/views/auto_mailer/normal_email.html.erb +11 -0
  38. data/spec/railsapps/rails_30/app/views/auto_mailer/normal_email.text +1 -0
  39. data/spec/railsapps/rails_30/app/views/mailer/normal_email.html.erb +11 -0
  40. data/spec/railsapps/rails_30/app/views/mailer/normal_email.text +1 -0
  41. data/spec/railsapps/rails_30/config/application.rb +19 -0
  42. data/spec/railsapps/rails_30/config/boot.rb +6 -0
  43. data/spec/railsapps/rails_30/config/environment.rb +5 -0
  44. data/spec/railsapps/rails_30/config/environments/development.rb +10 -0
  45. data/spec/railsapps/rails_30/config/initializers/secret_token.rb +1 -0
  46. data/spec/railsapps/rails_30/config/initializers/session_store.rb +1 -0
  47. data/spec/railsapps/rails_30/config/routes.rb +2 -0
  48. data/spec/railsapps/rails_30/public/images/rails.png +0 -0
  49. data/spec/railsapps/rails_30/public/stylesheets/email.css +2 -0
  50. data/spec/railsapps/rails_30/script/rails +6 -0
  51. data/spec/railsapps/rails_31/.gitignore +2 -0
  52. data/spec/railsapps/rails_31/Gemfile +11 -0
  53. data/spec/railsapps/rails_31/app/assets/images/rails.png +0 -0
  54. data/spec/railsapps/rails_31/app/assets/stylesheets/email.css.scss +2 -0
  55. data/spec/railsapps/rails_31/app/mailers/auto_mailer.rb +17 -0
  56. data/spec/railsapps/rails_31/app/mailers/mailer.rb +17 -0
  57. data/spec/railsapps/rails_31/app/views/auto_mailer/normal_email.html.erb +11 -0
  58. data/spec/railsapps/rails_31/app/views/auto_mailer/normal_email.text +1 -0
  59. data/spec/railsapps/rails_31/app/views/mailer/normal_email.html.erb +11 -0
  60. data/spec/railsapps/rails_31/app/views/mailer/normal_email.text +1 -0
  61. data/spec/railsapps/rails_31/config/application.rb +22 -0
  62. data/spec/railsapps/rails_31/config/boot.rb +6 -0
  63. data/spec/railsapps/rails_31/config/environment.rb +5 -0
  64. data/spec/railsapps/rails_31/config/environments/development.rb +11 -0
  65. data/spec/railsapps/rails_31/config/initializers/secret_token.rb +1 -0
  66. data/spec/railsapps/rails_31/config/initializers/session_store.rb +1 -0
  67. data/spec/railsapps/rails_31/config/initializers/wrap_parameters.rb +4 -0
  68. data/spec/railsapps/rails_31/config/routes.rb +2 -0
  69. data/spec/railsapps/rails_31/script/rails +6 -0
  70. data/spec/railsapps/rails_32/.gitignore +2 -0
  71. data/spec/railsapps/rails_32/Gemfile +11 -0
  72. data/spec/railsapps/rails_32/app/assets/images/rails.png +0 -0
  73. data/spec/railsapps/rails_32/app/assets/stylesheets/email.css.scss +2 -0
  74. data/spec/railsapps/rails_32/app/mailers/auto_mailer.rb +17 -0
  75. data/spec/railsapps/rails_32/app/mailers/mailer.rb +17 -0
  76. data/spec/railsapps/rails_32/app/views/auto_mailer/normal_email.html.erb +11 -0
  77. data/spec/railsapps/rails_32/app/views/auto_mailer/normal_email.text +1 -0
  78. data/spec/railsapps/rails_32/app/views/mailer/normal_email.html.erb +11 -0
  79. data/spec/railsapps/rails_32/app/views/mailer/normal_email.text +1 -0
  80. data/spec/railsapps/rails_32/config/application.rb +22 -0
  81. data/spec/railsapps/rails_32/config/boot.rb +6 -0
  82. data/spec/railsapps/rails_32/config/environment.rb +5 -0
  83. data/spec/railsapps/rails_32/config/environments/development.rb +11 -0
  84. data/spec/railsapps/rails_32/config/initializers/secret_token.rb +1 -0
  85. data/spec/railsapps/rails_32/config/initializers/session_store.rb +1 -0
  86. data/spec/railsapps/rails_32/config/initializers/wrap_parameters.rb +4 -0
  87. data/spec/railsapps/rails_32/config/routes.rb +2 -0
  88. data/spec/railsapps/rails_32/script/rails +6 -0
  89. data/spec/railsapps/rails_40/Gemfile +9 -0
  90. data/spec/railsapps/rails_40/app/assets/images/rails.png +0 -0
  91. data/spec/railsapps/rails_40/app/assets/stylesheets/email.css.scss +2 -0
  92. data/spec/railsapps/rails_40/app/mailers/auto_mailer.rb +17 -0
  93. data/spec/railsapps/rails_40/app/mailers/mailer.rb +17 -0
  94. data/spec/railsapps/rails_40/app/views/auto_mailer/normal_email.html.erb +11 -0
  95. data/spec/railsapps/rails_40/app/views/auto_mailer/normal_email.text +1 -0
  96. data/spec/railsapps/rails_40/app/views/mailer/normal_email.html.erb +11 -0
  97. data/spec/railsapps/rails_40/app/views/mailer/normal_email.text +1 -0
  98. data/spec/railsapps/rails_40/bin/rails +4 -0
  99. data/spec/railsapps/rails_40/config/application.rb +18 -0
  100. data/spec/railsapps/rails_40/config/boot.rb +4 -0
  101. data/spec/railsapps/rails_40/config/environment.rb +5 -0
  102. data/spec/railsapps/rails_40/config/environments/development.rb +9 -0
  103. data/spec/railsapps/rails_40/config/initializers/secret_token.rb +1 -0
  104. data/spec/railsapps/rails_40/config/initializers/session_store.rb +1 -0
  105. data/spec/railsapps/rails_40/config/routes.rb +2 -0
  106. data/spec/railsapps/rails_40_no_pipeline/Gemfile +9 -0
  107. data/spec/railsapps/rails_40_no_pipeline/app/mailers/auto_mailer.rb +17 -0
  108. data/spec/railsapps/rails_40_no_pipeline/app/mailers/mailer.rb +17 -0
  109. data/spec/railsapps/rails_40_no_pipeline/app/views/auto_mailer/normal_email.html.erb +11 -0
  110. data/spec/railsapps/rails_40_no_pipeline/app/views/auto_mailer/normal_email.text +1 -0
  111. data/spec/railsapps/rails_40_no_pipeline/app/views/mailer/normal_email.html.erb +11 -0
  112. data/spec/railsapps/rails_40_no_pipeline/app/views/mailer/normal_email.text +1 -0
  113. data/spec/railsapps/rails_40_no_pipeline/bin/rails +4 -0
  114. data/spec/railsapps/rails_40_no_pipeline/config/application.rb +19 -0
  115. data/spec/railsapps/rails_40_no_pipeline/config/boot.rb +4 -0
  116. data/spec/railsapps/rails_40_no_pipeline/config/environment.rb +5 -0
  117. data/spec/railsapps/rails_40_no_pipeline/config/environments/development.rb +9 -0
  118. data/spec/railsapps/rails_40_no_pipeline/config/initializers/secret_token.rb +1 -0
  119. data/spec/railsapps/rails_40_no_pipeline/config/initializers/session_store.rb +1 -0
  120. data/spec/railsapps/rails_40_no_pipeline/config/routes.rb +2 -0
  121. data/spec/railsapps/rails_40_no_pipeline/log/dee +0 -0
  122. data/spec/railsapps/rails_40_no_pipeline/public/images/rails.png +0 -0
  123. data/spec/railsapps/rails_40_no_pipeline/public/stylesheets/email.css +2 -0
  124. data/spec/railsapps/rails_40_precompiled/Gemfile +9 -0
  125. data/spec/railsapps/rails_40_precompiled/Rakefile +6 -0
  126. data/spec/railsapps/rails_40_precompiled/app/assets/images/rails.png +0 -0
  127. data/spec/railsapps/rails_40_precompiled/app/assets/stylesheets/email.css.scss +2 -0
  128. data/spec/railsapps/rails_40_precompiled/app/mailers/mailer.rb +17 -0
  129. data/spec/railsapps/rails_40_precompiled/app/views/mailer/normal_email.html.erb +11 -0
  130. data/spec/railsapps/rails_40_precompiled/app/views/mailer/normal_email.text +1 -0
  131. data/spec/railsapps/rails_40_precompiled/bin/rails +4 -0
  132. data/spec/railsapps/rails_40_precompiled/config/application.rb +18 -0
  133. data/spec/railsapps/rails_40_precompiled/config/boot.rb +4 -0
  134. data/spec/railsapps/rails_40_precompiled/config/environment.rb +5 -0
  135. data/spec/railsapps/rails_40_precompiled/config/environments/development.rb +14 -0
  136. data/spec/railsapps/rails_40_precompiled/config/initializers/secret_token.rb +1 -0
  137. data/spec/railsapps/rails_40_precompiled/config/initializers/session_store.rb +1 -0
  138. data/spec/railsapps/rails_40_precompiled/config/routes.rb +2 -0
  139. data/spec/railsapps/rails_40_precompiled/public/assets/email-fad0c62b8f82e2835c1d0bdc19894257.css +5 -0
  140. data/spec/railsapps/rails_40_precompiled/public/assets/email-fad0c62b8f82e2835c1d0bdc19894257.css.gz +0 -0
  141. data/spec/railsapps/rails_40_precompiled/public/assets/manifest-8a3d16aeb2a40fe5057dd998c3edab10.json +1 -0
  142. data/spec/railsapps/rails_40_precompiled/public/assets/rails-231a680f23887d9dd70710ea5efd3c62.png +0 -0
  143. data/spec/railsapps/rails_41/.gitignore +16 -0
  144. data/spec/railsapps/rails_41/Gemfile +8 -0
  145. data/spec/railsapps/rails_41/app/assets/images/rails.png +0 -0
  146. data/spec/railsapps/rails_41/app/assets/stylesheets/email.css.scss +2 -0
  147. data/spec/railsapps/rails_41/app/mailers/auto_mailer.rb +17 -0
  148. data/spec/railsapps/rails_41/app/mailers/mailer.rb +17 -0
  149. data/spec/railsapps/rails_41/app/views/auto_mailer/normal_email.html.erb +11 -0
  150. data/spec/railsapps/rails_41/app/views/auto_mailer/normal_email.text +1 -0
  151. data/spec/railsapps/rails_41/app/views/mailer/normal_email.html.erb +11 -0
  152. data/spec/railsapps/rails_41/app/views/mailer/normal_email.text +1 -0
  153. data/spec/railsapps/rails_41/bin/rails +4 -0
  154. data/spec/railsapps/rails_41/config.ru +4 -0
  155. data/spec/railsapps/rails_41/config/application.rb +13 -0
  156. data/spec/railsapps/rails_41/config/boot.rb +4 -0
  157. data/spec/railsapps/rails_41/config/environment.rb +5 -0
  158. data/spec/railsapps/rails_41/config/environments/development.rb +9 -0
  159. data/spec/railsapps/rails_41/config/initializers/secret_token.rb +1 -0
  160. data/spec/railsapps/rails_41/config/initializers/session_store.rb +1 -0
  161. data/spec/railsapps/rails_41/config/routes.rb +2 -0
  162. data/spec/spec_helper.rb +14 -0
  163. data/spec/support/have_selector_matcher.rb +3 -0
  164. data/spec/support/have_styling_matcher.rb +63 -0
  165. data/spec/support/rails_app.rb +70 -0
  166. metadata +443 -0
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 964013dea5eca0f622fc24a88b3dc4efdbfc5519
4
+ data.tar.gz: 58b489303032269e9750ebaa39dd39d96b5a72cb
5
+ SHA512:
6
+ metadata.gz: 8da2753c4dfcdec5d7b1b1f6d1e6ce9326b84526af24b51c7f0143fb277d698b430a17a019fbf0788608488412e56280a5c97fed753065ddf744fa95d5ce1d73
7
+ data.tar.gz: 94a4856d0196a0b0bd7c48bc3a3372e2edbc650e8abef706f1a71f78d682497576a902334c04e14d45233b01c4c399ae9fe340d1a6b96f7cde60f0502f90bf53
@@ -0,0 +1,19 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ .ruby-version
7
+ Gemfile.lock
8
+ InstalledFiles
9
+ _yardoc
10
+ coverage
11
+ doc/
12
+ lib/bundler/man
13
+ pkg
14
+ rdoc
15
+ spec/reports
16
+ test/tmp
17
+ test/version_tmp
18
+ tmp
19
+ **/*.log
@@ -0,0 +1,15 @@
1
+ language: ruby
2
+ rvm:
3
+ - 1.9.3
4
+ - 2.0.0
5
+ - 2.1.2
6
+ - jruby
7
+ - rbx
8
+
9
+ bundler_args: --without guard
10
+ script: "rake"
11
+
12
+ matrix:
13
+ allow_failures:
14
+ - rvm: rbx
15
+ - rvm: jruby
@@ -0,0 +1,9 @@
1
+ ### development version
2
+
3
+ [full changelog](https://github.com/Mange/roadie/compare/v1.0.0.pre1...master)
4
+
5
+ ### 1.0.0.pre1
6
+
7
+ [full changelog](https://github.com/Mange/roadie/compare/0000000...v1.0.0.pre1)
8
+
9
+ * First implementation
data/Gemfile ADDED
@@ -0,0 +1,17 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in roadie-rails.gemspec
4
+ gemspec
5
+
6
+ # Use git version of `roadie` until a full release have been made
7
+ gem 'roadie', git: 'git://github.com/Mange/roadie.git', branch: 'master'
8
+
9
+ # Additional development dependencies I use but don't want to declare in the
10
+ # gemfile since they aren't required to develop this codebase.
11
+ group :development do
12
+ gem 'guard'
13
+ gem 'guard-rspec'
14
+ end
15
+
16
+ # Added here so it does not show up on the Gemspec; I only want it for CI builds
17
+ gem 'coveralls', group: :test, require: nil
@@ -0,0 +1,16 @@
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
+
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Magnus Bergmark
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,317 @@
1
+ # roadie-rails
2
+
3
+ [![Build history and status](https://secure.travis-ci.org/Mange/roadie-rails.png)](http://travis-ci.org/#!/Mange/roadie-rails)
4
+ [![Code Climate](https://codeclimate.com/github/Mange/roadie-rails.png)](https://codeclimate.com/github/Mange/roadie-rails)
5
+ [![Coverage Status](https://coveralls.io/repos/Mange/roadie-rails/badge.png?branch=master)](https://coveralls.io/r/Mange/roadie-rails?branch=master)
6
+ [![Gem Version](https://badge.fury.io/rb/roadie-rails.png)](http://badge.fury.io/rb/roadie-rails)
7
+ [![Dependency Status](https://gemnasium.com/Mange/roadie-rails.png)](https://gemnasium.com/Mange/roadie-rails)
8
+
9
+ > Making HTML emails comfortable for the Rails rockstars.
10
+
11
+ **Note:** You probably want to use [Roadie 2.4][roadie2] for your Rails application right now. Roadie 3 and roadie-rails have no stable releases yet.
12
+
13
+ ---
14
+
15
+ This gem hooks up your Rails application with Roadie to help you generate HTML emails.
16
+
17
+ ## Installation ##
18
+
19
+ [Add this gem to your Gemfile as recommended by Rubygems][gem] and run `bundle install`.
20
+
21
+ ```ruby
22
+ gem 'roadie-rails', '~> x.y.0'
23
+ ```
24
+
25
+ ## Usage ##
26
+
27
+ `roadie-rails` have two primary means of usage. The first on is the "Automatic usage", which does almost everything automatically. It's the easiest way to hit the ground running in order to see if `roadie` would be a good fit for your application.
28
+
29
+ As soon as you require some more "advanced" features (congratulations!), you should migrate to the "Manual usage" which entails that you do some things by yourself.
30
+
31
+ ### Automatic usage ###
32
+
33
+ Include the `Roadie::Rails::Automatic` module inside your mailer. Roadie will do its magic when you try to deliver the message:
34
+
35
+ ```ruby
36
+ class NewsletterMailer < ActionMailer::Base
37
+ include Roadie::Rails::Automatic
38
+
39
+ def user_newsletter(user)
40
+ mail to: user.email, subject: subject_for_user(user)
41
+ end
42
+
43
+ private
44
+ def subject_for_user(user)
45
+ I18n.translate 'emails.user_newsletter.subject', name: user.name
46
+ end
47
+ end
48
+
49
+ # email has the original body; Roadie has not been invoked yet
50
+ email = NewsletterMailer.user_newsletter(User.first)
51
+
52
+ # This triggers Roadie inlining and will deliver the email with inlined styles
53
+ email.deliver
54
+ ```
55
+
56
+ By overriding the `#roadie_options` method in the mailer you can disable inlining in certain cases:
57
+
58
+ ```ruby
59
+ class NewsletterMailer < ActionMailer::Base
60
+ include Roadie::Rails::Automatic
61
+
62
+ private
63
+ def roadie_options
64
+ super unless Rails.env.test?
65
+ end
66
+ end
67
+ ```
68
+
69
+ Another way:
70
+
71
+ ```ruby
72
+ describe YourMailer do
73
+ describe "email contents" do
74
+ before do
75
+ # Disable inlining
76
+ YourMailer.any_instance.stub(:roadie_options).and_return(nil)
77
+ end
78
+ # ...
79
+ end
80
+
81
+ describe "inlined email contents" do
82
+ # ...
83
+ end
84
+ end
85
+ ```
86
+
87
+ If you need the extra flexibility, look at the "Manual usage" below.
88
+
89
+ ### Manual usage ###
90
+
91
+ Include the `Roadie::Rails::Mailer` module inside your `ActionMailer` and call `roadie_mail` with the same options that you would pass to `mail`.
92
+
93
+ ```ruby
94
+ class NewsletterMailer < ActionMailer::Base
95
+ include Roadie::Rails::Mailer
96
+
97
+ def user_newsletter(user)
98
+ roadie_mail to: user.email, subject: subject_for_user(user)
99
+ end
100
+
101
+ private
102
+ def subject_for_user(user)
103
+ I18n.translate 'emails.user_newsletter.subject', name: user.name
104
+ end
105
+ end
106
+ ```
107
+
108
+ This will inline the stylesheets right away, which sadly decreases performance for your tests where you might only want to inline in one of them. The upside is that you can selectively inline yourself.
109
+
110
+ ```ruby
111
+ class NewsletterMailer < ActionMailer::Base
112
+ include Roadie::Rails::Mailer
113
+
114
+ def subscriber_newsletter(subscriber, options = {})
115
+ use_roadie = options.fetch :use_roadie, true
116
+ mail_factory(use_roadie, normal_mail_options)
117
+ end
118
+
119
+ private
120
+ def mail_factory(use_roadie, options)
121
+ if use_roadie
122
+ roadie_mail options
123
+ else
124
+ mail options
125
+ end
126
+ end
127
+ end
128
+
129
+ # tests
130
+ describe NewsletterMailer do
131
+ it "is emailed to the subscriber's email" do
132
+ email = NewsletterMailer.subscriber_newsletter(subscriber, use_roadie: false)
133
+ email.to.should == subscriber.email
134
+ end
135
+
136
+ it "inlines the emails by default" do
137
+ email = NewsletterMailer.subscriber_newsletter(subscriber)
138
+ email.should be_good_and_cool_and_all_that_jazz
139
+ end
140
+ end
141
+ ```
142
+
143
+ Or, perhaps by doing this:
144
+
145
+ ```ruby
146
+ describe YourMailer do
147
+ describe "email contents" do
148
+ before do
149
+ # Redirect all roadie mail calls to the normal mail method
150
+ YourMailer.any_instance.stub(:roadie_mail) { |*args, &block| YourMailer.mail(*args, &block) }
151
+ end
152
+ # ...
153
+ end
154
+
155
+ describe "inlined email contents" do
156
+ # ...
157
+ end
158
+ end
159
+ ```
160
+
161
+ ### Configuration ###
162
+
163
+ Roadie can be configured in three places, depending on how specific you want to be:
164
+
165
+ 1. `Rails.application.config.roadie` (global, static).
166
+ 2. `YourMailer#roadie_options` (mailer, dynamic).
167
+ 3. Second argument to the `roadie_mail` (mail, specific and custom).
168
+
169
+ You can override at any level in the chain, depending on how specific you need to be.
170
+
171
+ Only the first two methods are available to you if you use the `Automatic` module.
172
+
173
+ ```ruby
174
+ # config/environments/production.rb
175
+ config.roadie.url_options = {host: "my-app.com", scheme: "https"}
176
+
177
+ # app/mailer/my_mailer.rb
178
+ class MyMailer
179
+ include Roadie::Rails::Mailer
180
+
181
+ protected
182
+ def roadie_options
183
+ super.merge(url_options: {host: Product.current.host})
184
+ end
185
+ end
186
+
187
+ # app/mailer/my_other_mailer.rb
188
+ class MyOtherMailer
189
+ include Roadie::Rails::Mailer
190
+
191
+ def some_mail(user)
192
+ roadie_email {to: "foo@example.com"}, roadie_options_for(user)
193
+ end
194
+
195
+ private
196
+ def roadie_options_for(user)
197
+ roadie_options.combine({
198
+ asset_providers: [MyCustomProvider.new(user)],
199
+ url_options: {host: user.subdomain_with_host},
200
+ })
201
+ end
202
+ end
203
+ ```
204
+
205
+ If you `#merge` you will replace the older value outright:
206
+
207
+ ```ruby
208
+ def roadie_options
209
+ original = super
210
+ original.url_options # => {protocol: "https", host: "foo.com"}
211
+ new = original.merge(url_options: {host: "bar.com"})
212
+ new.url_options # => {host: "bar.com"}
213
+ new
214
+ end
215
+ ```
216
+
217
+ If you want to combine two values, use `#combine`. `#combine` is closer to `Hash#deep_merge`:
218
+
219
+ ```ruby
220
+ def roadie_options
221
+ original = super
222
+ original.url_options # => {protocol: "https", host: "foo.com"}
223
+ new = original.combine(url_options: {host: "bar.com"})
224
+ new.url_options # => {protocol: "https", host: "bar.com"}
225
+ new
226
+ end
227
+ ```
228
+
229
+ `#combine` is smarter than `Hash#deep_merge`, though. It can combine callback `proc`s (so both get called) and `Roadie::ProviderList`s as well.
230
+
231
+ If you want to see the available configuration options, see the [Roadie gem][roadie].
232
+
233
+ ### Templates ###
234
+
235
+ Use normal `stylesheet_link_tag` and `foo_path` methods when generating your email and Roadie will look for the precompiled files on your filesystem, or by asking the asset pipeline to compile the files for you if it cannot be found.
236
+
237
+ ### Previewing ###
238
+
239
+ You can create a controller that gets the email and then renders the body from it.
240
+
241
+ ```ruby
242
+ class Admin::EmailsController < AdminController
243
+ def user_newsletter
244
+ render_email NewsletterMailer.user_newsletter(current_user)
245
+ end
246
+
247
+ def subscriber_newsletter
248
+ render_email NewsletterMailer.subscriber_newsletter(Subscriber.first || Subscriber.new)
249
+ end
250
+
251
+ private
252
+ def render_email(email)
253
+ respond_to do |format|
254
+ format.html { render html: email.html_body.decoded }
255
+ format.text { render text: email.text_body.decoded }
256
+ end
257
+ end
258
+ end
259
+ ```
260
+
261
+ ## Build status ##
262
+
263
+ Tested with [Travis CI](http://travis-ci.org) using [almost all combinations of](http://travis-ci.org/#!/Mange/roadie-rails):
264
+
265
+ * Ruby:
266
+ * MRI 1.9.3
267
+ * MRI 2.0.0
268
+ * MRI 2.1.0
269
+ * Rails
270
+ * 3.0
271
+ * 3.1
272
+ * 3.2
273
+ * 4.0
274
+ * 4.1
275
+
276
+ Let me know if you want any other combination supported officially.
277
+
278
+ ### Versioning ###
279
+
280
+ This project follows [Semantic Versioning][semver]. The 0.x branch is considered unstable.
281
+
282
+ ## Documentation ##
283
+
284
+ * [Online documentation for gem](http://rubydoc.info/gems/roadie-rails/frames)
285
+ * [Online documentation for master](http://rubydoc.info/github/Mange/roadie-rails/master/frames)
286
+ * [Changelog](https://github.com/Mange/roadie-rails/blob/master/Changelog.md)
287
+
288
+ ## Running specs ##
289
+
290
+ Start by setting up your machine, then you can run the specs like normal:
291
+
292
+ ```bash
293
+ ./setup.sh install
294
+ rake spec
295
+ ```
296
+
297
+ ## License ##
298
+
299
+ (The MIT License)
300
+
301
+ Copyright © 2013
302
+
303
+ * [Magnus Bergmark](https://github.com/Mange) <magnus.bergmark@gmail.com>
304
+
305
+ 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:
306
+
307
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
308
+
309
+ THE SOFTWARE IS PROVIDED ‘AS IS’, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
310
+
311
+
312
+ [roadie]: http://rubygems.org/gems/roadie
313
+ [semver]: http://semver.org/
314
+ [rdd]: http://tom.preston-werner.com/2010/08/23/readme-driven-development.html
315
+ [gem]: http://rubygems.org/gems/roadie-rails
316
+
317
+ [roadie2]: https://github.com/Mange/roadie/tree/2-4-stable
@@ -0,0 +1,14 @@
1
+ require "bundler/gem_tasks"
2
+
3
+ desc "Install gems for embedded Rails apps"
4
+ task :install_gems do
5
+ sh "./setup.sh install"
6
+ end
7
+
8
+ desc "Run specs"
9
+ task :spec do
10
+ sh "bundle exec rspec -f progress"
11
+ end
12
+
13
+ desc "Default: Install gems and run specs"
14
+ task :default => [:install_gems, :spec]