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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 25b78f55679dd13fd1322548704040a1a5b26b56
4
- data.tar.gz: abe6a1b8cdf72b94af2fd1474f853b88eebc9c37
3
+ metadata.gz: 7663413f12f0c4752826cbaaf71ea2ea16d1e04e
4
+ data.tar.gz: e6a4ea14c4e259cdf8b9b022b944f938025ee04d
5
5
  SHA512:
6
- metadata.gz: e3aeb49fb330efbc99e9e78f317d2ca8f4fa39f47ea91911f9d3a24f8ffa177085b4710b2ad207c22dfa0a8778aed204711dfc9ce3d765712626bb8605a59711
7
- data.tar.gz: 687240293795a24312436592e8141b7332bad5b91a51bad71029b61c84a966d9e771df712c0e1880745b2c46838e3a6ccbdc3ef34186aafbdc4f175849e9cf00
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
- def initialize ( app, options_hash = {}, &block )
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
@@ -5,27 +5,57 @@ module Redjs
5
5
 
6
6
  class Sprockets < Tilt::Template
7
7
 
8
- self.default_mime_type = 'application/javascript'
8
+ class << self
9
+
10
+ attr_accessor :auto_usage_paths
9
11
 
10
- def evaluate ( context, locals )
12
+ def evaluate ( context, data )
11
13
 
12
- result = Redjs::Processor.process context.logical_path, data
14
+ result = Redjs::Processor.process context.logical_path, data
13
15
 
14
- result[ :required ].each{ | required_path | context.require_asset required_path }
16
+ result[ :required ].each{ | required_path | context.require_asset required_path }
15
17
 
16
- result[ :data ]
18
+ result[ :data ]
17
19
 
18
- end
20
+ end
19
21
 
20
- def prepare
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
- def self.register ( sprockets )
48
+ self.auto_usage_paths = []
24
49
 
25
- sprockets.register_engine 'red', self
50
+ self.default_mime_type = 'application/javascript'
26
51
 
27
- sprockets.append_path Redjs::JAVASCRIPTS_PATH
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
@@ -1,5 +1,6 @@
1
1
  require 'set'
2
2
 
3
+ # not work yet
3
4
 
4
5
  module Redjs
5
6
 
data/lib/redjs/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  module Redjs
2
2
 
3
- VERSION = '0.0.2'
3
+ VERSION = '0.1.1'
4
4
 
5
5
  end
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.0.2
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-23 00:00:00.000000000 Z
11
+ date: 2015-02-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec