nutils 0.11.0 → 0.11.1
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/nutils/filters/sprockets.rb +9 -7
- data/lib/nutils.rb +1 -1
- metadata +4 -4
@@ -13,9 +13,6 @@ module Nutils
|
|
13
13
|
#
|
14
14
|
# @param [String] content The content to filter.
|
15
15
|
#
|
16
|
-
# @todo Use the content to build a Sprocket Asset instead of just get the
|
17
|
-
# `@item[:content_filename]`.
|
18
|
-
#
|
19
16
|
# @return [String] The filtered content.
|
20
17
|
def run(content, params={})
|
21
18
|
require 'sprockets'
|
@@ -33,9 +30,9 @@ module Nutils
|
|
33
30
|
tmp_filename.open('w') { |io| io.puts content }
|
34
31
|
|
35
32
|
load_path = params[:load_path] || []
|
36
|
-
load_path <<
|
33
|
+
load_path << filename.dirname.realpath
|
37
34
|
|
38
|
-
env = ::Sprockets::Environment.new(
|
35
|
+
env = ::Sprockets::Environment.new(filename.dirname.realpath)
|
39
36
|
|
40
37
|
# Assign load paths to Sprockets
|
41
38
|
load_path.each do |path|
|
@@ -45,13 +42,18 @@ module Nutils
|
|
45
42
|
# Get the Sprockets BundledAsset object for the content
|
46
43
|
main_asset = env.find_asset(tmp_filename.realpath)
|
47
44
|
|
45
|
+
# Select just the possible items that can be dependencies
|
46
|
+
possible_items = @items.select do |i|
|
47
|
+
load_path.find { |p| Pathname.new(p).realpath.to_s == Pathname.new(i[:content_filename]).dirname.realpath.to_s }
|
48
|
+
end
|
49
|
+
|
48
50
|
# Get Nanoc::Item equivalent for each dependence managed by Sprockets
|
49
51
|
dependencies = main_asset.dependencies.inject([]) do |dep, asset|
|
50
|
-
item =
|
52
|
+
item = possible_items.find { |i| asset.pathname == Pathname.new(i[:content_filename]).realpath }
|
51
53
|
dep << item unless item.nil?
|
52
54
|
dep
|
53
55
|
end
|
54
|
-
# Register Nanoc dependencies
|
56
|
+
# # Register Nanoc dependencies
|
55
57
|
depend_on(dependencies) unless dependencies.nil?
|
56
58
|
|
57
59
|
# Output compiled asset
|
data/lib/nutils.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nutils
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 49
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 11
|
9
|
-
-
|
10
|
-
version: 0.11.
|
9
|
+
- 1
|
10
|
+
version: 0.11.1
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Arnau Siches
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-
|
18
|
+
date: 2011-10-03 00:00:00 -04:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|