redjs-sprockets 0.0.2 → 0.1.1
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 +5 -1
- data/lib/redjs/sprockets/v2.rb +41 -11
- data/lib/redjs/sprockets/v3.rb +1 -0
- data/lib/redjs/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7663413f12f0c4752826cbaaf71ea2ea16d1e04e
|
4
|
+
data.tar.gz: e6a4ea14c4e259cdf8b9b022b944f938025ee04d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c9b1561e336dfe96e4bc4b8d78628f56728d6611e4860d088e199f3eb67931308f5c13f2ddb4a9fbe5212cb5e9acc62a32d1c4ddd033ee5ebb451d91a6627ba2
|
7
|
+
data.tar.gz: d29b6b54b9c6fafa5490843e40dc3cfa8ae3b41e1a3212398cecb2caf657308ff6c6915428669ac3a13d4fe9b15cd4527d9aceb312b7359a9f6464a5b300f095
|
@@ -8,7 +8,9 @@ module Redjs
|
|
8
8
|
|
9
9
|
class Middleman < ::Middleman::Extension
|
10
10
|
|
11
|
-
|
11
|
+
option :auto_usage, [], 'Array of paths where the ".red" file extension is auto assumed.'
|
12
|
+
|
13
|
+
def initialize ( app, options = {}, &block )
|
12
14
|
|
13
15
|
super
|
14
16
|
|
@@ -20,6 +22,8 @@ module Redjs
|
|
20
22
|
|
21
23
|
end
|
22
24
|
|
25
|
+
Redjs::Sprockets.auto_usage_paths += options[ :auto_usage ]
|
26
|
+
|
23
27
|
end
|
24
28
|
|
25
29
|
end
|
data/lib/redjs/sprockets/v2.rb
CHANGED
@@ -5,27 +5,57 @@ module Redjs
|
|
5
5
|
|
6
6
|
class Sprockets < Tilt::Template
|
7
7
|
|
8
|
-
|
8
|
+
class << self
|
9
|
+
|
10
|
+
attr_accessor :auto_usage_paths
|
9
11
|
|
10
|
-
|
12
|
+
def evaluate ( context, data )
|
11
13
|
|
12
|
-
|
14
|
+
result = Redjs::Processor.process context.logical_path, data
|
13
15
|
|
14
|
-
|
16
|
+
result[ :required ].each{ | required_path | context.require_asset required_path }
|
15
17
|
|
16
|
-
|
18
|
+
result[ :data ]
|
17
19
|
|
18
|
-
|
20
|
+
end
|
19
21
|
|
20
|
-
|
22
|
+
def register ( sprockets )
|
23
|
+
|
24
|
+
sprockets.register_engine 'red', self
|
25
|
+
|
26
|
+
sprockets.register_preprocessor 'application/javascript', :red do | context, data |
|
27
|
+
|
28
|
+
path = context.pathname.to_s
|
29
|
+
|
30
|
+
if path !~ /\.red[^\/]*$/ && auto_usage_paths.any?{ | allowed | path.include?( allowed.to_s ) }
|
31
|
+
|
32
|
+
evaluate context, data
|
33
|
+
|
34
|
+
else
|
35
|
+
|
36
|
+
data
|
37
|
+
|
38
|
+
end
|
39
|
+
|
40
|
+
end
|
41
|
+
|
42
|
+
sprockets.append_path Redjs::JAVASCRIPTS_PATH
|
43
|
+
|
44
|
+
end
|
45
|
+
|
21
46
|
end
|
22
47
|
|
23
|
-
|
48
|
+
self.auto_usage_paths = []
|
24
49
|
|
25
|
-
|
50
|
+
self.default_mime_type = 'application/javascript'
|
26
51
|
|
27
|
-
|
28
|
-
|
52
|
+
def evaluate ( context, locals )
|
53
|
+
|
54
|
+
self.class.evaluate context, data
|
55
|
+
|
56
|
+
end
|
57
|
+
|
58
|
+
def prepare
|
29
59
|
end
|
30
60
|
|
31
61
|
end
|
data/lib/redjs/sprockets/v3.rb
CHANGED
data/lib/redjs/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: redjs-sprockets
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dmitry Maganov
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-02-
|
11
|
+
date: 2015-02-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|