sprockets-dotjs 2.1.1 → 3.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,5 +1,5 @@
1
1
  module Sprockets
2
2
  module Dotjs
3
- VERSION = "2.1.1"
3
+ VERSION = "3.0.0"
4
4
  end
5
5
  end
@@ -1,6 +1,7 @@
1
1
  require 'sprockets'
2
2
  require 'tilt/template'
3
3
  require 'v8'
4
+ require 'digest/md5'
4
5
 
5
6
  module Sprockets
6
7
  module DotJS
@@ -19,13 +20,32 @@ module Sprockets
19
20
  @@context.eval(dotjs_lib)
20
21
  end
21
22
 
23
+ def build_dependencies(set = [],environment,path)
24
+ processed_asset = environment.find_asset(path, :bundle => false)
25
+ dependency_paths = processed_asset.send(:dependency_paths).each do |dependency_file|
26
+ if !set.include? dependency_file.pathname
27
+ set << dependency_file.pathname
28
+ build_dependencies(set,environment,dependency_file.pathname)
29
+ end
30
+ end
31
+ set
32
+ end
33
+
22
34
  def render(scope=Object.new, locals={}, &block)
23
35
  @@context['def'] = {}
24
- scope._dependency_paths.each {|a|
25
- @@context['doT']['compile'].call(open(a).read,@@context['def'])
36
+ dep = []
37
+ digest = scope.environment.file_digest(scope.pathname).to_s
38
+ scope._dependency_assets.each {|pathname|
39
+ if scope.pathname.to_s != pathname
40
+ dep << pathname
41
+ build_dependencies(dep,scope.environment,pathname)
42
+ end
26
43
  }
27
- val = @@context['doT']['compile'].call(data,@@context['def'])
28
- val.to_s
44
+ dep.reverse_each do |pathname|
45
+ @@context['doT']['compile'].call(open(pathname).read,@@context['def'])
46
+ digest << "#{pathname}:#{scope.environment.file_digest(pathname).to_s}"
47
+ end
48
+ @@context['doT']['compile'].call(data,@@context['def']).to_s
29
49
  end
30
50
  end
31
51
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sprockets-dotjs
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.1
4
+ version: 3.0.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-03-29 00:00:00.000000000 Z
12
+ date: 2013-04-09 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: sprockets