wireframe-haml 2.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (169) hide show
  1. data/README.rdoc +332 -0
  2. data/VERSION.yml +4 -0
  3. data/bin/css2sass +7 -0
  4. data/bin/haml +9 -0
  5. data/bin/html2haml +7 -0
  6. data/bin/sass +8 -0
  7. data/lib/haml/buffer.rb +255 -0
  8. data/lib/haml/engine.rb +268 -0
  9. data/lib/haml/error.rb +22 -0
  10. data/lib/haml/exec.rb +395 -0
  11. data/lib/haml/filters.rb +276 -0
  12. data/lib/haml/helpers/action_view_extensions.rb +45 -0
  13. data/lib/haml/helpers/action_view_mods.rb +181 -0
  14. data/lib/haml/helpers.rb +468 -0
  15. data/lib/haml/html.rb +218 -0
  16. data/lib/haml/precompiler.rb +889 -0
  17. data/lib/haml/shared.rb +45 -0
  18. data/lib/haml/template/patch.rb +58 -0
  19. data/lib/haml/template/plugin.rb +72 -0
  20. data/lib/haml/template.rb +51 -0
  21. data/lib/haml/util.rb +77 -0
  22. data/lib/haml/version.rb +47 -0
  23. data/lib/haml.rb +1042 -0
  24. data/lib/sass/css.rb +388 -0
  25. data/lib/sass/engine.rb +499 -0
  26. data/lib/sass/environment.rb +33 -0
  27. data/lib/sass/error.rb +35 -0
  28. data/lib/sass/plugin/merb.rb +56 -0
  29. data/lib/sass/plugin/rails.rb +24 -0
  30. data/lib/sass/plugin.rb +203 -0
  31. data/lib/sass/repl.rb +51 -0
  32. data/lib/sass/script/bool.rb +13 -0
  33. data/lib/sass/script/color.rb +97 -0
  34. data/lib/sass/script/funcall.rb +28 -0
  35. data/lib/sass/script/functions.rb +122 -0
  36. data/lib/sass/script/lexer.rb +152 -0
  37. data/lib/sass/script/literal.rb +60 -0
  38. data/lib/sass/script/number.rb +231 -0
  39. data/lib/sass/script/operation.rb +30 -0
  40. data/lib/sass/script/parser.rb +142 -0
  41. data/lib/sass/script/string.rb +42 -0
  42. data/lib/sass/script/unary_operation.rb +21 -0
  43. data/lib/sass/script/variable.rb +20 -0
  44. data/lib/sass/script.rb +38 -0
  45. data/lib/sass/tree/attr_node.rb +64 -0
  46. data/lib/sass/tree/comment_node.rb +34 -0
  47. data/lib/sass/tree/debug_node.rb +22 -0
  48. data/lib/sass/tree/directive_node.rb +50 -0
  49. data/lib/sass/tree/file_node.rb +27 -0
  50. data/lib/sass/tree/for_node.rb +29 -0
  51. data/lib/sass/tree/if_node.rb +27 -0
  52. data/lib/sass/tree/mixin_def_node.rb +18 -0
  53. data/lib/sass/tree/mixin_node.rb +34 -0
  54. data/lib/sass/tree/node.rb +99 -0
  55. data/lib/sass/tree/rule_node.rb +120 -0
  56. data/lib/sass/tree/variable_node.rb +24 -0
  57. data/lib/sass/tree/while_node.rb +20 -0
  58. data/lib/sass.rb +1062 -0
  59. data/test/benchmark.rb +99 -0
  60. data/test/haml/engine_test.rb +734 -0
  61. data/test/haml/helper_test.rb +224 -0
  62. data/test/haml/html2haml_test.rb +92 -0
  63. data/test/haml/markaby/standard.mab +52 -0
  64. data/test/haml/mocks/article.rb +6 -0
  65. data/test/haml/results/content_for_layout.xhtml +15 -0
  66. data/test/haml/results/eval_suppressed.xhtml +9 -0
  67. data/test/haml/results/filters.xhtml +62 -0
  68. data/test/haml/results/helpers.xhtml +93 -0
  69. data/test/haml/results/helpful.xhtml +10 -0
  70. data/test/haml/results/just_stuff.xhtml +68 -0
  71. data/test/haml/results/list.xhtml +12 -0
  72. data/test/haml/results/nuke_inner_whitespace.xhtml +40 -0
  73. data/test/haml/results/nuke_outer_whitespace.xhtml +148 -0
  74. data/test/haml/results/original_engine.xhtml +20 -0
  75. data/test/haml/results/partial_layout.xhtml +5 -0
  76. data/test/haml/results/partials.xhtml +21 -0
  77. data/test/haml/results/render_layout.xhtml +3 -0
  78. data/test/haml/results/silent_script.xhtml +74 -0
  79. data/test/haml/results/standard.xhtml +42 -0
  80. data/test/haml/results/tag_parsing.xhtml +23 -0
  81. data/test/haml/results/very_basic.xhtml +5 -0
  82. data/test/haml/results/whitespace_handling.xhtml +89 -0
  83. data/test/haml/rhtml/_av_partial_1.rhtml +12 -0
  84. data/test/haml/rhtml/_av_partial_2.rhtml +8 -0
  85. data/test/haml/rhtml/action_view.rhtml +62 -0
  86. data/test/haml/rhtml/standard.rhtml +54 -0
  87. data/test/haml/template_test.rb +204 -0
  88. data/test/haml/templates/_av_partial_1.haml +9 -0
  89. data/test/haml/templates/_av_partial_1_ugly.haml +9 -0
  90. data/test/haml/templates/_av_partial_2.haml +5 -0
  91. data/test/haml/templates/_av_partial_2_ugly.haml +5 -0
  92. data/test/haml/templates/_layout.erb +3 -0
  93. data/test/haml/templates/_layout_for_partial.haml +3 -0
  94. data/test/haml/templates/_partial.haml +8 -0
  95. data/test/haml/templates/_text_area.haml +3 -0
  96. data/test/haml/templates/action_view.haml +47 -0
  97. data/test/haml/templates/action_view_ugly.haml +47 -0
  98. data/test/haml/templates/breakage.haml +8 -0
  99. data/test/haml/templates/content_for_layout.haml +10 -0
  100. data/test/haml/templates/eval_suppressed.haml +11 -0
  101. data/test/haml/templates/filters.haml +66 -0
  102. data/test/haml/templates/helpers.haml +95 -0
  103. data/test/haml/templates/helpful.haml +11 -0
  104. data/test/haml/templates/just_stuff.haml +83 -0
  105. data/test/haml/templates/list.haml +12 -0
  106. data/test/haml/templates/nuke_inner_whitespace.haml +32 -0
  107. data/test/haml/templates/nuke_outer_whitespace.haml +144 -0
  108. data/test/haml/templates/original_engine.haml +17 -0
  109. data/test/haml/templates/partial_layout.haml +3 -0
  110. data/test/haml/templates/partialize.haml +1 -0
  111. data/test/haml/templates/partials.haml +12 -0
  112. data/test/haml/templates/render_layout.haml +2 -0
  113. data/test/haml/templates/silent_script.haml +40 -0
  114. data/test/haml/templates/standard.haml +42 -0
  115. data/test/haml/templates/standard_ugly.haml +1 -0
  116. data/test/haml/templates/tag_parsing.haml +21 -0
  117. data/test/haml/templates/very_basic.haml +4 -0
  118. data/test/haml/templates/whitespace_handling.haml +87 -0
  119. data/test/linked_rails.rb +12 -0
  120. data/test/sass/css2sass_test.rb +193 -0
  121. data/test/sass/engine_test.rb +786 -0
  122. data/test/sass/functions_test.rb +96 -0
  123. data/test/sass/more_results/more1.css +9 -0
  124. data/test/sass/more_results/more1_with_line_comments.css +26 -0
  125. data/test/sass/more_results/more_import.css +29 -0
  126. data/test/sass/more_templates/_more_partial.sass +2 -0
  127. data/test/sass/more_templates/more1.sass +23 -0
  128. data/test/sass/more_templates/more_import.sass +11 -0
  129. data/test/sass/plugin_test.rb +208 -0
  130. data/test/sass/results/alt.css +4 -0
  131. data/test/sass/results/basic.css +9 -0
  132. data/test/sass/results/compact.css +5 -0
  133. data/test/sass/results/complex.css +87 -0
  134. data/test/sass/results/compressed.css +1 -0
  135. data/test/sass/results/expanded.css +19 -0
  136. data/test/sass/results/import.css +29 -0
  137. data/test/sass/results/line_numbers.css +49 -0
  138. data/test/sass/results/mixins.css +95 -0
  139. data/test/sass/results/multiline.css +24 -0
  140. data/test/sass/results/nested.css +22 -0
  141. data/test/sass/results/parent_ref.css +13 -0
  142. data/test/sass/results/script.css +16 -0
  143. data/test/sass/results/subdir/nested_subdir/nested_subdir.css +1 -0
  144. data/test/sass/results/subdir/subdir.css +3 -0
  145. data/test/sass/results/units.css +11 -0
  146. data/test/sass/script_test.rb +153 -0
  147. data/test/sass/templates/_partial.sass +2 -0
  148. data/test/sass/templates/alt.sass +16 -0
  149. data/test/sass/templates/basic.sass +23 -0
  150. data/test/sass/templates/bork.sass +2 -0
  151. data/test/sass/templates/bork2.sass +2 -0
  152. data/test/sass/templates/compact.sass +17 -0
  153. data/test/sass/templates/complex.sass +309 -0
  154. data/test/sass/templates/compressed.sass +15 -0
  155. data/test/sass/templates/expanded.sass +17 -0
  156. data/test/sass/templates/import.sass +11 -0
  157. data/test/sass/templates/importee.sass +19 -0
  158. data/test/sass/templates/line_numbers.sass +13 -0
  159. data/test/sass/templates/mixins.sass +76 -0
  160. data/test/sass/templates/multiline.sass +20 -0
  161. data/test/sass/templates/nested.sass +25 -0
  162. data/test/sass/templates/parent_ref.sass +25 -0
  163. data/test/sass/templates/script.sass +101 -0
  164. data/test/sass/templates/subdir/nested_subdir/_nested_partial.sass +2 -0
  165. data/test/sass/templates/subdir/nested_subdir/nested_subdir.sass +3 -0
  166. data/test/sass/templates/subdir/subdir.sass +6 -0
  167. data/test/sass/templates/units.sass +11 -0
  168. data/test/test_helper.rb +21 -0
  169. metadata +247 -0
@@ -0,0 +1,144 @@
1
+ %p
2
+ %p
3
+ %q>
4
+ Foo
5
+ %p
6
+ %p
7
+ %q{:a => 1 + 1}>
8
+ Foo
9
+ %p
10
+ %p
11
+ %q> Foo
12
+ %p
13
+ %p
14
+ %q{:a => 1 + 1}> Foo
15
+ %p
16
+ %p
17
+ %q>
18
+ = "Foo"
19
+ %p
20
+ %p
21
+ %q{:a => 1 + 1}>
22
+ = "Foo"
23
+ %p
24
+ %p
25
+ %q>= "Foo"
26
+ %p
27
+ %p
28
+ %q{:a => 1 + 1}>= "Foo"
29
+ %p
30
+ %p
31
+ %q>
32
+ = "Foo\nBar"
33
+ %p
34
+ %p
35
+ %q{:a => 1 + 1}>
36
+ = "Foo\nBar"
37
+ %p
38
+ %p
39
+ %q>= "Foo\nBar"
40
+ %p
41
+ %p
42
+ %q{:a => 1 + 1}>= "Foo\nBar"
43
+ %p
44
+ %p
45
+ - tab_up
46
+ foo
47
+ %q>
48
+ Foo
49
+ bar
50
+ - tab_down
51
+ %p
52
+ %p
53
+ - tab_up
54
+ foo
55
+ %q{:a => 1 + 1}>
56
+ Foo
57
+ bar
58
+ - tab_down
59
+ %p
60
+ %p
61
+ - tab_up
62
+ foo
63
+ %q> Foo
64
+ bar
65
+ - tab_down
66
+ %p
67
+ %p
68
+ - tab_up
69
+ foo
70
+ %q{:a => 1 + 1}> Foo
71
+ bar
72
+ - tab_down
73
+ %p
74
+ %p
75
+ - tab_up
76
+ foo
77
+ %q>
78
+ = "Foo"
79
+ bar
80
+ - tab_down
81
+ %p
82
+ %p
83
+ - tab_up
84
+ foo
85
+ %q{:a => 1 + 1}>
86
+ = "Foo"
87
+ bar
88
+ - tab_down
89
+ %p
90
+ %p
91
+ - tab_up
92
+ foo
93
+ %q>= "Foo"
94
+ bar
95
+ - tab_down
96
+ %p
97
+ %p
98
+ - tab_up
99
+ foo
100
+ %q{:a => 1 + 1}>= "Foo"
101
+ bar
102
+ - tab_down
103
+ %p
104
+ %p
105
+ - tab_up
106
+ foo
107
+ %q>
108
+ = "Foo\nBar"
109
+ bar
110
+ - tab_down
111
+ %p
112
+ %p
113
+ - tab_up
114
+ foo
115
+ %q{:a => 1 + 1}>
116
+ = "Foo\nBar"
117
+ bar
118
+ - tab_down
119
+ %p
120
+ %p
121
+ - tab_up
122
+ foo
123
+ %q>= "Foo\nBar"
124
+ bar
125
+ - tab_down
126
+ %p
127
+ %p
128
+ - tab_up
129
+ foo
130
+ %q{:a => 1 + 1}>= "Foo\nBar"
131
+ bar
132
+ - tab_down
133
+ %p
134
+ %p
135
+ %q>
136
+ %p
137
+ %p
138
+ %q>/
139
+ %p
140
+ %p
141
+ %q{:a => 1 + 1}>
142
+ %p
143
+ %p
144
+ %q{:a => 1 + 1}>/
@@ -0,0 +1,17 @@
1
+ !!!
2
+ %html
3
+ %head
4
+ %title Stop. haml time
5
+ #content
6
+ %h1 This is a title!
7
+ %p Lorem ipsum dolor sit amet, consectetur adipisicing elit
8
+ %p{:class => 'foo'} Cigarettes!
9
+ %h2 Man alive!
10
+ %ul.things
11
+ %li Slippers
12
+ %li Shoes
13
+ %li Bathrobe
14
+ %li Coffee
15
+ %pre
16
+ This is some text that's in a pre block!
17
+ Let's see what happens when it's rendered! What about now, since we're on a new line?
@@ -0,0 +1,3 @@
1
+ %h1 Partial layout used with for block:
2
+ - render :layout => 'layout_for_partial.haml' do
3
+ %p Some content within a layout
@@ -0,0 +1 @@
1
+ = render :file => "#{name}.haml"
@@ -0,0 +1,12 @@
1
+ - @foo = 'value one'
2
+ %p
3
+ @foo =
4
+ = @foo
5
+ - @foo = 'value two'
6
+ %p
7
+ @foo =
8
+ = @foo
9
+ = test_partial "partial"
10
+ %p
11
+ @foo =
12
+ = @foo
@@ -0,0 +1,2 @@
1
+ = render :layout => 'layout' do
2
+ During
@@ -0,0 +1,40 @@
1
+ %div
2
+ %h1 I can count!
3
+ - (1..20).each do |i|
4
+ = i
5
+ %h1 I know my ABCs!
6
+ %ul
7
+ - ('a'..'z').each do |i|
8
+ %li= i
9
+ %h1 I can catch errors!
10
+ - begin
11
+ - String.silly
12
+ - rescue NameError => e
13
+ = "Oh no! \"#{e}\" happened!"
14
+ %p
15
+ "false" is:
16
+ - if false
17
+ = "true"
18
+ - else
19
+ = "false"
20
+ - if true
21
+ - 5.times do |i|
22
+ - if i % 2 == 1
23
+ Odd!
24
+ - else
25
+ Even!
26
+ - else
27
+ = "This can't happen!"
28
+ - 13 |
29
+ .foo
30
+ %strong foobar
31
+ - 5.times |
32
+ do |
33
+ |a| |
34
+ %strong= a
35
+ .test
36
+ - "foo |
37
+ bar |
38
+ baz" |
39
+
40
+ %p boom
@@ -0,0 +1,42 @@
1
+ !!!
2
+ %html{html_attrs}
3
+ %head
4
+ %title Hampton Catlin Is Totally Awesome
5
+ %meta{"http-equiv" => "Content-Type", :content => "text/html; charset=utf-8"}
6
+ %body
7
+ / You're In my house now!
8
+ .header
9
+ Yes, ladies and gentileman. He is just that egotistical.
10
+ Fantastic! This should be multi-line output
11
+ The question is if this would translate! Ahah!
12
+ = 1 + 9 + 8 + 2 #numbers should work and this should be ignored
13
+ #body= " Quotes should be loved! Just like people!"
14
+ - 120.times do |number|
15
+ - number
16
+ Wow.|
17
+ %p
18
+ = "Holy cow " + |
19
+ "multiline " + |
20
+ "tags! " + |
21
+ "A pipe (|) even!" |
22
+ = [1, 2, 3].collect { |n| "PipesIgnored|" }.join
23
+ = [1, 2, 3].collect { |n| |
24
+ n.to_s |
25
+ }.join("|") |
26
+ %div.silent
27
+ - foo = String.new
28
+ - foo << "this"
29
+ - foo << " shouldn't"
30
+ - foo << " evaluate"
31
+ = foo + " but now it should!"
32
+ -# Woah crap a comment!
33
+
34
+ -# That was a line that shouldn't close everything.
35
+ %ul.really.cool
36
+ - ('a'..'f').each do |a|
37
+ %li= a
38
+ #combo.of_divs_with_underscore= @should_eval = "with this text"
39
+ = "foo".each_line do |line|
40
+ - nil
41
+ .footer
42
+ %strong.shout= "This is a really long ruby quote. It should be loved and wrapped because its more than 50 characters. This value may change in the future and this test may look stupid. \nSo, I'm just making it *really* long. God, I hope this works"
@@ -0,0 +1 @@
1
+ standard.haml
@@ -0,0 +1,21 @@
1
+ %div.tags
2
+ %foo 1
3
+ %FOO 2
4
+ %fooBAR 3
5
+ %fooBar 4
6
+ %foo_bar 5
7
+ %foo-bar 6
8
+ %foo:bar 7
9
+ %foo.bar 8
10
+ %fooBAr_baz:boom_bar 9
11
+ %foo13 10
12
+ %foo2u 11
13
+ %div.classes
14
+ %p.foo.bar#baz#boom
15
+ .fooBar a
16
+ .foo-bar b
17
+ .foo_bar c
18
+ .FOOBAR d
19
+ .foo16 e
20
+ .123 f
21
+ .foo2u g
@@ -0,0 +1,4 @@
1
+ !!!
2
+ %html
3
+ %head
4
+ %body
@@ -0,0 +1,87 @@
1
+ #whitespace_test
2
+ = test_partial "text_area", :value => "Oneline"
3
+ = test_partial "text_area", :value => "Two\nlines"
4
+ ~ test_partial "text_area", :value => "Oneline"
5
+ ~ test_partial "text_area", :value => "Two\nlines"
6
+ #flattened~ test_partial "text_area", :value => "Two\nlines"
7
+ .hithere
8
+ ~ "Foo bar"
9
+ ~ "<pre>foo bar</pre>"
10
+ ~ "<pre>foo\nbar</pre>"
11
+ %p~ "<pre>foo\nbar</pre>"
12
+ %p~ "foo\nbar"
13
+ .foo
14
+ ~ 13
15
+ ~ "<textarea>\na\n</textarea>".each_line do |l|
16
+ - haml_concat l.strip
17
+ #whitespace_test
18
+ = test_partial "text_area", :value => "Oneline"
19
+ = test_partial "text_area", :value => "Two\nlines"
20
+ = find_and_preserve test_partial("text_area", :value => "Oneline")
21
+ = find_and_preserve test_partial("text_area", :value => "Two\nlines")
22
+ #flattened= find_and_preserve test_partial("text_area", :value => "Two\nlines")
23
+ .hithere
24
+ = find_and_preserve("Foo bar")
25
+ = find_and_preserve("<pre>foo bar</pre>")
26
+ = find_and_preserve("<pre>foo\nbar</pre>")
27
+ %p= find_and_preserve("<pre>foo\nbar</pre>")
28
+ %p= find_and_preserve("foo\nbar")
29
+ %pre
30
+ :preserve
31
+ ___
32
+ ,o88888
33
+ ,o8888888'
34
+ ,:o:o:oooo. ,8O88Pd8888"
35
+ ,.::.::o:ooooOoOoO. ,oO8O8Pd888'"
36
+ ,.:.::o:ooOoOoOO8O8OOo.8OOPd8O8O"
37
+ , ..:.::o:ooOoOOOO8OOOOo.FdO8O8"
38
+ , ..:.::o:ooOoOO8O888O8O,COCOO"
39
+ , . ..:.::o:ooOoOOOO8OOOOCOCO"
40
+ . ..:.::o:ooOoOoOO8O8OCCCC"o
41
+ . ..:.::o:ooooOoCoCCC"o:o
42
+ . ..:.::o:o:,cooooCo"oo:o:
43
+ ` . . ..:.:cocoooo"'o:o:::'
44
+ .` . ..::ccccoc"'o:o:o:::'
45
+ :.:. ,c:cccc"':.:.:.:.:.'
46
+ ..:.:"'`::::c:"'..:.:.:.:.:.' http://www.chris.com/ASCII/
47
+ ...:.'.:.::::"' . . . . .'
48
+ .. . ....:."' ` . . . ''
49
+ . . . ...."'
50
+ .. . ."' -hrr-
51
+ .
52
+
53
+
54
+ It's a planet!
55
+ %strong This shouldn't be bold!
56
+ %strong This should!
57
+ %textarea
58
+ :preserve
59
+ ___ ___ ___ ___
60
+ /\__\ /\ \ /\__\ /\__\
61
+ /:/ / /::\ \ /::| | /:/ /
62
+ /:/__/ /:/\:\ \ /:|:| | /:/ /
63
+ /::\ \ ___ /::\~\:\ \ /:/|:|__|__ /:/ /
64
+ /:/\:\ /\__\ /:/\:\ \:\__\ /:/ |::::\__\ /:/__/
65
+ \/__\:\/:/ / \/__\:\/:/ / \/__/~~/:/ / \:\ \
66
+ \::/ / \::/ / /:/ / \:\ \
67
+ /:/ / /:/ / /:/ / \:\ \
68
+ /:/ / /:/ / /:/ / \:\__\
69
+ \/__/ \/__/ \/__/ \/__/
70
+
71
+ Many
72
+ thanks
73
+ to
74
+ http://www.network-science.de/ascii/
75
+ %strong indeed!
76
+ .foo
77
+ = find_and_preserve(13)
78
+ %pre
79
+ :preserve
80
+ __ ______ __ ______
81
+ .----.| |--.|__ |.----.| |--..--------.| __ |
82
+ | __|| ||__ || __|| < | || __ |
83
+ |____||__|__||______||____||__|__||__|__|__||______|
84
+ %pre
85
+ :preserve
86
+ foo
87
+ bar
@@ -0,0 +1,12 @@
1
+ # allows testing with edge Rails by creating a test/rails symlink
2
+ linked_rails = File.dirname(__FILE__) + '/rails'
3
+
4
+ if File.exists?(linked_rails) && !$:.include?(linked_rails + '/activesupport/lib')
5
+ puts "[ using linked Rails ]"
6
+ $:.unshift linked_rails + '/activesupport/lib'
7
+ $:.unshift linked_rails + '/actionpack/lib'
8
+ else
9
+ require 'rubygems'
10
+ end
11
+ require 'action_controller'
12
+ require 'action_view'
@@ -0,0 +1,193 @@
1
+ require 'test/unit'
2
+ require File.dirname(__FILE__) + '/../test_helper'
3
+ require 'sass/css'
4
+
5
+ class CSS2SassTest < Test::Unit::TestCase
6
+ def test_basic
7
+ css = <<CSS
8
+ h1 {
9
+ color: red;
10
+ }
11
+ CSS
12
+ assert_equal(<<SASS, css2sass(css))
13
+ h1
14
+ :color red
15
+ SASS
16
+ assert_equal(<<SASS, css2sass(css, :alternate => true))
17
+ h1
18
+ color: red
19
+ SASS
20
+ end
21
+
22
+ def test_nesting
23
+ assert_equal(<<SASS, css2sass(<<CSS))
24
+ li
25
+ :display none
26
+
27
+ a
28
+ :text-decoration none
29
+
30
+ span
31
+ :color yellow
32
+
33
+ &:hover
34
+ :text-decoration underline
35
+ SASS
36
+ li {
37
+ display: none;
38
+ }
39
+
40
+ li a {
41
+ text-decoration: none;
42
+ }
43
+
44
+ li a span {
45
+ color: yellow;
46
+ }
47
+
48
+ li a:hover {
49
+ text-decoration: underline;
50
+ }
51
+ CSS
52
+ end
53
+
54
+ def test_comments_multiline
55
+ css = <<CSS
56
+ /* comment */
57
+ elephant.rawr {
58
+ rampages: excessively;
59
+ }
60
+
61
+ /* actual multiline
62
+ comment */
63
+ span.turkey {
64
+ isdinner: true;
65
+ }
66
+
67
+ .turducken {
68
+ /* Sounds funny
69
+ doesn't it */
70
+ chimera: not_really;
71
+ }
72
+
73
+ #overhere {
74
+ bored: sorta; /* it's for a good
75
+ cause */
76
+ better_than: thread_pools;
77
+ }
78
+
79
+ #one_more {
80
+ finally: srsly;
81
+ } /* just a line here */
82
+ CSS
83
+ sass = <<SASS
84
+ elephant.rawr
85
+ :rampages excessively
86
+
87
+
88
+ span.turkey
89
+ :isdinner true
90
+
91
+
92
+ .turducken
93
+ :chimera not_really
94
+
95
+
96
+ #overhere
97
+ :bored sorta
98
+ :better_than thread_pools
99
+
100
+
101
+ #one_more
102
+ :finally srsly
103
+ SASS
104
+ assert_equal(css2sass(css), sass)
105
+ end
106
+
107
+ def test_fold_commas
108
+ assert_equal(<<SASS, css2sass(<<CSS))
109
+ li
110
+ .one, .two
111
+ :color red
112
+ SASS
113
+ li .one {
114
+ color: red;
115
+ }
116
+ li .two {
117
+ color: red;
118
+ }
119
+ CSS
120
+
121
+ assert_equal(<<SASS, css2sass(<<CSS))
122
+ .one
123
+ :color green
124
+
125
+
126
+ .two
127
+ :color green
128
+ :color red
129
+
130
+
131
+ .three
132
+ :color red
133
+ SASS
134
+ .one, .two {
135
+ color: green;
136
+ }
137
+
138
+ .two, .three {
139
+ color: red;
140
+ }
141
+ CSS
142
+ end
143
+
144
+ def test_bad_formatting
145
+ assert_equal(<<SASS, css2sass(<<CSS))
146
+ hello
147
+ :parent true
148
+
149
+ there
150
+ :parent false
151
+
152
+ who
153
+ :hoo false
154
+
155
+ why
156
+ :y true
157
+
158
+ when
159
+ :wen nao
160
+
161
+
162
+ down_here
163
+ :yeah true
164
+ SASS
165
+ hello {
166
+ parent: true;
167
+ }
168
+
169
+ hello there {
170
+ parent: false;
171
+ }
172
+ hello who {
173
+ hoo: false;
174
+ }
175
+ hello why {
176
+ y: true;
177
+ }
178
+ hello when {
179
+ wen: nao;
180
+ }
181
+
182
+
183
+
184
+ down_here { yeah: true; }
185
+ CSS
186
+ end
187
+
188
+ private
189
+
190
+ def css2sass(string, opts={})
191
+ Sass::CSS.new(string, opts).render
192
+ end
193
+ end