redjs-sprockets 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/redjs/platforms/middleman.rb +2 -2
- data/lib/redjs/sprockets/v2.rb +23 -34
- data/lib/redjs/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f8be159e593e45b4c159c44b8aed36accf07db62
|
4
|
+
data.tar.gz: 0d62a1b717d11ff9f2dcd7685930eb87d728d04c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 23dad44cc9e48fd5bc010034aaee65e7c133438e572295f6bbf1eb679be02d3087e0b618688761cb4682a99b2d5dafb1a042d21d10a5aaf7e993bc6207b78b3f
|
7
|
+
data.tar.gz: ed31f74f17e3302ce703ab4b5257b41d04f7e5052ef9d64d8a0f9780d3ad3a7ef727ac52fa7c25065730f98276ec110988f47a7bacf7eff07a33aecefec527a4
|
@@ -14,7 +14,7 @@ module Redjs
|
|
14
14
|
|
15
15
|
super
|
16
16
|
|
17
|
-
::Tilt.register
|
17
|
+
::Tilt.register :red, Redjs::Sprockets
|
18
18
|
|
19
19
|
app.after_configuration do
|
20
20
|
|
@@ -22,7 +22,7 @@ module Redjs
|
|
22
22
|
|
23
23
|
end
|
24
24
|
|
25
|
-
Redjs::Sprockets.auto_usage_paths
|
25
|
+
Redjs::Sprockets.auto_usage_paths.merge options[ :auto_usage ]
|
26
26
|
|
27
27
|
end
|
28
28
|
|
data/lib/redjs/sprockets/v2.rb
CHANGED
@@ -1,61 +1,50 @@
|
|
1
|
-
require '
|
1
|
+
require 'set'
|
2
2
|
|
3
3
|
|
4
4
|
module Redjs
|
5
5
|
|
6
|
-
class Sprockets <
|
6
|
+
class Sprockets < Sprockets::Processor
|
7
7
|
|
8
|
-
|
9
|
-
|
10
|
-
attr_accessor :auto_usage_paths
|
11
|
-
|
12
|
-
def evaluate ( context, data )
|
13
|
-
|
14
|
-
result = Redjs::Processor.process context.logical_path, data
|
15
|
-
|
16
|
-
result[ :required ].each{ | required_path | context.require_asset required_path }
|
8
|
+
self.default_mime_type = 'application/javascript'
|
17
9
|
|
18
|
-
|
10
|
+
@processor = proc do | context, data |
|
19
11
|
|
20
|
-
|
12
|
+
result = Redjs::Processor.process context.logical_path, data
|
21
13
|
|
22
|
-
|
14
|
+
result[ :required ].each{ | required_path | context.require_asset required_path }
|
23
15
|
|
24
|
-
|
16
|
+
result[ :data ]
|
25
17
|
|
26
|
-
|
18
|
+
end
|
27
19
|
|
28
|
-
|
20
|
+
def self.auto_usage_paths
|
29
21
|
|
30
|
-
|
22
|
+
@auto_usage_paths ||= Set.new
|
31
23
|
|
32
|
-
|
24
|
+
end
|
33
25
|
|
34
|
-
|
26
|
+
def self.register ( sprockets )
|
35
27
|
|
36
|
-
|
28
|
+
sprockets.append_path Redjs::JAVASCRIPTS_PATH
|
37
29
|
|
38
|
-
|
30
|
+
sprockets.register_engine :red, self
|
39
31
|
|
40
|
-
|
32
|
+
sprockets.register_postprocessor default_mime_type, :red do | context, data |
|
41
33
|
|
42
|
-
|
43
|
-
|
44
|
-
end
|
45
|
-
|
46
|
-
end
|
34
|
+
path = context.pathname.to_s
|
47
35
|
|
48
|
-
|
36
|
+
if path !~ /\.red[^\/]*$/ && auto_usage_paths.any?{ | allowed | path.include?( allowed.to_s ) }
|
49
37
|
|
50
|
-
|
38
|
+
@processor.call context, data
|
51
39
|
|
52
|
-
|
40
|
+
else
|
53
41
|
|
54
|
-
|
42
|
+
data
|
55
43
|
|
56
|
-
|
44
|
+
end
|
57
45
|
|
58
|
-
|
46
|
+
end
|
47
|
+
|
59
48
|
end
|
60
49
|
|
61
50
|
end
|
data/lib/redjs/version.rb
CHANGED