premailer-rails3 0.2 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +1 -0
- data/Rakefile +5 -0
- data/lib/premailer-rails3.rb +1 -1
- data/lib/premailer-rails3/css_helper.rb +56 -0
- data/lib/premailer-rails3/hook.rb +23 -9
- data/lib/premailer-rails3/premailer.rb +14 -12
- data/lib/premailer-rails3/version.rb +1 -1
- data/premailer-rails3.gemspec +8 -1
- data/spec/fixtures/html.rb +38 -0
- data/spec/fixtures/message.rb +68 -0
- data/spec/premailer-rails3/css_helper_spec.rb +146 -0
- data/spec/premailer-rails3/hook_registration_spec.rb +10 -0
- data/spec/premailer-rails3/hook_spec.rb +73 -0
- data/spec/premailer-rails3/premailer_spec.rb +35 -0
- data/spec/spec_helper.rb +15 -0
- data/spec/stubs/action_mailer.rb +5 -0
- data/spec/stubs/dummy.rb +5 -0
- data/spec/stubs/hassle.rb +1 -0
- data/spec/stubs/rails.rb +63 -0
- data/spec/stubs/try.rb +5 -0
- metadata +130 -50
data/.gitignore
CHANGED
data/Rakefile
CHANGED
data/lib/premailer-rails3.rb
CHANGED
@@ -0,0 +1,56 @@
|
|
1
|
+
module PremailerRails
|
2
|
+
module CSSHelper
|
3
|
+
extend self
|
4
|
+
|
5
|
+
@@css_cache = {}
|
6
|
+
|
7
|
+
def css_for_doc(doc)
|
8
|
+
css = doc.search('link[@type="text/css"]').map { |link|
|
9
|
+
url = link.attributes['href']
|
10
|
+
load_css_at_path(url) unless url.blank?
|
11
|
+
}.reject(&:blank?).join("\n")
|
12
|
+
css = load_css_at_path(:default) if css.blank?
|
13
|
+
css
|
14
|
+
end
|
15
|
+
|
16
|
+
private
|
17
|
+
|
18
|
+
def load_css_at_path(path)
|
19
|
+
if path.is_a? String
|
20
|
+
# Remove everything after ? including ?
|
21
|
+
path = path[0..(path.index('?') - 1)] if path.include? '?'
|
22
|
+
# Remove the host
|
23
|
+
path = path.gsub(/^https?\:\/\/[^\/]*/, '') if path.index('http') == 0
|
24
|
+
end
|
25
|
+
|
26
|
+
# Don't cache in development.
|
27
|
+
if Rails.env.development? or not @@css_cache.include? path
|
28
|
+
@@css_cache[path] =
|
29
|
+
if defined? Hassle and Rails.configuration.middleware.include? Hassle
|
30
|
+
file = path == :default ? '/stylesheets/email.css' : path
|
31
|
+
File.read("#{Rails.root}/tmp/hassle#{file}")
|
32
|
+
elsif Rails.configuration.try(:assets).try(:enabled)
|
33
|
+
file = if path == :default
|
34
|
+
'email.css'
|
35
|
+
else
|
36
|
+
path.sub("#{Rails.configuration.assets.prefix}/", '')
|
37
|
+
end
|
38
|
+
if asset = Rails.application.assets.find_asset(file)
|
39
|
+
asset.body
|
40
|
+
else
|
41
|
+
raise "Couldn't find asset #{file} for premailer-rails3."
|
42
|
+
end
|
43
|
+
else
|
44
|
+
file = path == :default ? '/stylesheets/email.css' : path
|
45
|
+
File.read("#{Rails.root}/public#{file}")
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
@@css_cache[path]
|
50
|
+
rescue => ex
|
51
|
+
# Print an error and store empty string as the CSS.
|
52
|
+
puts ex.message
|
53
|
+
@@css_cache[path] = ''
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
@@ -1,18 +1,32 @@
|
|
1
1
|
module PremailerRails
|
2
2
|
class Hook
|
3
3
|
def self.delivering_email(message)
|
4
|
-
|
4
|
+
# If the mail only has one part, it may be stored in message.body. In that
|
5
|
+
# case, if the mail content type is text/html, the body part will be the
|
6
|
+
# html body.
|
7
|
+
if message.html_part
|
8
|
+
html_body = message.html_part.body.to_s
|
9
|
+
elsif message.content_type =~ /text\/html/
|
10
|
+
html_body = message.body.to_s
|
11
|
+
message.body = nil
|
12
|
+
end
|
5
13
|
|
6
|
-
|
7
|
-
|
14
|
+
if html_body
|
15
|
+
premailer = Premailer.new(html_body)
|
16
|
+
charset = message.charset
|
8
17
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
18
|
+
# IMPRTANT: Plain text part must be generated before CSS is inlined.
|
19
|
+
# Not doing so results in CSS declarations visible in the plain text
|
20
|
+
# part.
|
21
|
+
message.text_part do
|
22
|
+
content_type "text/plain; charset=#{charset}"
|
23
|
+
body premailer.to_plain_text
|
24
|
+
end unless message.text_part
|
13
25
|
|
14
|
-
|
15
|
-
|
26
|
+
message.html_part do
|
27
|
+
content_type "text/html; charset=#{charset}"
|
28
|
+
body premailer.to_inline_css
|
29
|
+
end
|
16
30
|
end
|
17
31
|
end
|
18
32
|
end
|
@@ -1,19 +1,21 @@
|
|
1
1
|
module PremailerRails
|
2
2
|
class Premailer < ::Premailer
|
3
3
|
def initialize(html)
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
4
|
+
# In order to pass the CSS as string to super it is necessary to access
|
5
|
+
# the parsed HTML beforehand. To do so, the adapter needs to be
|
6
|
+
# initialized. The ::Premailer::Adaptor handles the discovery of a
|
7
|
+
# suitable adaptor (Nokogiri or Hpricot). To make load_html work, an
|
8
|
+
# adaptor needs to be included and @options[:with_html_string] needs to be
|
9
|
+
# set. For further information, refer to ::Premailer#initialize.
|
10
|
+
@options = { :with_html_string => true }
|
11
|
+
::Premailer.send(:include, Adapter.find(Adapter.use))
|
12
|
+
doc = load_html(html)
|
9
13
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
def load_html(string)
|
16
|
-
Hpricot(string)
|
14
|
+
options = {
|
15
|
+
:with_html_string => true,
|
16
|
+
:css_string => CSSHelper.css_for_doc(doc)
|
17
|
+
}
|
18
|
+
super(html, options)
|
17
19
|
end
|
18
20
|
end
|
19
21
|
end
|
data/premailer-rails3.gemspec
CHANGED
@@ -23,5 +23,12 @@ Gem::Specification.new do |s|
|
|
23
23
|
s.require_paths = ["lib"]
|
24
24
|
|
25
25
|
s.add_dependency("premailer", ["~> 1.7"])
|
26
|
-
s.add_dependency("
|
26
|
+
s.add_dependency("rails", ["~> 3"])
|
27
|
+
|
28
|
+
s.add_development_dependency 'rspec-core'
|
29
|
+
s.add_development_dependency 'rspec-expectations'
|
30
|
+
s.add_development_dependency 'mocha'
|
31
|
+
s.add_development_dependency 'mail'
|
32
|
+
s.add_development_dependency 'nokogiri'
|
33
|
+
s.add_development_dependency 'hpricot'
|
27
34
|
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
module Fixtures
|
2
|
+
module HTML
|
3
|
+
extend self
|
4
|
+
|
5
|
+
TEMPLATE = <<-HTML
|
6
|
+
<html>
|
7
|
+
<head>
|
8
|
+
%s
|
9
|
+
</head>
|
10
|
+
<body>
|
11
|
+
<p>
|
12
|
+
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
|
13
|
+
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim
|
14
|
+
veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea
|
15
|
+
commodo consequat.
|
16
|
+
</p>
|
17
|
+
</body>
|
18
|
+
</html>
|
19
|
+
HTML
|
20
|
+
|
21
|
+
LINK = <<-LINK
|
22
|
+
<link rel='stylesheet' type='text/css' href='%s' />
|
23
|
+
LINK
|
24
|
+
|
25
|
+
def with_css_links(*files)
|
26
|
+
links = []
|
27
|
+
files.each do |file|
|
28
|
+
links << LINK % "http://example.com/#{file}"
|
29
|
+
end
|
30
|
+
|
31
|
+
TEMPLATE % links.join("\n")
|
32
|
+
end
|
33
|
+
|
34
|
+
def with_no_css_link
|
35
|
+
with_css_links
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,68 @@
|
|
1
|
+
require 'mail'
|
2
|
+
|
3
|
+
module Fixtures
|
4
|
+
module Message
|
5
|
+
extend self
|
6
|
+
|
7
|
+
HTML_PART = <<-HTML
|
8
|
+
<html>
|
9
|
+
<head>
|
10
|
+
</head>
|
11
|
+
<body>
|
12
|
+
<p>
|
13
|
+
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
|
14
|
+
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim
|
15
|
+
veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea
|
16
|
+
commodo consequat.
|
17
|
+
</p>
|
18
|
+
</body>
|
19
|
+
</html>
|
20
|
+
HTML
|
21
|
+
|
22
|
+
TEXT_PART = <<-TEXT
|
23
|
+
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor
|
24
|
+
incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis
|
25
|
+
nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
|
26
|
+
TEXT
|
27
|
+
|
28
|
+
def with_parts(*part_types)
|
29
|
+
message = base_message
|
30
|
+
|
31
|
+
message.html_part do
|
32
|
+
body HTML_PART
|
33
|
+
content_type 'text/html; charset=UTF-8'
|
34
|
+
end if part_types.include? :html
|
35
|
+
|
36
|
+
message.text_part do
|
37
|
+
body TEXT_PART
|
38
|
+
content_type 'text/plain; charset=UTF-8'
|
39
|
+
end if part_types.include? :text
|
40
|
+
|
41
|
+
message
|
42
|
+
end
|
43
|
+
|
44
|
+
def with_body(body_type)
|
45
|
+
message = base_message
|
46
|
+
|
47
|
+
case body_type
|
48
|
+
when :html
|
49
|
+
message.body = HTML_PART
|
50
|
+
message.content_type 'text/html; charset=UTF-8'
|
51
|
+
when :text
|
52
|
+
message.body = TEXT_PART
|
53
|
+
message.content_type 'text/plain; charset=UTF-8'
|
54
|
+
end
|
55
|
+
|
56
|
+
message
|
57
|
+
end
|
58
|
+
|
59
|
+
private
|
60
|
+
|
61
|
+
def base_message
|
62
|
+
Mail.new do
|
63
|
+
to 'some@email.com'
|
64
|
+
subject 'testing premailer-rails3'
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
@@ -0,0 +1,146 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe PremailerRails::CSSHelper do
|
4
|
+
# Reset the CSS cache
|
5
|
+
after { PremailerRails::CSSHelper.send(:class_variable_set, '@@css_cache', {}) }
|
6
|
+
|
7
|
+
def load_css_at_path(path)
|
8
|
+
PremailerRails::CSSHelper.send(:load_css_at_path, path)
|
9
|
+
end
|
10
|
+
|
11
|
+
def css_for_doc(doc)
|
12
|
+
PremailerRails::CSSHelper.css_for_doc(doc)
|
13
|
+
end
|
14
|
+
|
15
|
+
describe '#css_for_doc' do
|
16
|
+
let(:html) { Fixtures::HTML.with_css_links(*files) }
|
17
|
+
let(:doc) { Hpricot(html) }
|
18
|
+
|
19
|
+
context 'when HTML contains linked CSS files' do
|
20
|
+
let(:files) { %w[ stylesheets/base.css stylesheets/font.css ] }
|
21
|
+
|
22
|
+
it 'should return the content of both files concatenated' do
|
23
|
+
PremailerRails::CSSHelper \
|
24
|
+
.expects(:load_css_at_path) \
|
25
|
+
.with('http://example.com/stylesheets/base.css') \
|
26
|
+
.returns('content of base.css')
|
27
|
+
PremailerRails::CSSHelper \
|
28
|
+
.expects(:load_css_at_path) \
|
29
|
+
.with('http://example.com/stylesheets/font.css') \
|
30
|
+
.returns('content of font.css')
|
31
|
+
|
32
|
+
css_for_doc(doc).should == "content of base.css\ncontent of font.css"
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
context 'when HTML contains no linked CSS file' do
|
37
|
+
let(:files) { [] }
|
38
|
+
|
39
|
+
it 'should return the content of the default file' do
|
40
|
+
PremailerRails::CSSHelper \
|
41
|
+
.expects(:load_css_at_path) \
|
42
|
+
.with(:default) \
|
43
|
+
.returns('content of default css file')
|
44
|
+
|
45
|
+
css_for_doc(doc).should == 'content of default css file'
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
describe '#load_css_at_path' do
|
51
|
+
context 'when path is a url' do
|
52
|
+
it 'should load the CSS at the local path' do
|
53
|
+
File.expects(:read).with('RAILS_ROOT/public/stylesheets/base.css')
|
54
|
+
|
55
|
+
load_css_at_path('http://example.com/stylesheets/base.css?test')
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
context 'when file is cached' do
|
60
|
+
it 'should return the cached value' do
|
61
|
+
cache = PremailerRails::CSSHelper.send(:class_variable_get, '@@css_cache')
|
62
|
+
cache['/stylesheets/base.css'] = 'content of base.css'
|
63
|
+
|
64
|
+
load_css_at_path('http://example.com/stylesheets/base.css') \
|
65
|
+
.should == 'content of base.css'
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
context 'when in development mode' do
|
70
|
+
it 'should not return cached values' do
|
71
|
+
cache = PremailerRails::CSSHelper.send(:class_variable_get, '@@css_cache')
|
72
|
+
cache['/stylesheets/base.css'] = 'cached content of base.css'
|
73
|
+
File.expects(:read) \
|
74
|
+
.with('RAILS_ROOT/public/stylesheets/base.css') \
|
75
|
+
.returns('new content of base.css')
|
76
|
+
Rails.env.stubs(:development?).returns(true)
|
77
|
+
|
78
|
+
load_css_at_path('http://example.com/stylesheets/base.css') \
|
79
|
+
.should == 'new content of base.css'
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
context 'when Hassle is used' do
|
84
|
+
before { Rails.configuration.middleware.stubs(:include?) \
|
85
|
+
.with(Hassle) \
|
86
|
+
.returns(true) }
|
87
|
+
|
88
|
+
it 'should load email.css when the default CSS is requested' do
|
89
|
+
File.expects(:read) \
|
90
|
+
.with('RAILS_ROOT/tmp/hassle/stylesheets/email.css') \
|
91
|
+
.returns('content of default css')
|
92
|
+
|
93
|
+
load_css_at_path(:default).should == 'content of default css'
|
94
|
+
end
|
95
|
+
|
96
|
+
it 'should return the content of the file compiled by Hassle' do
|
97
|
+
File.expects(:read) \
|
98
|
+
.with('RAILS_ROOT/tmp/hassle/stylesheets/base.css') \
|
99
|
+
.returns('content of base.css')
|
100
|
+
|
101
|
+
load_css_at_path('http://example.com/stylesheets/base.css') \
|
102
|
+
.should == 'content of base.css'
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
context 'when Rails asset pipeline is used' do
|
107
|
+
before { Rails.configuration.assets.stubs(:enabled).returns(true) }
|
108
|
+
|
109
|
+
it 'should load email.css when the default CSS is requested' do
|
110
|
+
Rails.application.assets.expects(:find_asset) \
|
111
|
+
.with('email.css') \
|
112
|
+
.returns(mock(:body => 'content of default css'))
|
113
|
+
|
114
|
+
load_css_at_path(:default).should == 'content of default css'
|
115
|
+
end
|
116
|
+
|
117
|
+
it 'should return the content of the file compiled by Rails' do
|
118
|
+
Rails.application.assets.expects(:find_asset) \
|
119
|
+
.with('base.css') \
|
120
|
+
.returns(mock(:body => 'content of base.css'))
|
121
|
+
|
122
|
+
load_css_at_path('http://example.com/assets/base.css') \
|
123
|
+
.should == 'content of base.css'
|
124
|
+
end
|
125
|
+
end
|
126
|
+
|
127
|
+
context 'when static stylesheets are used' do
|
128
|
+
it 'should load email.css when the default CSS is requested' do
|
129
|
+
File.expects(:read) \
|
130
|
+
.with('RAILS_ROOT/public/stylesheets/email.css') \
|
131
|
+
.returns('content of default css')
|
132
|
+
|
133
|
+
load_css_at_path(:default).should == 'content of default css'
|
134
|
+
end
|
135
|
+
|
136
|
+
it 'should return the content of the static file' do
|
137
|
+
File.expects(:read) \
|
138
|
+
.with('RAILS_ROOT/public/stylesheets/base.css') \
|
139
|
+
.returns('content of base.css')
|
140
|
+
|
141
|
+
load_css_at_path('http://example.com/stylesheets/base.css') \
|
142
|
+
.should == 'content of base.css'
|
143
|
+
end
|
144
|
+
end
|
145
|
+
end
|
146
|
+
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe 'ActionMailer::Base.register_interceptor' do
|
4
|
+
it 'should register interceptor PremailerRails::Hook' do
|
5
|
+
ActionMailer::Base \
|
6
|
+
.expects(:register_interceptor) \
|
7
|
+
.with(PremailerRails::Hook)
|
8
|
+
load 'premailer-rails3.rb'
|
9
|
+
end
|
10
|
+
end
|
@@ -0,0 +1,73 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe PremailerRails::Hook do
|
4
|
+
describe '.delivering_email' do
|
5
|
+
before { File.stubs(:read).returns('') }
|
6
|
+
def run_hook(message)
|
7
|
+
PremailerRails::Hook.delivering_email(message)
|
8
|
+
end
|
9
|
+
|
10
|
+
context 'when message contains html part' do
|
11
|
+
let(:message) { Fixtures::Message.with_parts :html }
|
12
|
+
|
13
|
+
it 'should create a text part from the html part' do
|
14
|
+
PremailerRails::Premailer.any_instance.expects(:to_plain_text)
|
15
|
+
run_hook(message)
|
16
|
+
message.text_part.should be_a Mail::Part
|
17
|
+
end
|
18
|
+
|
19
|
+
it 'should inline the css in the html part' do
|
20
|
+
PremailerRails::Premailer.any_instance.expects(:to_inline_css)
|
21
|
+
run_hook(message)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
context 'when message contains text part' do
|
26
|
+
let(:message) { Fixtures::Message.with_parts :text }
|
27
|
+
|
28
|
+
it 'should not modify the message' do
|
29
|
+
Premailer.expects(:new).never
|
30
|
+
run_hook(message)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
context 'when message contains html and text part' do
|
35
|
+
let(:message) { Fixtures::Message.with_parts :html, :text }
|
36
|
+
|
37
|
+
it 'should not create a text part from the html part' do
|
38
|
+
PremailerRails::Premailer.any_instance.expects(:to_plain_text).never
|
39
|
+
run_hook(message)
|
40
|
+
message.text_part.should be_a Mail::Part
|
41
|
+
end
|
42
|
+
|
43
|
+
it 'should inline the css in the html part' do
|
44
|
+
PremailerRails::Premailer.any_instance.expects(:to_inline_css)
|
45
|
+
run_hook(message)
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
context 'when message contains html body' do
|
50
|
+
let(:message) { Fixtures::Message.with_body :html }
|
51
|
+
|
52
|
+
it 'should create a text part from the html part' do
|
53
|
+
PremailerRails::Premailer.any_instance.expects(:to_plain_text)
|
54
|
+
run_hook(message)
|
55
|
+
end
|
56
|
+
|
57
|
+
it 'should create a html part and inline the css' do
|
58
|
+
PremailerRails::Premailer.any_instance.expects(:to_inline_css)
|
59
|
+
run_hook(message)
|
60
|
+
message.html_part.should be_a Mail::Part
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
context 'when message contains text body' do
|
65
|
+
let(:message) { Fixtures::Message.with_body :text }
|
66
|
+
|
67
|
+
it 'should not modify the message' do
|
68
|
+
Premailer.expects(:new).never
|
69
|
+
run_hook(message)
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
# coding: UTF-8
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe PremailerRails::Premailer do
|
6
|
+
[ :nokogiri, :hpricot ].each do |adapter|
|
7
|
+
context "when adapter is #{adapter}" do
|
8
|
+
before { ::Premailer::Adapter.stubs(:use).returns(adapter) }
|
9
|
+
|
10
|
+
describe '#to_plain_text' do
|
11
|
+
it 'should include the text from the HTML part' do
|
12
|
+
premailer = PremailerRails::Premailer.new(Fixtures::Message::HTML_PART)
|
13
|
+
premailer.to_plain_text.gsub(/\s/, ' ').strip \
|
14
|
+
.should == Fixtures::Message::TEXT_PART.gsub(/\s/, ' ').strip
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
describe '#to_inline_css' do
|
19
|
+
it 'should return the HTML with the CSS inlined' do
|
20
|
+
PremailerRails::CSSHelper.stubs(:css_for_doc).returns('p { color: red; }')
|
21
|
+
html = Fixtures::Message::HTML_PART
|
22
|
+
premailer = PremailerRails::Premailer.new(html)
|
23
|
+
premailer.to_inline_css.should include '<p style="color: red;">'
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
describe '.new' do
|
30
|
+
it 'should extract the CSS' do
|
31
|
+
PremailerRails::CSSHelper.expects(:css_for_doc)
|
32
|
+
PremailerRails::Premailer.new('some html')
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'stubs/action_mailer'
|
2
|
+
require 'stubs/rails'
|
3
|
+
require 'stubs/try'
|
4
|
+
require 'stubs/hassle'
|
5
|
+
require 'fixtures/message'
|
6
|
+
require 'fixtures/html'
|
7
|
+
|
8
|
+
require 'hpricot'
|
9
|
+
require 'nokogiri'
|
10
|
+
|
11
|
+
require 'premailer-rails3'
|
12
|
+
|
13
|
+
RSpec.configure do |config|
|
14
|
+
config.mock_with :mocha
|
15
|
+
end
|
data/spec/stubs/dummy.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
module Hassle; end
|
data/spec/stubs/rails.rb
ADDED
@@ -0,0 +1,63 @@
|
|
1
|
+
require 'stubs/dummy'
|
2
|
+
|
3
|
+
module Rails
|
4
|
+
extend self
|
5
|
+
|
6
|
+
module Configuration
|
7
|
+
extend self
|
8
|
+
|
9
|
+
module Middleware
|
10
|
+
extend self
|
11
|
+
|
12
|
+
def include?(what)
|
13
|
+
false
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
module Assets
|
18
|
+
extend self
|
19
|
+
|
20
|
+
def prefix
|
21
|
+
'/assets'
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def middleware
|
26
|
+
Middleware
|
27
|
+
end
|
28
|
+
|
29
|
+
def assets
|
30
|
+
Assets
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
module Env
|
35
|
+
extend self
|
36
|
+
|
37
|
+
def development?
|
38
|
+
false
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
module Application
|
43
|
+
extend self
|
44
|
+
|
45
|
+
def assets; end
|
46
|
+
end
|
47
|
+
|
48
|
+
def env
|
49
|
+
Env
|
50
|
+
end
|
51
|
+
|
52
|
+
def configuration
|
53
|
+
Configuration
|
54
|
+
end
|
55
|
+
|
56
|
+
def root
|
57
|
+
'RAILS_ROOT'
|
58
|
+
end
|
59
|
+
|
60
|
+
def application
|
61
|
+
Application
|
62
|
+
end
|
63
|
+
end
|
data/spec/stubs/try.rb
ADDED
metadata
CHANGED
@@ -1,90 +1,170 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: premailer-rails3
|
3
|
-
version: !ruby/object:Gem::Version
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
4
5
|
prerelease:
|
5
|
-
version: "0.2"
|
6
6
|
platform: ruby
|
7
|
-
authors:
|
7
|
+
authors:
|
8
8
|
- Philipe Fatio
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
dependencies:
|
16
|
-
- !ruby/object:Gem::Dependency
|
12
|
+
date: 2011-09-29 00:00:00.000000000Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
17
15
|
name: premailer
|
18
|
-
|
19
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
16
|
+
requirement: &2157702240 !ruby/object:Gem::Requirement
|
20
17
|
none: false
|
21
|
-
requirements:
|
18
|
+
requirements:
|
22
19
|
- - ~>
|
23
|
-
- !ruby/object:Gem::Version
|
24
|
-
version:
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '1.7'
|
25
22
|
type: :runtime
|
26
|
-
version_requirements: *id001
|
27
|
-
- !ruby/object:Gem::Dependency
|
28
|
-
name: hpricot
|
29
23
|
prerelease: false
|
30
|
-
|
24
|
+
version_requirements: *2157702240
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: rails
|
27
|
+
requirement: &2157701400 !ruby/object:Gem::Requirement
|
31
28
|
none: false
|
32
|
-
requirements:
|
29
|
+
requirements:
|
33
30
|
- - ~>
|
34
|
-
- !ruby/object:Gem::Version
|
35
|
-
version:
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '3'
|
36
33
|
type: :runtime
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: *2157701400
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: rspec-core
|
38
|
+
requirement: &2157700700 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ! '>='
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: '0'
|
44
|
+
type: :development
|
45
|
+
prerelease: false
|
46
|
+
version_requirements: *2157700700
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: rspec-expectations
|
49
|
+
requirement: &2157699900 !ruby/object:Gem::Requirement
|
50
|
+
none: false
|
51
|
+
requirements:
|
52
|
+
- - ! '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
type: :development
|
56
|
+
prerelease: false
|
57
|
+
version_requirements: *2157699900
|
58
|
+
- !ruby/object:Gem::Dependency
|
59
|
+
name: mocha
|
60
|
+
requirement: &2157699220 !ruby/object:Gem::Requirement
|
61
|
+
none: false
|
62
|
+
requirements:
|
63
|
+
- - ! '>='
|
64
|
+
- !ruby/object:Gem::Version
|
65
|
+
version: '0'
|
66
|
+
type: :development
|
67
|
+
prerelease: false
|
68
|
+
version_requirements: *2157699220
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: mail
|
71
|
+
requirement: &2157679360 !ruby/object:Gem::Requirement
|
72
|
+
none: false
|
73
|
+
requirements:
|
74
|
+
- - ! '>='
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: '0'
|
77
|
+
type: :development
|
78
|
+
prerelease: false
|
79
|
+
version_requirements: *2157679360
|
80
|
+
- !ruby/object:Gem::Dependency
|
81
|
+
name: nokogiri
|
82
|
+
requirement: &2157678940 !ruby/object:Gem::Requirement
|
83
|
+
none: false
|
84
|
+
requirements:
|
85
|
+
- - ! '>='
|
86
|
+
- !ruby/object:Gem::Version
|
87
|
+
version: '0'
|
88
|
+
type: :development
|
89
|
+
prerelease: false
|
90
|
+
version_requirements: *2157678940
|
91
|
+
- !ruby/object:Gem::Dependency
|
92
|
+
name: hpricot
|
93
|
+
requirement: &2157678160 !ruby/object:Gem::Requirement
|
94
|
+
none: false
|
95
|
+
requirements:
|
96
|
+
- - ! '>='
|
97
|
+
- !ruby/object:Gem::Version
|
98
|
+
version: '0'
|
99
|
+
type: :development
|
100
|
+
prerelease: false
|
101
|
+
version_requirements: *2157678160
|
102
|
+
description: ! "This gem brings you the power of the premailer gem to Rails 3\n without
|
103
|
+
any configuration needs. Create HTML emails, include a\n CSS
|
104
|
+
file as you do in a normal HTML document and premailer will\n inline
|
105
|
+
the included CSS."
|
106
|
+
email:
|
44
107
|
- philipe.fatio@gmail.com
|
45
108
|
executables: []
|
46
|
-
|
47
109
|
extensions: []
|
48
|
-
|
49
110
|
extra_rdoc_files: []
|
50
|
-
|
51
|
-
files:
|
111
|
+
files:
|
52
112
|
- .gitignore
|
53
113
|
- Gemfile
|
54
114
|
- README.md
|
55
115
|
- Rakefile
|
56
116
|
- lib/premailer-rails3.rb
|
117
|
+
- lib/premailer-rails3/css_helper.rb
|
57
118
|
- lib/premailer-rails3/hook.rb
|
58
119
|
- lib/premailer-rails3/premailer.rb
|
59
120
|
- lib/premailer-rails3/version.rb
|
60
121
|
- premailer-rails3.gemspec
|
61
|
-
|
122
|
+
- spec/fixtures/html.rb
|
123
|
+
- spec/fixtures/message.rb
|
124
|
+
- spec/premailer-rails3/css_helper_spec.rb
|
125
|
+
- spec/premailer-rails3/hook_registration_spec.rb
|
126
|
+
- spec/premailer-rails3/hook_spec.rb
|
127
|
+
- spec/premailer-rails3/premailer_spec.rb
|
128
|
+
- spec/spec_helper.rb
|
129
|
+
- spec/stubs/action_mailer.rb
|
130
|
+
- spec/stubs/dummy.rb
|
131
|
+
- spec/stubs/hassle.rb
|
132
|
+
- spec/stubs/rails.rb
|
133
|
+
- spec/stubs/try.rb
|
62
134
|
homepage: https://github.com/fphilipe/premailer-rails3
|
63
135
|
licenses: []
|
64
|
-
|
65
136
|
post_install_message:
|
66
137
|
rdoc_options: []
|
67
|
-
|
68
|
-
require_paths:
|
138
|
+
require_paths:
|
69
139
|
- lib
|
70
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
140
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
71
141
|
none: false
|
72
|
-
requirements:
|
73
|
-
- -
|
74
|
-
- !ruby/object:Gem::Version
|
75
|
-
version:
|
76
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
142
|
+
requirements:
|
143
|
+
- - ! '>='
|
144
|
+
- !ruby/object:Gem::Version
|
145
|
+
version: '0'
|
146
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
77
147
|
none: false
|
78
|
-
requirements:
|
79
|
-
- -
|
80
|
-
- !ruby/object:Gem::Version
|
81
|
-
version:
|
148
|
+
requirements:
|
149
|
+
- - ! '>='
|
150
|
+
- !ruby/object:Gem::Version
|
151
|
+
version: '0'
|
82
152
|
requirements: []
|
83
|
-
|
84
153
|
rubyforge_project: premailer-rails3
|
85
|
-
rubygems_version: 1.
|
154
|
+
rubygems_version: 1.8.8
|
86
155
|
signing_key:
|
87
156
|
specification_version: 3
|
88
157
|
summary: Easily create HTML emails in Rails 3.
|
89
|
-
test_files:
|
90
|
-
|
158
|
+
test_files:
|
159
|
+
- spec/fixtures/html.rb
|
160
|
+
- spec/fixtures/message.rb
|
161
|
+
- spec/premailer-rails3/css_helper_spec.rb
|
162
|
+
- spec/premailer-rails3/hook_registration_spec.rb
|
163
|
+
- spec/premailer-rails3/hook_spec.rb
|
164
|
+
- spec/premailer-rails3/premailer_spec.rb
|
165
|
+
- spec/spec_helper.rb
|
166
|
+
- spec/stubs/action_mailer.rb
|
167
|
+
- spec/stubs/dummy.rb
|
168
|
+
- spec/stubs/hassle.rb
|
169
|
+
- spec/stubs/rails.rb
|
170
|
+
- spec/stubs/try.rb
|