premailer-rails3 1.0.1 → 1.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -36,4 +36,31 @@ Simply add the gem to your Gemfile in your Rails project:
36
36
 
37
37
  gem 'premailer-rails3'
38
38
 
39
+ premailer-rails3 requires either nokogiri or hpricot. It doesn't list them as a
40
+ dependency so you can choose which one to use.
41
+
42
+ gem 'nokogiri'
43
+ # or
44
+ gem 'hpricot'
45
+
46
+ If both are loaded for some reason, premailer chooses hpricot.
47
+
39
48
  That's it!
49
+
50
+ ## Configuration
51
+
52
+ Premailer itself accepts a number of options. In order for premailer-rails3 to
53
+ pass these options on to the underlying premailer instance, specify them in an
54
+ initializer:
55
+
56
+ ```ruby
57
+ PremailerRails.config = {
58
+ :preserve_styles => true,
59
+ :remove_ids => true
60
+ }
61
+ ```
62
+
63
+ For a list of options, refer to the [Premailer documentation](http://rubydoc.info/gems/premailer/1.7.3/Premailer:initialize)
64
+
65
+ Note that the options `with_html_string` and `css_string` are used to make this
66
+ gem work and will thus be overridden.
@@ -3,4 +3,11 @@ require 'premailer-rails3/css_helper'
3
3
  require 'premailer-rails3/premailer'
4
4
  require 'premailer-rails3/hook'
5
5
 
6
+ module PremailerRails3
7
+ @config = {}
8
+ class << self
9
+ attr_accessor :config
10
+ end
11
+ end
12
+
6
13
  ActionMailer::Base.register_interceptor(PremailerRails::Hook)
@@ -36,7 +36,7 @@ module PremailerRails
36
36
  path.sub("#{Rails.configuration.assets.prefix}/", '')
37
37
  end
38
38
  if asset = Rails.application.assets.find_asset(file)
39
- asset.body
39
+ asset.to_s
40
40
  else
41
41
  raise "Couldn't find asset #{file} for premailer-rails3."
42
42
  end
@@ -54,8 +54,7 @@ module PremailerRails
54
54
  end
55
55
 
56
56
  def assets_enabled?
57
- return false unless Rails.configuration.respond_to?(:assets)
58
- Rails.configuration.assets.enabled
57
+ Rails.configuration.assets.enabled rescue false
59
58
  end
60
59
  end
61
60
  end
@@ -11,10 +11,10 @@ module PremailerRails
11
11
  ::Premailer.send(:include, Adapter.find(Adapter.use))
12
12
  doc = load_html(html)
13
13
 
14
- options = {
14
+ options = PremailerRails3.config.merge(
15
15
  :with_html_string => true,
16
16
  :css_string => CSSHelper.css_for_doc(doc)
17
- }
17
+ )
18
18
  super(html, options)
19
19
  end
20
20
  end
@@ -1,3 +1,3 @@
1
1
  module PremailerRails
2
- VERSION = "1.0.1"
2
+ VERSION = "1.0.2"
3
3
  end
@@ -0,0 +1,13 @@
1
+ require 'spec_helper'
2
+
3
+ describe PremailerRails3 do
4
+ describe '#config' do
5
+ subject { PremailerRails3.config }
6
+ it { should == {} }
7
+
8
+ context 'when set' do
9
+ before { PremailerRails3.config = { :foo => :bar } }
10
+ it { should == { :foo => :bar } }
11
+ end
12
+ end
13
+ end
@@ -31,5 +31,11 @@ describe PremailerRails::Premailer do
31
31
  PremailerRails::CSSHelper.expects(:css_for_doc)
32
32
  PremailerRails::Premailer.new('some html')
33
33
  end
34
+
35
+ it 'should pass on the configs' do
36
+ PremailerRails3.config = { :foo => :bar }
37
+ premailer = PremailerRails::Premailer.new('some html')
38
+ premailer.instance_variable_get(:'@options')[:foo].should == :bar
39
+ end
34
40
  end
35
41
  end
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.1
4
+ version: 1.0.2
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-10-20 00:00:00.000000000Z
12
+ date: 2012-02-10 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: premailer
16
- requirement: &2165290820 !ruby/object:Gem::Requirement
16
+ requirement: &2166561480 !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: *2165290820
24
+ version_requirements: *2166561480
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: rails
27
- requirement: &2165289360 !ruby/object:Gem::Requirement
27
+ requirement: &2166560900 !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: *2165289360
35
+ version_requirements: *2166560900
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: rspec-core
38
- requirement: &2165287880 !ruby/object:Gem::Requirement
38
+ requirement: &2166560420 !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: *2165287880
46
+ version_requirements: *2166560420
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: rspec-expectations
49
- requirement: &2165278160 !ruby/object:Gem::Requirement
49
+ requirement: &2166559940 !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: *2165278160
57
+ version_requirements: *2166559940
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: mocha
60
- requirement: &2165276660 !ruby/object:Gem::Requirement
60
+ requirement: &2166559460 !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: *2165276660
68
+ version_requirements: *2166559460
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: mail
71
- requirement: &2165275360 !ruby/object:Gem::Requirement
71
+ requirement: &2166558980 !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: *2165275360
79
+ version_requirements: *2166558980
80
80
  - !ruby/object:Gem::Dependency
81
81
  name: nokogiri
82
- requirement: &2165272480 !ruby/object:Gem::Requirement
82
+ requirement: &2166558500 !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: *2165272480
90
+ version_requirements: *2166558500
91
91
  - !ruby/object:Gem::Dependency
92
92
  name: hpricot
93
- requirement: &2165270980 !ruby/object:Gem::Requirement
93
+ requirement: &2166558020 !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: *2165270980
101
+ version_requirements: *2166558020
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
@@ -125,6 +125,7 @@ files:
125
125
  - spec/premailer-rails3/css_helper_spec.rb
126
126
  - spec/premailer-rails3/hook_registration_spec.rb
127
127
  - spec/premailer-rails3/hook_spec.rb
128
+ - spec/premailer-rails3/premailer_rails_3_spec.rb
128
129
  - spec/premailer-rails3/premailer_spec.rb
129
130
  - spec/spec_helper.rb
130
131
  - spec/stubs/action_mailer.rb
@@ -161,9 +162,11 @@ test_files:
161
162
  - spec/premailer-rails3/css_helper_spec.rb
162
163
  - spec/premailer-rails3/hook_registration_spec.rb
163
164
  - spec/premailer-rails3/hook_spec.rb
165
+ - spec/premailer-rails3/premailer_rails_3_spec.rb
164
166
  - spec/premailer-rails3/premailer_spec.rb
165
167
  - spec/spec_helper.rb
166
168
  - spec/stubs/action_mailer.rb
167
169
  - spec/stubs/dummy.rb
168
170
  - spec/stubs/hassle.rb
169
171
  - spec/stubs/rails.rb
172
+ has_rdoc: