emcee 1.0.1 → 1.0.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -33,6 +33,11 @@ class DummyAppIntegrationTest < ActionController::TestCase
33
33
  <p>test3</p>
34
34
  <p>test2</p>
35
35
  <p>test1</p>
36
+ <polymer-element name="test6" attributes="source">
37
+ <template>
38
+ <img src="{{ source }}">
39
+ </template>
40
+ </polymer-element>
36
41
  EOS
37
42
  end
38
43
  end
@@ -1,7 +1,7 @@
1
1
  require 'test_helper'
2
- require 'emcee/processors/import_processor'
3
- require 'emcee/processors/script_processor'
4
- require 'emcee/processors/stylesheet_processor'
2
+ require 'emcee/post_processors/import_processor'
3
+ require 'emcee/post_processors/script_processor'
4
+ require 'emcee/post_processors/stylesheet_processor'
5
5
 
6
6
  require 'coffee-rails'
7
7
  require 'sass'
@@ -28,7 +28,7 @@ class ContextStub
28
28
  end
29
29
  end
30
30
 
31
- class ProcessorsTest < ActiveSupport::TestCase
31
+ class PostProcessorsTest < ActiveSupport::TestCase
32
32
  setup do
33
33
  @context = ContextStub.new
34
34
  @body = <<-EOS.strip_heredoc
@@ -40,7 +40,7 @@ class ProcessorsTest < ActiveSupport::TestCase
40
40
  end
41
41
 
42
42
  test "processing imports should work" do
43
- processor = Emcee::ImportProcessor.new(@context)
43
+ processor = Emcee::PostProcessors::ImportProcessor.new(@context)
44
44
  processed = processor.process(@body)
45
45
 
46
46
  assert_equal 1, @context.assets.length
@@ -53,7 +53,7 @@ class ProcessorsTest < ActiveSupport::TestCase
53
53
  end
54
54
 
55
55
  test "processing stylesheets should work" do
56
- processor = Emcee::StylesheetProcessor.new(@context)
56
+ processor = Emcee::PostProcessors::StylesheetProcessor.new(@context)
57
57
  processed = processor.process(@body)
58
58
 
59
59
  assert_equal processed, <<-EOS.strip_heredoc
@@ -65,7 +65,7 @@ class ProcessorsTest < ActiveSupport::TestCase
65
65
  end
66
66
 
67
67
  test "processing scripts should work" do
68
- processor = Emcee::ScriptProcessor.new(@context)
68
+ processor = Emcee::PostProcessors::ScriptProcessor.new(@context)
69
69
  processed = processor.process(@body)
70
70
 
71
71
  assert_equal processed, <<-EOS.strip_heredoc
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: emcee
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Huth
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-07-01 00:00:00.000000000 Z
11
+ date: 2014-07-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nokogiri
@@ -95,10 +95,10 @@ files:
95
95
  - lib/emcee/helpers/asset_url_helper.rb
96
96
  - lib/emcee/helpers/sprockets_helper.rb
97
97
  - lib/emcee/loose_assets.rb
98
- - lib/emcee/processors/directive_processor.rb
99
- - lib/emcee/processors/import_processor.rb
100
- - lib/emcee/processors/script_processor.rb
101
- - lib/emcee/processors/stylesheet_processor.rb
98
+ - lib/emcee/post_processors/import_processor.rb
99
+ - lib/emcee/post_processors/script_processor.rb
100
+ - lib/emcee/post_processors/stylesheet_processor.rb
101
+ - lib/emcee/pre_processors/directive_processor.rb
102
102
  - lib/emcee/railtie.rb
103
103
  - lib/emcee/version.rb
104
104
  - lib/generators/emcee/install/install_generator.rb
@@ -115,6 +115,7 @@ files:
115
115
  - test/dummy/app/assets/components/test/test3.css
116
116
  - test/dummy/app/assets/components/test/test3.html
117
117
  - test/dummy/app/assets/components/test1.html
118
+ - test/dummy/app/assets/components/test6.html
118
119
  - test/dummy/app/assets/javascripts/application.js
119
120
  - test/dummy/app/assets/stylesheets/application.css
120
121
  - test/dummy/app/controllers/application_controller.rb
@@ -163,10 +164,12 @@ files:
163
164
  - test/dummy/tmp/cache/assets/test/sprockets/83958b863f75dc6cbe887cc7e0db513f
164
165
  - test/dummy/tmp/cache/assets/test/sprockets/96626508ecce28b11270d0e13ca4edff
165
166
  - test/dummy/tmp/cache/assets/test/sprockets/cffd775d018f68ce5dba1ee0d951a994
167
+ - test/dummy/tmp/cache/assets/test/sprockets/d4ee6708adf72d1eb87e17c8ac3ae163
166
168
  - test/dummy/tmp/cache/assets/test/sprockets/d771ace226fc8215a3572e0aa35bb0d6
167
169
  - test/dummy/tmp/cache/assets/test/sprockets/de38944857ad9b137b1a944b4458197f
168
170
  - test/dummy/tmp/cache/assets/test/sprockets/e0561b1cebd62df57d5d6ac9d2b23033
169
171
  - test/dummy/tmp/cache/assets/test/sprockets/ea6d25feb3cd8cc19f7982458443f784
172
+ - test/dummy/tmp/cache/assets/test/sprockets/ef2c9664b54fb0d162127bdea23cb7d9
170
173
  - test/dummy/tmp/cache/assets/test/sprockets/f16d30b33e206690649697e498a2f1a8
171
174
  - test/dummy/tmp/cache/assets/test/sprockets/f7cbd26ba1d28d48de824f0e94586655
172
175
  - test/dummy/tmp/cache/assets/test/sprockets/fadf553480495a92d11dade99298bf7e
@@ -174,7 +177,7 @@ files:
174
177
  - test/dummy/vendor/assets/components/test4.js
175
178
  - test/dummy_app_integration_test.rb
176
179
  - test/helpers_test.rb
177
- - test/processors_test.rb
180
+ - test/post_processors_test.rb
178
181
  - test/test_helper.rb
179
182
  homepage: https://github.com/ahuth/emcee
180
183
  licenses:
@@ -210,6 +213,7 @@ test_files:
210
213
  - test/dummy/app/assets/components/test/test3.css
211
214
  - test/dummy/app/assets/components/test/test3.html
212
215
  - test/dummy/app/assets/components/test1.html
216
+ - test/dummy/app/assets/components/test6.html
213
217
  - test/dummy/app/assets/javascripts/application.js
214
218
  - test/dummy/app/assets/stylesheets/application.css
215
219
  - test/dummy/app/controllers/application_controller.rb
@@ -260,10 +264,12 @@ test_files:
260
264
  - test/dummy/tmp/cache/assets/test/sprockets/83958b863f75dc6cbe887cc7e0db513f
261
265
  - test/dummy/tmp/cache/assets/test/sprockets/96626508ecce28b11270d0e13ca4edff
262
266
  - test/dummy/tmp/cache/assets/test/sprockets/cffd775d018f68ce5dba1ee0d951a994
267
+ - test/dummy/tmp/cache/assets/test/sprockets/d4ee6708adf72d1eb87e17c8ac3ae163
263
268
  - test/dummy/tmp/cache/assets/test/sprockets/d771ace226fc8215a3572e0aa35bb0d6
264
269
  - test/dummy/tmp/cache/assets/test/sprockets/de38944857ad9b137b1a944b4458197f
265
270
  - test/dummy/tmp/cache/assets/test/sprockets/e0561b1cebd62df57d5d6ac9d2b23033
266
271
  - test/dummy/tmp/cache/assets/test/sprockets/ea6d25feb3cd8cc19f7982458443f784
272
+ - test/dummy/tmp/cache/assets/test/sprockets/ef2c9664b54fb0d162127bdea23cb7d9
267
273
  - test/dummy/tmp/cache/assets/test/sprockets/f16d30b33e206690649697e498a2f1a8
268
274
  - test/dummy/tmp/cache/assets/test/sprockets/f7cbd26ba1d28d48de824f0e94586655
269
275
  - test/dummy/tmp/cache/assets/test/sprockets/fadf553480495a92d11dade99298bf7e
@@ -271,6 +277,6 @@ test_files:
271
277
  - test/dummy/vendor/assets/components/test4.js
272
278
  - test/dummy_app_integration_test.rb
273
279
  - test/helpers_test.rb
274
- - test/processors_test.rb
280
+ - test/post_processors_test.rb
275
281
  - test/test_helper.rb
276
282
  has_rdoc:
@@ -1,33 +0,0 @@
1
- module Emcee
2
- # The `DirectiveProcessor` is responsible for parsing and evaluating
3
- # directive comments in a source file.
4
- class DirectiveProcessor < Sprockets::DirectiveProcessor
5
- # Matches the entire header/directive block. This is everything from the
6
- # top of the file, enclosed in html comments.
7
- HEADER_PATTERN = /\A((?m:\s*)(<!--(?m:.*?)-->))+/
8
-
9
- # Implement `render` so that it uses our own header pattern.
10
- def render(context, locals)
11
- @context = context
12
- @pathname = context.pathname
13
- @directory = File.dirname(@pathname)
14
-
15
- @header = data[HEADER_PATTERN, 0] || ""
16
- @body = $' || data
17
- # Ensure body ends in a new line
18
- @body += "\n" if @body != "" && @body !~ /\n\Z/m
19
-
20
- @included_pathnames = []
21
-
22
- @result = ""
23
- @result.force_encoding(body.encoding)
24
-
25
- @has_written_body = false
26
-
27
- process_directives
28
- process_source
29
-
30
- @result
31
- end
32
- end
33
- end
@@ -1,34 +0,0 @@
1
- require 'nokogiri'
2
-
3
- module Emcee
4
- # ImportProcessor scans a file for html imports and adds them to the current
5
- # required assets.
6
- class ImportProcessor
7
- def initialize(context)
8
- @context = context
9
- @directory = File.dirname(context.pathname)
10
- end
11
-
12
- def process(data)
13
- doc = Nokogiri::HTML.fragment(data)
14
- require_assets(doc)
15
- remove_imports(doc)
16
- doc.to_s.lstrip
17
- end
18
-
19
- private
20
-
21
- def require_assets(doc)
22
- doc.css("link[rel='import']").each do |node|
23
- path = File.absolute_path(node.attribute("href"), @directory)
24
- @context.require_asset(path)
25
- end
26
- end
27
-
28
- def remove_imports(doc)
29
- doc.css("link[rel='import']").each do |node|
30
- node.remove
31
- end
32
- end
33
- end
34
- end
@@ -1,39 +0,0 @@
1
- require 'nokogiri'
2
-
3
- module Emcee
4
- # ScriptProcessor scans a document for external script references and inlines
5
- # them into the current document.
6
- class ScriptProcessor
7
- def initialize(context)
8
- @context = context
9
- @directory = File.dirname(context.pathname)
10
- end
11
-
12
- def process(data)
13
- doc = Nokogiri::HTML.fragment(data)
14
- inline_scripts(doc)
15
- doc.to_s
16
- end
17
-
18
- private
19
-
20
- def inline_scripts(doc)
21
- doc.css("script[src]").each do |node|
22
- path = absolute_path(node.attribute("src"))
23
- content = @context.evaluate(path)
24
- script = create_script(doc, content)
25
- node.replace(script)
26
- end
27
- end
28
-
29
- def absolute_path(path)
30
- File.absolute_path(path, @directory)
31
- end
32
-
33
- def create_script(doc, content)
34
- node = Nokogiri::XML::Node.new("script", doc)
35
- node.content = content
36
- node
37
- end
38
- end
39
- end
@@ -1,39 +0,0 @@
1
- require 'nokogiri'
2
-
3
- module Emcee
4
- # StylesheetProcessor scans a document for external stylesheet references and
5
- # inlines them into the current document.
6
- class StylesheetProcessor
7
- def initialize(context)
8
- @context = context
9
- @directory = File.dirname(context.pathname)
10
- end
11
-
12
- def process(data)
13
- doc = Nokogiri::HTML.fragment(data)
14
- inline_styles(doc)
15
- doc.to_s
16
- end
17
-
18
- private
19
-
20
- def inline_styles(doc)
21
- doc.css("link[rel='stylesheet']").each do |node|
22
- path = absolute_path(node.attribute("href"))
23
- content = @context.evaluate(path)
24
- style = create_style(doc, content)
25
- node.replace(style)
26
- end
27
- end
28
-
29
- def absolute_path(path)
30
- File.absolute_path(path, @directory)
31
- end
32
-
33
- def create_style(doc, content)
34
- node = Nokogiri::XML::Node.new("style", doc)
35
- node.content = content
36
- node
37
- end
38
- end
39
- end