sexxy-emails 0.0.3 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
data/lib/sexxy_emails.rb CHANGED
@@ -1,12 +1,14 @@
1
+ require 'sexxy_emails/railtie' if defined?(Rails)
2
+
1
3
  module SexxyEmails
2
4
 
3
5
  require File.expand_path('../sexxy_emails/css', __FILE__)
4
6
 
5
- VERSION = '0.0.3'.freeze
7
+ VERSION = '0.0.5'.freeze
6
8
 
7
9
  class << self
8
10
  def public_folder
9
- if apps = Padrino::Application.descendants
11
+ if defined?(::Padrino::Application) && apps = Padrino::Application.descendants
10
12
  apps.first.public_folder
11
13
  elsif defined?(Rails)
12
14
  Rails.public_path
@@ -14,12 +16,12 @@ module SexxyEmails
14
16
  end
15
17
 
16
18
  def included(base)
17
- if base < Padrino::Application
19
+ if defined?(::Padrino::Application) && base < ::Padrino::Application
18
20
  require File.expand_path('../sexxy_emails/padrino_mailer', __FILE__)
19
21
  Mail::Message.send(:include, PadrinoMailer::MailerHelper)
20
22
  Mail::Message.send(:include, PadrinoMailer::MailerMethods)
21
- elsif base < ActionMailer::Base
22
- require File.expand_path('../sexxy_emails/action_mailer', __FILE__)
23
+ elsif defined?(::ActionMailer::Base) && base < ::ActionMailer::Base
24
+ setup_action_mailer(base)
23
25
  base.send(:include, ActionMailer::MailerMethods)
24
26
  base.instance_eval do
25
27
  helper SexxyEmails::ActionMailer::MailerHelper
@@ -28,5 +30,9 @@ module SexxyEmails
28
30
  end
29
31
  # For Padrino
30
32
  alias :registered :included
33
+
34
+ def setup_action_mailer(base)
35
+ require File.expand_path('../sexxy_emails/action_mailer', __FILE__)
36
+ end
31
37
  end
32
38
  end
@@ -8,7 +8,7 @@ module SexxyEmails::ActionMailer
8
8
 
9
9
  module MailerHelper
10
10
  def stylesheet_include_tag(css)
11
- path = css.match(/\.css/) ? s : "#{css}.css"
11
+ path = css.match(/\.css/) ? css : "#{css}.css"
12
12
  content_tag(:style) do
13
13
  File.open(File.join(SexxyEmails.public_folder, 'stylesheets', path)).read
14
14
  end
@@ -1,5 +1,6 @@
1
1
  require 'nokogiri'
2
2
  require 'css_parser'
3
+ require 'css_parser/rule_set'
3
4
 
4
5
  module SexxyEmails::Css
5
6
  include CssParser
@@ -31,8 +32,8 @@ module SexxyEmails::Css
31
32
  declaration
32
33
  else
33
34
  CssParser.merge(
34
- RuleSet.new(nil, declaration),
35
- RuleSet.new(nil, node['style'])).declarations_to_s
35
+ CssParser::RuleSet.new(nil, declaration),
36
+ CssParser::RuleSet.new(nil, node['style'])).declarations_to_s
36
37
  end
37
38
  end
38
39
 
@@ -8,7 +8,7 @@ module SexxyEmails::PadrinoMailer
8
8
 
9
9
  module MailerHelper
10
10
  def stylesheet_include_tag(css)
11
- path = css.match(/\.css/) ? s : "#{css}.css"
11
+ path = css.match(/\.css/) ? css : "#{css}.css"
12
12
  style = "<style>"
13
13
  style << File.open(File.join(SexxyEmails.public_folder, 'stylesheets', path)).read
14
14
  style << "</style>"
@@ -0,0 +1,20 @@
1
+ require 'rails/railtie'
2
+
3
+ module SexxyEmails
4
+ class Railtie < Rails::Railtie
5
+
6
+ # config.after_initialize do |app|
7
+ # app.config.paths.add 'app/paths', eager_load: true
8
+
9
+ # if Rails.env.test?
10
+ # # Require test gems.
11
+ # end
12
+ # end
13
+
14
+ initializer "sexxy_emails.setup_action_mailer" do |app|
15
+ ActiveSupport.on_load :action_mailer do
16
+ SexxyEmails.setup_action_mailer self
17
+ end
18
+ end
19
+ end
20
+ end
@@ -4,9 +4,9 @@ require 'rails/all'
4
4
 
5
5
  if defined?(Bundler)
6
6
  # If you precompile assets before deploying to production, use this line
7
- Bundler.require(*Rails.groups(:assets => %w(development test)))
7
+ # Bundler.require(*Rails.groups(:assets => %w(development test)))
8
8
  # If you want your assets lazily compiled in production, use this line
9
- # Bundler.require(:default, :assets, Rails.env)
9
+ Bundler.require(:default, Rails.env)
10
10
  end
11
11
 
12
12
  module ExampleApp
@@ -59,9 +59,9 @@ module ExampleApp
59
59
  config.active_record.whitelist_attributes = true
60
60
 
61
61
  # Enable the asset pipeline
62
- config.assets.enabled = true
62
+ # config.assets.enabled = true
63
63
 
64
64
  # Version of your assets, change this if you want to expire all your assets
65
- config.assets.version = '1.0'
65
+ # config.assets.version = '1.0'
66
66
  end
67
67
  end
@@ -30,8 +30,8 @@ ExampleApp::Application.configure do
30
30
  config.active_record.auto_explain_threshold_in_seconds = 0.5
31
31
 
32
32
  # Do not compress assets
33
- config.assets.compress = false
33
+ # config.assets.compress = false
34
34
 
35
35
  # Expands the lines which load the assets
36
- config.assets.debug = true
36
+ # config.assets.debug = true
37
37
  end
@@ -4,9 +4,9 @@
4
4
  # is enabled by default.
5
5
 
6
6
  # Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array.
7
- ActiveSupport.on_load(:action_controller) do
8
- wrap_parameters :format => [:json]
9
- end
7
+ # ActiveSupport.on_load(:action_controller) do
8
+ # wrap_parameters :format => [:json]
9
+ # end
10
10
 
11
11
  # Disable root element in JSON by default.
12
12
  ActiveSupport.on_load(:active_record) do
data/test/test_helper.rb CHANGED
@@ -1,4 +1,4 @@
1
1
  require 'rubygems'
2
2
  require 'pry'
3
3
  require 'minitest/autorun'
4
- require 'mocha'
4
+ require 'mocha/setup'
metadata CHANGED
@@ -1,150 +1,108 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: sexxy-emails
3
- version: !ruby/object:Gem::Version
4
- hash: 25
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.5
5
5
  prerelease:
6
- segments:
7
- - 0
8
- - 0
9
- - 3
10
- version: 0.0.3
11
6
  platform: ruby
12
- authors:
7
+ authors:
13
8
  - Craig McNamara
14
9
  autorequire:
15
10
  bindir: bin
16
11
  cert_chain: []
17
-
18
- date: 2012-11-10 00:00:00 -08:00
19
- default_executable:
20
- dependencies:
21
- - !ruby/object:Gem::Dependency
12
+ date: 2012-11-10 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
22
15
  name: css_parser
23
- prerelease: false
24
- requirement: &id001 !ruby/object:Gem::Requirement
16
+ requirement: !ruby/object:Gem::Requirement
25
17
  none: false
26
- requirements:
27
- - - ">="
28
- - !ruby/object:Gem::Version
29
- hash: 3
30
- segments:
31
- - 0
32
- version: "0"
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
33
22
  type: :runtime
34
- version_requirements: *id001
35
- - !ruby/object:Gem::Dependency
36
- name: nokogiri
37
23
  prerelease: false
38
- requirement: &id002 !ruby/object:Gem::Requirement
24
+ version_requirements: !ruby/object:Gem::Requirement
39
25
  none: false
40
- requirements:
41
- - - ">="
42
- - !ruby/object:Gem::Version
43
- hash: 3
44
- segments:
45
- - 0
46
- version: "0"
47
- type: :runtime
48
- version_requirements: *id002
49
- - !ruby/object:Gem::Dependency
50
- name: rdoc
51
- prerelease: false
52
- requirement: &id003 !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
30
+ - !ruby/object:Gem::Dependency
31
+ name: nokogiri
32
+ requirement: !ruby/object:Gem::Requirement
53
33
  none: false
54
- requirements:
55
- - - ">="
56
- - !ruby/object:Gem::Version
57
- hash: 3
58
- segments:
59
- - 0
60
- version: "0"
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
61
38
  type: :runtime
62
- version_requirements: *id003
63
- - !ruby/object:Gem::Dependency
64
- name: rails
65
39
  prerelease: false
66
- requirement: &id004 !ruby/object:Gem::Requirement
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ - !ruby/object:Gem::Dependency
47
+ name: rdoc
48
+ requirement: !ruby/object:Gem::Requirement
67
49
  none: false
68
- requirements:
69
- - - ">="
70
- - !ruby/object:Gem::Version
71
- hash: 7
72
- segments:
73
- - 3
74
- - 0
75
- - 0
76
- version: 3.0.0
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
77
54
  type: :development
78
- version_requirements: *id004
79
- - !ruby/object:Gem::Dependency
80
- name: padrino
81
55
  prerelease: false
82
- requirement: &id005 !ruby/object:Gem::Requirement
56
+ version_requirements: !ruby/object:Gem::Requirement
83
57
  none: false
84
- requirements:
85
- - - ">="
86
- - !ruby/object:Gem::Version
87
- hash: 3
88
- segments:
89
- - 0
90
- version: "0"
91
- type: :development
92
- version_requirements: *id005
93
- - !ruby/object:Gem::Dependency
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ - !ruby/object:Gem::Dependency
94
63
  name: rake
95
- prerelease: false
96
- requirement: &id006 !ruby/object:Gem::Requirement
64
+ requirement: !ruby/object:Gem::Requirement
97
65
  none: false
98
- requirements:
99
- - - ">="
100
- - !ruby/object:Gem::Version
101
- hash: 3
102
- segments:
103
- - 0
104
- version: "0"
66
+ requirements:
67
+ - - ! '>='
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
105
70
  type: :development
106
- version_requirements: *id006
107
- - !ruby/object:Gem::Dependency
108
- name: minitest
109
71
  prerelease: false
110
- requirement: &id007 !ruby/object:Gem::Requirement
72
+ version_requirements: !ruby/object:Gem::Requirement
111
73
  none: false
112
- requirements:
113
- - - ">="
114
- - !ruby/object:Gem::Version
115
- hash: 3
116
- segments:
117
- - 0
118
- version: "0"
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
78
+ - !ruby/object:Gem::Dependency
79
+ name: minitest
80
+ requirement: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - ! '>='
84
+ - !ruby/object:Gem::Version
85
+ version: '0'
119
86
  type: :development
120
- version_requirements: *id007
121
- - !ruby/object:Gem::Dependency
122
- name: mocha
123
87
  prerelease: false
124
- requirement: &id008 !ruby/object:Gem::Requirement
88
+ version_requirements: !ruby/object:Gem::Requirement
125
89
  none: false
126
- requirements:
127
- - - ">="
128
- - !ruby/object:Gem::Version
129
- hash: 3
130
- segments:
131
- - 0
132
- version: "0"
133
- type: :development
134
- version_requirements: *id008
135
- description: Adds inline css support to action mailer so you can use a stylesheet to tame your email templates.
90
+ requirements:
91
+ - - ! '>='
92
+ - !ruby/object:Gem::Version
93
+ version: '0'
94
+ description: Adds inline css support to action mailer so you can use a stylesheet
95
+ to tame your email templates.
136
96
  email: craig.mcnamara@gmail.com
137
97
  executables: []
138
-
139
98
  extensions: []
140
-
141
99
  extra_rdoc_files: []
142
-
143
- files:
100
+ files:
144
101
  - lib/sexxy_emails.rb
145
102
  - lib/sexxy_emails/action_mailer.rb
146
103
  - lib/sexxy_emails/css.rb
147
104
  - lib/sexxy_emails/padrino_mailer.rb
105
+ - lib/sexxy_emails/railtie.rb
148
106
  - test/example_padrino_app/app.rb
149
107
  - test/example_padrino_app/views/mailers/basic.html.erb
150
108
  - test/example_rails_app/app/assets/images/rails.png
@@ -194,39 +152,30 @@ files:
194
152
  - test/sexxy_emails/rails_action_mailer_test.rb
195
153
  - test/stylesheets/basic.css
196
154
  - test/test_helper.rb
197
- has_rdoc: true
198
155
  homepage: https://github.com/craigmcnamara/sexxy-emails
199
156
  licenses: []
200
-
201
157
  post_install_message:
202
158
  rdoc_options: []
203
-
204
- require_paths:
159
+ require_paths:
205
160
  - lib
206
- required_ruby_version: !ruby/object:Gem::Requirement
161
+ required_ruby_version: !ruby/object:Gem::Requirement
207
162
  none: false
208
- requirements:
209
- - - ">="
210
- - !ruby/object:Gem::Version
211
- hash: 3
212
- segments:
213
- - 0
214
- version: "0"
215
- required_rubygems_version: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - ! '>='
165
+ - !ruby/object:Gem::Version
166
+ version: '0'
167
+ required_rubygems_version: !ruby/object:Gem::Requirement
216
168
  none: false
217
- requirements:
218
- - - ">="
219
- - !ruby/object:Gem::Version
220
- hash: 3
221
- segments:
222
- - 0
223
- version: "0"
169
+ requirements:
170
+ - - ! '>='
171
+ - !ruby/object:Gem::Version
172
+ version: '0'
224
173
  requirements: []
225
-
226
174
  rubyforge_project:
227
- rubygems_version: 1.6.2
175
+ rubygems_version: 1.8.19
228
176
  signing_key:
229
177
  specification_version: 3
230
- summary: Make your email templates sexxy. The name was inspired by General David H. Petraeus.
231
- test_files:
178
+ summary: Make your email templates sexxy. The name was inspired by General David H.
179
+ Petraeus.
180
+ test_files:
232
181
  - test/test_helper.rb