roadie 2.4.3 → 3.0.0.pre1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (87) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +3 -0
  3. data/.travis.yml +9 -14
  4. data/.yardopts +1 -1
  5. data/Changelog.md +22 -10
  6. data/Gemfile +3 -0
  7. data/Guardfile +11 -1
  8. data/README.md +165 -163
  9. data/Rakefile +2 -19
  10. data/lib/roadie.rb +14 -69
  11. data/lib/roadie/asset_provider.rb +7 -58
  12. data/lib/roadie/asset_scanner.rb +92 -0
  13. data/lib/roadie/document.rb +103 -0
  14. data/lib/roadie/errors.rb +57 -0
  15. data/lib/roadie/filesystem_provider.rb +21 -62
  16. data/lib/roadie/inliner.rb +71 -218
  17. data/lib/roadie/markup_improver.rb +88 -0
  18. data/lib/roadie/null_provider.rb +13 -0
  19. data/lib/roadie/null_url_rewriter.rb +12 -0
  20. data/lib/roadie/provider_list.rb +67 -0
  21. data/lib/roadie/rspec.rb +1 -0
  22. data/lib/roadie/rspec/asset_provider.rb +49 -0
  23. data/lib/roadie/selector.rb +42 -18
  24. data/lib/roadie/style_block.rb +33 -0
  25. data/lib/roadie/style_properties.rb +29 -0
  26. data/lib/roadie/style_property.rb +93 -0
  27. data/lib/roadie/stylesheet.rb +65 -0
  28. data/lib/roadie/url_generator.rb +126 -0
  29. data/lib/roadie/url_rewriter.rb +84 -0
  30. data/lib/roadie/version.rb +1 -1
  31. data/roadie.gemspec +6 -10
  32. data/spec/fixtures/big_em.css +1 -0
  33. data/spec/fixtures/stylesheets/green.css +1 -0
  34. data/spec/integration_spec.rb +125 -95
  35. data/spec/lib/roadie/asset_scanner_spec.rb +153 -0
  36. data/spec/lib/roadie/css_not_found_spec.rb +16 -0
  37. data/spec/lib/roadie/document_spec.rb +123 -0
  38. data/spec/lib/roadie/filesystem_provider_spec.rb +25 -72
  39. data/spec/lib/roadie/inliner_spec.rb +105 -537
  40. data/spec/lib/roadie/markup_improver_spec.rb +78 -0
  41. data/spec/lib/roadie/null_provider_spec.rb +21 -0
  42. data/spec/lib/roadie/null_url_rewriter_spec.rb +19 -0
  43. data/spec/lib/roadie/provider_list_spec.rb +81 -0
  44. data/spec/lib/roadie/selector_spec.rb +7 -5
  45. data/spec/lib/roadie/style_block_spec.rb +35 -0
  46. data/spec/lib/roadie/style_properties_spec.rb +61 -0
  47. data/spec/lib/roadie/style_property_spec.rb +82 -0
  48. data/spec/lib/roadie/stylesheet_spec.rb +41 -0
  49. data/spec/lib/roadie/test_provider_spec.rb +29 -0
  50. data/spec/lib/roadie/url_generator_spec.rb +120 -0
  51. data/spec/lib/roadie/url_rewriter_spec.rb +79 -0
  52. data/spec/shared_examples/asset_provider.rb +11 -0
  53. data/spec/shared_examples/url_rewriter.rb +23 -0
  54. data/spec/spec_helper.rb +5 -60
  55. data/spec/support/have_node_matcher.rb +2 -2
  56. data/spec/support/have_selector_matcher.rb +1 -1
  57. data/spec/support/have_styling_matcher.rb +48 -14
  58. data/spec/support/test_provider.rb +13 -0
  59. metadata +73 -177
  60. data/Appraisals +0 -15
  61. data/gemfiles/rails_3.0.gemfile +0 -7
  62. data/gemfiles/rails_3.0.gemfile.lock +0 -123
  63. data/gemfiles/rails_3.1.gemfile +0 -7
  64. data/gemfiles/rails_3.1.gemfile.lock +0 -126
  65. data/gemfiles/rails_3.2.gemfile +0 -7
  66. data/gemfiles/rails_3.2.gemfile.lock +0 -124
  67. data/gemfiles/rails_4.0.gemfile +0 -7
  68. data/gemfiles/rails_4.0.gemfile.lock +0 -119
  69. data/lib/roadie/action_mailer_extensions.rb +0 -95
  70. data/lib/roadie/asset_pipeline_provider.rb +0 -28
  71. data/lib/roadie/css_file_not_found.rb +0 -22
  72. data/lib/roadie/railtie.rb +0 -39
  73. data/lib/roadie/style_declaration.rb +0 -42
  74. data/spec/fixtures/app/assets/stylesheets/integration.css +0 -10
  75. data/spec/fixtures/public/stylesheets/integration.css +0 -10
  76. data/spec/fixtures/views/integration_mailer/marketing.html.erb +0 -2
  77. data/spec/fixtures/views/integration_mailer/notification.html.erb +0 -8
  78. data/spec/fixtures/views/integration_mailer/notification.text.erb +0 -6
  79. data/spec/lib/roadie/action_mailer_extensions_spec.rb +0 -227
  80. data/spec/lib/roadie/asset_pipeline_provider_spec.rb +0 -65
  81. data/spec/lib/roadie/css_file_not_found_spec.rb +0 -29
  82. data/spec/lib/roadie/style_declaration_spec.rb +0 -49
  83. data/spec/lib/roadie_spec.rb +0 -101
  84. data/spec/shared_examples/asset_provider_examples.rb +0 -11
  85. data/spec/support/anonymous_mailer.rb +0 -21
  86. data/spec/support/change_url_options.rb +0 -5
  87. data/spec/support/parse_styling.rb +0 -25
@@ -1,7 +0,0 @@
1
- # This file was generated by Appraisal
2
-
3
- source "https://rubygems.org"
4
-
5
- gem "rails", "~> 3.1.0"
6
-
7
- gemspec :path=>"../"
@@ -1,126 +0,0 @@
1
- PATH
2
- remote: /Users/mange/Projects/roadie
3
- specs:
4
- roadie (2.4.2)
5
- actionmailer (> 3.0.0, < 5.0.0)
6
- css_parser (~> 1.3.4)
7
- nokogiri (> 1.5.0)
8
- sprockets
9
-
10
- GEM
11
- remote: https://rubygems.org/
12
- specs:
13
- actionmailer (3.1.4)
14
- actionpack (= 3.1.4)
15
- mail (~> 2.3.0)
16
- actionpack (3.1.4)
17
- activemodel (= 3.1.4)
18
- activesupport (= 3.1.4)
19
- builder (~> 3.0.0)
20
- erubis (~> 2.7.0)
21
- i18n (~> 0.6)
22
- rack (~> 1.3.6)
23
- rack-cache (~> 1.1)
24
- rack-mount (~> 0.8.2)
25
- rack-test (~> 0.6.1)
26
- sprockets (~> 2.0.3)
27
- activemodel (3.1.4)
28
- activesupport (= 3.1.4)
29
- builder (~> 3.0.0)
30
- i18n (~> 0.6)
31
- activerecord (3.1.4)
32
- activemodel (= 3.1.4)
33
- activesupport (= 3.1.4)
34
- arel (~> 2.2.3)
35
- tzinfo (~> 0.3.29)
36
- activeresource (3.1.4)
37
- activemodel (= 3.1.4)
38
- activesupport (= 3.1.4)
39
- activesupport (3.1.4)
40
- multi_json (~> 1.0)
41
- addressable (2.3.5)
42
- appraisal (0.5.2)
43
- bundler
44
- rake
45
- arel (2.2.3)
46
- builder (3.0.0)
47
- css_parser (1.3.5)
48
- addressable
49
- diff-lcs (1.2.4)
50
- erubis (2.7.0)
51
- hike (1.2.1)
52
- i18n (0.6.1)
53
- json (1.7.5)
54
- mail (2.3.3)
55
- i18n (>= 0.4.0)
56
- mime-types (~> 1.16)
57
- treetop (~> 1.4.8)
58
- mime-types (1.19)
59
- mini_portile (0.5.1)
60
- multi_json (1.4.0)
61
- nokogiri (1.6.0)
62
- mini_portile (~> 0.5.0)
63
- polyglot (0.3.3)
64
- rack (1.3.6)
65
- rack-cache (1.2)
66
- rack (>= 0.4)
67
- rack-mount (0.8.3)
68
- rack (>= 1.0.0)
69
- rack-ssl (1.3.2)
70
- rack
71
- rack-test (0.6.2)
72
- rack (>= 1.0)
73
- rails (3.1.4)
74
- actionmailer (= 3.1.4)
75
- actionpack (= 3.1.4)
76
- activerecord (= 3.1.4)
77
- activeresource (= 3.1.4)
78
- activesupport (= 3.1.4)
79
- bundler (~> 1.0)
80
- railties (= 3.1.4)
81
- railties (3.1.4)
82
- actionpack (= 3.1.4)
83
- activesupport (= 3.1.4)
84
- rack-ssl (~> 1.3.2)
85
- rake (>= 0.8.7)
86
- rdoc (~> 3.4)
87
- thor (~> 0.14.6)
88
- rake (10.0.2)
89
- rdoc (3.12)
90
- json (~> 1.4)
91
- rspec (2.14.1)
92
- rspec-core (~> 2.14.0)
93
- rspec-expectations (~> 2.14.0)
94
- rspec-mocks (~> 2.14.0)
95
- rspec-core (2.14.5)
96
- rspec-expectations (2.14.3)
97
- diff-lcs (>= 1.1.3, < 2.0)
98
- rspec-mocks (2.14.3)
99
- rspec-rails (2.14.0)
100
- actionpack (>= 3.0)
101
- activesupport (>= 3.0)
102
- railties (>= 3.0)
103
- rspec-core (~> 2.14.0)
104
- rspec-expectations (~> 2.14.0)
105
- rspec-mocks (~> 2.14.0)
106
- sprockets (2.0.3)
107
- hike (~> 1.2)
108
- rack (~> 1.0)
109
- tilt (~> 1.1, != 1.3.0)
110
- thor (0.14.6)
111
- tilt (1.3.3)
112
- treetop (1.4.12)
113
- polyglot
114
- polyglot (>= 0.3.1)
115
- tzinfo (0.3.35)
116
-
117
- PLATFORMS
118
- ruby
119
-
120
- DEPENDENCIES
121
- appraisal
122
- rails (~> 3.1.0)
123
- rake
124
- roadie!
125
- rspec
126
- rspec-rails
@@ -1,7 +0,0 @@
1
- # This file was generated by Appraisal
2
-
3
- source "https://rubygems.org"
4
-
5
- gem "rails", "~> 3.2.0"
6
-
7
- gemspec :path=>"../"
@@ -1,124 +0,0 @@
1
- PATH
2
- remote: /Users/mange/Projects/roadie
3
- specs:
4
- roadie (2.4.2)
5
- actionmailer (> 3.0.0, < 5.0.0)
6
- css_parser (~> 1.3.4)
7
- nokogiri (> 1.5.0)
8
- sprockets
9
-
10
- GEM
11
- remote: https://rubygems.org/
12
- specs:
13
- actionmailer (3.2.2)
14
- actionpack (= 3.2.2)
15
- mail (~> 2.4.0)
16
- actionpack (3.2.2)
17
- activemodel (= 3.2.2)
18
- activesupport (= 3.2.2)
19
- builder (~> 3.0.0)
20
- erubis (~> 2.7.0)
21
- journey (~> 1.0.1)
22
- rack (~> 1.4.0)
23
- rack-cache (~> 1.1)
24
- rack-test (~> 0.6.1)
25
- sprockets (~> 2.1.2)
26
- activemodel (3.2.2)
27
- activesupport (= 3.2.2)
28
- builder (~> 3.0.0)
29
- activerecord (3.2.2)
30
- activemodel (= 3.2.2)
31
- activesupport (= 3.2.2)
32
- arel (~> 3.0.2)
33
- tzinfo (~> 0.3.29)
34
- activeresource (3.2.2)
35
- activemodel (= 3.2.2)
36
- activesupport (= 3.2.2)
37
- activesupport (3.2.2)
38
- i18n (~> 0.6)
39
- multi_json (~> 1.0)
40
- addressable (2.3.5)
41
- appraisal (0.5.2)
42
- bundler
43
- rake
44
- arel (3.0.2)
45
- builder (3.0.0)
46
- css_parser (1.3.5)
47
- addressable
48
- diff-lcs (1.2.4)
49
- erubis (2.7.0)
50
- hike (1.2.1)
51
- i18n (0.6.1)
52
- journey (1.0.4)
53
- json (1.7.5)
54
- mail (2.4.4)
55
- i18n (>= 0.4.0)
56
- mime-types (~> 1.16)
57
- treetop (~> 1.4.8)
58
- mime-types (1.19)
59
- mini_portile (0.5.1)
60
- multi_json (1.4.0)
61
- nokogiri (1.6.0)
62
- mini_portile (~> 0.5.0)
63
- polyglot (0.3.3)
64
- rack (1.4.1)
65
- rack-cache (1.2)
66
- rack (>= 0.4)
67
- rack-ssl (1.3.2)
68
- rack
69
- rack-test (0.6.2)
70
- rack (>= 1.0)
71
- rails (3.2.2)
72
- actionmailer (= 3.2.2)
73
- actionpack (= 3.2.2)
74
- activerecord (= 3.2.2)
75
- activeresource (= 3.2.2)
76
- activesupport (= 3.2.2)
77
- bundler (~> 1.0)
78
- railties (= 3.2.2)
79
- railties (3.2.2)
80
- actionpack (= 3.2.2)
81
- activesupport (= 3.2.2)
82
- rack-ssl (~> 1.3.2)
83
- rake (>= 0.8.7)
84
- rdoc (~> 3.4)
85
- thor (~> 0.14.6)
86
- rake (10.0.2)
87
- rdoc (3.12)
88
- json (~> 1.4)
89
- rspec (2.14.1)
90
- rspec-core (~> 2.14.0)
91
- rspec-expectations (~> 2.14.0)
92
- rspec-mocks (~> 2.14.0)
93
- rspec-core (2.14.5)
94
- rspec-expectations (2.14.3)
95
- diff-lcs (>= 1.1.3, < 2.0)
96
- rspec-mocks (2.14.3)
97
- rspec-rails (2.14.0)
98
- actionpack (>= 3.0)
99
- activesupport (>= 3.0)
100
- railties (>= 3.0)
101
- rspec-core (~> 2.14.0)
102
- rspec-expectations (~> 2.14.0)
103
- rspec-mocks (~> 2.14.0)
104
- sprockets (2.1.2)
105
- hike (~> 1.2)
106
- rack (~> 1.0)
107
- tilt (~> 1.1, != 1.3.0)
108
- thor (0.14.6)
109
- tilt (1.3.3)
110
- treetop (1.4.12)
111
- polyglot
112
- polyglot (>= 0.3.1)
113
- tzinfo (0.3.35)
114
-
115
- PLATFORMS
116
- ruby
117
-
118
- DEPENDENCIES
119
- appraisal
120
- rails (~> 3.2.0)
121
- rake
122
- roadie!
123
- rspec
124
- rspec-rails
@@ -1,7 +0,0 @@
1
- # This file was generated by Appraisal
2
-
3
- source "https://rubygems.org"
4
-
5
- gem "rails", "~> 4.0"
6
-
7
- gemspec :path=>"../"
@@ -1,119 +0,0 @@
1
- PATH
2
- remote: /Users/mange/Projects/roadie
3
- specs:
4
- roadie (2.4.2)
5
- actionmailer (> 3.0.0, < 5.0.0)
6
- css_parser (~> 1.3.4)
7
- nokogiri (> 1.5.0)
8
- sprockets
9
-
10
- GEM
11
- remote: https://rubygems.org/
12
- specs:
13
- actionmailer (4.0.0)
14
- actionpack (= 4.0.0)
15
- mail (~> 2.5.3)
16
- actionpack (4.0.0)
17
- activesupport (= 4.0.0)
18
- builder (~> 3.1.0)
19
- erubis (~> 2.7.0)
20
- rack (~> 1.5.2)
21
- rack-test (~> 0.6.2)
22
- activemodel (4.0.0)
23
- activesupport (= 4.0.0)
24
- builder (~> 3.1.0)
25
- activerecord (4.0.0)
26
- activemodel (= 4.0.0)
27
- activerecord-deprecated_finders (~> 1.0.2)
28
- activesupport (= 4.0.0)
29
- arel (~> 4.0.0)
30
- activerecord-deprecated_finders (1.0.3)
31
- activesupport (4.0.0)
32
- i18n (~> 0.6, >= 0.6.4)
33
- minitest (~> 4.2)
34
- multi_json (~> 1.3)
35
- thread_safe (~> 0.1)
36
- tzinfo (~> 0.3.37)
37
- addressable (2.3.5)
38
- appraisal (0.5.2)
39
- bundler
40
- rake
41
- arel (4.0.0)
42
- atomic (1.1.10)
43
- builder (3.1.4)
44
- css_parser (1.3.5)
45
- addressable
46
- diff-lcs (1.2.4)
47
- erubis (2.7.0)
48
- hike (1.2.3)
49
- i18n (0.6.4)
50
- mail (2.5.4)
51
- mime-types (~> 1.16)
52
- treetop (~> 1.4.8)
53
- mime-types (1.23)
54
- mini_portile (0.5.1)
55
- minitest (4.7.5)
56
- multi_json (1.7.7)
57
- nokogiri (1.6.0)
58
- mini_portile (~> 0.5.0)
59
- polyglot (0.3.3)
60
- rack (1.5.2)
61
- rack-test (0.6.2)
62
- rack (>= 1.0)
63
- rails (4.0.0)
64
- actionmailer (= 4.0.0)
65
- actionpack (= 4.0.0)
66
- activerecord (= 4.0.0)
67
- activesupport (= 4.0.0)
68
- bundler (>= 1.3.0, < 2.0)
69
- railties (= 4.0.0)
70
- sprockets-rails (~> 2.0.0)
71
- railties (4.0.0)
72
- actionpack (= 4.0.0)
73
- activesupport (= 4.0.0)
74
- rake (>= 0.8.7)
75
- thor (>= 0.18.1, < 2.0)
76
- rake (10.1.0)
77
- rspec (2.14.1)
78
- rspec-core (~> 2.14.0)
79
- rspec-expectations (~> 2.14.0)
80
- rspec-mocks (~> 2.14.0)
81
- rspec-core (2.14.5)
82
- rspec-expectations (2.14.3)
83
- diff-lcs (>= 1.1.3, < 2.0)
84
- rspec-mocks (2.14.3)
85
- rspec-rails (2.14.0)
86
- actionpack (>= 3.0)
87
- activesupport (>= 3.0)
88
- railties (>= 3.0)
89
- rspec-core (~> 2.14.0)
90
- rspec-expectations (~> 2.14.0)
91
- rspec-mocks (~> 2.14.0)
92
- sprockets (2.10.0)
93
- hike (~> 1.2)
94
- multi_json (~> 1.0)
95
- rack (~> 1.0)
96
- tilt (~> 1.1, != 1.3.0)
97
- sprockets-rails (2.0.0)
98
- actionpack (>= 3.0)
99
- activesupport (>= 3.0)
100
- sprockets (~> 2.8)
101
- thor (0.18.1)
102
- thread_safe (0.1.0)
103
- atomic
104
- tilt (1.4.1)
105
- treetop (1.4.14)
106
- polyglot
107
- polyglot (>= 0.3.1)
108
- tzinfo (0.3.37)
109
-
110
- PLATFORMS
111
- ruby
112
-
113
- DEPENDENCIES
114
- appraisal
115
- rails (~> 4.0)
116
- rake
117
- roadie!
118
- rspec
119
- rspec-rails
@@ -1,95 +0,0 @@
1
- require 'uri'
2
- require 'nokogiri'
3
- require 'css_parser'
4
-
5
- module Roadie
6
- # This module adds the Roadie functionality to ActionMailer 3 when included in ActionMailer::Base.
7
- #
8
- # If you want to add Roadie to any other mail framework, take a look at how this module is implemented.
9
- module ActionMailerExtensions
10
- def self.included(base)
11
- base.class_eval do
12
- if base.method_defined?(:collect_responses)
13
- alias_method_chain :collect_responses, :inline_styles
14
- else
15
- alias_method_chain :collect_responses_and_parts_order, :inline_styles
16
- end
17
- alias_method_chain :mail, :inline_styles
18
- end
19
- end
20
-
21
- protected
22
- def mail_with_inline_styles(headers = {}, &block)
23
- if headers.has_key?(:css)
24
- @targets = headers[:css]
25
- else
26
- @targets = default_css_targets
27
- end
28
-
29
- if headers.has_key?(:after_inlining)
30
- @after_inlining_handler = headers[:after_inlining]
31
- else
32
- @after_inlining_handler = default_after_inlining || Roadie.after_inlining_handler
33
- end
34
-
35
- mail_without_inline_styles(headers, &block).tap do |email|
36
- email.header.fields.delete_if { |field| %w(css after_inlining).include?(field.name) }
37
- end
38
- end
39
-
40
- # Rails 4
41
- def collect_responses_with_inline_styles(headers, &block)
42
- responses = collect_responses_without_inline_styles(headers, &block)
43
- if Roadie.enabled?
44
- responses.map { |response| inline_style_response(response) }
45
- else
46
- responses
47
- end
48
- end
49
-
50
- # Rails 3
51
- def collect_responses_and_parts_order_with_inline_styles(headers, &block)
52
- responses, order = collect_responses_and_parts_order_without_inline_styles(headers, &block)
53
- if Roadie.enabled?
54
- [responses.map { |response| inline_style_response(response) }, order]
55
- else
56
- [responses, order]
57
- end
58
- end
59
-
60
- private
61
- def default_css_targets
62
- self.class.default[:css]
63
- end
64
-
65
- def default_after_inlining
66
- self.class.default[:after_inlining]
67
- end
68
-
69
- def after_inlining_handler
70
- @after_inlining_handler
71
- end
72
-
73
- def inline_style_response(response)
74
- if response[:content_type] == 'text/html'
75
- response.merge :body => Roadie.inline_css(Roadie.current_provider, css_targets, response[:body], url_options, after_inlining_handler)
76
- else
77
- response
78
- end
79
- end
80
-
81
- def css_targets
82
- Array.wrap(@targets || []).map { |target| resolve_target(target) }.compact.map(&:to_s)
83
- end
84
-
85
- def resolve_target(target)
86
- if target.kind_of? Proc
87
- instance_exec(&target)
88
- elsif target.respond_to? :call
89
- target.call
90
- else
91
- target
92
- end
93
- end
94
- end
95
- end