sprockets-sass 1.1.0 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/sprockets/sass/importer.rb +8 -3
- data/lib/sprockets/sass/version.rb +1 -1
- data/spec/sprockets-sass_spec.rb +24 -0
- metadata +4 -4
@@ -60,7 +60,7 @@ module Sprockets
|
|
60
60
|
context = options[:custom][:sprockets_context]
|
61
61
|
imports = resolve_glob(context, glob, base_path).inject('') do |imports, path|
|
62
62
|
context.depend_on path
|
63
|
-
relative_path = path.relative_path_from Pathname.new(
|
63
|
+
relative_path = path.relative_path_from Pathname.new(base_path).dirname
|
64
64
|
imports << %(@import "#{relative_path}";\n)
|
65
65
|
end
|
66
66
|
return nil if imports.empty?
|
@@ -97,13 +97,18 @@ module Sprockets
|
|
97
97
|
def possible_files(context, path, base_path)
|
98
98
|
path = Pathname.new(path)
|
99
99
|
base_path = Pathname.new(base_path).dirname
|
100
|
-
root_path = Pathname.new(context.root_path)
|
101
100
|
paths = [ path, partialize_path(path) ]
|
102
101
|
|
102
|
+
# Find base_path's root
|
103
|
+
env_root_paths = context.environment.paths.map {|p| Pathname.new(p) }
|
104
|
+
root_path = env_root_paths.detect do |env_root_path|
|
105
|
+
base_path.to_s.start_with?(env_root_path.to_s)
|
106
|
+
end
|
107
|
+
root_path ||= context.root_path
|
108
|
+
|
103
109
|
# Add the relative path from the root, if necessary
|
104
110
|
if path.relative? && base_path != root_path
|
105
111
|
relative_path = base_path.relative_path_from(root_path).join path
|
106
|
-
|
107
112
|
paths.unshift(relative_path, partialize_path(relative_path))
|
108
113
|
end
|
109
114
|
|
data/spec/sprockets-sass_spec.rb
CHANGED
@@ -145,6 +145,30 @@ describe Sprockets::Sass do
|
|
145
145
|
expect(asset.to_s).to eql("body {\n color: blue; }\n")
|
146
146
|
end
|
147
147
|
|
148
|
+
it 'imports nested partials with relative path from the assets load path' do
|
149
|
+
vendor = @root.directory 'vendor'
|
150
|
+
@env.append_path vendor.to_s
|
151
|
+
|
152
|
+
@assets.file 'folder/main.css.scss', %(@import "dep";\nbody { color: $color; })
|
153
|
+
vendor.file 'dep.css.scss', '@import "folder1/dep1";'
|
154
|
+
vendor.file 'folder1/_dep1.scss', '@import "folder2/dep2";'
|
155
|
+
vendor.file 'folder1/folder2/_dep2.scss', '$color: blue;'
|
156
|
+
asset = @env['folder/main.css']
|
157
|
+
expect(asset.to_s).to eql("body {\n color: blue; }\n")
|
158
|
+
end
|
159
|
+
|
160
|
+
it 'imports nested partials with relative path and glob from the assets load path' do
|
161
|
+
vendor = @root.directory 'vendor'
|
162
|
+
@env.append_path vendor.to_s
|
163
|
+
|
164
|
+
@assets.file 'folder/main.css.scss', %(@import "dep";\nbody { color: $color; })
|
165
|
+
vendor.file 'dep.css.scss', '@import "folder1/dep1";'
|
166
|
+
vendor.file 'folder1/_dep1.scss', '@import "folder2/*";'
|
167
|
+
vendor.file 'folder1/folder2/_dep2.scss', '$color: blue;'
|
168
|
+
asset = @env['folder/main.css']
|
169
|
+
expect(asset.to_s).to eql("body {\n color: blue; }\n")
|
170
|
+
end
|
171
|
+
|
148
172
|
it 'allows global Sass configuration' do
|
149
173
|
Sprockets::Sass.options[:style] = :compact
|
150
174
|
@assets.file 'main.css.scss', "body {\n color: blue;\n}"
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sprockets-sass
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.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: 2014-
|
12
|
+
date: 2014-07-10 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: sprockets
|
@@ -232,7 +232,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
232
232
|
version: '0'
|
233
233
|
segments:
|
234
234
|
- 0
|
235
|
-
hash:
|
235
|
+
hash: -2591285633856815059
|
236
236
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
237
237
|
none: false
|
238
238
|
requirements:
|
@@ -241,7 +241,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
241
241
|
version: '0'
|
242
242
|
segments:
|
243
243
|
- 0
|
244
|
-
hash:
|
244
|
+
hash: -2591285633856815059
|
245
245
|
requirements: []
|
246
246
|
rubyforge_project: sprockets-sass
|
247
247
|
rubygems_version: 1.8.23
|