premailer-rails 1.6.0 → 1.6.1

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
2
  SHA1:
3
- metadata.gz: 5a2073ed1c61cca54326ea63233c597afc05673a
4
- data.tar.gz: 8a067a0516b3ff404ead0d70b147408a0ca88dea
3
+ metadata.gz: f2248a4e7484976c9aa3f9260873dc82927adb6d
4
+ data.tar.gz: 0a3eb925b80da4498279e90e452931f87ac048d1
5
5
  SHA512:
6
- metadata.gz: 613d3feeeceb8be28f49e32c656b945d98ce23b6b22ef597e063a519a3e798e250e8ae80fe0a2bcd700acd6ee6b13efbdf92bf9813266c61aa0ef147d9fc4e45
7
- data.tar.gz: 869483a1f22ae2e38587eb73f763fa11f430271c74a30f0ebdbb08164893113dd962027b43524abec789467481209e764d98cfb4798305b1c9662975a5ed8fa2
6
+ metadata.gz: 3dadbfdf3c5e22ee924824bfc8ac398957723207fd46e1f245c92da341830514ba64f6b0fe34d0cdf602329960f83f1eaa6134631d639589e714b3230665c19b
7
+ data.tar.gz: 9866e101c03db3be48bc0c840ec382875f7f7aee0042f9200712ac2eb28eb7665edde74d59df0c366dde132ef91bcbc108a2990ccaa6757c48f8474e6b2424d3
@@ -6,7 +6,7 @@ rvm:
6
6
  - 1.9.3
7
7
  - ruby-head
8
8
  - jruby-19mode
9
- - rbx-19mode
9
+ - rbx-2.1.1
10
10
  env:
11
11
  - "ACTION_MAILER_VERSION=3.1.0"
12
12
  - "ACTION_MAILER_VERSION=3.2.0"
data/Gemfile CHANGED
@@ -1,4 +1,4 @@
1
- source "https://rubygems.org"
1
+ source 'https://rubygems.org'
2
2
 
3
3
  gemspec
4
4
 
@@ -12,6 +12,7 @@ else
12
12
  gem 'actionmailer', "~> #{action_mailer_version}"
13
13
  end
14
14
 
15
- platforms :jruby do
16
- gem "jruby-openssl"
15
+ platforms :rbx do
16
+ gem 'rubysl'
17
+ gem 'racc'
17
18
  end
data/README.md CHANGED
@@ -30,11 +30,44 @@ Rails. Although premailer-rails has certain Rails specific features, **it also
30
30
  works in the absence of Rails** making it compatible with other frameworks such
31
31
  as sinatra.
32
32
 
33
+ ## How It Works
34
+
33
35
  premailer-rails works with actionmailer by registering a delivery hook. This
34
36
  causes all emails that are delivered to be processed by premailer-rails. This
35
- means that, by simply including premailer-rails in your `Gemfile`, you'll get
37
+ means that by simply including premailer-rails in your `Gemfile` you'll get
36
38
  styled emails without having to set anything up.
37
39
 
40
+ Whenever premailer-rails processes an email, it collects the URLs of all linked
41
+ stylesheets (`<link rel="stylesheet" href="css_url">`). Then, for each of these
42
+ URLs, it tries to get the content through a couple of strategies. As long as
43
+ a strategy does not return anything, the next one is used. The strategies and
44
+ their order are as follows:
45
+
46
+ 1. **Cache:** If there's a file in cache matching that URL, the cache content
47
+ is returned. The cache right now is rather rudimentary. Whenever a CSS file
48
+ is retrieved, it is stored in memory such that subsequent requests to the
49
+ same file are faster. The caching is disabled inside Rails in the
50
+ development environment.
51
+
52
+ 2. **File System:** If there's a file inside `public/` with the same path as in
53
+ the URL, it is read from disk. E.g. if the URL is
54
+ `http://cdn.example.com/assets/email.css` the contents of the file located
55
+ at `public/assets/email.css` gets returned if it exists.
56
+
57
+ 3. **Asset Pipeline:** If Rails is available and the asset pipeline is enabled,
58
+ the file is retrieved through the asset pipeline. E.g. if the URL is
59
+ `http://cdn.example.com/assets/email-fingerprint123.css`, the file
60
+ `email.css` is requested from the asset pipeline. That is, the fingerprint
61
+ and the prefix (in this case `assets` is the prefix) are stripped before
62
+ requesting it from the asset pipeline.
63
+
64
+ 4. **Network:** As a last resort, the URL is simply requested and the response
65
+ body is used. This is usefull when the assets are not bundled in the
66
+ application and only available on a CDN. On Heroku e.g. you can add assets
67
+ to your `.slugignore` causing your assets to not be available to the app
68
+ (and thus resulting in a smaller app) and deploy the assets to a CDN such
69
+ as S3/CloudFront.
70
+
38
71
  ## Installation
39
72
 
40
73
  Simply add the gem to your `Gemfile`:
@@ -99,6 +132,18 @@ class UserMailer < ActionMailer::Base
99
132
  end
100
133
  ```
101
134
 
135
+ ## Small Print
136
+
137
+ ### Author
138
+
139
+ Philipe Fatio ([@fphilipe][fphilipe twitter])
140
+
141
+ [![Support via Gittip][tip-image]][tip-link]
142
+
143
+ ### License
144
+
145
+ premailer-rails is released under the MIT license. See the [license file].
146
+
102
147
  [build-image]: https://travis-ci.org/fphilipe/premailer-rails.png
103
148
  [build-link]: https://travis-ci.org/fphilipe/premailer-rails
104
149
  [gem-image]: https://badge.fury.io/rb/premailer-rails.png
@@ -111,6 +156,8 @@ end
111
156
  [cov-link]: https://coveralls.io/r/fphilipe/premailer-rails
112
157
  [stats-image]: https://d2weczhvl823v0.cloudfront.net/fphilipe/premailer-rails/trend.png
113
158
  [stats-link]: https://bitdeli.com/
159
+ [tip-image]: https://rawgithub.com/twolfson/gittip-badge/0.1.0/dist/gittip.png
160
+ [tip-link]: https://www.gittip.com/fphilipe/
114
161
 
115
162
  [premailer]: https://github.com/premailer/premailer
116
163
  [actionmailer]: https://github.com/rails/rails/tree/master/actionmailer
@@ -118,3 +165,6 @@ end
118
165
  [hpricot]: https://github.com/hpricot/hpricot
119
166
 
120
167
  [premailer documentation]: http://rubydoc.info/gems/premailer/1.7.3/Premailer:initialize
168
+
169
+ [fphilipe twitter]: https://twitter.com/fphilipe
170
+ [license file]: LICENSE
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.6.0
1
+ 1.6.1
@@ -6,7 +6,6 @@ require 'premailer/rails/css_loaders'
6
6
  require 'premailer/rails/css_helper'
7
7
  require 'premailer/rails/customized_premailer'
8
8
  require 'premailer/rails/hook'
9
- require 'premailer/rails/nokogiri_fix'
10
9
 
11
10
  class Premailer
12
11
  module Rails
@@ -54,8 +54,8 @@ class Premailer
54
54
 
55
55
  def generate_alternative_part
56
56
  part = Mail::Part.new(content_type: 'multipart/alternative')
57
- part.add_part(generate_html_part)
58
57
  part.add_part(generate_text_part)
58
+ part.add_part(generate_html_part)
59
59
 
60
60
  part
61
61
  end
@@ -26,5 +26,5 @@ Gem::Specification.new do |s|
26
26
  s.add_development_dependency 'rspec', '>= 3.0.0.beta1'
27
27
  s.add_development_dependency 'nokogiri'
28
28
  s.add_development_dependency 'hpricot' unless RUBY_PLATFORM == 'java'
29
- s.add_development_dependency 'coveralls'
29
+ s.add_development_dependency 'coveralls' if RUBY_ENGINE == 'ruby'
30
30
  end
@@ -1,12 +1,14 @@
1
- if ENV['CI']
2
- require 'coveralls'
3
- Coveralls::Output.silent = true
4
- Coveralls.wear! do
5
- add_filter 'spec/'
1
+ if RUBY_ENGINE == 'ruby'
2
+ if ENV['CI']
3
+ require 'coveralls'
4
+ Coveralls::Output.silent = true
5
+ Coveralls.wear! do
6
+ add_filter 'spec/'
7
+ end
8
+ else
9
+ require 'simplecov'
10
+ SimpleCov.start
6
11
  end
7
- else
8
- require 'simplecov'
9
- SimpleCov.start
10
12
  end
11
13
 
12
14
  require 'premailer/rails'
@@ -1,3 +1,5 @@
1
+ # coding: utf-8
2
+
1
3
  require 'mail'
2
4
 
3
5
  module Fixtures
@@ -19,6 +21,20 @@ module Fixtures
19
21
  </html>
20
22
  HTML
21
23
 
24
+ UNICODE_STRING = '٩(-̮̮̃-̃)۶ ٩(●̮̮̃•̃)۶ ٩(͡๏̯͡๏)۶ ٩(-̮̮̃•̃).'
25
+
26
+ HTML_PART_WITH_UNICODE = <<-HTML
27
+ <html>
28
+ <head>
29
+ </head>
30
+ <body>
31
+ <p>
32
+ #{UNICODE_STRING}
33
+ </p>
34
+ </body>
35
+ </html>
36
+ HTML
37
+
22
38
  HTML_PART_WITH_CSS = <<-HTML
23
39
  <html>
24
40
  <head>
@@ -37,6 +37,15 @@ describe Premailer::Rails::CustomizedPremailer do
37
37
  expect(premailer.to_inline_css).to match(regex)
38
38
  end
39
39
  end
40
+
41
+ context 'when HTML contains unicode' do
42
+ it 'should not mess those up' do
43
+ html = Fixtures::Message::HTML_PART_WITH_UNICODE
44
+ premailer = Premailer::Rails::CustomizedPremailer.new(html)
45
+ expect(premailer.to_inline_css).to \
46
+ include(Fixtures::Message::UNICODE_STRING)
47
+ end
48
+ end
40
49
  end
41
50
  end
42
51
  end
@@ -48,13 +57,13 @@ describe Premailer::Rails::CustomizedPremailer do
48
57
  end
49
58
 
50
59
  it 'should pass on the configs' do
51
- Premailer::Rails.config = { foo: :bar }
60
+ Premailer::Rails.config.merge!(foo: :bar)
52
61
  premailer = Premailer::Rails::CustomizedPremailer.new('some html')
53
62
  expect(premailer.instance_variable_get(:'@options')[:foo]).to eq(:bar)
54
63
  end
55
64
 
56
65
  it 'should not allow to override with_html_string' do
57
- Premailer::Rails.config = { with_html_string: false }
66
+ Premailer::Rails.config.merge!(with_html_string: false)
58
67
  premailer = Premailer::Rails::CustomizedPremailer.new('some html')
59
68
  options = premailer.instance_variable_get(:'@options')
60
69
  expect(options[:with_html_string]).to eq(true)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: premailer-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.6.0
4
+ version: 1.6.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Philipe Fatio
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-11-20 00:00:00.000000000 Z
11
+ date: 2013-12-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: premailer
@@ -136,7 +136,6 @@ files:
136
136
  - lib/premailer/rails/css_loaders/network_loader.rb
137
137
  - lib/premailer/rails/customized_premailer.rb
138
138
  - lib/premailer/rails/hook.rb
139
- - lib/premailer/rails/nokogiri_fix.rb
140
139
  - lib/premailer/rails/version.rb
141
140
  - premailer-rails.gemspec
142
141
  - spec/integration/css_helper_spec.rb
@@ -169,7 +168,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
169
168
  version: '0'
170
169
  requirements: []
171
170
  rubyforge_project:
172
- rubygems_version: 2.0.2
171
+ rubygems_version: 2.1.11
173
172
  signing_key:
174
173
  specification_version: 4
175
174
  summary: Easily create styled HTML emails in Rails.
@@ -1,15 +0,0 @@
1
- require 'premailer/adapter/nokogiri'
2
-
3
- Premailer::Adapter::Nokogiri.module_eval do
4
- # Patch load_html method to fix character encoding issues.
5
- def load_html(html)
6
- if RUBY_VERSION.to_f >= 1.9
7
- html = html.force_encoding('UTF-8').encode!
8
- ::Nokogiri::HTML(html) {|c| c.recover }
9
- else
10
- # :nocov:
11
- ::Nokogiri::HTML(html, nil, 'UTF-8') {|c| c.recover }
12
- # :nocov:
13
- end
14
- end
15
- end