sprockets-sass 0.2.3 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.md +37 -1
- data/lib/sprockets/sass.rb +5 -0
- data/lib/sprockets/sass/sass_template.rb +27 -4
- data/lib/sprockets/sass/version.rb +1 -1
- data/spec/spec_helper.rb +6 -0
- data/spec/sprockets-sass_spec.rb +18 -1
- data/sprockets-sass.gemspec +1 -0
- metadata +33 -52
data/README.md
CHANGED
@@ -14,7 +14,7 @@ _Note: This works in Rails 3.1, thanks to the [sass-rails gem](http://github.com
|
|
14
14
|
* Imports either Sass syntax, or just regular CSS files.
|
15
15
|
* Imported files are preprocessed by Sprockets, so `.css.scss.erb` files can be imported.
|
16
16
|
Directives from within imported files also work as expected.
|
17
|
-
*
|
17
|
+
* Automatic integration with Compass.
|
18
18
|
* Supports glob imports, like sass-rails.
|
19
19
|
|
20
20
|
|
@@ -90,6 +90,42 @@ button {
|
|
90
90
|
```
|
91
91
|
|
92
92
|
|
93
|
+
Compass Integration
|
94
|
+
-------------------
|
95
|
+
|
96
|
+
As of version 0.3.0, Compass is automatically detected and integrated. All you have to do
|
97
|
+
is configure Compass like you normally would:
|
98
|
+
|
99
|
+
``` ruby
|
100
|
+
require "sprockets"
|
101
|
+
require "sprockets-sass"
|
102
|
+
require "sass"
|
103
|
+
require "compass"
|
104
|
+
|
105
|
+
Compass.configuration do |compass|
|
106
|
+
# ...
|
107
|
+
end
|
108
|
+
|
109
|
+
map "/assets" do
|
110
|
+
environment = Sprockets::Environment.new
|
111
|
+
environment.append_path "assets/stylesheets"
|
112
|
+
run environment
|
113
|
+
end
|
114
|
+
|
115
|
+
# etc...
|
116
|
+
```
|
117
|
+
|
118
|
+
The load paths and other options from Compass are automatically used:
|
119
|
+
|
120
|
+
``` scss
|
121
|
+
// assets/stylesheets/application.css.scss
|
122
|
+
@import "compass/css3";
|
123
|
+
|
124
|
+
button {
|
125
|
+
@include border-radius(5px);
|
126
|
+
}
|
127
|
+
```
|
128
|
+
|
93
129
|
Copyright
|
94
130
|
---------
|
95
131
|
|
data/lib/sprockets/sass.rb
CHANGED
@@ -6,6 +6,11 @@ require "sprockets/engines"
|
|
6
6
|
module Sprockets
|
7
7
|
module Sass
|
8
8
|
autoload :Importer, "sprockets/sass/importer"
|
9
|
+
|
10
|
+
# Global configuration for `Sass::Engine` instances.
|
11
|
+
def self.options
|
12
|
+
@options ||= {}
|
13
|
+
end
|
9
14
|
end
|
10
15
|
|
11
16
|
register_engine ".sass", Sass::SassTemplate
|
@@ -13,11 +13,13 @@ module Sprockets
|
|
13
13
|
:sass
|
14
14
|
end
|
15
15
|
|
16
|
+
# See `Tilt::Template#prepare`.
|
16
17
|
def prepare
|
17
18
|
@context = nil
|
18
19
|
@output = nil
|
19
20
|
end
|
20
21
|
|
22
|
+
# See `Tilt::Template#evaluate`.
|
21
23
|
def evaluate(context, locals, &block)
|
22
24
|
@output ||= begin
|
23
25
|
@context = context
|
@@ -25,10 +27,16 @@ module Sprockets
|
|
25
27
|
end
|
26
28
|
end
|
27
29
|
|
28
|
-
|
30
|
+
protected
|
29
31
|
|
32
|
+
# A reference to the custom Sass importer, `Sprockets::Sass::Importer`.
|
33
|
+
def importer
|
34
|
+
Importer.new context
|
35
|
+
end
|
36
|
+
|
37
|
+
# Assemble the options for the `Sass::Engine`
|
30
38
|
def sass_options
|
31
|
-
options.merge(
|
39
|
+
merge_sass_options(default_sass_options, options).merge(
|
32
40
|
:filename => eval_file,
|
33
41
|
:line => line,
|
34
42
|
:syntax => syntax,
|
@@ -36,8 +44,23 @@ module Sprockets
|
|
36
44
|
)
|
37
45
|
end
|
38
46
|
|
39
|
-
|
40
|
-
|
47
|
+
# Get the default, global Sass options. Start with Compass's
|
48
|
+
# options, if it's available.
|
49
|
+
def default_sass_options
|
50
|
+
if defined?(Compass)
|
51
|
+
merge_sass_options Compass.sass_engine_options.dup, Sprockets::Sass.options
|
52
|
+
else
|
53
|
+
Sprockets::Sass.options.dup
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
# Merges two sets of `Sass::Engine` options, prepending
|
58
|
+
# the `:load_paths` instead of clobbering them.
|
59
|
+
def merge_sass_options(options, other_options)
|
60
|
+
if (load_paths = options[:load_paths]) && (other_paths = other_options[:load_paths])
|
61
|
+
other_options[:load_paths] = other_paths + load_paths
|
62
|
+
end
|
63
|
+
options.merge other_options
|
41
64
|
end
|
42
65
|
end
|
43
66
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,7 +1,13 @@
|
|
1
1
|
require "sprockets"
|
2
2
|
require "sprockets-sass"
|
3
|
+
require "compass"
|
3
4
|
require "construct"
|
4
5
|
|
6
|
+
Compass.configuration do |compass|
|
7
|
+
compass.line_comments = false
|
8
|
+
compass.output_style = :nested
|
9
|
+
end
|
10
|
+
|
5
11
|
# Requires supporting files with custom matchers and macros, etc,
|
6
12
|
# in ./support/ and its subdirectories.
|
7
13
|
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
|
data/spec/sprockets-sass_spec.rb
CHANGED
@@ -94,14 +94,31 @@ describe Sprockets::Sass do
|
|
94
94
|
asset.to_s.should == "body {\n color: blue; }\n"
|
95
95
|
end
|
96
96
|
|
97
|
+
it "allows global Sass configuration" do
|
98
|
+
Sprockets::Sass.options[:style] = :compact
|
99
|
+
@assets.file "main.css.scss", "body {\n color: blue;\n}"
|
100
|
+
|
101
|
+
asset = @env["main.css"]
|
102
|
+
asset.to_s.should == "body { color: blue; }\n"
|
103
|
+
Sprockets::Sass.options.delete(:style)
|
104
|
+
end
|
105
|
+
|
97
106
|
it "imports files from the Sass load path" do
|
98
107
|
vendor = @root.directory "vendor"
|
99
|
-
Sass
|
108
|
+
Sprockets::Sass.options[:load_paths] = [ vendor.to_s ]
|
100
109
|
|
101
110
|
@assets.file "main.css.scss", %(@import "dep";\nbody { color: $color; })
|
102
111
|
vendor.file "dep.scss", "$color: blue;"
|
103
112
|
asset = @env["main.css"]
|
104
113
|
asset.to_s.should == "body {\n color: blue; }\n"
|
114
|
+
Sprockets::Sass.options.delete(:load_paths)
|
115
|
+
end
|
116
|
+
|
117
|
+
it "works with the Compass framework" do
|
118
|
+
@assets.file "main.css.scss", %(@import "compass/typography/text/nowrap";\np { @include nowrap; })
|
119
|
+
|
120
|
+
asset = @env["main.css"]
|
121
|
+
asset.to_s.should == "p {\n white-space: nowrap; }\n"
|
105
122
|
end
|
106
123
|
|
107
124
|
it "imports globbed files" do
|
data/sprockets-sass.gemspec
CHANGED
metadata
CHANGED
@@ -1,13 +1,8 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sprockets-sass
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash: 17
|
5
4
|
prerelease:
|
6
|
-
|
7
|
-
- 0
|
8
|
-
- 2
|
9
|
-
- 3
|
10
|
-
version: 0.2.3
|
5
|
+
version: 0.3.0
|
11
6
|
platform: ruby
|
12
7
|
authors:
|
13
8
|
- Pete Browne
|
@@ -15,82 +10,74 @@ autorequire:
|
|
15
10
|
bindir: bin
|
16
11
|
cert_chain: []
|
17
12
|
|
18
|
-
date: 2011-
|
13
|
+
date: 2011-10-01 00:00:00 Z
|
19
14
|
dependencies:
|
20
15
|
- !ruby/object:Gem::Dependency
|
21
|
-
|
16
|
+
name: sprockets
|
17
|
+
prerelease: false
|
18
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
22
19
|
none: false
|
23
20
|
requirements:
|
24
21
|
- - ~>
|
25
22
|
- !ruby/object:Gem::Version
|
26
|
-
hash: 3
|
27
|
-
segments:
|
28
|
-
- 2
|
29
|
-
- 0
|
30
23
|
version: "2.0"
|
31
|
-
requirement: *id001
|
32
|
-
name: sprockets
|
33
|
-
prerelease: false
|
34
24
|
type: :runtime
|
25
|
+
version_requirements: *id001
|
35
26
|
- !ruby/object:Gem::Dependency
|
36
|
-
|
27
|
+
name: rake
|
28
|
+
prerelease: false
|
29
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
37
30
|
none: false
|
38
31
|
requirements:
|
39
32
|
- - ">="
|
40
33
|
- !ruby/object:Gem::Version
|
41
|
-
hash: 3
|
42
|
-
segments:
|
43
|
-
- 0
|
44
34
|
version: "0"
|
45
|
-
requirement: *id002
|
46
|
-
name: rake
|
47
|
-
prerelease: false
|
48
35
|
type: :development
|
36
|
+
version_requirements: *id002
|
49
37
|
- !ruby/object:Gem::Dependency
|
50
|
-
|
38
|
+
name: rspec
|
39
|
+
prerelease: false
|
40
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
51
41
|
none: false
|
52
42
|
requirements:
|
53
43
|
- - ~>
|
54
44
|
- !ruby/object:Gem::Version
|
55
|
-
hash: 15
|
56
|
-
segments:
|
57
|
-
- 2
|
58
|
-
- 6
|
59
45
|
version: "2.6"
|
60
|
-
requirement: *id003
|
61
|
-
name: rspec
|
62
|
-
prerelease: false
|
63
46
|
type: :development
|
47
|
+
version_requirements: *id003
|
64
48
|
- !ruby/object:Gem::Dependency
|
65
|
-
|
49
|
+
name: test-construct
|
50
|
+
prerelease: false
|
51
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
66
52
|
none: false
|
67
53
|
requirements:
|
68
54
|
- - ~>
|
69
55
|
- !ruby/object:Gem::Version
|
70
|
-
hash: 11
|
71
|
-
segments:
|
72
|
-
- 1
|
73
|
-
- 2
|
74
56
|
version: "1.2"
|
75
|
-
requirement: *id004
|
76
|
-
name: test-construct
|
77
|
-
prerelease: false
|
78
57
|
type: :development
|
58
|
+
version_requirements: *id004
|
79
59
|
- !ruby/object:Gem::Dependency
|
80
|
-
|
60
|
+
name: sass
|
61
|
+
prerelease: false
|
62
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
81
63
|
none: false
|
82
64
|
requirements:
|
83
65
|
- - ~>
|
84
66
|
- !ruby/object:Gem::Version
|
85
|
-
hash: 5
|
86
|
-
segments:
|
87
|
-
- 3
|
88
|
-
- 1
|
89
67
|
version: "3.1"
|
90
|
-
|
91
|
-
|
68
|
+
type: :development
|
69
|
+
version_requirements: *id005
|
70
|
+
- !ruby/object:Gem::Dependency
|
71
|
+
name: compass
|
92
72
|
prerelease: false
|
73
|
+
requirement: &id006 !ruby/object:Gem::Requirement
|
74
|
+
none: false
|
75
|
+
requirements:
|
76
|
+
- - "="
|
77
|
+
- !ruby/object:Gem::Version
|
78
|
+
version: "0.11"
|
93
79
|
type: :development
|
80
|
+
version_requirements: *id006
|
94
81
|
description: When using Sprockets 2.0 with Sass you will eventually run into a pretty big issue. `//= require` directives will not allow Sass mixins, variables, etc. to be shared between files. So you'll try to use `@import`, and that'll also blow up in your face. `sprockets-sass` fixes all of this by creating a Sass::Importer that is Sprockets aware.
|
95
82
|
email:
|
96
83
|
- me@petebrowne.com
|
@@ -128,23 +115,17 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
128
115
|
requirements:
|
129
116
|
- - ">="
|
130
117
|
- !ruby/object:Gem::Version
|
131
|
-
hash: 3
|
132
|
-
segments:
|
133
|
-
- 0
|
134
118
|
version: "0"
|
135
119
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
136
120
|
none: false
|
137
121
|
requirements:
|
138
122
|
- - ">="
|
139
123
|
- !ruby/object:Gem::Version
|
140
|
-
hash: 3
|
141
|
-
segments:
|
142
|
-
- 0
|
143
124
|
version: "0"
|
144
125
|
requirements: []
|
145
126
|
|
146
127
|
rubyforge_project: sprockets-sass
|
147
|
-
rubygems_version: 1.8.
|
128
|
+
rubygems_version: 1.8.8
|
148
129
|
signing_key:
|
149
130
|
specification_version: 3
|
150
131
|
summary: Better Sass integration with Sprockets 2.0
|