haml 3.0.25 → 3.1.0.alpha.2
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of haml might be problematic. Click here for more details.
- data/.yardopts +1 -1
- data/CONTRIBUTING +0 -1
- data/EDGE_GEM_VERSION +1 -0
- data/MIT-LICENSE +1 -1
- data/README.md +10 -175
- data/Rakefile +56 -84
- data/VERSION +1 -1
- data/VERSION_NAME +1 -1
- data/init.rb +1 -1
- data/lib/haml.rb +14 -12
- data/lib/haml/engine.rb +1 -1
- data/lib/haml/exec.rb +19 -316
- data/lib/haml/helpers/action_view_extensions.rb +1 -1
- data/lib/haml/html.rb +69 -76
- data/lib/haml/precompiler.rb +34 -41
- data/lib/haml/railtie.rb +4 -6
- data/lib/haml/template/plugin.rb +6 -16
- data/lib/haml/util.rb +91 -107
- data/lib/haml/version.rb +7 -0
- data/test/benchmark.rb +2 -9
- data/test/haml/engine_test.rb +195 -92
- data/test/haml/html2haml/erb_tests.rb +0 -14
- data/test/haml/util_test.rb +32 -0
- data/test/test_helper.rb +0 -39
- metadata +96 -324
- data/bin/css2sass +0 -13
- data/bin/sass +0 -8
- data/bin/sass-convert +0 -7
- data/extra/haml-mode.el +0 -753
- data/extra/sass-mode.el +0 -207
- data/lib/haml/util/subset_map.rb +0 -101
- data/lib/sass.rb +0 -29
- data/lib/sass/callbacks.rb +0 -52
- data/lib/sass/css.rb +0 -294
- data/lib/sass/engine.rb +0 -720
- data/lib/sass/environment.rb +0 -143
- data/lib/sass/error.rb +0 -198
- data/lib/sass/files.rb +0 -160
- data/lib/sass/less.rb +0 -382
- data/lib/sass/plugin.rb +0 -279
- data/lib/sass/plugin/configuration.rb +0 -221
- data/lib/sass/plugin/generic.rb +0 -15
- data/lib/sass/plugin/merb.rb +0 -37
- data/lib/sass/plugin/rack.rb +0 -47
- data/lib/sass/plugin/rails.rb +0 -32
- data/lib/sass/plugin/staleness_checker.rb +0 -123
- data/lib/sass/repl.rb +0 -58
- data/lib/sass/script.rb +0 -63
- data/lib/sass/script/bool.rb +0 -18
- data/lib/sass/script/color.rb +0 -491
- data/lib/sass/script/css_lexer.rb +0 -29
- data/lib/sass/script/css_parser.rb +0 -31
- data/lib/sass/script/funcall.rb +0 -77
- data/lib/sass/script/functions.rb +0 -861
- data/lib/sass/script/interpolation.rb +0 -70
- data/lib/sass/script/lexer.rb +0 -337
- data/lib/sass/script/literal.rb +0 -236
- data/lib/sass/script/node.rb +0 -112
- data/lib/sass/script/number.rb +0 -423
- data/lib/sass/script/operation.rb +0 -95
- data/lib/sass/script/parser.rb +0 -401
- data/lib/sass/script/string.rb +0 -67
- data/lib/sass/script/string_interpolation.rb +0 -93
- data/lib/sass/script/unary_operation.rb +0 -57
- data/lib/sass/script/variable.rb +0 -48
- data/lib/sass/scss.rb +0 -17
- data/lib/sass/scss/css_parser.rb +0 -46
- data/lib/sass/scss/parser.rb +0 -855
- data/lib/sass/scss/rx.rb +0 -126
- data/lib/sass/scss/sass_parser.rb +0 -11
- data/lib/sass/scss/script_lexer.rb +0 -15
- data/lib/sass/scss/script_parser.rb +0 -25
- data/lib/sass/scss/static_parser.rb +0 -40
- data/lib/sass/selector.rb +0 -361
- data/lib/sass/selector/abstract_sequence.rb +0 -62
- data/lib/sass/selector/comma_sequence.rb +0 -82
- data/lib/sass/selector/sequence.rb +0 -237
- data/lib/sass/selector/simple.rb +0 -113
- data/lib/sass/selector/simple_sequence.rb +0 -136
- data/lib/sass/tree/charset_node.rb +0 -37
- data/lib/sass/tree/comment_node.rb +0 -128
- data/lib/sass/tree/debug_node.rb +0 -36
- data/lib/sass/tree/directive_node.rb +0 -75
- data/lib/sass/tree/extend_node.rb +0 -65
- data/lib/sass/tree/for_node.rb +0 -55
- data/lib/sass/tree/if_node.rb +0 -69
- data/lib/sass/tree/import_node.rb +0 -102
- data/lib/sass/tree/mixin_def_node.rb +0 -48
- data/lib/sass/tree/mixin_node.rb +0 -111
- data/lib/sass/tree/node.rb +0 -464
- data/lib/sass/tree/prop_node.rb +0 -220
- data/lib/sass/tree/root_node.rb +0 -163
- data/lib/sass/tree/rule_node.rb +0 -261
- data/lib/sass/tree/variable_node.rb +0 -39
- data/lib/sass/tree/warn_node.rb +0 -42
- data/lib/sass/tree/while_node.rb +0 -36
- data/test/haml/util/subset_map_test.rb +0 -91
- data/test/sass/callbacks_test.rb +0 -61
- data/test/sass/conversion_test.rb +0 -1218
- data/test/sass/css2sass_test.rb +0 -364
- data/test/sass/data/hsl-rgb.txt +0 -319
- data/test/sass/engine_test.rb +0 -2267
- data/test/sass/extend_test.rb +0 -1348
- data/test/sass/functions_test.rb +0 -556
- data/test/sass/less_conversion_test.rb +0 -653
- data/test/sass/more_results/more1.css +0 -9
- data/test/sass/more_results/more1_with_line_comments.css +0 -26
- data/test/sass/more_results/more_import.css +0 -29
- data/test/sass/more_templates/_more_partial.sass +0 -2
- data/test/sass/more_templates/more1.sass +0 -23
- data/test/sass/more_templates/more_import.sass +0 -11
- data/test/sass/plugin_test.rb +0 -433
- data/test/sass/results/alt.css +0 -4
- data/test/sass/results/basic.css +0 -9
- data/test/sass/results/compact.css +0 -5
- data/test/sass/results/complex.css +0 -86
- data/test/sass/results/compressed.css +0 -1
- data/test/sass/results/expanded.css +0 -19
- data/test/sass/results/import.css +0 -31
- data/test/sass/results/import_charset.css +0 -4
- data/test/sass/results/import_charset_1_8.css +0 -4
- data/test/sass/results/import_charset_ibm866.css +0 -4
- data/test/sass/results/line_numbers.css +0 -49
- data/test/sass/results/mixins.css +0 -95
- data/test/sass/results/multiline.css +0 -24
- data/test/sass/results/nested.css +0 -22
- data/test/sass/results/options.css +0 -1
- data/test/sass/results/parent_ref.css +0 -13
- data/test/sass/results/script.css +0 -16
- data/test/sass/results/scss_import.css +0 -31
- data/test/sass/results/scss_importee.css +0 -2
- data/test/sass/results/subdir/nested_subdir/nested_subdir.css +0 -1
- data/test/sass/results/subdir/subdir.css +0 -3
- data/test/sass/results/units.css +0 -11
- data/test/sass/results/warn.css +0 -0
- data/test/sass/results/warn_imported.css +0 -0
- data/test/sass/script_conversion_test.rb +0 -314
- data/test/sass/script_test.rb +0 -470
- data/test/sass/scss/css_test.rb +0 -916
- data/test/sass/scss/rx_test.rb +0 -156
- data/test/sass/scss/scss_test.rb +0 -1122
- data/test/sass/scss/test_helper.rb +0 -37
- data/test/sass/templates/_imported_charset_ibm866.sass +0 -4
- data/test/sass/templates/_imported_charset_utf8.sass +0 -4
- data/test/sass/templates/_partial.sass +0 -2
- data/test/sass/templates/alt.sass +0 -16
- data/test/sass/templates/basic.sass +0 -23
- data/test/sass/templates/bork1.sass +0 -2
- data/test/sass/templates/bork2.sass +0 -2
- data/test/sass/templates/bork3.sass +0 -2
- data/test/sass/templates/bork4.sass +0 -2
- data/test/sass/templates/compact.sass +0 -17
- data/test/sass/templates/complex.sass +0 -305
- data/test/sass/templates/compressed.sass +0 -15
- data/test/sass/templates/expanded.sass +0 -17
- data/test/sass/templates/import.sass +0 -12
- data/test/sass/templates/import_charset.sass +0 -7
- data/test/sass/templates/import_charset_1_8.sass +0 -4
- data/test/sass/templates/import_charset_ibm866.sass +0 -9
- data/test/sass/templates/importee.less +0 -2
- data/test/sass/templates/importee.sass +0 -19
- data/test/sass/templates/line_numbers.sass +0 -13
- data/test/sass/templates/mixin_bork.sass +0 -5
- data/test/sass/templates/mixins.sass +0 -76
- data/test/sass/templates/multiline.sass +0 -20
- data/test/sass/templates/nested.sass +0 -25
- data/test/sass/templates/nested_bork1.sass +0 -2
- data/test/sass/templates/nested_bork2.sass +0 -2
- data/test/sass/templates/nested_bork3.sass +0 -2
- data/test/sass/templates/nested_bork4.sass +0 -2
- data/test/sass/templates/nested_mixin_bork.sass +0 -6
- data/test/sass/templates/options.sass +0 -2
- data/test/sass/templates/parent_ref.sass +0 -25
- data/test/sass/templates/script.sass +0 -101
- data/test/sass/templates/scss_import.scss +0 -11
- data/test/sass/templates/scss_importee.scss +0 -1
- data/test/sass/templates/subdir/nested_subdir/_nested_partial.sass +0 -2
- data/test/sass/templates/subdir/nested_subdir/nested_subdir.sass +0 -3
- data/test/sass/templates/subdir/subdir.sass +0 -6
- data/test/sass/templates/units.sass +0 -11
- data/test/sass/templates/warn.sass +0 -3
- data/test/sass/templates/warn_imported.sass +0 -4
- data/vendor/fssm/LICENSE +0 -20
- data/vendor/fssm/README.markdown +0 -55
- data/vendor/fssm/Rakefile +0 -59
- data/vendor/fssm/VERSION.yml +0 -5
- data/vendor/fssm/example.rb +0 -9
- data/vendor/fssm/fssm.gemspec +0 -77
- data/vendor/fssm/lib/fssm.rb +0 -33
- 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/rubycocoa/fsevents.rb +0 -131
- data/vendor/fssm/lib/fssm/monitor.rb +0 -26
- data/vendor/fssm/lib/fssm/path.rb +0 -91
- data/vendor/fssm/lib/fssm/pathname.rb +0 -502
- data/vendor/fssm/lib/fssm/state/directory.rb +0 -57
- data/vendor/fssm/lib/fssm/state/file.rb +0 -24
- data/vendor/fssm/lib/fssm/support.rb +0 -63
- data/vendor/fssm/lib/fssm/tree.rb +0 -176
- 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.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/path_spec.rb +0 -75
- 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
@@ -1,9 +0,0 @@
|
|
1
|
-
body { font: Arial; background: blue; }
|
2
|
-
|
3
|
-
#page { width: 700px; height: 100; }
|
4
|
-
#page #header { height: 300px; }
|
5
|
-
#page #header h1 { font-size: 50px; color: blue; }
|
6
|
-
|
7
|
-
#content.user.show #container.top #column.left { width: 100px; }
|
8
|
-
#content.user.show #container.top #column.right { width: 600px; }
|
9
|
-
#content.user.show #container.bottom { background: brown; }
|
@@ -1,26 +0,0 @@
|
|
1
|
-
/* line 3, ../more_templates/more1.sass */
|
2
|
-
body {
|
3
|
-
font: Arial;
|
4
|
-
background: blue; }
|
5
|
-
|
6
|
-
/* line 7, ../more_templates/more1.sass */
|
7
|
-
#page {
|
8
|
-
width: 700px;
|
9
|
-
height: 100; }
|
10
|
-
/* line 10, ../more_templates/more1.sass */
|
11
|
-
#page #header {
|
12
|
-
height: 300px; }
|
13
|
-
/* line 12, ../more_templates/more1.sass */
|
14
|
-
#page #header h1 {
|
15
|
-
font-size: 50px;
|
16
|
-
color: blue; }
|
17
|
-
|
18
|
-
/* line 18, ../more_templates/more1.sass */
|
19
|
-
#content.user.show #container.top #column.left {
|
20
|
-
width: 100px; }
|
21
|
-
/* line 20, ../more_templates/more1.sass */
|
22
|
-
#content.user.show #container.top #column.right {
|
23
|
-
width: 600px; }
|
24
|
-
/* line 22, ../more_templates/more1.sass */
|
25
|
-
#content.user.show #container.bottom {
|
26
|
-
background: brown; }
|
@@ -1,29 +0,0 @@
|
|
1
|
-
imported { otherconst: hello; myconst: goodbye; pre-mixin: here; }
|
2
|
-
|
3
|
-
body { font: Arial; background: blue; }
|
4
|
-
|
5
|
-
#page { width: 700px; height: 100; }
|
6
|
-
#page #header { height: 300px; }
|
7
|
-
#page #header h1 { font-size: 50px; color: blue; }
|
8
|
-
|
9
|
-
#content.user.show #container.top #column.left { width: 100px; }
|
10
|
-
#content.user.show #container.top #column.right { width: 600px; }
|
11
|
-
#content.user.show #container.bottom { background: brown; }
|
12
|
-
|
13
|
-
midrule { inthe: middle; }
|
14
|
-
|
15
|
-
body { font: Arial; background: blue; }
|
16
|
-
|
17
|
-
#page { width: 700px; height: 100; }
|
18
|
-
#page #header { height: 300px; }
|
19
|
-
#page #header h1 { font-size: 50px; color: blue; }
|
20
|
-
|
21
|
-
#content.user.show #container.top #column.left { width: 100px; }
|
22
|
-
#content.user.show #container.top #column.right { width: 600px; }
|
23
|
-
#content.user.show #container.bottom { background: brown; }
|
24
|
-
|
25
|
-
@import url(basic.css);
|
26
|
-
@import url(../results/complex.css);
|
27
|
-
#foo { background-color: #bbaaff; }
|
28
|
-
|
29
|
-
nonimported { myconst: hello; otherconst: goodbye; post-mixin: here; }
|
@@ -1,23 +0,0 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
body
|
4
|
-
:font Arial
|
5
|
-
:background blue
|
6
|
-
|
7
|
-
#page
|
8
|
-
:width 700px
|
9
|
-
:height 100
|
10
|
-
#header
|
11
|
-
:height 300px
|
12
|
-
h1
|
13
|
-
:font-size 50px
|
14
|
-
:color blue
|
15
|
-
|
16
|
-
#content.user.show
|
17
|
-
#container.top
|
18
|
-
#column.left
|
19
|
-
:width 100px
|
20
|
-
#column.right
|
21
|
-
:width 600px
|
22
|
-
#container.bottom
|
23
|
-
:background brown
|
data/test/sass/plugin_test.rb
DELETED
@@ -1,433 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
require File.dirname(__FILE__) + '/../test_helper'
|
3
|
-
require 'sass/plugin'
|
4
|
-
require 'fileutils'
|
5
|
-
|
6
|
-
class SassPluginTest < Test::Unit::TestCase
|
7
|
-
@@templates = %w{
|
8
|
-
complex script parent_ref import scss_import alt
|
9
|
-
subdir/subdir subdir/nested_subdir/nested_subdir
|
10
|
-
options
|
11
|
-
}
|
12
|
-
@@templates += %w[import_charset import_charset_ibm866] unless Haml::Util.ruby1_8?
|
13
|
-
@@templates << 'import_charset_1_8' if Haml::Util.ruby1_8?
|
14
|
-
|
15
|
-
def setup
|
16
|
-
FileUtils.mkdir tempfile_loc
|
17
|
-
FileUtils.mkdir tempfile_loc(nil,"more_")
|
18
|
-
set_plugin_opts
|
19
|
-
update_all_stylesheets!
|
20
|
-
reset_mtimes
|
21
|
-
end
|
22
|
-
|
23
|
-
def teardown
|
24
|
-
clean_up_sassc
|
25
|
-
clear_callbacks
|
26
|
-
FileUtils.rm_r tempfile_loc
|
27
|
-
FileUtils.rm_r tempfile_loc(nil,"more_")
|
28
|
-
end
|
29
|
-
|
30
|
-
@@templates.each do |name|
|
31
|
-
define_method("test_template_renders_correctly (#{name})") do
|
32
|
-
assert_renders_correctly(name)
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
def test_no_update
|
37
|
-
File.delete(tempfile_loc('basic'))
|
38
|
-
assert_needs_update 'basic'
|
39
|
-
update_all_stylesheets!
|
40
|
-
assert_stylesheet_updated 'basic'
|
41
|
-
end
|
42
|
-
|
43
|
-
def test_update_needed_when_modified
|
44
|
-
touch 'basic'
|
45
|
-
assert_needs_update 'basic'
|
46
|
-
update_all_stylesheets!
|
47
|
-
assert_stylesheet_updated 'basic'
|
48
|
-
end
|
49
|
-
|
50
|
-
def test_update_needed_when_dependency_modified
|
51
|
-
touch 'basic'
|
52
|
-
assert_needs_update 'import'
|
53
|
-
update_all_stylesheets!
|
54
|
-
assert_stylesheet_updated 'basic'
|
55
|
-
assert_stylesheet_updated 'import'
|
56
|
-
end
|
57
|
-
|
58
|
-
def test_update_needed_when_scss_dependency_modified
|
59
|
-
touch 'scss_importee'
|
60
|
-
assert_needs_update 'import'
|
61
|
-
update_all_stylesheets!
|
62
|
-
assert_stylesheet_updated 'scss_importee'
|
63
|
-
assert_stylesheet_updated 'import'
|
64
|
-
end
|
65
|
-
|
66
|
-
def test_scss_update_needed_when_dependency_modified
|
67
|
-
touch 'basic'
|
68
|
-
assert_needs_update 'scss_import'
|
69
|
-
update_all_stylesheets!
|
70
|
-
assert_stylesheet_updated 'basic'
|
71
|
-
assert_stylesheet_updated 'scss_import'
|
72
|
-
end
|
73
|
-
|
74
|
-
def test_full_exception_handling
|
75
|
-
File.delete(tempfile_loc('bork1'))
|
76
|
-
update_all_stylesheets!
|
77
|
-
File.open(tempfile_loc('bork1')) do |file|
|
78
|
-
assert_equal(<<CSS.strip, file.read.split("\n")[0...6].join("\n"))
|
79
|
-
/*
|
80
|
-
Syntax error: Undefined variable: "$bork".
|
81
|
-
on line 2 of #{template_loc('bork1')}
|
82
|
-
|
83
|
-
1: bork
|
84
|
-
2: :bork $bork
|
85
|
-
CSS
|
86
|
-
end
|
87
|
-
File.delete(tempfile_loc('bork1'))
|
88
|
-
end
|
89
|
-
|
90
|
-
def test_nonfull_exception_handling
|
91
|
-
old_full_exception = Sass::Plugin.options[:full_exception]
|
92
|
-
Sass::Plugin.options[:full_exception] = false
|
93
|
-
|
94
|
-
File.delete(tempfile_loc('bork1'))
|
95
|
-
assert_raise(Sass::SyntaxError) {update_all_stylesheets!}
|
96
|
-
ensure
|
97
|
-
Sass::Plugin.options[:full_exception] = old_full_exception
|
98
|
-
end
|
99
|
-
|
100
|
-
def test_two_template_directories
|
101
|
-
set_plugin_opts :template_location => {
|
102
|
-
template_loc => tempfile_loc,
|
103
|
-
template_loc(nil,'more_') => tempfile_loc(nil,'more_')
|
104
|
-
}
|
105
|
-
update_all_stylesheets!
|
106
|
-
['more1', 'more_import'].each { |name| assert_renders_correctly(name, :prefix => 'more_') }
|
107
|
-
end
|
108
|
-
|
109
|
-
def test_two_template_directories_with_line_annotations
|
110
|
-
set_plugin_opts :line_comments => true,
|
111
|
-
:style => :nested,
|
112
|
-
:template_location => {
|
113
|
-
template_loc => tempfile_loc,
|
114
|
-
template_loc(nil,'more_') => tempfile_loc(nil,'more_')
|
115
|
-
}
|
116
|
-
update_all_stylesheets!
|
117
|
-
assert_renders_correctly('more1_with_line_comments', 'more1', :prefix => 'more_')
|
118
|
-
end
|
119
|
-
|
120
|
-
def test_doesnt_render_partials
|
121
|
-
assert !File.exists?(tempfile_loc('_partial'))
|
122
|
-
end
|
123
|
-
|
124
|
-
def test_template_location_array
|
125
|
-
assert_equal [[template_loc, tempfile_loc]], Sass::Plugin.template_location_array
|
126
|
-
end
|
127
|
-
|
128
|
-
def test_add_template_location
|
129
|
-
Sass::Plugin.add_template_location(template_loc(nil, "more_"), tempfile_loc(nil, "more_"))
|
130
|
-
assert_equal(
|
131
|
-
[[template_loc, tempfile_loc], [template_loc(nil, "more_"), tempfile_loc(nil, "more_")]],
|
132
|
-
Sass::Plugin.template_location_array)
|
133
|
-
|
134
|
-
touch 'more1', 'more_'
|
135
|
-
touch 'basic'
|
136
|
-
assert_needs_update "more1", "more_"
|
137
|
-
assert_needs_update "basic"
|
138
|
-
update_all_stylesheets!
|
139
|
-
assert_doesnt_need_update "more1", "more_"
|
140
|
-
assert_doesnt_need_update "basic"
|
141
|
-
end
|
142
|
-
|
143
|
-
def test_remove_template_location
|
144
|
-
Sass::Plugin.add_template_location(template_loc(nil, "more_"), tempfile_loc(nil, "more_"))
|
145
|
-
Sass::Plugin.remove_template_location(template_loc, tempfile_loc)
|
146
|
-
assert_equal(
|
147
|
-
[[template_loc(nil, "more_"), tempfile_loc(nil, "more_")]],
|
148
|
-
Sass::Plugin.template_location_array)
|
149
|
-
|
150
|
-
touch 'more1', 'more_'
|
151
|
-
touch 'basic'
|
152
|
-
assert_needs_update "more1", "more_"
|
153
|
-
assert_needs_update "basic"
|
154
|
-
update_all_stylesheets!
|
155
|
-
assert_doesnt_need_update "more1", "more_"
|
156
|
-
assert_needs_update "basic"
|
157
|
-
end
|
158
|
-
|
159
|
-
# Callbacks
|
160
|
-
|
161
|
-
def test_updating_stylesheets_callback
|
162
|
-
# Should run even when there's nothing to update
|
163
|
-
assert_callback :updating_stylesheets, []
|
164
|
-
end
|
165
|
-
|
166
|
-
def test_updating_stylesheets_callback_with_individual_files
|
167
|
-
files = [[template_loc("basic"), tempfile_loc("basic")]]
|
168
|
-
assert_callback(:updating_stylesheets, files) {Haml::Util.silence_haml_warnings{Sass::Plugin.update_stylesheets(files)}}
|
169
|
-
end
|
170
|
-
|
171
|
-
def test_updating_stylesheets_callback_with_never_update
|
172
|
-
Sass::Plugin.options[:never_update] = true
|
173
|
-
assert_no_callback :updating_stylesheets
|
174
|
-
end
|
175
|
-
|
176
|
-
def test_updating_stylesheet_callback_for_updated_template
|
177
|
-
Sass::Plugin.options[:always_update] = false
|
178
|
-
touch 'basic'
|
179
|
-
assert_no_callback :updating_stylesheet, template_loc("complex"), tempfile_loc("complex") do
|
180
|
-
assert_callbacks(
|
181
|
-
[:updating_stylesheet, template_loc("basic"), tempfile_loc("basic")],
|
182
|
-
[:updating_stylesheet, template_loc("import"), tempfile_loc("import")])
|
183
|
-
end
|
184
|
-
end
|
185
|
-
|
186
|
-
def test_updating_stylesheet_callback_for_fresh_template
|
187
|
-
Sass::Plugin.options[:always_update] = false
|
188
|
-
assert_no_callback :updating_stylesheet
|
189
|
-
end
|
190
|
-
|
191
|
-
def test_updating_stylesheet_callback_for_error_template
|
192
|
-
Sass::Plugin.options[:always_update] = false
|
193
|
-
touch 'bork1'
|
194
|
-
assert_no_callback :updating_stylesheet
|
195
|
-
end
|
196
|
-
|
197
|
-
def test_not_updating_stylesheet_callback_for_fresh_template
|
198
|
-
Sass::Plugin.options[:always_update] = false
|
199
|
-
assert_callback :not_updating_stylesheet, template_loc("basic"), tempfile_loc("basic")
|
200
|
-
end
|
201
|
-
|
202
|
-
def test_not_updating_stylesheet_callback_for_updated_template
|
203
|
-
Sass::Plugin.options[:always_update] = false
|
204
|
-
assert_callback :not_updating_stylesheet, template_loc("complex"), tempfile_loc("complex") do
|
205
|
-
assert_no_callbacks(
|
206
|
-
[:updating_stylesheet, template_loc("basic"), tempfile_loc("basic")],
|
207
|
-
[:updating_stylesheet, template_loc("import"), tempfile_loc("import")])
|
208
|
-
end
|
209
|
-
end
|
210
|
-
|
211
|
-
def test_not_updating_stylesheet_callback_with_never_update
|
212
|
-
Sass::Plugin.options[:never_update] = true
|
213
|
-
assert_no_callback :not_updating_stylesheet
|
214
|
-
end
|
215
|
-
|
216
|
-
def test_not_updating_stylesheet_callback_for_partial
|
217
|
-
Sass::Plugin.options[:always_update] = false
|
218
|
-
assert_no_callback :not_updating_stylesheet, template_loc("_partial"), tempfile_loc("_partial")
|
219
|
-
end
|
220
|
-
|
221
|
-
def test_not_updating_stylesheet_callback_for_error
|
222
|
-
Sass::Plugin.options[:always_update] = false
|
223
|
-
touch 'bork1'
|
224
|
-
assert_no_callback :not_updating_stylesheet, template_loc("bork1"), tempfile_loc("bork1")
|
225
|
-
end
|
226
|
-
|
227
|
-
def test_compilation_error_callback
|
228
|
-
Sass::Plugin.options[:always_update] = false
|
229
|
-
touch 'bork1'
|
230
|
-
assert_callback(:compilation_error,
|
231
|
-
lambda {|e| e.message == 'Undefined variable: "$bork".'},
|
232
|
-
template_loc("bork1"), tempfile_loc("bork1"))
|
233
|
-
end
|
234
|
-
|
235
|
-
def test_compilation_error_callback_for_file_access
|
236
|
-
Sass::Plugin.options[:always_update] = false
|
237
|
-
assert_callback(:compilation_error,
|
238
|
-
lambda {|e| e.is_a?(Errno::ENOENT)},
|
239
|
-
template_loc("nonexistent"), tempfile_loc("nonexistent")) do
|
240
|
-
Sass::Plugin.update_stylesheets([[template_loc("nonexistent"), tempfile_loc("nonexistent")]])
|
241
|
-
end
|
242
|
-
end
|
243
|
-
|
244
|
-
def test_creating_directory_callback
|
245
|
-
Sass::Plugin.options[:always_update] = false
|
246
|
-
dir = File.join(tempfile_loc, "subdir", "nested_subdir")
|
247
|
-
FileUtils.rm_r dir
|
248
|
-
assert_callback :creating_directory, dir
|
249
|
-
end
|
250
|
-
|
251
|
-
## Regression
|
252
|
-
|
253
|
-
def test_cached_dependencies_update
|
254
|
-
FileUtils.mv(template_loc("basic"), template_loc("basic", "more_"))
|
255
|
-
set_plugin_opts :load_paths => [result_loc, template_loc(nil, "more_")]
|
256
|
-
|
257
|
-
touch 'basic', 'more_'
|
258
|
-
assert_needs_update "import"
|
259
|
-
update_all_stylesheets!
|
260
|
-
assert_renders_correctly("import")
|
261
|
-
ensure
|
262
|
-
FileUtils.mv(template_loc("basic", "more_"), template_loc("basic"))
|
263
|
-
end
|
264
|
-
|
265
|
-
private
|
266
|
-
|
267
|
-
def assert_renders_correctly(*arguments)
|
268
|
-
options = arguments.last.is_a?(Hash) ? arguments.pop : {}
|
269
|
-
prefix = options[:prefix]
|
270
|
-
result_name = arguments.shift
|
271
|
-
tempfile_name = arguments.shift || result_name
|
272
|
-
|
273
|
-
expected_str = File.read(result_loc(result_name, prefix))
|
274
|
-
actual_str = File.read(tempfile_loc(tempfile_name, prefix))
|
275
|
-
unless Haml::Util.ruby1_8?
|
276
|
-
expected_str = expected_str.force_encoding('IBM866') if result_name == 'import_charset_ibm866'
|
277
|
-
actual_str = actual_str.force_encoding('IBM866') if tempfile_name == 'import_charset_ibm866'
|
278
|
-
end
|
279
|
-
expected_lines = expected_str.split("\n")
|
280
|
-
actual_lines = actual_str.split("\n")
|
281
|
-
|
282
|
-
if actual_lines.first == "/*" && expected_lines.first != "/*"
|
283
|
-
assert(false, actual_lines[0..Haml::Util.enum_with_index(actual_lines).find {|l, i| l == "*/"}.last].join("\n"))
|
284
|
-
end
|
285
|
-
|
286
|
-
expected_lines.zip(actual_lines).each_with_index do |pair, line|
|
287
|
-
message = "template: #{result_name}\nline: #{line + 1}"
|
288
|
-
assert_equal(pair.first, pair.last, message)
|
289
|
-
end
|
290
|
-
if expected_lines.size < actual_lines.size
|
291
|
-
assert(false, "#{actual_lines.size - expected_lines.size} Trailing lines found in #{tempfile_name}.css: #{actual_lines[expected_lines.size..-1].join('\n')}")
|
292
|
-
end
|
293
|
-
end
|
294
|
-
|
295
|
-
def assert_stylesheet_updated(name)
|
296
|
-
assert_doesnt_need_update name
|
297
|
-
|
298
|
-
# Make sure it isn't an exception
|
299
|
-
expected_lines = File.read(result_loc(name)).split("\n")
|
300
|
-
actual_lines = File.read(tempfile_loc(name)).split("\n")
|
301
|
-
if actual_lines.first == "/*" && expected_lines.first != "/*"
|
302
|
-
assert(false, actual_lines[0..actual_lines.enum_with_index.find {|l, i| l == "*/"}.last].join("\n"))
|
303
|
-
end
|
304
|
-
end
|
305
|
-
|
306
|
-
def assert_callback(name, *expected_args)
|
307
|
-
run = false
|
308
|
-
Sass::Plugin.send("on_#{name}") do |*args|
|
309
|
-
run ||= expected_args.zip(args).all? do |ea, a|
|
310
|
-
ea.respond_to?(:call) ? ea.call(a) : ea == a
|
311
|
-
end
|
312
|
-
end
|
313
|
-
|
314
|
-
if block_given?
|
315
|
-
yield
|
316
|
-
else
|
317
|
-
update_all_stylesheets!
|
318
|
-
end
|
319
|
-
|
320
|
-
assert run, "Expected #{name} callback to be run with arguments:\n #{expected_args.inspect}"
|
321
|
-
end
|
322
|
-
|
323
|
-
def assert_no_callback(name, *unexpected_args)
|
324
|
-
Sass::Plugin.send("on_#{name}") do |*a|
|
325
|
-
next unless unexpected_args.empty? || a == unexpected_args
|
326
|
-
|
327
|
-
msg = "Expected #{name} callback not to be run"
|
328
|
-
if !unexpected_args.empty?
|
329
|
-
msg << " with arguments #{unexpected_args.inspect}"
|
330
|
-
elsif !a.empty?
|
331
|
-
msg << ",\n was run with arguments #{a.inspect}"
|
332
|
-
end
|
333
|
-
|
334
|
-
flunk msg
|
335
|
-
end
|
336
|
-
|
337
|
-
if block_given?
|
338
|
-
yield
|
339
|
-
else
|
340
|
-
update_all_stylesheets!
|
341
|
-
end
|
342
|
-
end
|
343
|
-
|
344
|
-
def assert_callbacks(*args)
|
345
|
-
return update_all_stylesheets! if args.empty?
|
346
|
-
assert_callback(*args.pop) {assert_callbacks(*args)}
|
347
|
-
end
|
348
|
-
|
349
|
-
def assert_no_callbacks(*args)
|
350
|
-
return update_all_stylesheets! if args.empty?
|
351
|
-
assert_no_callback(*args.pop) {assert_no_callbacks(*args)}
|
352
|
-
end
|
353
|
-
|
354
|
-
def clear_callbacks
|
355
|
-
Sass::Plugin.instance_variable_set('@_sass_callbacks', {})
|
356
|
-
end
|
357
|
-
|
358
|
-
def update_all_stylesheets!
|
359
|
-
Haml::Util.silence_haml_warnings do
|
360
|
-
Sass::Plugin.update_stylesheets
|
361
|
-
end
|
362
|
-
end
|
363
|
-
|
364
|
-
def assert_needs_update(*args)
|
365
|
-
assert(Sass::Plugin::StalenessChecker.stylesheet_needs_update?(tempfile_loc(*args), template_loc(*args)),
|
366
|
-
"Expected #{template_loc(*args)} to need an update.")
|
367
|
-
end
|
368
|
-
|
369
|
-
def assert_doesnt_need_update(*args)
|
370
|
-
assert(!Sass::Plugin::StalenessChecker.stylesheet_needs_update?(tempfile_loc(*args), template_loc(*args)),
|
371
|
-
"Expected #{template_loc(*args)} not to need an update.")
|
372
|
-
end
|
373
|
-
|
374
|
-
def touch(*args)
|
375
|
-
FileUtils.touch(template_loc(*args))
|
376
|
-
end
|
377
|
-
|
378
|
-
def reset_mtimes
|
379
|
-
Sass::Plugin::StalenessChecker.dependencies_cache = {}
|
380
|
-
atime = Time.now
|
381
|
-
mtime = Time.now - 5
|
382
|
-
Dir["{#{template_loc},#{tempfile_loc}}/**/*.{css,sass,scss}"].each {|f| File.utime(atime, mtime, f)}
|
383
|
-
end
|
384
|
-
|
385
|
-
def template_loc(name = nil, prefix = nil)
|
386
|
-
if name
|
387
|
-
scss = absolutize "#{prefix}templates/#{name}.scss"
|
388
|
-
File.exists?(scss) ? scss : absolutize("#{prefix}templates/#{name}.sass")
|
389
|
-
else
|
390
|
-
absolutize "#{prefix}templates"
|
391
|
-
end
|
392
|
-
end
|
393
|
-
|
394
|
-
def tempfile_loc(name = nil, prefix = nil)
|
395
|
-
if name
|
396
|
-
absolutize "#{prefix}tmp/#{name}.css"
|
397
|
-
else
|
398
|
-
absolutize "#{prefix}tmp"
|
399
|
-
end
|
400
|
-
end
|
401
|
-
|
402
|
-
def result_loc(name = nil, prefix = nil)
|
403
|
-
if name
|
404
|
-
absolutize "#{prefix}results/#{name}.css"
|
405
|
-
else
|
406
|
-
absolutize "#{prefix}results"
|
407
|
-
end
|
408
|
-
end
|
409
|
-
|
410
|
-
def absolutize(file)
|
411
|
-
"#{File.dirname(__FILE__)}/#{file}"
|
412
|
-
end
|
413
|
-
|
414
|
-
def set_plugin_opts(overrides = {})
|
415
|
-
Sass::Plugin.options = {
|
416
|
-
:template_location => template_loc,
|
417
|
-
:css_location => tempfile_loc,
|
418
|
-
:style => :compact,
|
419
|
-
:load_paths => [result_loc],
|
420
|
-
:always_update => true,
|
421
|
-
:never_update => false,
|
422
|
-
}.merge(overrides)
|
423
|
-
end
|
424
|
-
end
|
425
|
-
|
426
|
-
class Sass::Engine
|
427
|
-
alias_method :old_render, :render
|
428
|
-
|
429
|
-
def render
|
430
|
-
raise "bork bork bork!" if @template[0] == "{bork now!}"
|
431
|
-
old_render
|
432
|
-
end
|
433
|
-
end
|