premailer-rails3 1.0.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format doc
2
+ --color
data/README.md CHANGED
@@ -1,13 +1,39 @@
1
1
  # Premailer Rails 3 README
2
2
 
3
- This gem is a no config solution for the wonderful [Premailer gem](https://github.com/alexdunae/premailer) to be used with Rails 3.
3
+ This gem is a no config solution for the wonderful
4
+ [Premailer gem](https://github.com/alexdunae/premailer) to be used with Rails 3.
4
5
  It uses interceptors which were introduced in Rails 3 and tweaks all mails which
5
- receive the `deliver` method and adds a plain text part to it and inlines all CSS rules into the HTML part.
6
+ are `deliver`ed and adds a plain text part to them and inlines all CSS rules
7
+ into the HTML part.
6
8
 
7
- Currently it ignores any stylesheets linked within the email in favour of applying the stylesheet found at `public/stylesheets/email.css` or, if you use SASS on Heroku with Hassle, at `tmp/hassle/stylesheets/email.css`.
9
+ By default it inlines all the CSS files that are linked to in the HTML:
10
+
11
+ ```html
12
+ <link type='text/css' ... />
13
+ ```
14
+
15
+ Don't worry about the host in the CSS URL since this will be ignored.
16
+
17
+ If no CSS file is linked to in the HTML it will try to load a default CSS file
18
+ `email.css`.
19
+
20
+ Every CSS file (including the default `email.css`) is loaded from within the
21
+ app. The retrieval of the file depends on your assets configuration:
22
+
23
+ * Rails 3.1 asset pipeline: It will load the compiled version of the CSS asset
24
+ which is normally located in `app/assets/stylesheets/`.
25
+
26
+ * Classic static assets: It will try to load the CSS file located in
27
+ `public/stylesheets/`
28
+
29
+ * [Hassle](https://github.com/pedro/hassle): It will try to load the
30
+ compiled CSS file located in the default Hassle location
31
+ `tmp/hassle/stylesheets/`
8
32
 
9
33
  ## Installation
10
34
 
11
35
  Simply add the gem to your Gemfile in your Rails project:
12
36
 
13
37
  gem 'premailer-rails3'
38
+
39
+ That's it!
@@ -29,7 +29,7 @@ module PremailerRails
29
29
  if defined? Hassle and Rails.configuration.middleware.include? Hassle
30
30
  file = path == :default ? '/stylesheets/email.css' : path
31
31
  File.read("#{Rails.root}/tmp/hassle#{file}")
32
- elsif Rails.configuration.try(:assets).try(:enabled)
32
+ elsif assets_enabled?
33
33
  file = if path == :default
34
34
  'email.css'
35
35
  else
@@ -52,5 +52,10 @@ module PremailerRails
52
52
  puts ex.message
53
53
  @@css_cache[path] = ''
54
54
  end
55
+
56
+ def assets_enabled?
57
+ return false unless Rails.configuration.respond_to?(:assets)
58
+ Rails.configuration.assets.enabled
59
+ end
55
60
  end
56
61
  end
@@ -1,3 +1,3 @@
1
1
  module PremailerRails
2
- VERSION = "1.0.0"
2
+ VERSION = "1.0.1"
3
3
  end
@@ -104,7 +104,14 @@ describe PremailerRails::CSSHelper do
104
104
  end
105
105
 
106
106
  context 'when Rails asset pipeline is used' do
107
- before { Rails.configuration.assets.stubs(:enabled).returns(true) }
107
+ before {
108
+ Rails.configuration.stubs(:assets).returns(
109
+ stub(
110
+ :enabled => true,
111
+ :prefix => '/assets'
112
+ )
113
+ )
114
+ }
108
115
 
109
116
  it 'should load email.css when the default CSS is requested' do
110
117
  Rails.application.assets.expects(:find_asset) \
data/spec/spec_helper.rb CHANGED
@@ -1,6 +1,5 @@
1
1
  require 'stubs/action_mailer'
2
2
  require 'stubs/rails'
3
- require 'stubs/try'
4
3
  require 'stubs/hassle'
5
4
  require 'fixtures/message'
6
5
  require 'fixtures/html'
data/spec/stubs/rails.rb CHANGED
@@ -14,21 +14,9 @@ module Rails
14
14
  end
15
15
  end
16
16
 
17
- module Assets
18
- extend self
19
-
20
- def prefix
21
- '/assets'
22
- end
23
- end
24
-
25
17
  def middleware
26
18
  Middleware
27
19
  end
28
-
29
- def assets
30
- Assets
31
- end
32
20
  end
33
21
 
34
22
  module Env
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: premailer-rails3
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-09-29 00:00:00.000000000Z
12
+ date: 2011-10-20 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: premailer
16
- requirement: &2157702240 !ruby/object:Gem::Requirement
16
+ requirement: &2165290820 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '1.7'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *2157702240
24
+ version_requirements: *2165290820
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: rails
27
- requirement: &2157701400 !ruby/object:Gem::Requirement
27
+ requirement: &2165289360 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ~>
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '3'
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *2157701400
35
+ version_requirements: *2165289360
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: rspec-core
38
- requirement: &2157700700 !ruby/object:Gem::Requirement
38
+ requirement: &2165287880 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: '0'
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *2157700700
46
+ version_requirements: *2165287880
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: rspec-expectations
49
- requirement: &2157699900 !ruby/object:Gem::Requirement
49
+ requirement: &2165278160 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: '0'
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *2157699900
57
+ version_requirements: *2165278160
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: mocha
60
- requirement: &2157699220 !ruby/object:Gem::Requirement
60
+ requirement: &2165276660 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ! '>='
@@ -65,10 +65,10 @@ dependencies:
65
65
  version: '0'
66
66
  type: :development
67
67
  prerelease: false
68
- version_requirements: *2157699220
68
+ version_requirements: *2165276660
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: mail
71
- requirement: &2157679360 !ruby/object:Gem::Requirement
71
+ requirement: &2165275360 !ruby/object:Gem::Requirement
72
72
  none: false
73
73
  requirements:
74
74
  - - ! '>='
@@ -76,10 +76,10 @@ dependencies:
76
76
  version: '0'
77
77
  type: :development
78
78
  prerelease: false
79
- version_requirements: *2157679360
79
+ version_requirements: *2165275360
80
80
  - !ruby/object:Gem::Dependency
81
81
  name: nokogiri
82
- requirement: &2157678940 !ruby/object:Gem::Requirement
82
+ requirement: &2165272480 !ruby/object:Gem::Requirement
83
83
  none: false
84
84
  requirements:
85
85
  - - ! '>='
@@ -87,10 +87,10 @@ dependencies:
87
87
  version: '0'
88
88
  type: :development
89
89
  prerelease: false
90
- version_requirements: *2157678940
90
+ version_requirements: *2165272480
91
91
  - !ruby/object:Gem::Dependency
92
92
  name: hpricot
93
- requirement: &2157678160 !ruby/object:Gem::Requirement
93
+ requirement: &2165270980 !ruby/object:Gem::Requirement
94
94
  none: false
95
95
  requirements:
96
96
  - - ! '>='
@@ -98,7 +98,7 @@ dependencies:
98
98
  version: '0'
99
99
  type: :development
100
100
  prerelease: false
101
- version_requirements: *2157678160
101
+ version_requirements: *2165270980
102
102
  description: ! "This gem brings you the power of the premailer gem to Rails 3\n without
103
103
  any configuration needs. Create HTML emails, include a\n CSS
104
104
  file as you do in a normal HTML document and premailer will\n inline
@@ -110,6 +110,7 @@ extensions: []
110
110
  extra_rdoc_files: []
111
111
  files:
112
112
  - .gitignore
113
+ - .rspec
113
114
  - Gemfile
114
115
  - README.md
115
116
  - Rakefile
@@ -130,7 +131,6 @@ files:
130
131
  - spec/stubs/dummy.rb
131
132
  - spec/stubs/hassle.rb
132
133
  - spec/stubs/rails.rb
133
- - spec/stubs/try.rb
134
134
  homepage: https://github.com/fphilipe/premailer-rails3
135
135
  licenses: []
136
136
  post_install_message:
@@ -167,4 +167,3 @@ test_files:
167
167
  - spec/stubs/dummy.rb
168
168
  - spec/stubs/hassle.rb
169
169
  - spec/stubs/rails.rb
170
- - spec/stubs/try.rb
data/spec/stubs/try.rb DELETED
@@ -1,5 +0,0 @@
1
- class Object
2
- def try(method, *args)
3
- self.__send__(method, *args) rescue nil
4
- end
5
- end