haml-edge 2.3.6 → 2.3.7
Sign up to get free protection for your applications and to get access to all the features.
- data/EDGE_GEM_VERSION +1 -1
- data/VERSION +1 -1
- data/lib/sass/engine.rb +16 -36
- data/lib/sass/tree/directive_node.rb +1 -4
- data/lib/sass/tree/{file_node.rb → import_node.rb} +29 -5
- data/test/sass/engine_test.rb +2 -2
- data/test/sass/plugin_test.rb +22 -2
- data/test/sass/templates/import.sass +1 -1
- metadata +3 -3
data/EDGE_GEM_VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.3.
|
1
|
+
2.3.7
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.3.
|
1
|
+
2.3.7
|
data/lib/sass/engine.rb
CHANGED
@@ -12,7 +12,7 @@ require 'sass/tree/if_node'
|
|
12
12
|
require 'sass/tree/while_node'
|
13
13
|
require 'sass/tree/for_node'
|
14
14
|
require 'sass/tree/debug_node'
|
15
|
-
require 'sass/tree/
|
15
|
+
require 'sass/tree/import_node'
|
16
16
|
require 'sass/environment'
|
17
17
|
require 'sass/script'
|
18
18
|
require 'sass/error'
|
@@ -227,21 +227,23 @@ END
|
|
227
227
|
|
228
228
|
def build_tree(parent, line, root = false)
|
229
229
|
@line = line.index
|
230
|
-
|
230
|
+
node_or_nodes = parse_line(parent, line, root)
|
231
231
|
|
232
|
-
|
233
|
-
|
234
|
-
|
232
|
+
Array(node_or_nodes).each do |node|
|
233
|
+
# Node is a symbol if it's non-outputting, like a variable assignment
|
234
|
+
next unless node.is_a? Tree::Node
|
235
235
|
|
236
|
-
|
237
|
-
|
236
|
+
node.line = line.index
|
237
|
+
node.filename = line.filename
|
238
238
|
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
239
|
+
if node.is_a?(Tree::CommentNode)
|
240
|
+
node.lines = line.children
|
241
|
+
else
|
242
|
+
append_children(node, line.children, false)
|
243
|
+
end
|
243
244
|
end
|
244
|
-
|
245
|
+
|
246
|
+
node_or_nodes
|
245
247
|
end
|
246
248
|
|
247
249
|
def append_children(parent, children, root)
|
@@ -279,7 +281,7 @@ END
|
|
279
281
|
case child
|
280
282
|
when Tree::MixinDefNode
|
281
283
|
raise SyntaxError.new("Mixins may only be defined at the root of a document.", line.index)
|
282
|
-
when Tree::
|
284
|
+
when Tree::ImportNode
|
283
285
|
raise SyntaxError.new("Import directives may only be used at the root of a document.", line.index)
|
284
286
|
end
|
285
287
|
end
|
@@ -365,7 +367,7 @@ END
|
|
365
367
|
# it's a CSS @import rule and we don't want to touch it.
|
366
368
|
if directive == "import" && value !~ /^(url\(|")/
|
367
369
|
raise SyntaxError.new("Illegal nesting: Nothing may be nested beneath import directives.", @line + 1) unless line.children.empty?
|
368
|
-
|
370
|
+
value.split(/,\s*/).map {|f| Tree::ImportNode.new(f)}
|
369
371
|
elsif directive == "for"
|
370
372
|
parse_for(line, root, value)
|
371
373
|
elsif directive == "else"
|
@@ -470,27 +472,5 @@ END
|
|
470
472
|
offset = options[:offset] || 0
|
471
473
|
Script.parse(script, line, offset, @options[:filename])
|
472
474
|
end
|
473
|
-
|
474
|
-
def import_paths
|
475
|
-
paths = (@options[:load_paths] || []).dup
|
476
|
-
paths.unshift(File.dirname(@options[:filename])) if @options[:filename]
|
477
|
-
paths
|
478
|
-
end
|
479
|
-
|
480
|
-
def import(files)
|
481
|
-
files.split(/,\s*/).map do |filename|
|
482
|
-
engine = nil
|
483
|
-
|
484
|
-
begin
|
485
|
-
filename = Sass::Files.find_file_to_import(filename, import_paths)
|
486
|
-
rescue Exception => e
|
487
|
-
raise SyntaxError.new(e.message, @line)
|
488
|
-
end
|
489
|
-
|
490
|
-
next Tree::DirectiveNode.new("@import url(#{filename})") if filename =~ /\.css$/
|
491
|
-
|
492
|
-
Tree::FileNode.new(filename)
|
493
|
-
end.flatten
|
494
|
-
end
|
495
475
|
end
|
496
476
|
end
|
@@ -5,10 +5,7 @@ module Sass::Tree
|
|
5
5
|
# only CSS directives like `@media` and `@font-face` become {DirectiveNode}s.
|
6
6
|
#
|
7
7
|
# `@import` is a bit of a weird case;
|
8
|
-
#
|
9
|
-
# it becomes a {FileNode},
|
10
|
-
# but if it's importing a plain CSS file,
|
11
|
-
# it becomes a {DirectiveNode}.
|
8
|
+
# it becomes an {ImportNode}.
|
12
9
|
#
|
13
10
|
# @see Sass::Tree
|
14
11
|
class DirectiveNode < Node
|
@@ -3,10 +3,10 @@ module Sass
|
|
3
3
|
# A static node that wraps the {Sass::Tree} for an `@import`ed file.
|
4
4
|
# It doesn't have a functional purpose other than to add the `@import`ed file
|
5
5
|
# to the backtrace if an error occurs.
|
6
|
-
class
|
7
|
-
# @param
|
8
|
-
def initialize(
|
9
|
-
@
|
6
|
+
class ImportNode < Node
|
7
|
+
# @param imported_filename [String] The name of the imported file
|
8
|
+
def initialize(imported_filename)
|
9
|
+
@imported_filename = imported_filename
|
10
10
|
super()
|
11
11
|
end
|
12
12
|
|
@@ -30,12 +30,36 @@ module Sass
|
|
30
30
|
# @param environment [Sass::Environment] The lexical environment containing
|
31
31
|
# variable and mixin values
|
32
32
|
def perform!(environment)
|
33
|
-
|
33
|
+
return unless full_filename = import
|
34
|
+
self.children = Sass::Files.tree_for(full_filename, @options).children
|
34
35
|
self.children = perform_children(environment)
|
35
36
|
rescue Sass::SyntaxError => e
|
36
37
|
e.add_backtrace_entry(@filename)
|
37
38
|
raise e
|
38
39
|
end
|
40
|
+
|
41
|
+
private
|
42
|
+
|
43
|
+
def import_paths
|
44
|
+
paths = (@options[:load_paths] || []).dup
|
45
|
+
paths.unshift(File.dirname(@options[:filename])) if @options[:filename]
|
46
|
+
paths
|
47
|
+
end
|
48
|
+
|
49
|
+
def import
|
50
|
+
begin
|
51
|
+
full_filename = Sass::Files.find_file_to_import(@imported_filename, import_paths)
|
52
|
+
rescue Exception => e
|
53
|
+
raise SyntaxError.new(e.message, self.line)
|
54
|
+
end
|
55
|
+
|
56
|
+
if full_filename =~ /\.css$/
|
57
|
+
@to_s = "@import url(#{full_filename});"
|
58
|
+
return false
|
59
|
+
end
|
60
|
+
|
61
|
+
return full_filename
|
62
|
+
end
|
39
63
|
end
|
40
64
|
end
|
41
65
|
end
|
data/test/sass/engine_test.rb
CHANGED
@@ -126,8 +126,8 @@ class SassEngineTest < Test::Unit::TestCase
|
|
126
126
|
render("p\n\ta: b\n\tq\n\t\tc: d\n"))
|
127
127
|
end
|
128
128
|
|
129
|
-
|
130
|
-
|
129
|
+
EXCEPTION_MAP.each do |key, value|
|
130
|
+
define_method("test_exception (#{key.inspect})") do
|
131
131
|
line = 10
|
132
132
|
begin
|
133
133
|
Sass::Engine.new(key, :filename => __FILE__, :line => line).render
|
data/test/sass/plugin_test.rb
CHANGED
@@ -34,7 +34,7 @@ class SassPluginTest < Test::Unit::TestCase
|
|
34
34
|
end
|
35
35
|
|
36
36
|
def test_update_needed_when_modified
|
37
|
-
sleep
|
37
|
+
sleep 1
|
38
38
|
FileUtils.touch(template_loc('basic'))
|
39
39
|
assert Sass::Plugin.stylesheet_needs_update?('basic', template_loc, tempfile_loc)
|
40
40
|
Sass::Plugin.update_stylesheets
|
@@ -42,7 +42,7 @@ class SassPluginTest < Test::Unit::TestCase
|
|
42
42
|
end
|
43
43
|
|
44
44
|
def test_update_needed_when_dependency_modified
|
45
|
-
sleep
|
45
|
+
sleep 1
|
46
46
|
FileUtils.touch(template_loc('basic'))
|
47
47
|
assert Sass::Plugin.stylesheet_needs_update?('import', template_loc, tempfile_loc)
|
48
48
|
Sass::Plugin.update_stylesheets
|
@@ -122,6 +122,21 @@ class SassPluginTest < Test::Unit::TestCase
|
|
122
122
|
assert !File.exists?(tempfile_loc('_partial'))
|
123
123
|
end
|
124
124
|
|
125
|
+
## Regression
|
126
|
+
|
127
|
+
def test_cached_dependencies_update
|
128
|
+
FileUtils.mv(template_loc("basic"), template_loc("basic", "more_"))
|
129
|
+
set_plugin_opts :load_paths => [result_loc, template_loc(nil, "more_")]
|
130
|
+
|
131
|
+
sleep 1
|
132
|
+
FileUtils.touch(template_loc("basic", "more_"))
|
133
|
+
assert Sass::Plugin.stylesheet_needs_update?("import", template_loc, tempfile_loc)
|
134
|
+
Sass::Plugin.update_stylesheets
|
135
|
+
assert_renders_correctly("import")
|
136
|
+
ensure
|
137
|
+
FileUtils.mv(template_loc("basic", "more_"), template_loc("basic"))
|
138
|
+
end
|
139
|
+
|
125
140
|
private
|
126
141
|
|
127
142
|
def assert_renders_correctly(*arguments)
|
@@ -182,6 +197,11 @@ class SassPluginTest < Test::Unit::TestCase
|
|
182
197
|
:always_update => true,
|
183
198
|
}.merge(overrides)
|
184
199
|
end
|
200
|
+
|
201
|
+
def wait_a_tick
|
202
|
+
time = Time.now
|
203
|
+
loop {break if Time.now.sec != time.sec}
|
204
|
+
end
|
185
205
|
end
|
186
206
|
|
187
207
|
module Sass::Plugin
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: haml-edge
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.3.
|
4
|
+
version: 2.3.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nathan Weizenbaum
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2009-07-
|
13
|
+
date: 2009-07-12 00:00:00 -04:00
|
14
14
|
default_executable:
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
@@ -102,9 +102,9 @@ files:
|
|
102
102
|
- lib/sass/tree/comment_node.rb
|
103
103
|
- lib/sass/tree/debug_node.rb
|
104
104
|
- lib/sass/tree/directive_node.rb
|
105
|
-
- lib/sass/tree/file_node.rb
|
106
105
|
- lib/sass/tree/for_node.rb
|
107
106
|
- lib/sass/tree/if_node.rb
|
107
|
+
- lib/sass/tree/import_node.rb
|
108
108
|
- lib/sass/tree/mixin_def_node.rb
|
109
109
|
- lib/sass/tree/mixin_node.rb
|
110
110
|
- lib/sass/tree/node.rb
|