awesomemailer 0.1.2 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG CHANGED
@@ -1,3 +1,6 @@
1
+ 0.1.3
2
+ * Added support for matching against multiple asset hosts
3
+
1
4
  0.1.2
2
5
  * Added support for @media queries and vendor prefixes
3
6
  in the header. Should solve most issues w/CSS3 in
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.2
1
+ 0.1.4
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "awesomemailer"
8
- s.version = "0.1.2"
8
+ s.version = "0.1.4"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Flip Sasser"]
@@ -1,7 +1,5 @@
1
1
  require 'abstract_controller'
2
2
  require 'action_mailer'
3
- require 'nokogiri'
4
- require 'css_parser'
5
3
 
6
4
  module AwesomeMailer
7
5
  class Base < ActionMailer::Base
@@ -1,3 +1,6 @@
1
+ require 'css_parser'
2
+ require 'nokogiri'
3
+
1
4
  module AwesomeMailer
2
5
  class Renderer
3
6
  attr_accessor :document
@@ -49,7 +52,6 @@ module AwesomeMailer
49
52
  declarations -= vendor_specific_declarations
50
53
  append_styles_to_head!(document, selector, vendor_specific_declarations, media_query)
51
54
  end
52
-
53
55
  # Include regular styles inline
54
56
  append_styles_to_body!(document, selector, declarations)
55
57
  end
@@ -58,6 +60,13 @@ module AwesomeMailer
58
60
  end
59
61
  end
60
62
 
63
+ def asset_host
64
+ rails? && (
65
+ Rails.configuration.action_mailer.try(:asset_host) ||
66
+ Rails.configuration.action_controller.try(:asset_host)
67
+ )
68
+ end
69
+
61
70
  def asset_pipeline_path
62
71
  return false unless sprockets?
63
72
  /^#{Regexp.escape(Rails.configuration.assets[:prefix])}\//
@@ -67,6 +76,12 @@ module AwesomeMailer
67
76
  @css_parser ||= CssParser::Parser.new
68
77
  end
69
78
 
79
+ def default_host
80
+ if host = AwesomeMailer::Base.default_url_options[:host]
81
+ "#{AwesomeMailer::Base.default_url_options[:scheme] || 'http'}://#{host}"
82
+ end
83
+ end
84
+
70
85
  def head
71
86
  @head ||= document.at('head') || Nokogiri::XML::Node.new('head', document.root).tap do |head|
72
87
  document.root.children.first.add_previous_sibling(head)
@@ -82,7 +97,7 @@ module AwesomeMailer
82
97
  end
83
98
 
84
99
  def host
85
- if host = AwesomeMailer::Base.default_url_options[:host]
100
+ if host = asset_host || default_host
86
101
  Addressable::URI.heuristic_parse(host, scheme: 'http')
87
102
  end
88
103
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: awesomemailer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: