inline_styles_mailer 1.0.1 → 1.0.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 90f953a4701883b50e6877e503faefa2a0065062
4
- data.tar.gz: be0992b44ad67895c45ffdf585963b53c58ce5a2
3
+ metadata.gz: 5e1389e41082caa2d0472886c8e51022cbce2659
4
+ data.tar.gz: 1a73bfb345f3e10cfff7ab3a0cd037befb426a36
5
5
  SHA512:
6
- metadata.gz: a4580aa94c6304bba9fb4640712c1e2f8787b8e85c050e2f1da5286ed810251bd2df8f9e9d47728dc126eeba1f401f1a27bd9cfc3bd01347e11949c464c5ee71
7
- data.tar.gz: ad140d8d77a849b096e2fc37bb040f6c7ca1362bc2560ddcdc3b9274ba1239a484ebd323220488af944e67d1025e1cad9e5bf4e6a9b2b00534ecd7d3b2e17791
6
+ metadata.gz: 12c4cb965729bebe1dde750e47a18ae5d633e697f9753b7adc13466b879a4ea840eec23f90e2f695e833055f48abae6273d3bedd81b677f3e3e9f08790182f7c
7
+ data.tar.gz: 477a86cab6c58746d0fcf65ace05de7169311ab678755fff4c81b2551703781520f8978b17b24f289ebc560a34943659a12d1e325feda73eb80f6d53d6ca0e02
data/.travis.yml CHANGED
@@ -1,7 +1,7 @@
1
1
  language: ruby
2
2
  matrix:
3
3
  include:
4
- - rvm: 2.0.0
4
+ - rvm: 2.0.0-p648
5
5
  gemfile: spec/Gemfile.rails-4.2
6
6
  - rvm: 2.1.8
7
7
  gemfile: spec/Gemfile.rails-4.2
@@ -13,4 +13,8 @@ matrix:
13
13
  gemfile: spec/Gemfile.rails-4.2
14
14
  - rvm: 2.3.0
15
15
  gemfile: spec/Gemfile.rails-5.0
16
+ - rvm: 2.3.3
17
+ gemfile: spec/Gemfile.rails-5.1
18
+ - rvm: 2.3.3
19
+ gemfile: spec/Gemfile.rails-5.2
16
20
  sudo: false
data/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  ## Next
2
2
 
3
+ ## v1.0.2
4
+
5
+ Added support for Rails 5.1 and 5.2.
6
+
7
+ ## v1.0.1
8
+
9
+ Now works with Rails 5.0 final (just a change to the `.gemspec`)
10
+
11
+ ## v1.0.0
12
+
13
+ Changes to the way we find nested templates which might break the way you define their location (but probably won't affect most people). See the [note here](https://github.com/billhorsman/inline_styles_mailer#upgrading-to-version-10).
14
+
3
15
  ## v0.0.9
4
16
 
5
17
  Now needs Ruby 1.9.3 (drop support for 1.9.2), because Rails 4.1 does so.
@@ -35,4 +47,4 @@ Documentation changes only.
35
47
 
36
48
  ## v0.0.1
37
49
 
38
- Initial release
50
+ Initial release
data/README.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## Update for Rails 5.1+
2
+
3
+ I've started to use the [premailer](https://github.com/premailer/premailer) gem for Rails > 5.0. I'd welcome patches to keep this gem going.
4
+
1
5
  ## Inline Styles Mailer [![Build Status](https://secure.travis-ci.org/billhorsman/inline_styles_mailer.png)](http://travis-ci.org/billhorsman/inline_styles_mailer)
2
6
 
3
7
  Using Jack Danger's excellent [Inline Styles](https://github.com/jackdanger/inline_styles) gem is even easier if you're using Rails 3.1+ and this gem.
@@ -98,7 +102,7 @@ We decided to bump up the major version because of a fix (5d0b6f4) we made to th
98
102
 
99
103
  ## What versions of Rails does this work with?
100
104
 
101
- We run tests using Rails `4.2.6` and `5.0.0.beta3`.
105
+ We run tests using Rails `4.2.6`, `5.0.0.beta3`, `5.1.6` and `5.2`
102
106
 
103
107
  | Version | Working? |
104
108
  | --- | --- |
@@ -109,9 +113,13 @@ We run tests using Rails `4.2.6` and `5.0.0.beta3`.
109
113
  | 4.1 | Yes |
110
114
  | 4.2 | Yes |
111
115
  | 5.0 | Yes |
116
+ | 5.1 | Yes |
117
+ | 5.2 | Yes |
112
118
 
113
119
  \* It relies on the asset pipeline so I'd be surprised if it works. Not tested.
114
120
 
121
+ \** I'm recommending using the [premailer](https://github.com/premailer/premailer) gem for Rails > 5.0.
122
+
115
123
  ## What about Ruby?
116
124
 
117
125
  Anything later than Ruby `1.9.2` should be fine. We test using Ruby 2.0.0`, `2.1.8`, `2.2.4` and `2.3.0`.
@@ -22,6 +22,6 @@ Gem::Specification.new do |s|
22
22
  s.required_ruby_version = '>= 1.9.3'
23
23
  s.add_development_dependency "rspec"
24
24
  s.add_runtime_dependency "inline_styles"
25
- s.add_runtime_dependency "rails", [">= 3.1", "< 5.1"]
25
+ s.add_runtime_dependency "rails", [">= 3.1", "<= 5.2"]
26
26
  s.add_runtime_dependency "sass-rails"
27
27
  end
@@ -23,9 +23,8 @@ module InlineStylesMailer
23
23
  end
24
24
 
25
25
  def css_content
26
- @stylesheets ||= ["_#{self.name.underscore}*"]
27
26
  @stylesheet_path ||= File.join("app", "assets", "stylesheets")
28
- @css_content ||= @stylesheets.map {|stylesheet|
27
+ @css_content ||= stylesheets.map {|stylesheet|
29
28
  Dir[Rails.root.join(@stylesheet_path, "#{stylesheet}")].map {|file|
30
29
  case file
31
30
  when /\.scss$/
@@ -41,6 +40,10 @@ module InlineStylesMailer
41
40
  @css_content
42
41
  end
43
42
 
43
+ def stylesheets
44
+ @stylesheets ||= [self.name.underscore.sub(/^(.*\/)*(.*)$/, '\1_\2*')]
45
+ end
46
+
44
47
  def page
45
48
  @page ||= InlineStyles::Page.new.with_css(css_content)
46
49
  end
@@ -61,7 +64,7 @@ module InlineStylesMailer
61
64
  # Rails 3.1 takes an array, while Rails 3.0 takes a string.
62
65
  # See https://github.com/billhorsman/inline_styles_mailer/issues/1
63
66
  prefixes = options[:template_path] || self.class.name.underscore
64
- prefixes = [prefixes] unless Rails.version =~ /^3\.0/
67
+ prefixes = [prefixes].flatten unless Rails.version =~ /^3\.0/
65
68
  templates = lookup_context.find_all(options[:template_name] || action_name, prefixes)
66
69
  options.reverse_merge!(:mime_version => "1.0", :charset => "UTF-8", :content_type => "text/plain", :parts_order => [ "text/plain", "text/enriched", "text/html"])
67
70
  templates.sort_by {|t|
@@ -82,7 +85,12 @@ module InlineStylesMailer
82
85
  case extension
83
86
  when :html
84
87
  html = render_to_string :file => file, :layout => layout_to_use, handlers: [handler]
85
- render :text => self.class.page.with_html(html).apply
88
+ # Rails 5.1 removed render :text
89
+ if Gem.loaded_specs['rails'].version >= Gem::Version.create('5.0')
90
+ render :plain => self.class.page.with_html(html).apply
91
+ else
92
+ render :text => self.class.page.with_html(html).apply
93
+ end
86
94
  else
87
95
  render
88
96
  end
@@ -1,3 +1,3 @@
1
1
  module InlineStylesMailer
2
- VERSION = "1.0.1"
2
+ VERSION = "1.0.2"
3
3
  end
@@ -0,0 +1,5 @@
1
+ source 'https://rubygems.org'
2
+ gem 'inline_styles'
3
+ gem 'rails', '~> 5.1.6'
4
+ gem 'rspec'
5
+ gem 'sass-rails'
@@ -0,0 +1,5 @@
1
+ source 'https://rubygems.org'
2
+ gem 'inline_styles'
3
+ gem 'rails', '~> 5.2'
4
+ gem 'rspec'
5
+ gem 'sass-rails'
@@ -1,5 +1,5 @@
1
1
  body {
2
- background: yellow;
2
+ background-color: yellow;
3
3
  p {
4
4
  color: red;
5
5
  }
@@ -1,5 +1,5 @@
1
1
  body {
2
- background: yellow;
2
+ background-color: yellow;
3
3
  }
4
4
  body p {
5
5
  color: blue;
@@ -1,5 +1,5 @@
1
1
  body
2
- :background yellow
2
+ :background-color yellow
3
3
  p
4
4
  :color green
5
5
 
@@ -1,5 +1,5 @@
1
1
  body {
2
- background: yellow;
2
+ background-color: yellow;
3
3
  p {
4
4
  color: orange;
5
5
  }
@@ -0,0 +1,6 @@
1
+ body {
2
+ background-color: orange;
3
+ p {
4
+ color: purple;
5
+ }
6
+ }
File without changes
@@ -0,0 +1,11 @@
1
+ require 'rails/all'
2
+
3
+ module Foo
4
+ class BarMailer < ActionMailer::Base
5
+ include InlineStylesMailer
6
+
7
+ def bar
8
+ mail(:to => "test@localhost", :subject => "Test Bar")
9
+ end
10
+ end
11
+ end
@@ -0,0 +1 @@
1
+ <p>Testing foobar html.</p>
@@ -18,7 +18,7 @@ describe InlineStylesMailer do
18
18
  mail = FooMailer.foo
19
19
  mail.body.parts.length.should eq(2)
20
20
  mail.body.parts[1].body.should =~ /<p style="color: red;">Testing foo text\/html\.<\/p>/
21
- mail.body.parts[1].body.should =~ /<body style="background: yellow;">/
21
+ mail.body.parts[1].body.should =~ /<body style="background-color: yellow;">/
22
22
  end
23
23
  end
24
24
 
@@ -30,7 +30,7 @@ describe InlineStylesMailer do
30
30
  mail = FooMailer.foo
31
31
  mail.body.parts.length.should eq(2)
32
32
  mail.body.parts[1].body.should =~ /<p style="color: orange;">Testing foo text\/html\.<\/p>/
33
- mail.body.parts[1].body.should =~ /<body style="background: yellow;">/
33
+ mail.body.parts[1].body.should =~ /<body style="background-color: yellow;">/
34
34
  end
35
35
  end
36
36
 
@@ -42,7 +42,7 @@ describe InlineStylesMailer do
42
42
  mail = FooMailer.foo
43
43
  mail.body.parts.length.should eq(2)
44
44
  mail.body.parts[1].body.should =~ /<p style="color: green;">Testing foo text\/html\.<\/p>/
45
- mail.body.parts[1].body.should =~ /<body style="background: yellow;">/
45
+ mail.body.parts[1].body.should =~ /<body style="background-color: yellow;">/
46
46
  end
47
47
  end
48
48
 
@@ -54,7 +54,7 @@ describe InlineStylesMailer do
54
54
  mail = FooMailer.foo
55
55
  mail.body.parts.length.should eq(2)
56
56
  mail.body.parts[1].body.should =~ /<p style="color: blue;">Testing foo text\/html\.<\/p>/
57
- mail.body.parts[1].body.should =~ /<body style="background: yellow;">/
57
+ mail.body.parts[1].body.should =~ /<body style="background-color: yellow;">/
58
58
  end
59
59
  end
60
60
 
@@ -82,4 +82,18 @@ describe InlineStylesMailer do
82
82
 
83
83
  end
84
84
 
85
+ describe "Namespaced mailers" do
86
+ context "Default CSS file" do
87
+ before do
88
+ Foo::BarMailer.stylesheet_path "assets/stylesheets"
89
+ end
90
+
91
+ it "should inline the CSS" do
92
+ mail = Foo::BarMailer.bar
93
+ mail.body.should =~ /<p style="color: purple;">Testing foobar html\.<\/p>/
94
+ mail.body.should =~ /<body style="background-color: orange;">/
95
+ end
96
+ end
97
+ end
98
+
85
99
  end
data/spec/spec_helper.rb CHANGED
@@ -4,7 +4,7 @@ require 'rails/all'
4
4
  ActionMailer::Base.delivery_method = :test
5
5
  ActionMailer::Base.prepend_view_path File.join(File.dirname(__FILE__), "fixtures", "views")
6
6
 
7
- Dir["#{File.dirname(__FILE__)}/fixtures/mailers/*.rb"].each { |f| require f }
7
+ Dir["#{File.dirname(__FILE__)}/fixtures/mailers/**/*.rb"].each { |f| require f }
8
8
 
9
9
  RSpec.configure do |config|
10
10
  config.expect_with :rspec do |c|
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: inline_styles_mailer
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bill Horsman
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-07-02 00:00:00.000000000 Z
11
+ date: 2018-04-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec
@@ -45,9 +45,9 @@ dependencies:
45
45
  - - ">="
46
46
  - !ruby/object:Gem::Version
47
47
  version: '3.1'
48
- - - "<"
48
+ - - "<="
49
49
  - !ruby/object:Gem::Version
50
- version: '5.1'
50
+ version: '5.2'
51
51
  type: :runtime
52
52
  prerelease: false
53
53
  version_requirements: !ruby/object:Gem::Requirement
@@ -55,9 +55,9 @@ dependencies:
55
55
  - - ">="
56
56
  - !ruby/object:Gem::Version
57
57
  version: '3.1'
58
- - - "<"
58
+ - - "<="
59
59
  - !ruby/object:Gem::Version
60
- version: '5.1'
60
+ version: '5.2'
61
61
  - !ruby/object:Gem::Dependency
62
62
  name: sass-rails
63
63
  requirement: !ruby/object:Gem::Requirement
@@ -93,11 +93,17 @@ files:
93
93
  - lib/inline_styles_mailer/version.rb
94
94
  - spec/Gemfile.rails-4.2
95
95
  - spec/Gemfile.rails-5.0
96
+ - spec/Gemfile.rails-5.1
97
+ - spec/Gemfile.rails-5.2
96
98
  - spec/fixtures/assets/stylesheets/_foo_mailer.css.scss
97
99
  - spec/fixtures/assets/stylesheets/_override.css
98
100
  - spec/fixtures/assets/stylesheets/_override.css.sass
99
101
  - spec/fixtures/assets/stylesheets/_override.css.scss
102
+ - spec/fixtures/assets/stylesheets/foo/_bar_mailer.css.scss
100
103
  - spec/fixtures/layout.html.erb
104
+ - spec/fixtures/mailers/Untitled
105
+ - spec/fixtures/mailers/foo/bar_mailer.rb
106
+ - spec/fixtures/views/foo/bar_mailer/bar.html.erb
101
107
  - spec/fixtures/views/foo_mailer/backwards.html.erb
102
108
  - spec/fixtures/views/foo_mailer/backwards.text.erb
103
109
  - spec/fixtures/views/foo_mailer/foo.html.erb
@@ -125,18 +131,24 @@ required_rubygems_version: !ruby/object:Gem::Requirement
125
131
  version: '0'
126
132
  requirements: []
127
133
  rubyforge_project: inline_styles_mailer
128
- rubygems_version: 2.6.4
134
+ rubygems_version: 2.6.13
129
135
  signing_key:
130
136
  specification_version: 4
131
137
  summary: Convenient use of inline_styles gem with Rails 3.1+ and Rails 4
132
138
  test_files:
133
139
  - spec/Gemfile.rails-4.2
134
140
  - spec/Gemfile.rails-5.0
141
+ - spec/Gemfile.rails-5.1
142
+ - spec/Gemfile.rails-5.2
135
143
  - spec/fixtures/assets/stylesheets/_foo_mailer.css.scss
136
144
  - spec/fixtures/assets/stylesheets/_override.css
137
145
  - spec/fixtures/assets/stylesheets/_override.css.sass
138
146
  - spec/fixtures/assets/stylesheets/_override.css.scss
147
+ - spec/fixtures/assets/stylesheets/foo/_bar_mailer.css.scss
139
148
  - spec/fixtures/layout.html.erb
149
+ - spec/fixtures/mailers/Untitled
150
+ - spec/fixtures/mailers/foo/bar_mailer.rb
151
+ - spec/fixtures/views/foo/bar_mailer/bar.html.erb
140
152
  - spec/fixtures/views/foo_mailer/backwards.html.erb
141
153
  - spec/fixtures/views/foo_mailer/backwards.text.erb
142
154
  - spec/fixtures/views/foo_mailer/foo.html.erb