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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7663413f12f0c4752826cbaaf71ea2ea16d1e04e
4
- data.tar.gz: e6a4ea14c4e259cdf8b9b022b944f938025ee04d
3
+ metadata.gz: f8be159e593e45b4c159c44b8aed36accf07db62
4
+ data.tar.gz: 0d62a1b717d11ff9f2dcd7685930eb87d728d04c
5
5
  SHA512:
6
- metadata.gz: c9b1561e336dfe96e4bc4b8d78628f56728d6611e4860d088e199f3eb67931308f5c13f2ddb4a9fbe5212cb5e9acc62a32d1c4ddd033ee5ebb451d91a6627ba2
7
- data.tar.gz: d29b6b54b9c6fafa5490843e40dc3cfa8ae3b41e1a3212398cecb2caf657308ff6c6915428669ac3a13d4fe9b15cd4527d9aceb312b7359a9f6464a5b300f095
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 'red', Redjs::Sprockets
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 += options[ :auto_usage ]
25
+ Redjs::Sprockets.auto_usage_paths.merge options[ :auto_usage ]
26
26
 
27
27
  end
28
28
 
@@ -1,61 +1,50 @@
1
- require 'tilt'
1
+ require 'set'
2
2
 
3
3
 
4
4
  module Redjs
5
5
 
6
- class Sprockets < Tilt::Template
6
+ class Sprockets < Sprockets::Processor
7
7
 
8
- class << self
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
- result[ :data ]
10
+ @processor = proc do | context, data |
19
11
 
20
- end
12
+ result = Redjs::Processor.process context.logical_path, data
21
13
 
22
- def register ( sprockets )
14
+ result[ :required ].each{ | required_path | context.require_asset required_path }
23
15
 
24
- sprockets.register_engine 'red', self
16
+ result[ :data ]
25
17
 
26
- sprockets.register_preprocessor 'application/javascript', :red do | context, data |
18
+ end
27
19
 
28
- path = context.pathname.to_s
20
+ def self.auto_usage_paths
29
21
 
30
- if path !~ /\.red[^\/]*$/ && auto_usage_paths.any?{ | allowed | path.include?( allowed.to_s ) }
22
+ @auto_usage_paths ||= Set.new
31
23
 
32
- evaluate context, data
24
+ end
33
25
 
34
- else
26
+ def self.register ( sprockets )
35
27
 
36
- data
28
+ sprockets.append_path Redjs::JAVASCRIPTS_PATH
37
29
 
38
- end
30
+ sprockets.register_engine :red, self
39
31
 
40
- end
32
+ sprockets.register_postprocessor default_mime_type, :red do | context, data |
41
33
 
42
- sprockets.append_path Redjs::JAVASCRIPTS_PATH
43
-
44
- end
45
-
46
- end
34
+ path = context.pathname.to_s
47
35
 
48
- self.auto_usage_paths = []
36
+ if path !~ /\.red[^\/]*$/ && auto_usage_paths.any?{ | allowed | path.include?( allowed.to_s ) }
49
37
 
50
- self.default_mime_type = 'application/javascript'
38
+ @processor.call context, data
51
39
 
52
- def evaluate ( context, locals )
40
+ else
53
41
 
54
- self.class.evaluate context, data
42
+ data
55
43
 
56
- end
44
+ end
57
45
 
58
- def prepare
46
+ end
47
+
59
48
  end
60
49
 
61
50
  end
data/lib/redjs/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  module Redjs
2
2
 
3
- VERSION = '0.1.1'
3
+ VERSION = '0.1.2'
4
4
 
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: redjs-sprockets
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dmitry Maganov