sprockets-sass 0.2.1 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/sprockets/sass.rb +3 -3
- data/lib/sprockets/sass/importer.rb +5 -5
- data/lib/sprockets/sass/version.rb +1 -1
- data/spec/sprockets-sass_spec.rb +26 -18
- metadata +4 -4
data/lib/sprockets/sass.rb
CHANGED
@@ -6,8 +6,8 @@ require "sprockets/engines"
|
|
6
6
|
module Sprockets
|
7
7
|
module Sass
|
8
8
|
autoload :Importer, "sprockets/sass/importer"
|
9
|
-
|
10
|
-
::Sprockets.register_engine ".sass", SassTemplate
|
11
|
-
::Sprockets.register_engine ".scss", ScssTemplate
|
12
9
|
end
|
10
|
+
|
11
|
+
register_engine ".sass", Sass::SassTemplate
|
12
|
+
register_engine ".scss", Sass::ScssTemplate
|
13
13
|
end
|
@@ -53,7 +53,7 @@ module Sprockets
|
|
53
53
|
# Create a Sass::Engine from the given path.
|
54
54
|
def engine_from_path(path, options)
|
55
55
|
pathname = resolve(path) or return nil
|
56
|
-
context.
|
56
|
+
context.depend_on pathname
|
57
57
|
::Sass::Engine.new evaluate(pathname), options.merge(
|
58
58
|
:filename => pathname.to_s,
|
59
59
|
:syntax => syntax(pathname),
|
@@ -65,7 +65,7 @@ module Sprockets
|
|
65
65
|
# a glob of files.
|
66
66
|
def engine_from_glob(glob, base_path, options)
|
67
67
|
imports = resolve_glob(glob, base_path).inject("") do |imports, path|
|
68
|
-
context.
|
68
|
+
context.depend_on path
|
69
69
|
relative_path = path.relative_path_from Pathname.new(context.root_path)
|
70
70
|
imports << %(@import "#{relative_path}";\n)
|
71
71
|
end
|
@@ -93,13 +93,13 @@ module Sprockets
|
|
93
93
|
path_with_glob = base_path.dirname.join(glob).to_s
|
94
94
|
|
95
95
|
Pathname.glob(path_with_glob).sort.select do |path|
|
96
|
-
path != context.pathname && context.asset_requirable?(path)
|
96
|
+
path != context.pathname # && context.asset_requirable?(path)
|
97
97
|
end
|
98
98
|
end
|
99
99
|
|
100
100
|
# Finds the asset using the context from Sprockets.
|
101
101
|
def resolve_path(path)
|
102
|
-
context.resolve
|
102
|
+
context.resolve path #, :content_type => :self
|
103
103
|
rescue ::Sprockets::FileNotFound, ::Sprockets::ContentTypeMismatch
|
104
104
|
nil
|
105
105
|
end
|
@@ -115,7 +115,7 @@ module Sprockets
|
|
115
115
|
def evaluate(path)
|
116
116
|
processors = context.environment.attributes_for(path).processors.dup
|
117
117
|
processors.delete_if { |processor| processor < Tilt::SassTemplate }
|
118
|
-
context.evaluate
|
118
|
+
context.evaluate(path, :processors => processors)
|
119
119
|
end
|
120
120
|
end
|
121
121
|
end
|
data/spec/sprockets-sass_spec.rb
CHANGED
@@ -15,35 +15,35 @@ describe Sprockets::Sass do
|
|
15
15
|
it "processes scss files normally" do
|
16
16
|
@assets.file "main.css.scss", "//= require dep"
|
17
17
|
@assets.file "dep.css.scss", "body { color: blue; }"
|
18
|
-
asset = @env["main.css
|
18
|
+
asset = @env["main.css"]
|
19
19
|
asset.to_s.should == "body {\n color: blue; }\n"
|
20
20
|
end
|
21
21
|
|
22
22
|
it "processes sass files normally" do
|
23
23
|
@assets.file "main.css.sass", "//= require dep"
|
24
24
|
@assets.file "dep.css.sass", "body\n color: blue"
|
25
|
-
asset = @env["main.css
|
25
|
+
asset = @env["main.css"]
|
26
26
|
asset.to_s.should == "body {\n color: blue; }\n"
|
27
27
|
end
|
28
28
|
|
29
29
|
it "imports standard files" do
|
30
30
|
@assets.file "main.css.scss", %(@import "dep";\nbody { color: $color; })
|
31
31
|
@assets.file "dep.css.scss", "$color: blue;"
|
32
|
-
asset = @env["main.css
|
32
|
+
asset = @env["main.css"]
|
33
33
|
asset.to_s.should == "body {\n color: blue; }\n"
|
34
34
|
end
|
35
35
|
|
36
36
|
it "imports partial style files" do
|
37
37
|
@assets.file "main.css.scss", %(@import "dep";\nbody { color: $color; })
|
38
38
|
@assets.file "_dep.css.scss", "$color: blue;"
|
39
|
-
asset = @env["main.css
|
39
|
+
asset = @env["main.css"]
|
40
40
|
asset.to_s.should == "body {\n color: blue; }\n"
|
41
41
|
end
|
42
42
|
|
43
43
|
it "imports other syntax" do
|
44
44
|
@assets.file "main.css.scss", %(@import "dep";\nbody { color: $color; })
|
45
|
-
@assets.file "dep.
|
46
|
-
asset = @env["main.css
|
45
|
+
@assets.file "dep.sass", "$color: blue\nhtml\n height: 100%"
|
46
|
+
asset = @env["main.css"]
|
47
47
|
asset.to_s.should == "html {\n height: 100%; }\n\nbody {\n color: blue; }\n"
|
48
48
|
end
|
49
49
|
|
@@ -51,28 +51,36 @@ describe Sprockets::Sass do
|
|
51
51
|
@assets.file "main.css.scss", %(@import "dep";)
|
52
52
|
@assets.file "dep.css", "/*\n *= require subdep\n */"
|
53
53
|
@assets.file "subdep.css.scss", "$color: blue;\nbody { color: $color; }"
|
54
|
-
asset = @env["main.css
|
54
|
+
asset = @env["main.css"]
|
55
55
|
asset.to_s.should include("body {\n color: blue; }\n")
|
56
56
|
end
|
57
57
|
|
58
58
|
it "imports files with additional processors" do
|
59
59
|
@assets.file "main.css.scss", %(@import "dep";\nbody { color: $color; })
|
60
60
|
@assets.file "dep.css.scss.erb", "$color: <%= 'blue' %>;"
|
61
|
-
asset = @env["main.css
|
61
|
+
asset = @env["main.css"]
|
62
62
|
asset.to_s.should == "body {\n color: blue; }\n"
|
63
63
|
end
|
64
64
|
|
65
65
|
it "imports relative files" do
|
66
66
|
@assets.file "folder/main.css.scss", %(@import "./dep";\nbody { color: $color; })
|
67
67
|
@assets.file "folder/dep.css.scss", "$color: blue;"
|
68
|
-
asset = @env["folder/main.css
|
68
|
+
asset = @env["folder/main.css"]
|
69
69
|
asset.to_s.should == "body {\n color: blue; }\n"
|
70
70
|
end
|
71
71
|
|
72
72
|
it "imports files relative to root" do
|
73
73
|
@assets.file "folder/main.css.scss", %(@import "dep";\nbody { color: $color; })
|
74
74
|
@assets.file "dep.css.scss", "$color: blue;"
|
75
|
-
asset = @env["folder/main.css
|
75
|
+
asset = @env["folder/main.css"]
|
76
|
+
asset.to_s.should == "body {\n color: blue; }\n"
|
77
|
+
end
|
78
|
+
|
79
|
+
it "shares Sass environment with other imports" do
|
80
|
+
@assets.file "main.css.scss", %(@import "dep1";\n@import "dep2";)
|
81
|
+
@assets.file "_dep1.scss", "$color: blue;"
|
82
|
+
@assets.file "_dep2.scss", "body { color: $color; }"
|
83
|
+
asset = @env["main.css"]
|
76
84
|
asset.to_s.should == "body {\n color: blue; }\n"
|
77
85
|
end
|
78
86
|
|
@@ -82,7 +90,7 @@ describe Sprockets::Sass do
|
|
82
90
|
|
83
91
|
@assets.file "main.css.scss", %(@import "dep";\nbody { color: $color; })
|
84
92
|
vendor.file "dep.css.scss", "$color: blue;"
|
85
|
-
asset = @env["main.css
|
93
|
+
asset = @env["main.css"]
|
86
94
|
asset.to_s.should == "body {\n color: blue; }\n"
|
87
95
|
end
|
88
96
|
|
@@ -92,7 +100,7 @@ describe Sprockets::Sass do
|
|
92
100
|
|
93
101
|
@assets.file "main.css.scss", %(@import "dep";\nbody { color: $color; })
|
94
102
|
vendor.file "dep.scss", "$color: blue;"
|
95
|
-
asset = @env["main.css
|
103
|
+
asset = @env["main.css"]
|
96
104
|
asset.to_s.should == "body {\n color: blue; }\n"
|
97
105
|
end
|
98
106
|
|
@@ -100,7 +108,7 @@ describe Sprockets::Sass do
|
|
100
108
|
@assets.file "main.css.scss", %(@import "folder/*";\nbody { color: $color; background: $bg-color; })
|
101
109
|
@assets.file "folder/dep1.css.scss", "$color: blue;"
|
102
110
|
@assets.file "folder/dep2.css.scss", "$bg-color: red;"
|
103
|
-
asset = @env["main.css
|
111
|
+
asset = @env["main.css"]
|
104
112
|
asset.to_s.should == "body {\n color: blue;\n background: red; }\n"
|
105
113
|
end
|
106
114
|
|
@@ -108,7 +116,7 @@ describe Sprockets::Sass do
|
|
108
116
|
@assets.file "main.css.scss", %(@import "dep";\nbody { color: $color; })
|
109
117
|
dep = @assets.file "dep.css.scss", "$color: blue;"
|
110
118
|
|
111
|
-
asset = @env["main.css
|
119
|
+
asset = @env["main.css"]
|
112
120
|
asset.should be_fresh
|
113
121
|
|
114
122
|
mtime = Time.now + 1
|
@@ -123,7 +131,7 @@ describe Sprockets::Sass do
|
|
123
131
|
@assets.file "dep1.css.scss", %(@import "dep2";\n)
|
124
132
|
dep = @assets.file "dep2.css.scss", "$color: blue;"
|
125
133
|
|
126
|
-
asset = @env["main.css
|
134
|
+
asset = @env["main.css"]
|
127
135
|
asset.should be_fresh
|
128
136
|
|
129
137
|
mtime = Time.now + 1
|
@@ -135,10 +143,10 @@ describe Sprockets::Sass do
|
|
135
143
|
|
136
144
|
it "adds dependencies when imported from a glob" do
|
137
145
|
@assets.file "main.css.scss", %(@import "folder/*";\nbody { color: $color; background: $bg-color; })
|
138
|
-
@assets.file "folder/
|
139
|
-
dep = @assets.file "folder/
|
146
|
+
@assets.file "folder/_dep1.scss", "$color: blue;"
|
147
|
+
dep = @assets.file "folder/_dep2.scss", "$bg-color: red;"
|
140
148
|
|
141
|
-
asset = @env["main.css
|
149
|
+
asset = @env["main.css"]
|
142
150
|
asset.should be_fresh
|
143
151
|
|
144
152
|
mtime = Time.now + 1
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sprockets-sass
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 19
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 2
|
9
|
-
-
|
10
|
-
version: 0.2.
|
9
|
+
- 2
|
10
|
+
version: 0.2.2
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Pete Browne
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-09-
|
18
|
+
date: 2011-09-29 00:00:00 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
version_requirements: &id001 !ruby/object:Gem::Requirement
|