emcee 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/emcee.rb +4 -3
- data/lib/emcee/helpers/{action_view.rb → action_view/asset_tag_helper.rb} +0 -11
- data/lib/emcee/helpers/action_view/asset_url_helper.rb +15 -0
- data/lib/emcee/helpers/{sprockets_compressing.rb → sprockets/compressing_helpers.rb} +4 -1
- data/lib/emcee/helpers/{sprockets_view.rb → sprockets/view_helpers.rb} +0 -0
- data/lib/emcee/processors/html_processor.rb +2 -0
- data/lib/emcee/processors/processor_base.rb +57 -0
- data/lib/emcee/processors/processor_imports.rb +19 -0
- data/lib/emcee/processors/processor_scripts.rb +27 -0
- data/lib/emcee/processors/processor_stylesheets.rb +27 -0
- data/lib/emcee/railtie.rb +0 -1
- data/lib/emcee/version.rb +1 -1
- data/test/controllers_test.rb +21 -0
- data/test/dummy/app/controllers/dummy_controller.rb +6 -0
- data/test/dummy/config/routes.rb +1 -0
- data/test/dummy/log/test.log +12581 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/af6ba4ae23c6790e0f474b01ceee8dd9 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/cf517b62bd978b748afe38d5beb317de +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/df6cfcc50da209231a7d9e140e5bafdc +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/e0949aa3dcdcab5f8b45d30e26f6ddd2 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/ffd4adb86602a60c7fcedd5d472166d3 +0 -0
- data/test/processors_test.rb +3 -4
- metadata +10 -9
- data/lib/emcee/processors/processor_includes.rb +0 -98
- data/lib/tasks/emcee_tasks.rake +0 -4
- data/test/dummy/db/development.sqlite3 +0 -0
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
data/test/processors_test.rb
CHANGED
@@ -31,7 +31,7 @@ class ProcessorsTest < ActiveSupport::TestCase
|
|
31
31
|
@processor = ProcessorStub.new
|
32
32
|
@context = ContextStub.new
|
33
33
|
@directory = "/dir"
|
34
|
-
@body = %
|
34
|
+
@body = %q{
|
35
35
|
<link rel="import" href="test.html">
|
36
36
|
<link rel="stylesheet" href="test.css">
|
37
37
|
<script src="test.js"></script>
|
@@ -45,7 +45,6 @@ class ProcessorsTest < ActiveSupport::TestCase
|
|
45
45
|
assert_equal "/dir/test.html", @context.assets[0]
|
46
46
|
|
47
47
|
assert_equal processed, %q{
|
48
|
-
|
49
48
|
<link rel="stylesheet" href="test.css">
|
50
49
|
<script src="test.js"></script>
|
51
50
|
<p>test</p>
|
@@ -56,7 +55,7 @@ class ProcessorsTest < ActiveSupport::TestCase
|
|
56
55
|
processed = @processor.process_stylesheets(@body, @directory)
|
57
56
|
assert_equal processed, %q{
|
58
57
|
<link rel="import" href="test.html">
|
59
|
-
<style>/* contents */</style>
|
58
|
+
<style>/* contents */</style>
|
60
59
|
<script src="test.js"></script>
|
61
60
|
<p>test</p>
|
62
61
|
}
|
@@ -67,7 +66,7 @@ class ProcessorsTest < ActiveSupport::TestCase
|
|
67
66
|
assert_equal processed, %q{
|
68
67
|
<link rel="import" href="test.html">
|
69
68
|
<link rel="stylesheet" href="test.css">
|
70
|
-
<script>/* contents */</script>
|
69
|
+
<script>/* contents */</script>
|
71
70
|
<p>test</p>
|
72
71
|
}
|
73
72
|
end
|
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: 0.1.
|
4
|
+
version: 0.1.3
|
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-03-
|
11
|
+
date: 2014-03-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -49,16 +49,19 @@ files:
|
|
49
49
|
- Rakefile
|
50
50
|
- lib/emcee.rb
|
51
51
|
- lib/emcee/compressors/html_compressor.rb
|
52
|
-
- lib/emcee/helpers/action_view.rb
|
53
|
-
- lib/emcee/helpers/
|
54
|
-
- lib/emcee/helpers/
|
52
|
+
- lib/emcee/helpers/action_view/asset_tag_helper.rb
|
53
|
+
- lib/emcee/helpers/action_view/asset_url_helper.rb
|
54
|
+
- lib/emcee/helpers/sprockets/compressing_helpers.rb
|
55
|
+
- lib/emcee/helpers/sprockets/view_helpers.rb
|
55
56
|
- lib/emcee/processors/html_processor.rb
|
56
|
-
- lib/emcee/processors/
|
57
|
+
- lib/emcee/processors/processor_base.rb
|
58
|
+
- lib/emcee/processors/processor_imports.rb
|
59
|
+
- lib/emcee/processors/processor_scripts.rb
|
60
|
+
- lib/emcee/processors/processor_stylesheets.rb
|
57
61
|
- lib/emcee/railtie.rb
|
58
62
|
- lib/emcee/version.rb
|
59
63
|
- lib/generators/emcee/install/install_generator.rb
|
60
64
|
- lib/generators/emcee/install/templates/application.html
|
61
|
-
- lib/tasks/emcee_tasks.rake
|
62
65
|
- test/compressors_test.rb
|
63
66
|
- test/controllers_test.rb
|
64
67
|
- test/dummy/README.rdoc
|
@@ -95,7 +98,6 @@ files:
|
|
95
98
|
- test/dummy/config/initializers/wrap_parameters.rb
|
96
99
|
- test/dummy/config/locales/en.yml
|
97
100
|
- test/dummy/config/routes.rb
|
98
|
-
- test/dummy/db/development.sqlite3
|
99
101
|
- test/dummy/db/test.sqlite3
|
100
102
|
- test/dummy/log/development.log
|
101
103
|
- test/dummy/log/test.log
|
@@ -206,7 +208,6 @@ test_files:
|
|
206
208
|
- test/dummy/config/locales/en.yml
|
207
209
|
- test/dummy/config/routes.rb
|
208
210
|
- test/dummy/config.ru
|
209
|
-
- test/dummy/db/development.sqlite3
|
210
211
|
- test/dummy/db/test.sqlite3
|
211
212
|
- test/dummy/log/development.log
|
212
213
|
- test/dummy/log/test.log
|
@@ -1,98 +0,0 @@
|
|
1
|
-
module Emcee
|
2
|
-
module Processors
|
3
|
-
# This module has method definition that we will include into HtmlProcessor.
|
4
|
-
#
|
5
|
-
# We seperate these out to make them easier to test. Testing a class that inherits
|
6
|
-
# from Sprockets::DirectiveProcessor (which our HtmlProcessor does) is not
|
7
|
-
# straightforward.
|
8
|
-
#
|
9
|
-
module Includes
|
10
|
-
# Match an html import tag.
|
11
|
-
#
|
12
|
-
# <link rel="import" href="assets/example.html">
|
13
|
-
#
|
14
|
-
IMPORT_PATTERN = /^ *<link .*rel=["']import["'].*>$/
|
15
|
-
|
16
|
-
# Match a stylesheet link tag.
|
17
|
-
#
|
18
|
-
# <link rel="stylesheet" href="assets/example.css">
|
19
|
-
#
|
20
|
-
STYLESHEET_PATTERN = /^ *<link .*rel=["']stylesheet["'].*>$/
|
21
|
-
|
22
|
-
# Match a script tag.
|
23
|
-
#
|
24
|
-
# <script src="assets/example.js"></script>
|
25
|
-
#
|
26
|
-
SCRIPT_PATTERN = /^ *<script .*src=["'].+\.js["']><\/script>$/
|
27
|
-
|
28
|
-
# Match the path from the href attribute of an html import or stylesheet
|
29
|
-
# include tag. Captures the actual path.
|
30
|
-
#
|
31
|
-
# href="/assets/example.css"
|
32
|
-
#
|
33
|
-
HREF_PATH_PATTERN = /href=["'](?<path>[\w\.\/-]+)["']/
|
34
|
-
|
35
|
-
# Match the source path from a script tag. Captures the actual path.
|
36
|
-
#
|
37
|
-
# src="/assets/example.js"
|
38
|
-
#
|
39
|
-
SRC_PATH_PATTERN = /src=["'](?<path>[\w\.\/-]+)["']/
|
40
|
-
|
41
|
-
# Return a file's contents as text. This is split out as a method so that
|
42
|
-
# we can test the other methods in this module without actually reading from
|
43
|
-
# the filesystem.
|
44
|
-
def read_file(path)
|
45
|
-
File.read(path)
|
46
|
-
end
|
47
|
-
|
48
|
-
# Scan the body for html imports. If any are found, tell sprockets to
|
49
|
-
# require their files like we would for a directive. Then remove the import.
|
50
|
-
def process_imports(body, context, directory)
|
51
|
-
body.scan(IMPORT_PATTERN) do |import_tag|
|
52
|
-
if path = import_tag[HREF_PATH_PATTERN, :path]
|
53
|
-
absolute_path = File.absolute_path(path, directory)
|
54
|
-
context.require_asset(absolute_path)
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|
58
|
-
body.gsub(IMPORT_PATTERN, "")
|
59
|
-
end
|
60
|
-
|
61
|
-
# Scan the body for external stylesheet references. If any are found,
|
62
|
-
# inline the files in place of the references.
|
63
|
-
def process_stylesheets(body, directory)
|
64
|
-
to_inline = []
|
65
|
-
|
66
|
-
body.scan(STYLESHEET_PATTERN) do |stylesheet_tag|
|
67
|
-
if path = stylesheet_tag[HREF_PATH_PATTERN, :path]
|
68
|
-
absolute_path = File.absolute_path(path, directory)
|
69
|
-
stylesheet_contents = read_file(absolute_path)
|
70
|
-
to_inline << [stylesheet_tag, "<style>" + stylesheet_contents + "</style>"]
|
71
|
-
end
|
72
|
-
end
|
73
|
-
|
74
|
-
to_inline.reduce(body) do |output, (tag, contents)|
|
75
|
-
output.gsub(tag, contents)
|
76
|
-
end
|
77
|
-
end
|
78
|
-
|
79
|
-
# Scan the body for external script references. If any are found, inline
|
80
|
-
# the files in place of the references.
|
81
|
-
def process_scripts(body, directory)
|
82
|
-
to_inline = []
|
83
|
-
|
84
|
-
body.scan(SCRIPT_PATTERN) do |script_tag|
|
85
|
-
if path = script_tag[SRC_PATH_PATTERN, :path]
|
86
|
-
absolute_path = File.absolute_path(path, directory)
|
87
|
-
script_contents = read_file(absolute_path)
|
88
|
-
to_inline << [script_tag, "<script>" + script_contents + "</script>"]
|
89
|
-
end
|
90
|
-
end
|
91
|
-
|
92
|
-
to_inline.reduce(body) do |output, (tag, contents)|
|
93
|
-
output.gsub(tag, contents)
|
94
|
-
end
|
95
|
-
end
|
96
|
-
end
|
97
|
-
end
|
98
|
-
end
|
data/lib/tasks/emcee_tasks.rake
DELETED
File without changes
|