haml-edge 2.3.194 → 2.3.195
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/EDGE_GEM_VERSION +1 -1
- data/VERSION +1 -1
- data/lib/haml/exec.rb +16 -6
- data/lib/sass/css.rb +25 -6
- data/test/sass/css2sass_test.rb +31 -0
- metadata +2 -2
data/EDGE_GEM_VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.3.
|
1
|
+
2.3.195
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.3.
|
1
|
+
2.3.195
|
data/lib/haml/exec.rb
CHANGED
@@ -15,14 +15,11 @@ module Haml
|
|
15
15
|
|
16
16
|
# Parses the command-line arguments and runs the executable.
|
17
17
|
# Calls `Kernel#exit` at the end, so it never returns.
|
18
|
+
#
|
19
|
+
# @see #parse
|
18
20
|
def parse!
|
19
21
|
begin
|
20
|
-
|
21
|
-
@opts.parse!(@args)
|
22
|
-
|
23
|
-
process_result
|
24
|
-
|
25
|
-
@options
|
22
|
+
parse
|
26
23
|
rescue Exception => e
|
27
24
|
raise e if @options[:trace] || e.is_a?(SystemExit)
|
28
25
|
|
@@ -32,6 +29,19 @@ module Haml
|
|
32
29
|
exit 0
|
33
30
|
end
|
34
31
|
|
32
|
+
# Parses the command-line arguments and runs the executable.
|
33
|
+
# This does not handle exceptions or exit the program.
|
34
|
+
#
|
35
|
+
# @see #parse!
|
36
|
+
def parse
|
37
|
+
@opts = OptionParser.new(&method(:set_opts))
|
38
|
+
@opts.parse!(@args)
|
39
|
+
|
40
|
+
process_result
|
41
|
+
|
42
|
+
@options
|
43
|
+
end
|
44
|
+
|
35
45
|
# @return [String] A description of the executable
|
36
46
|
def to_s
|
37
47
|
@opts.to_s
|
data/lib/sass/css.rb
CHANGED
@@ -79,7 +79,10 @@ module Sass
|
|
79
79
|
# @param root [Tree::Node] The parent node
|
80
80
|
def expand_commas(root)
|
81
81
|
root.children.map! do |child|
|
82
|
-
|
82
|
+
unless child.is_a?(Tree::RuleNode) && child.rule.first.include?(',')
|
83
|
+
expand_commas(child) if child.is_a?(Tree::DirectiveNode)
|
84
|
+
next child
|
85
|
+
end
|
83
86
|
child.rule.first.split(',').map do |rule|
|
84
87
|
node = Tree::RuleNode.new([rule.strip])
|
85
88
|
node.children = child.children
|
@@ -126,9 +129,12 @@ module Sass
|
|
126
129
|
def parent_ref_rules(root)
|
127
130
|
current_rule = nil
|
128
131
|
root.children.map! do |child|
|
129
|
-
|
132
|
+
unless child.is_a?(Tree::RuleNode)
|
133
|
+
parent_ref_rules(child) if child.is_a?(Tree::DirectiveNode)
|
134
|
+
next child
|
135
|
+
end
|
130
136
|
|
131
|
-
first, rest = child.rule.first.scan(
|
137
|
+
first, rest = child.rule.first.scan(/\A(&?(?: .|[^ ])[^.#: \[]*)([.#: \[].*)?\Z/m).first
|
132
138
|
|
133
139
|
if current_rule.nil? || current_rule.rule.first != first
|
134
140
|
current_rule = Tree::RuleNode.new([first])
|
@@ -164,9 +170,12 @@ module Sass
|
|
164
170
|
# @param root [Tree::Node] The parent node
|
165
171
|
def remove_parent_refs(root)
|
166
172
|
root.children.each do |child|
|
167
|
-
|
173
|
+
case child
|
174
|
+
when Tree::RuleNode
|
168
175
|
child.rule.first.gsub! /^& +/, ''
|
169
176
|
remove_parent_refs child
|
177
|
+
when Tree::DirectiveNode
|
178
|
+
remove_parent_refs child
|
170
179
|
end
|
171
180
|
end
|
172
181
|
end
|
@@ -195,7 +204,14 @@ module Sass
|
|
195
204
|
#
|
196
205
|
# @param root [Tree::Node] The parent node
|
197
206
|
def flatten_rules(root)
|
198
|
-
root.children.each
|
207
|
+
root.children.each do |child|
|
208
|
+
case child
|
209
|
+
when Tree::RuleNode
|
210
|
+
flatten_rule(child)
|
211
|
+
when Tree::DirectiveNode
|
212
|
+
flatten_rules(child)
|
213
|
+
end
|
214
|
+
end
|
199
215
|
end
|
200
216
|
|
201
217
|
# Flattens a single rule
|
@@ -236,7 +252,10 @@ module Sass
|
|
236
252
|
def fold_commas(root)
|
237
253
|
prev_rule = nil
|
238
254
|
root.children.map! do |child|
|
239
|
-
|
255
|
+
unless child.is_a?(Tree::RuleNode)
|
256
|
+
fold_commas(child) if child.is_a?(Tree::DirectiveNode)
|
257
|
+
next child
|
258
|
+
end
|
240
259
|
|
241
260
|
if prev_rule && prev_rule.children == child.children
|
242
261
|
prev_rule.rule.first << ", #{child.rule.first}"
|
data/test/sass/css2sass_test.rb
CHANGED
@@ -237,6 +237,37 @@ SASS
|
|
237
237
|
CSS
|
238
238
|
end
|
239
239
|
|
240
|
+
# Regressions
|
241
|
+
|
242
|
+
def test_nesting_within_media
|
243
|
+
assert_equal(<<SASS, css2sass(<<CSS))
|
244
|
+
@media all
|
245
|
+
.next .vevent
|
246
|
+
padding-left: 0
|
247
|
+
padding-right: 0
|
248
|
+
SASS
|
249
|
+
@media all {
|
250
|
+
.next .vevent {
|
251
|
+
padding-left: 0;
|
252
|
+
padding-right: 0; } }
|
253
|
+
CSS
|
254
|
+
end
|
255
|
+
|
256
|
+
def test_multiline_selector_within_media_and_with_child_selector
|
257
|
+
assert_equal(<<SASS, css2sass(<<CSS))
|
258
|
+
@media all
|
259
|
+
foo bar, baz
|
260
|
+
padding-left: 0
|
261
|
+
padding-right: 0
|
262
|
+
SASS
|
263
|
+
@media all {
|
264
|
+
foo bar,
|
265
|
+
baz {
|
266
|
+
padding-left: 0;
|
267
|
+
padding-right: 0; } }
|
268
|
+
CSS
|
269
|
+
end
|
270
|
+
|
240
271
|
# Error reporting
|
241
272
|
|
242
273
|
def test_error_reporting
|
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.195
|
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: 2010-04-
|
13
|
+
date: 2010-04-10 00:00:00 -04:00
|
14
14
|
default_executable:
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|