sass 3.1.15 → 3.1.16
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 +4 -5
- data/Rakefile +2 -2
- data/VERSION +1 -1
- data/lib/sass/css.rb +144 -48
- data/lib/sass/engine.rb +3 -1
- data/lib/sass/plugin/compiler.rb +25 -32
- data/lib/sass/plugin/listener.rb +59 -0
- data/lib/sass/script/lexer.rb +1 -1
- data/lib/sass/script/list.rb +1 -0
- data/lib/sass/scss/parser.rb +90 -4
- data/lib/sass/scss/rx.rb +5 -0
- data/lib/sass/scss/static_parser.rb +1 -1
- data/lib/sass/selector/abstract_sequence.rb +11 -2
- data/lib/sass/selector/simple.rb +6 -0
- data/lib/sass/tree/comment_node.rb +1 -1
- data/lib/sass/tree/node.rb +2 -2
- data/lib/sass/tree/visitors/check_nesting.rb +2 -2
- data/lib/sass/tree/visitors/cssize.rb +1 -1
- data/lib/sass/util.rb +3 -2
- data/test/sass/conversion_test.rb +10 -0
- data/test/sass/css2sass_test.rb +24 -0
- data/test/sass/engine_test.rb +1 -0
- data/test/sass/scss/css_test.rb +53 -0
- data/vendor/listen/CHANGELOG.md +72 -0
- data/vendor/listen/Gemfile +35 -0
- data/vendor/listen/Guardfile +8 -0
- data/vendor/{fssm → listen}/LICENSE +1 -1
- data/vendor/listen/README.md +297 -0
- data/vendor/listen/Rakefile +47 -0
- data/vendor/listen/Vagrantfile +96 -0
- data/vendor/listen/lib/listen.rb +38 -0
- data/vendor/listen/lib/listen/adapter.rb +159 -0
- data/vendor/listen/lib/listen/adapters/darwin.rb +84 -0
- data/vendor/listen/lib/listen/adapters/linux.rb +99 -0
- data/vendor/listen/lib/listen/adapters/polling.rb +66 -0
- data/vendor/listen/lib/listen/adapters/windows.rb +82 -0
- data/vendor/listen/lib/listen/directory_record.rb +257 -0
- data/vendor/listen/lib/listen/listener.rb +186 -0
- data/vendor/listen/lib/listen/multi_listener.rb +121 -0
- data/vendor/listen/lib/listen/turnstile.rb +28 -0
- data/vendor/listen/lib/listen/version.rb +3 -0
- data/vendor/listen/listen.gemspec +26 -0
- data/vendor/listen/spec/listen/adapter_spec.rb +142 -0
- data/vendor/listen/spec/listen/adapters/darwin_spec.rb +31 -0
- data/vendor/listen/spec/listen/adapters/linux_spec.rb +30 -0
- data/vendor/listen/spec/listen/adapters/polling_spec.rb +68 -0
- data/vendor/listen/spec/listen/adapters/windows_spec.rb +24 -0
- data/vendor/listen/spec/listen/directory_record_spec.rb +807 -0
- data/vendor/listen/spec/listen/listener_spec.rb +151 -0
- data/vendor/listen/spec/listen/multi_listener_spec.rb +151 -0
- data/vendor/listen/spec/listen/turnstile_spec.rb +56 -0
- data/vendor/listen/spec/listen_spec.rb +73 -0
- data/vendor/listen/spec/spec_helper.rb +16 -0
- data/vendor/listen/spec/support/adapter_helper.rb +538 -0
- data/vendor/listen/spec/support/directory_record_helper.rb +35 -0
- data/vendor/listen/spec/support/fixtures_helper.rb +29 -0
- data/vendor/listen/spec/support/listeners_helper.rb +133 -0
- data/vendor/listen/spec/support/platform_helper.rb +11 -0
- metadata +40 -40
- data/vendor/fssm/Gemfile +0 -3
- data/vendor/fssm/README.markdown +0 -83
- data/vendor/fssm/Rakefile +0 -11
- data/vendor/fssm/example.rb +0 -12
- data/vendor/fssm/ext/rakefile.rb +0 -14
- data/vendor/fssm/fssm.gemspec +0 -27
- data/vendor/fssm/lib/fssm.rb +0 -74
- data/vendor/fssm/lib/fssm/backends/fsevents.rb +0 -36
- data/vendor/fssm/lib/fssm/backends/inotify.rb +0 -26
- data/vendor/fssm/lib/fssm/backends/polling.rb +0 -25
- data/vendor/fssm/lib/fssm/backends/rbfsevent.rb +0 -42
- data/vendor/fssm/lib/fssm/backends/rubycocoa/fsevents.rb +0 -131
- data/vendor/fssm/lib/fssm/monitor.rb +0 -36
- data/vendor/fssm/lib/fssm/path.rb +0 -94
- data/vendor/fssm/lib/fssm/pathname.rb +0 -36
- data/vendor/fssm/lib/fssm/state/directory.rb +0 -75
- data/vendor/fssm/lib/fssm/state/file.rb +0 -24
- data/vendor/fssm/lib/fssm/support.rb +0 -87
- data/vendor/fssm/lib/fssm/tree.rb +0 -176
- data/vendor/fssm/lib/fssm/version.rb +0 -3
- data/vendor/fssm/profile/prof-cache.rb +0 -40
- data/vendor/fssm/profile/prof-fssm-pathname.html +0 -1231
- data/vendor/fssm/profile/prof-pathname-rubinius.rb +0 -35
- data/vendor/fssm/profile/prof-pathname.rb +0 -68
- data/vendor/fssm/profile/prof-plain-pathname.html +0 -988
- data/vendor/fssm/profile/prof.html +0 -2379
- data/vendor/fssm/spec/count_down_latch.rb +0 -151
- data/vendor/fssm/spec/monitor_spec.rb +0 -202
- data/vendor/fssm/spec/path_spec.rb +0 -96
- data/vendor/fssm/spec/root/duck/quack.txt +0 -0
- data/vendor/fssm/spec/root/file.css +0 -0
- data/vendor/fssm/spec/root/file.rb +0 -0
- data/vendor/fssm/spec/root/file.yml +0 -0
- data/vendor/fssm/spec/root/moo/cow.txt +0 -0
- data/vendor/fssm/spec/spec_helper.rb +0 -14
data/README.md
CHANGED
|
@@ -175,16 +175,15 @@ See `sass-convert --help` for further information and options.
|
|
|
175
175
|
|
|
176
176
|
Sass was envisioned by [Hampton Catlin](http://hamptoncatlin.com) (hcatlin).
|
|
177
177
|
However, Hampton doesn't even know his way around the code anymore and now
|
|
178
|
-
occasionally consults on the language issues. Hampton lives in
|
|
179
|
-
|
|
178
|
+
occasionally consults on the language issues. Hampton lives in Cambridge, UK and
|
|
179
|
+
is the owner of [Catlin Software](http://www.catlinsoftware.com/).
|
|
180
180
|
|
|
181
181
|
[Nathan Weizenbaum](http://nex-3.com) is the primary developer and architect of
|
|
182
182
|
Sass. His hard work has kept the project alive by endlessly answering forum
|
|
183
183
|
posts, fixing bugs, refactoring, finding speed improvements, writing
|
|
184
184
|
documentation, implementing new features, and getting Hampton coffee (a fitting
|
|
185
|
-
task for a boy-genius). Nathan lives in Seattle, Washington and
|
|
186
|
-
|
|
187
|
-
consults for Unspace Interactive.
|
|
185
|
+
task for a boy-genius). Nathan lives in Seattle, Washington and works on
|
|
186
|
+
[Dart](http://dartlang.org) application libraries at Google.
|
|
188
187
|
|
|
189
188
|
[Chris Eppstein](http://acts-as-architect.blogspot.com) is a core contributor to
|
|
190
189
|
Sass and the creator of Compass, the first Sass-based framework. Chris focuses
|
data/Rakefile
CHANGED
|
@@ -115,9 +115,9 @@ task :submodules do
|
|
|
115
115
|
if File.exist?(File.dirname(__FILE__) + "/.git")
|
|
116
116
|
sh %{git submodule sync}
|
|
117
117
|
sh %{git submodule update --init}
|
|
118
|
-
elsif !File.exist?(File.dirname(__FILE__) + "/vendor/
|
|
118
|
+
elsif !File.exist?(File.dirname(__FILE__) + "/vendor/listen/lib")
|
|
119
119
|
warn <<WARN
|
|
120
|
-
WARNING: vendor/
|
|
120
|
+
WARNING: vendor/listen doesn't exist, and this isn't a git repository so
|
|
121
121
|
I can't get it automatically!
|
|
122
122
|
WARN
|
|
123
123
|
end
|
data/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
3.1.
|
|
1
|
+
3.1.16
|
data/lib/sass/css.rb
CHANGED
|
@@ -75,14 +75,29 @@ module Sass
|
|
|
75
75
|
# @return [Tree::Node] The root node of the parsed tree
|
|
76
76
|
def build_tree
|
|
77
77
|
root = Sass::SCSS::CssParser.new(@template, @options[:filename]).parse
|
|
78
|
+
parse_selectors root
|
|
78
79
|
expand_commas root
|
|
80
|
+
nest_seqs root
|
|
79
81
|
parent_ref_rules root
|
|
80
|
-
remove_parent_refs root
|
|
81
82
|
flatten_rules root
|
|
82
83
|
fold_commas root
|
|
84
|
+
dump_selectors root
|
|
83
85
|
root
|
|
84
86
|
end
|
|
85
87
|
|
|
88
|
+
# Parse all the selectors in the document and assign them to
|
|
89
|
+
# {Sass::Tree::RuleNode#parsed_rules}.
|
|
90
|
+
#
|
|
91
|
+
# @param root [Tree::Node] The parent node
|
|
92
|
+
def parse_selectors(root)
|
|
93
|
+
root.children.each do |child|
|
|
94
|
+
next parse_selectors(child) if child.is_a?(Tree::DirectiveNode)
|
|
95
|
+
next unless child.is_a?(Tree::RuleNode)
|
|
96
|
+
parser = Sass::SCSS::CssParser.new(child.rule.first, child.filename, child.line)
|
|
97
|
+
child.parsed_rules = parser.parse_selector
|
|
98
|
+
end
|
|
99
|
+
end
|
|
100
|
+
|
|
86
101
|
# Transform
|
|
87
102
|
#
|
|
88
103
|
# foo, bar, baz
|
|
@@ -100,13 +115,14 @@ module Sass
|
|
|
100
115
|
# @param root [Tree::Node] The parent node
|
|
101
116
|
def expand_commas(root)
|
|
102
117
|
root.children.map! do |child|
|
|
103
|
-
|
|
118
|
+
# child.parsed_rules.members.size > 1 iff the rule contains a comma
|
|
119
|
+
unless child.is_a?(Tree::RuleNode) && child.parsed_rules.members.size > 1
|
|
104
120
|
expand_commas(child) if child.is_a?(Tree::DirectiveNode)
|
|
105
121
|
next child
|
|
106
122
|
end
|
|
107
|
-
child.
|
|
108
|
-
|
|
109
|
-
node =
|
|
123
|
+
child.parsed_rules.members.map do |seq|
|
|
124
|
+
node = Tree::RuleNode.new([])
|
|
125
|
+
node.parsed_rules = make_cseq(seq)
|
|
110
126
|
node.children = child.children
|
|
111
127
|
node
|
|
112
128
|
end
|
|
@@ -114,22 +130,7 @@ module Sass
|
|
|
114
130
|
root.children.flatten!
|
|
115
131
|
end
|
|
116
132
|
|
|
117
|
-
# Make rules use
|
|
118
|
-
#
|
|
119
|
-
# foo
|
|
120
|
-
# color: green
|
|
121
|
-
# foo.bar
|
|
122
|
-
# color: blue
|
|
123
|
-
#
|
|
124
|
-
# becomes
|
|
125
|
-
#
|
|
126
|
-
# foo
|
|
127
|
-
# color: green
|
|
128
|
-
# &.bar
|
|
129
|
-
# color: blue
|
|
130
|
-
#
|
|
131
|
-
# This has the side effect of nesting rules,
|
|
132
|
-
# so that
|
|
133
|
+
# Make rules use nesting so that
|
|
133
134
|
#
|
|
134
135
|
# foo
|
|
135
136
|
# color: green
|
|
@@ -142,28 +143,31 @@ module Sass
|
|
|
142
143
|
#
|
|
143
144
|
# foo
|
|
144
145
|
# color: green
|
|
145
|
-
#
|
|
146
|
+
# bar
|
|
146
147
|
# color: red
|
|
147
|
-
#
|
|
148
|
+
# baz
|
|
148
149
|
# color: blue
|
|
149
150
|
#
|
|
150
151
|
# @param root [Tree::Node] The parent node
|
|
151
|
-
def
|
|
152
|
+
def nest_seqs(root)
|
|
152
153
|
current_rule = nil
|
|
153
154
|
root.children.map! do |child|
|
|
154
155
|
unless child.is_a?(Tree::RuleNode)
|
|
155
|
-
|
|
156
|
+
nest_seqs(child) if child.is_a?(Tree::DirectiveNode)
|
|
156
157
|
next child
|
|
157
158
|
end
|
|
158
159
|
|
|
159
|
-
|
|
160
|
+
seq = first_seq(child)
|
|
161
|
+
seq.members.reject! {|sseq| sseq == "\n"}
|
|
162
|
+
first, rest = seq.members.first, seq.members[1..-1]
|
|
160
163
|
|
|
161
|
-
if current_rule.nil? || current_rule
|
|
162
|
-
current_rule = Tree::RuleNode.new([
|
|
164
|
+
if current_rule.nil? || first_sseq(current_rule) != first
|
|
165
|
+
current_rule = Tree::RuleNode.new([])
|
|
166
|
+
current_rule.parsed_rules = make_seq(first)
|
|
163
167
|
end
|
|
164
168
|
|
|
165
|
-
|
|
166
|
-
child.
|
|
169
|
+
unless rest.empty?
|
|
170
|
+
child.parsed_rules = make_seq(*rest)
|
|
167
171
|
current_rule << child
|
|
168
172
|
else
|
|
169
173
|
current_rule.children += child.children
|
|
@@ -174,32 +178,57 @@ module Sass
|
|
|
174
178
|
root.children.compact!
|
|
175
179
|
root.children.uniq!
|
|
176
180
|
|
|
177
|
-
root.children.each {
|
|
181
|
+
root.children.each {|v| nest_seqs(v)}
|
|
178
182
|
end
|
|
179
183
|
|
|
180
|
-
#
|
|
184
|
+
# Make rules use parent refs so that
|
|
181
185
|
#
|
|
182
186
|
# foo
|
|
183
|
-
#
|
|
184
|
-
#
|
|
187
|
+
# color: green
|
|
188
|
+
# foo.bar
|
|
189
|
+
# color: blue
|
|
185
190
|
#
|
|
186
191
|
# becomes
|
|
187
192
|
#
|
|
188
193
|
# foo
|
|
189
|
-
#
|
|
194
|
+
# color: green
|
|
195
|
+
# &.bar
|
|
190
196
|
# color: blue
|
|
191
197
|
#
|
|
192
198
|
# @param root [Tree::Node] The parent node
|
|
193
|
-
def
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
child
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
199
|
+
def parent_ref_rules(root)
|
|
200
|
+
current_rule = nil
|
|
201
|
+
root.children.map! do |child|
|
|
202
|
+
unless child.is_a?(Tree::RuleNode)
|
|
203
|
+
parent_ref_rules(child) if child.is_a?(Tree::DirectiveNode)
|
|
204
|
+
next child
|
|
205
|
+
end
|
|
206
|
+
|
|
207
|
+
sseq = first_sseq(child)
|
|
208
|
+
next child unless sseq.is_a?(Sass::Selector::SimpleSequence)
|
|
209
|
+
|
|
210
|
+
firsts, rest = [sseq.members.first], sseq.members[1..-1]
|
|
211
|
+
firsts.push rest.shift if firsts.first.is_a?(Sass::Selector::Parent)
|
|
212
|
+
|
|
213
|
+
if current_rule.nil? || first_sseq(current_rule).members != firsts
|
|
214
|
+
current_rule = Tree::RuleNode.new([])
|
|
215
|
+
current_rule.parsed_rules = make_sseq(*firsts)
|
|
216
|
+
end
|
|
217
|
+
|
|
218
|
+
unless rest.empty?
|
|
219
|
+
rest.unshift Sass::Selector::Parent.new
|
|
220
|
+
child.parsed_rules = make_sseq(*rest)
|
|
221
|
+
current_rule << child
|
|
222
|
+
else
|
|
223
|
+
current_rule.children += child.children
|
|
201
224
|
end
|
|
225
|
+
|
|
226
|
+
current_rule
|
|
202
227
|
end
|
|
228
|
+
root.children.compact!
|
|
229
|
+
root.children.uniq!
|
|
230
|
+
|
|
231
|
+
root.children.each {|v| parent_ref_rules(v)}
|
|
203
232
|
end
|
|
204
233
|
|
|
205
234
|
# Flatten rules so that
|
|
@@ -236,7 +265,7 @@ module Sass
|
|
|
236
265
|
end
|
|
237
266
|
end
|
|
238
267
|
|
|
239
|
-
# Flattens a single rule
|
|
268
|
+
# Flattens a single rule.
|
|
240
269
|
#
|
|
241
270
|
# @param rule [Tree::RuleNode] The candidate for flattening
|
|
242
271
|
# @see #flatten_rules
|
|
@@ -244,10 +273,10 @@ module Sass
|
|
|
244
273
|
while rule.children.size == 1 && rule.children.first.is_a?(Tree::RuleNode)
|
|
245
274
|
child = rule.children.first
|
|
246
275
|
|
|
247
|
-
if child.
|
|
248
|
-
rule.
|
|
276
|
+
if first_simple_sel(child).is_a?(Sass::Selector::Parent)
|
|
277
|
+
rule.parsed_rules = child.parsed_rules.resolve_parent_refs(rule.parsed_rules)
|
|
249
278
|
else
|
|
250
|
-
rule.
|
|
279
|
+
rule.parsed_rules = make_seq(first_sseq(rule), *first_seq(child).members)
|
|
251
280
|
end
|
|
252
281
|
|
|
253
282
|
rule.children = child.children
|
|
@@ -280,7 +309,7 @@ module Sass
|
|
|
280
309
|
end
|
|
281
310
|
|
|
282
311
|
if prev_rule && prev_rule.children == child.children
|
|
283
|
-
prev_rule.
|
|
312
|
+
prev_rule.parsed_rules.members << first_seq(child)
|
|
284
313
|
next nil
|
|
285
314
|
end
|
|
286
315
|
|
|
@@ -290,5 +319,72 @@ module Sass
|
|
|
290
319
|
end
|
|
291
320
|
root.children.compact!
|
|
292
321
|
end
|
|
322
|
+
|
|
323
|
+
# Dump all the parsed {Sass::Tree::RuleNode} selectors to strings.
|
|
324
|
+
#
|
|
325
|
+
# @param root [Tree::Node] The parent node
|
|
326
|
+
def dump_selectors(root)
|
|
327
|
+
root.children.each do |child|
|
|
328
|
+
next dump_selectors(child) if child.is_a?(Tree::DirectiveNode)
|
|
329
|
+
next unless child.is_a?(Tree::RuleNode)
|
|
330
|
+
child.rule = [child.parsed_rules.to_s]
|
|
331
|
+
dump_selectors(child)
|
|
332
|
+
end
|
|
333
|
+
end
|
|
334
|
+
|
|
335
|
+
# Create a {Sass::Selector::CommaSequence}.
|
|
336
|
+
#
|
|
337
|
+
# @param seqs [Array<Sass::Selector::Sequence>]
|
|
338
|
+
# @return [Sass::Selector::CommaSequence]
|
|
339
|
+
def make_cseq(*seqs)
|
|
340
|
+
Sass::Selector::CommaSequence.new(seqs)
|
|
341
|
+
end
|
|
342
|
+
|
|
343
|
+
# Create a {Sass::Selector::CommaSequence} containing only a single
|
|
344
|
+
# {Sass::Selector::Sequence}.
|
|
345
|
+
#
|
|
346
|
+
# @param sseqs [Array<Sass::Selector::Sequence, String>]
|
|
347
|
+
# @return [Sass::Selector::CommaSequence]
|
|
348
|
+
def make_seq(*sseqs)
|
|
349
|
+
make_cseq(Sass::Selector::Sequence.new(sseqs))
|
|
350
|
+
end
|
|
351
|
+
|
|
352
|
+
# Create a {Sass::Selector::CommaSequence} containing only a single
|
|
353
|
+
# {Sass::Selector::Sequence} which in turn contains only a single
|
|
354
|
+
# {Sass::Selector::SimpleSequence}.
|
|
355
|
+
#
|
|
356
|
+
# @param sseqs [Array<Sass::Selector::Sequence, String>]
|
|
357
|
+
# @return [Sass::Selector::CommaSequence]
|
|
358
|
+
def make_sseq(*sseqs)
|
|
359
|
+
make_seq(Sass::Selector::SimpleSequence.new(sseqs))
|
|
360
|
+
end
|
|
361
|
+
|
|
362
|
+
# Return the first {Sass::Selector::Sequence} in a {Sass::Tree::RuleNode}.
|
|
363
|
+
#
|
|
364
|
+
# @param rule [Sass::Tree::RuleNode]
|
|
365
|
+
# @return [Sass::Selector::Sequence]
|
|
366
|
+
def first_seq(rule)
|
|
367
|
+
rule.parsed_rules.members.first
|
|
368
|
+
end
|
|
369
|
+
|
|
370
|
+
# Return the first {Sass::Selector::SimpleSequence} in a
|
|
371
|
+
# {Sass::Tree::RuleNode}.
|
|
372
|
+
#
|
|
373
|
+
# @param rule [Sass::Tree::RuleNode]
|
|
374
|
+
# @return [Sass::Selector::SimpleSequence, String]
|
|
375
|
+
def first_sseq(rule)
|
|
376
|
+
first_seq(rule).members.first
|
|
377
|
+
end
|
|
378
|
+
|
|
379
|
+
# Return the first {Sass::Selector::Simple} in a {Sass::Tree::RuleNode},
|
|
380
|
+
# unless the rule begins with a combinator.
|
|
381
|
+
#
|
|
382
|
+
# @param rule [Sass::Tree::RuleNode]
|
|
383
|
+
# @return [Sass::Selector::Simple?]
|
|
384
|
+
def first_simple_sel(rule)
|
|
385
|
+
sseq = first_sseq(rule)
|
|
386
|
+
return unless sseq.is_a?(Sass::Selector::SimpleSequence)
|
|
387
|
+
sseq.members.first
|
|
388
|
+
end
|
|
293
389
|
end
|
|
294
390
|
end
|
data/lib/sass/engine.rb
CHANGED
|
@@ -777,8 +777,10 @@ WARNING
|
|
|
777
777
|
|
|
778
778
|
val = scanner[1] || scanner[2]
|
|
779
779
|
scanner.scan(/\s*/)
|
|
780
|
-
if media = scanner.scan(/[
|
|
780
|
+
if media = scanner.scan(/[a-zA-Z].*/)
|
|
781
781
|
Tree::DirectiveNode.new("@import #{str || uri} #{media}")
|
|
782
|
+
elsif !scanner.match?(/[,;]|$/)
|
|
783
|
+
raise SyntaxError.new("Invalid @import: \"#{str || uri} #{scanner.rest}\"")
|
|
782
784
|
elsif uri
|
|
783
785
|
Tree::DirectiveNode.new("@import #{uri}")
|
|
784
786
|
elsif val =~ /^http:\/\//
|
data/lib/sass/plugin/compiler.rb
CHANGED
|
@@ -5,6 +5,7 @@ require 'sass'
|
|
|
5
5
|
require 'sass/callbacks'
|
|
6
6
|
require 'sass/plugin/configuration'
|
|
7
7
|
require 'sass/plugin/staleness_checker'
|
|
8
|
+
require 'sass/plugin/listener'
|
|
8
9
|
|
|
9
10
|
module Sass::Plugin
|
|
10
11
|
|
|
@@ -218,10 +219,10 @@ module Sass::Plugin
|
|
|
218
219
|
#
|
|
219
220
|
# Before the watching starts in earnest, `watch` calls \{#update\_stylesheets}.
|
|
220
221
|
#
|
|
221
|
-
# Note that `watch` uses the [
|
|
222
|
+
# Note that `watch` uses the [Listen](http://github.com/guard/listen) library
|
|
222
223
|
# to monitor the filesystem for changes.
|
|
223
|
-
#
|
|
224
|
-
# The version of
|
|
224
|
+
# Listen isn't loaded until `watch` is run.
|
|
225
|
+
# The version of Listen distributed with Sass is loaded by default,
|
|
225
226
|
# but if another version has already been loaded that will be used instead.
|
|
226
227
|
#
|
|
227
228
|
# @param individual_files [Array<(String, String)>]
|
|
@@ -234,15 +235,15 @@ module Sass::Plugin
|
|
|
234
235
|
update_stylesheets(individual_files)
|
|
235
236
|
|
|
236
237
|
begin
|
|
237
|
-
require '
|
|
238
|
+
require 'listen'
|
|
238
239
|
rescue LoadError => e
|
|
239
|
-
dir = Sass::Util.scope("vendor/
|
|
240
|
+
dir = Sass::Util.scope("vendor/listen/lib")
|
|
240
241
|
if $LOAD_PATH.include?(dir)
|
|
241
242
|
e.message << "\n" <<
|
|
242
243
|
if File.exists?(scope(".git"))
|
|
243
244
|
'Run "git submodule update --init" to get the recommended version.'
|
|
244
245
|
else
|
|
245
|
-
'Run "gem install
|
|
246
|
+
'Run "gem install listen" to get it.'
|
|
246
247
|
end
|
|
247
248
|
raise e
|
|
248
249
|
else
|
|
@@ -251,59 +252,51 @@ module Sass::Plugin
|
|
|
251
252
|
end
|
|
252
253
|
end
|
|
253
254
|
|
|
254
|
-
unless individual_files.empty? && FSSM::Backends::Default.name == "FSSM::Backends::FSEvents"
|
|
255
|
-
# As of FSSM 0.1.4, it doesn't support FSevents on individual files,
|
|
256
|
-
# but it also isn't smart enough to switch to polling itself.
|
|
257
|
-
require 'fssm/backends/polling'
|
|
258
|
-
Sass::Util.silence_warnings do
|
|
259
|
-
FSSM::Backends.const_set(:Default, FSSM::Backends::Polling)
|
|
260
|
-
end
|
|
261
|
-
end
|
|
262
|
-
|
|
263
255
|
# TODO: Keep better track of what depends on what
|
|
264
256
|
# so we don't have to run a global update every time anything changes.
|
|
265
|
-
|
|
257
|
+
Sass::Plugin::Listener.new do |l|
|
|
266
258
|
template_location_array.each do |template_location, css_location|
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
path.update do |base, relative|
|
|
259
|
+
l.directory(template_location, {
|
|
260
|
+
:modified => lambda do |base, relative|
|
|
261
|
+
next if relative !~ /\.s[ac]ss$/
|
|
271
262
|
run_template_modified File.join(base, relative)
|
|
272
263
|
update_stylesheets(individual_files)
|
|
273
|
-
end
|
|
264
|
+
end,
|
|
274
265
|
|
|
275
|
-
|
|
266
|
+
:added => lambda do |base, relative|
|
|
267
|
+
next if relative !~ /\.s[ac]ss$/
|
|
276
268
|
run_template_created File.join(base, relative)
|
|
277
269
|
update_stylesheets(individual_files)
|
|
278
|
-
end
|
|
270
|
+
end,
|
|
279
271
|
|
|
280
|
-
|
|
272
|
+
:removed => lambda do |base, relative|
|
|
273
|
+
next if relative !~ /\.s[ac]ss$/
|
|
281
274
|
run_template_deleted File.join(base, relative)
|
|
282
275
|
css = File.join(css_location, relative.gsub(/\.s[ac]ss$/, '.css'))
|
|
283
276
|
try_delete_css css
|
|
284
277
|
update_stylesheets(individual_files)
|
|
285
278
|
end
|
|
286
|
-
|
|
279
|
+
})
|
|
287
280
|
end
|
|
288
281
|
|
|
289
282
|
individual_files.each do |template, css|
|
|
290
|
-
|
|
291
|
-
|
|
283
|
+
l.file(template, {
|
|
284
|
+
:modified => lambda do
|
|
292
285
|
run_template_modified template
|
|
293
286
|
update_stylesheets(individual_files)
|
|
294
|
-
end
|
|
287
|
+
end,
|
|
295
288
|
|
|
296
|
-
|
|
289
|
+
:added => lambda do
|
|
297
290
|
run_template_created template
|
|
298
291
|
update_stylesheets(individual_files)
|
|
299
|
-
end
|
|
292
|
+
end,
|
|
300
293
|
|
|
301
|
-
|
|
294
|
+
:removed => lambda do
|
|
302
295
|
run_template_deleted template
|
|
303
296
|
try_delete_css css
|
|
304
297
|
update_stylesheets(individual_files)
|
|
305
298
|
end
|
|
306
|
-
|
|
299
|
+
})
|
|
307
300
|
end
|
|
308
301
|
end
|
|
309
302
|
end
|