roadie 2.3.2 → 2.3.3

Sign up to get free protection for your applications and to get access to all the features.
data/Changelog.md CHANGED
@@ -1,8 +1,17 @@
1
1
  ### dev
2
2
 
3
- [full changelog](https://github.com/Mange/roadie/compare/v2.3.2...master)
3
+ [full changelog](https://github.com/Mange/roadie/compare/v2.3.3...master)
4
4
 
5
- * Nothing yet
5
+ * No changes yet.
6
+
7
+ ### 2.3.3
8
+
9
+ [full changelog](https://github.com/Mange/roadie/compare/v2.3.2...v2.3.3)
10
+
11
+ * Enhancements:
12
+ * Allow proc objects to the `:css` option
13
+ * Bug fixes:
14
+ * Ignore HTML comments and CDATA sections in CSS (support TinyMCE)
6
15
 
7
16
  ### 2.3.2
8
17
 
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- roadie (2.3.2)
4
+ roadie (2.3.3)
5
5
  actionmailer (> 3.0.0, < 3.3.0)
6
6
  css_parser
7
7
  nokogiri (>= 1.4.4)
@@ -37,7 +37,7 @@ GEM
37
37
  activemodel (= 3.0.12)
38
38
  activesupport (= 3.0.12)
39
39
  activesupport (3.0.12)
40
- addressable (2.2.7)
40
+ addressable (2.3.2)
41
41
  appraisal (0.4.1)
42
42
  bundler
43
43
  rake
@@ -65,8 +65,8 @@ GEM
65
65
  mime-types (~> 1.16)
66
66
  treetop (~> 1.4.8)
67
67
  mime-types (1.18)
68
- multi_json (1.1.0)
69
- nokogiri (1.5.2)
68
+ multi_json (1.3.6)
69
+ nokogiri (1.5.5)
70
70
  polyglot (0.3.3)
71
71
  rack (1.2.5)
72
72
  rack-mount (0.6.14)
data/README.md CHANGED
@@ -38,7 +38,7 @@ Let me know if you want any other combination supported officially.
38
38
 
39
39
  ### Versioning ###
40
40
 
41
- This project follows [Semtantic Versioning](http://semver.org/) and has been since version 1.0.0.
41
+ This project follows [Semantic Versioning](http://semver.org/) and has been since version 1.0.0.
42
42
 
43
43
  Features
44
44
  --------
@@ -46,8 +46,15 @@ module Roadie
46
46
  end
47
47
 
48
48
  def css_targets
49
- return [] unless @targets
50
- Array.wrap(@targets || []).map { |target| target.to_s }
49
+ Array.wrap(@targets || []).map { |target| resolve_target(target) }.compact.map(&:to_s)
50
+ end
51
+
52
+ def resolve_target(target)
53
+ if target.respond_to? :call
54
+ target.call
55
+ else
56
+ target
57
+ end
51
58
  end
52
59
  end
53
60
  end
@@ -65,15 +65,15 @@ module Roadie
65
65
 
66
66
  def parsed_css
67
67
  CssParser::Parser.new.tap do |parser|
68
- parser.add_block!(css) if css
69
- parser.add_block!(inline_css)
68
+ parser.add_block! clean_css(css) if css
69
+ parser.add_block! clean_css(inline_css)
70
70
  end
71
71
  end
72
72
 
73
73
  def adjust_html
74
74
  Nokogiri::HTML.parse(html).tap do |document|
75
75
  yield document
76
- end.to_html
76
+ end.dup.to_html
77
77
  end
78
78
 
79
79
  def add_missing_structure
@@ -207,5 +207,19 @@ module Roadie
207
207
  absolute_path_url or blacklisted_element
208
208
  end
209
209
  end
210
+
211
+ CLEANING_MATCHER = /
212
+ (^\s* # Beginning-of-lines matches
213
+ (<!\[CDATA\[)|
214
+ (<!--+)
215
+ )|( # End-of-line matches
216
+ (--+>)|
217
+ (\]\]>)
218
+ $)
219
+ /x.freeze
220
+
221
+ def clean_css(css)
222
+ css.gsub(CLEANING_MATCHER, '')
223
+ end
210
224
  end
211
225
  end
@@ -1,3 +1,3 @@
1
1
  module Roadie
2
- VERSION = '2.3.2'
2
+ VERSION = '2.3.3'
3
3
  end
@@ -30,6 +30,22 @@ module Roadie
30
30
  Roadie.stub(:current_provider => provider)
31
31
  end
32
32
 
33
+ it "uses the default CSS when :css is not specified" do
34
+ expect_global_css ['default']
35
+ mailer.default_css
36
+ end
37
+
38
+ it "uses the specified CSS instead of the default" do
39
+ expect_global_css ['some', 'other/files']
40
+ mailer.override_css([:some, 'other/files'])
41
+ end
42
+
43
+ it "allows procs defining the CSS files to use" do
44
+ expect_global_css ['from proc']
45
+ proc = lambda { 'from proc' }
46
+ mailer.override_css([proc])
47
+ end
48
+
33
49
  it "uses no global CSS when :css is set to nil" do
34
50
  expect_global_css []
35
51
  mailer.override_css(nil)
@@ -40,14 +56,9 @@ module Roadie
40
56
  mailer.override_css(false)
41
57
  end
42
58
 
43
- it "uses the default CSS when :css is not specified" do
44
- expect_global_css ['default']
45
- mailer.default_css
46
- end
47
-
48
- it "uses the specified CSS instead of the default" do
49
- expect_global_css ['some', 'other/files']
50
- mailer.override_css([:some, 'other/files'])
59
+ it "uses no global CSS when :css is set to a proc returning nil" do
60
+ expect_global_css []
61
+ mailer.override_css(lambda { nil })
51
62
  end
52
63
  end
53
64
 
@@ -115,6 +115,26 @@ describe Roadie::Inliner do
115
115
  expect { rendering('<p></p>') }.not_to raise_error
116
116
  end
117
117
 
118
+ it 'ignores HTML comments and CDATA sections' do
119
+ # TinyMCE posts invalid CSS. We support that just to be pragmatic.
120
+ use_css %(<![CDATA[
121
+ <!--
122
+ p { color: green }
123
+ -->
124
+ ]]>)
125
+ expect { rendering '<p></p>' }.not_to raise_error
126
+
127
+ use_css %(
128
+ <!--
129
+ <![CDATA[
130
+ <![CDATA[
131
+ span { color: red }
132
+ ]]>
133
+ -->
134
+ )
135
+ expect { rendering '<p></p>' }.not_to raise_error
136
+ end
137
+
118
138
  describe "inline <style> element" do
119
139
  it "is used for inlined styles" do
120
140
  rendering(<<-HTML).should have_styling([['color', 'green'], ['font-size', '1.1em']])
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: roadie
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.3.2
4
+ version: 2.3.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-07-09 00:00:00.000000000 Z
12
+ date: 2012-10-22 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: nokogiri
@@ -206,7 +206,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
206
206
  version: '0'
207
207
  segments:
208
208
  - 0
209
- hash: -3017908964885938458
209
+ hash: 2753670790342683218
210
210
  required_rubygems_version: !ruby/object:Gem::Requirement
211
211
  none: false
212
212
  requirements:
@@ -215,7 +215,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
215
215
  version: '0'
216
216
  segments:
217
217
  - 0
218
- hash: -3017908964885938458
218
+ hash: 2753670790342683218
219
219
  requirements: []
220
220
  rubyforge_project:
221
221
  rubygems_version: 1.8.24