sass 3.1.0.alpha.2
Sign up to get free protection for your applications and to get access to all the features.
- data/.yardopts +11 -0
- data/CONTRIBUTING +3 -0
- data/EDGE_GEM_VERSION +1 -0
- data/MIT-LICENSE +20 -0
- data/README.md +201 -0
- data/REVISION +1 -0
- data/Rakefile +353 -0
- data/VERSION +1 -0
- data/VERSION_NAME +1 -0
- data/bin/css2sass +13 -0
- data/bin/sass +8 -0
- data/bin/sass-convert +7 -0
- data/extra/update_watch.rb +13 -0
- data/init.rb +18 -0
- data/lib/sass.rb +71 -0
- data/lib/sass/cache_store.rb +208 -0
- data/lib/sass/callbacks.rb +66 -0
- data/lib/sass/css.rb +294 -0
- data/lib/sass/engine.rb +792 -0
- data/lib/sass/environment.rb +143 -0
- data/lib/sass/error.rb +201 -0
- data/lib/sass/exec.rb +619 -0
- data/lib/sass/importers.rb +22 -0
- data/lib/sass/importers/base.rb +138 -0
- data/lib/sass/importers/filesystem.rb +121 -0
- data/lib/sass/less.rb +363 -0
- data/lib/sass/plugin.rb +126 -0
- data/lib/sass/plugin/compiler.rb +346 -0
- data/lib/sass/plugin/configuration.rb +123 -0
- data/lib/sass/plugin/generic.rb +15 -0
- data/lib/sass/plugin/merb.rb +48 -0
- data/lib/sass/plugin/rack.rb +47 -0
- data/lib/sass/plugin/rails.rb +41 -0
- data/lib/sass/plugin/staleness_checker.rb +145 -0
- data/lib/sass/railtie.rb +8 -0
- data/lib/sass/repl.rb +58 -0
- data/lib/sass/root.rb +7 -0
- data/lib/sass/script.rb +63 -0
- data/lib/sass/script/bool.rb +18 -0
- data/lib/sass/script/color.rb +490 -0
- data/lib/sass/script/css_lexer.rb +29 -0
- data/lib/sass/script/css_parser.rb +31 -0
- data/lib/sass/script/funcall.rb +78 -0
- data/lib/sass/script/functions.rb +852 -0
- data/lib/sass/script/interpolation.rb +70 -0
- data/lib/sass/script/lexer.rb +337 -0
- data/lib/sass/script/literal.rb +236 -0
- data/lib/sass/script/node.rb +101 -0
- data/lib/sass/script/number.rb +420 -0
- data/lib/sass/script/operation.rb +92 -0
- data/lib/sass/script/parser.rb +392 -0
- data/lib/sass/script/string.rb +67 -0
- data/lib/sass/script/string_interpolation.rb +93 -0
- data/lib/sass/script/unary_operation.rb +57 -0
- data/lib/sass/script/variable.rb +48 -0
- data/lib/sass/scss.rb +17 -0
- data/lib/sass/scss/css_parser.rb +51 -0
- data/lib/sass/scss/parser.rb +838 -0
- data/lib/sass/scss/rx.rb +126 -0
- data/lib/sass/scss/sass_parser.rb +11 -0
- data/lib/sass/scss/script_lexer.rb +15 -0
- data/lib/sass/scss/script_parser.rb +25 -0
- data/lib/sass/scss/static_parser.rb +40 -0
- data/lib/sass/selector.rb +361 -0
- data/lib/sass/selector/abstract_sequence.rb +62 -0
- data/lib/sass/selector/comma_sequence.rb +82 -0
- data/lib/sass/selector/sequence.rb +236 -0
- data/lib/sass/selector/simple.rb +113 -0
- data/lib/sass/selector/simple_sequence.rb +135 -0
- data/lib/sass/shared.rb +78 -0
- data/lib/sass/tree/comment_node.rb +128 -0
- data/lib/sass/tree/debug_node.rb +36 -0
- data/lib/sass/tree/directive_node.rb +75 -0
- data/lib/sass/tree/extend_node.rb +65 -0
- data/lib/sass/tree/for_node.rb +67 -0
- data/lib/sass/tree/if_node.rb +81 -0
- data/lib/sass/tree/import_node.rb +124 -0
- data/lib/sass/tree/mixin_def_node.rb +60 -0
- data/lib/sass/tree/mixin_node.rb +123 -0
- data/lib/sass/tree/node.rb +490 -0
- data/lib/sass/tree/prop_node.rb +220 -0
- data/lib/sass/tree/root_node.rb +125 -0
- data/lib/sass/tree/rule_node.rb +273 -0
- data/lib/sass/tree/variable_node.rb +39 -0
- data/lib/sass/tree/warn_node.rb +42 -0
- data/lib/sass/tree/while_node.rb +48 -0
- data/lib/sass/util.rb +687 -0
- data/lib/sass/util/subset_map.rb +101 -0
- data/lib/sass/version.rb +109 -0
- data/rails/init.rb +1 -0
- data/test/sass/cache_test.rb +74 -0
- data/test/sass/callbacks_test.rb +61 -0
- data/test/sass/conversion_test.rb +1210 -0
- data/test/sass/css2sass_test.rb +364 -0
- data/test/sass/data/hsl-rgb.txt +319 -0
- data/test/sass/engine_test.rb +2273 -0
- data/test/sass/extend_test.rb +1348 -0
- data/test/sass/functions_test.rb +565 -0
- data/test/sass/importer_test.rb +104 -0
- data/test/sass/less_conversion_test.rb +632 -0
- data/test/sass/mock_importer.rb +49 -0
- data/test/sass/more_results/more1.css +9 -0
- data/test/sass/more_results/more1_with_line_comments.css +26 -0
- data/test/sass/more_results/more_import.css +29 -0
- data/test/sass/more_templates/_more_partial.sass +2 -0
- data/test/sass/more_templates/more1.sass +23 -0
- data/test/sass/more_templates/more_import.sass +11 -0
- data/test/sass/plugin_test.rb +430 -0
- data/test/sass/results/alt.css +4 -0
- data/test/sass/results/basic.css +9 -0
- data/test/sass/results/compact.css +5 -0
- data/test/sass/results/complex.css +86 -0
- data/test/sass/results/compressed.css +1 -0
- data/test/sass/results/expanded.css +19 -0
- data/test/sass/results/import.css +31 -0
- data/test/sass/results/line_numbers.css +49 -0
- data/test/sass/results/mixins.css +95 -0
- data/test/sass/results/multiline.css +24 -0
- data/test/sass/results/nested.css +22 -0
- data/test/sass/results/options.css +1 -0
- data/test/sass/results/parent_ref.css +13 -0
- data/test/sass/results/script.css +16 -0
- data/test/sass/results/scss_import.css +31 -0
- data/test/sass/results/scss_importee.css +2 -0
- data/test/sass/results/subdir/nested_subdir/nested_subdir.css +1 -0
- data/test/sass/results/subdir/subdir.css +3 -0
- data/test/sass/results/units.css +11 -0
- data/test/sass/results/warn.css +0 -0
- data/test/sass/results/warn_imported.css +0 -0
- data/test/sass/script_conversion_test.rb +254 -0
- data/test/sass/script_test.rb +459 -0
- data/test/sass/scss/css_test.rb +897 -0
- data/test/sass/scss/rx_test.rb +156 -0
- data/test/sass/scss/scss_test.rb +1088 -0
- data/test/sass/scss/test_helper.rb +37 -0
- data/test/sass/templates/_partial.sass +2 -0
- data/test/sass/templates/alt.sass +16 -0
- data/test/sass/templates/basic.sass +23 -0
- data/test/sass/templates/bork1.sass +2 -0
- data/test/sass/templates/bork2.sass +2 -0
- data/test/sass/templates/bork3.sass +2 -0
- data/test/sass/templates/bork4.sass +2 -0
- data/test/sass/templates/compact.sass +17 -0
- data/test/sass/templates/complex.sass +305 -0
- data/test/sass/templates/compressed.sass +15 -0
- data/test/sass/templates/expanded.sass +17 -0
- data/test/sass/templates/import.sass +12 -0
- data/test/sass/templates/importee.less +2 -0
- data/test/sass/templates/importee.sass +19 -0
- data/test/sass/templates/line_numbers.sass +13 -0
- data/test/sass/templates/mixin_bork.sass +5 -0
- data/test/sass/templates/mixins.sass +76 -0
- data/test/sass/templates/multiline.sass +20 -0
- data/test/sass/templates/nested.sass +25 -0
- data/test/sass/templates/nested_bork1.sass +2 -0
- data/test/sass/templates/nested_bork2.sass +2 -0
- data/test/sass/templates/nested_bork3.sass +2 -0
- data/test/sass/templates/nested_bork4.sass +2 -0
- data/test/sass/templates/nested_mixin_bork.sass +6 -0
- data/test/sass/templates/options.sass +2 -0
- data/test/sass/templates/parent_ref.sass +25 -0
- data/test/sass/templates/script.sass +101 -0
- data/test/sass/templates/scss_import.scss +11 -0
- data/test/sass/templates/scss_importee.scss +1 -0
- data/test/sass/templates/subdir/nested_subdir/_nested_partial.sass +2 -0
- data/test/sass/templates/subdir/nested_subdir/nested_subdir.sass +3 -0
- data/test/sass/templates/subdir/subdir.sass +6 -0
- data/test/sass/templates/units.sass +11 -0
- data/test/sass/templates/warn.sass +3 -0
- data/test/sass/templates/warn_imported.sass +4 -0
- data/test/sass/test_helper.rb +8 -0
- data/test/sass/util/subset_map_test.rb +91 -0
- data/test/sass/util_test.rb +275 -0
- data/test/test_helper.rb +64 -0
- data/vendor/fssm/LICENSE +20 -0
- data/vendor/fssm/README.markdown +55 -0
- data/vendor/fssm/Rakefile +59 -0
- data/vendor/fssm/VERSION.yml +5 -0
- data/vendor/fssm/example.rb +9 -0
- data/vendor/fssm/fssm.gemspec +77 -0
- data/vendor/fssm/lib/fssm.rb +33 -0
- data/vendor/fssm/lib/fssm/backends/fsevents.rb +36 -0
- data/vendor/fssm/lib/fssm/backends/inotify.rb +26 -0
- data/vendor/fssm/lib/fssm/backends/polling.rb +25 -0
- data/vendor/fssm/lib/fssm/backends/rubycocoa/fsevents.rb +131 -0
- data/vendor/fssm/lib/fssm/monitor.rb +26 -0
- data/vendor/fssm/lib/fssm/path.rb +91 -0
- data/vendor/fssm/lib/fssm/pathname.rb +502 -0
- data/vendor/fssm/lib/fssm/state/directory.rb +57 -0
- data/vendor/fssm/lib/fssm/state/file.rb +24 -0
- data/vendor/fssm/lib/fssm/support.rb +63 -0
- data/vendor/fssm/lib/fssm/tree.rb +176 -0
- data/vendor/fssm/profile/prof-cache.rb +40 -0
- data/vendor/fssm/profile/prof-fssm-pathname.html +1231 -0
- data/vendor/fssm/profile/prof-pathname.rb +68 -0
- data/vendor/fssm/profile/prof-plain-pathname.html +988 -0
- data/vendor/fssm/profile/prof.html +2379 -0
- data/vendor/fssm/spec/path_spec.rb +75 -0
- 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 +14 -0
- metadata +297 -0
@@ -0,0 +1,275 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require File.dirname(__FILE__) + '/../test_helper'
|
3
|
+
require 'pathname'
|
4
|
+
|
5
|
+
class UtilTest < Test::Unit::TestCase
|
6
|
+
include Sass::Util
|
7
|
+
|
8
|
+
class Dumpable
|
9
|
+
attr_reader :arr
|
10
|
+
def initialize; @arr = []; end
|
11
|
+
def _before_dump; @arr << :before; end
|
12
|
+
def _after_dump; @arr << :after; end
|
13
|
+
def _around_dump
|
14
|
+
@arr << :around_before
|
15
|
+
yield
|
16
|
+
@arr << :around_after
|
17
|
+
end
|
18
|
+
def _after_load; @arr << :loaded; end
|
19
|
+
end
|
20
|
+
|
21
|
+
def test_scope
|
22
|
+
assert(File.exist?(scope("Rakefile")))
|
23
|
+
end
|
24
|
+
|
25
|
+
def test_to_hash
|
26
|
+
assert_equal({
|
27
|
+
:foo => 1,
|
28
|
+
:bar => 2,
|
29
|
+
:baz => 3
|
30
|
+
}, to_hash([[:foo, 1], [:bar, 2], [:baz, 3]]))
|
31
|
+
end
|
32
|
+
|
33
|
+
def test_map_keys
|
34
|
+
assert_equal({
|
35
|
+
"foo" => 1,
|
36
|
+
"bar" => 2,
|
37
|
+
"baz" => 3
|
38
|
+
}, map_keys({:foo => 1, :bar => 2, :baz => 3}) {|k| k.to_s})
|
39
|
+
end
|
40
|
+
|
41
|
+
def test_map_vals
|
42
|
+
assert_equal({
|
43
|
+
:foo => "1",
|
44
|
+
:bar => "2",
|
45
|
+
:baz => "3"
|
46
|
+
}, map_vals({:foo => 1, :bar => 2, :baz => 3}) {|k| k.to_s})
|
47
|
+
end
|
48
|
+
|
49
|
+
def test_map_hash
|
50
|
+
assert_equal({
|
51
|
+
"foo" => "1",
|
52
|
+
"bar" => "2",
|
53
|
+
"baz" => "3"
|
54
|
+
}, map_hash({:foo => 1, :bar => 2, :baz => 3}) {|k, v| [k.to_s, v.to_s]})
|
55
|
+
end
|
56
|
+
|
57
|
+
def test_powerset
|
58
|
+
return unless Set[Set[]] == Set[Set[]] # There's a bug in Ruby 1.8.6 that breaks nested set equality
|
59
|
+
assert_equal([[].to_set].to_set,
|
60
|
+
powerset([]))
|
61
|
+
assert_equal([[].to_set, [1].to_set].to_set,
|
62
|
+
powerset([1]))
|
63
|
+
assert_equal([[].to_set, [1].to_set, [2].to_set, [1, 2].to_set].to_set,
|
64
|
+
powerset([1, 2]))
|
65
|
+
assert_equal([[].to_set, [1].to_set, [2].to_set, [3].to_set,
|
66
|
+
[1, 2].to_set, [2, 3].to_set, [1, 3].to_set, [1, 2, 3].to_set].to_set,
|
67
|
+
powerset([1, 2, 3]))
|
68
|
+
end
|
69
|
+
|
70
|
+
def test_restrict
|
71
|
+
assert_equal(0.5, restrict(0.5, 0..1))
|
72
|
+
assert_equal(1, restrict(2, 0..1))
|
73
|
+
assert_equal(1.3, restrict(2, 0..1.3))
|
74
|
+
assert_equal(0, restrict(-1, 0..1))
|
75
|
+
end
|
76
|
+
|
77
|
+
def test_merge_adjacent_strings
|
78
|
+
assert_equal(["foo bar baz", :bang, "biz bop", 12],
|
79
|
+
merge_adjacent_strings(["foo ", "bar ", "baz", :bang, "biz", " bop", 12]))
|
80
|
+
str = "foo"
|
81
|
+
assert_equal(["foo foo foo", :bang, "foo foo", 12],
|
82
|
+
merge_adjacent_strings([str, " ", str, " ", str, :bang, str, " ", str, 12]))
|
83
|
+
end
|
84
|
+
|
85
|
+
def test_intersperse
|
86
|
+
assert_equal(["foo", " ", "bar", " ", "baz"],
|
87
|
+
intersperse(%w[foo bar baz], " "))
|
88
|
+
assert_equal([], intersperse([], " "))
|
89
|
+
end
|
90
|
+
|
91
|
+
def test_substitute
|
92
|
+
assert_equal(["foo", "bar", "baz", 3, 4],
|
93
|
+
substitute([1, 2, 3, 4], [1, 2], ["foo", "bar", "baz"]))
|
94
|
+
assert_equal([1, "foo", "bar", "baz", 4],
|
95
|
+
substitute([1, 2, 3, 4], [2, 3], ["foo", "bar", "baz"]))
|
96
|
+
assert_equal([1, 2, "foo", "bar", "baz"],
|
97
|
+
substitute([1, 2, 3, 4], [3, 4], ["foo", "bar", "baz"]))
|
98
|
+
|
99
|
+
assert_equal([1, "foo", "bar", "baz", 2, 3, 4],
|
100
|
+
substitute([1, 2, 2, 2, 3, 4], [2, 2], ["foo", "bar", "baz"]))
|
101
|
+
end
|
102
|
+
|
103
|
+
def test_strip_string_array
|
104
|
+
assert_equal(["foo ", " bar ", " baz"],
|
105
|
+
strip_string_array([" foo ", " bar ", " baz "]))
|
106
|
+
assert_equal([:foo, " bar ", " baz"],
|
107
|
+
strip_string_array([:foo, " bar ", " baz "]))
|
108
|
+
assert_equal(["foo ", " bar ", :baz],
|
109
|
+
strip_string_array([" foo ", " bar ", :baz]))
|
110
|
+
end
|
111
|
+
|
112
|
+
def test_paths
|
113
|
+
assert_equal([[1, 3, 5], [2, 3, 5], [1, 4, 5], [2, 4, 5]],
|
114
|
+
paths([[1, 2], [3, 4], [5]]))
|
115
|
+
assert_equal([[]], paths([]))
|
116
|
+
assert_equal([[1, 2, 3]], paths([[1], [2], [3]]))
|
117
|
+
end
|
118
|
+
|
119
|
+
def test_lcs
|
120
|
+
assert_equal([1, 2, 3], lcs([1, 2, 3], [1, 2, 3]))
|
121
|
+
assert_equal([], lcs([], [1, 2, 3]))
|
122
|
+
assert_equal([], lcs([1, 2, 3], []))
|
123
|
+
assert_equal([1, 2, 3], lcs([5, 1, 4, 2, 3, 17], [0, 0, 1, 2, 6, 3]))
|
124
|
+
|
125
|
+
assert_equal([1], lcs([1, 2, 3, 4], [4, 3, 2, 1]))
|
126
|
+
assert_equal([1, 2], lcs([1, 2, 3, 4], [3, 4, 1, 2]))
|
127
|
+
end
|
128
|
+
|
129
|
+
def test_lcs_with_block
|
130
|
+
assert_equal(["1", "2", "3"],
|
131
|
+
lcs([1, 4, 2, 5, 3], [1, 2, 3]) {|a, b| a == b && a.to_s})
|
132
|
+
assert_equal([-4, 2, 8],
|
133
|
+
lcs([-5, 3, 2, 8], [-4, 1, 8]) {|a, b| (a - b).abs <= 1 && [a, b].max})
|
134
|
+
end
|
135
|
+
|
136
|
+
def test_silence_warnings
|
137
|
+
old_stderr, $stderr = $stderr, StringIO.new
|
138
|
+
warn "Out"
|
139
|
+
assert_equal("Out\n", $stderr.string)
|
140
|
+
silence_warnings {warn "In"}
|
141
|
+
assert_equal("Out\n", $stderr.string)
|
142
|
+
ensure
|
143
|
+
$stderr = old_stderr
|
144
|
+
end
|
145
|
+
|
146
|
+
def test_sass_warn
|
147
|
+
assert_warning("Foo!") {sass_warn "Foo!"}
|
148
|
+
end
|
149
|
+
|
150
|
+
def test_silence_sass_warnings
|
151
|
+
old_stderr, $stderr = $stderr, StringIO.new
|
152
|
+
silence_sass_warnings {warn "Out"}
|
153
|
+
assert_equal("Out\n", $stderr.string)
|
154
|
+
silence_sass_warnings {sass_warn "In"}
|
155
|
+
assert_equal("Out\n", $stderr.string)
|
156
|
+
ensure
|
157
|
+
$stderr = old_stderr
|
158
|
+
end
|
159
|
+
|
160
|
+
def test_has
|
161
|
+
assert(has?(:instance_method, String, :chomp!))
|
162
|
+
assert(has?(:private_instance_method, Sass::Engine, :parse_interp))
|
163
|
+
end
|
164
|
+
|
165
|
+
def test_enum_with_index
|
166
|
+
assert_equal(%w[foo0 bar1 baz2],
|
167
|
+
enum_with_index(%w[foo bar baz]).map {|s, i| "#{s}#{i}"})
|
168
|
+
end
|
169
|
+
|
170
|
+
def test_enum_cons
|
171
|
+
assert_equal(%w[foobar barbaz],
|
172
|
+
enum_cons(%w[foo bar baz], 2).map {|s1, s2| "#{s1}#{s2}"})
|
173
|
+
end
|
174
|
+
|
175
|
+
def test_ord
|
176
|
+
assert_equal(102, ord("f"))
|
177
|
+
assert_equal(98, ord("bar"))
|
178
|
+
end
|
179
|
+
|
180
|
+
def test_flatten
|
181
|
+
assert_equal([1, 2, 3], flatten([1, 2, 3], 0))
|
182
|
+
assert_equal([1, 2, 3], flatten([1, 2, 3], 1))
|
183
|
+
assert_equal([1, 2, 3], flatten([1, 2, 3], 2))
|
184
|
+
|
185
|
+
assert_equal([[1, 2], 3], flatten([[1, 2], 3], 0))
|
186
|
+
assert_equal([1, 2, 3], flatten([[1, 2], 3], 1))
|
187
|
+
assert_equal([1, 2, 3], flatten([[1, 2], 3], 2))
|
188
|
+
|
189
|
+
assert_equal([[[1], 2], [3], 4], flatten([[[1], 2], [3], 4], 0))
|
190
|
+
assert_equal([[1], 2, 3, 4], flatten([[[1], 2], [3], 4], 1))
|
191
|
+
assert_equal([1, 2, 3, 4], flatten([[[1], 2], [3], 4], 2))
|
192
|
+
end
|
193
|
+
|
194
|
+
def test_set_hash
|
195
|
+
assert(set_hash(Set[1, 2, 3]) == set_hash(Set[3, 2, 1]))
|
196
|
+
assert(set_hash(Set[1, 2, 3]) == set_hash(Set[1, 2, 3]))
|
197
|
+
|
198
|
+
s1 = Set[]
|
199
|
+
s1 << 1
|
200
|
+
s1 << 2
|
201
|
+
s1 << 3
|
202
|
+
s2 = Set[]
|
203
|
+
s2 << 3
|
204
|
+
s2 << 2
|
205
|
+
s2 << 1
|
206
|
+
assert(set_hash(s1) == set_hash(s2))
|
207
|
+
end
|
208
|
+
|
209
|
+
def test_set_eql
|
210
|
+
assert(set_eql?(Set[1, 2, 3], Set[3, 2, 1]))
|
211
|
+
assert(set_eql?(Set[1, 2, 3], Set[1, 2, 3]))
|
212
|
+
|
213
|
+
s1 = Set[]
|
214
|
+
s1 << 1
|
215
|
+
s1 << 2
|
216
|
+
s1 << 3
|
217
|
+
s2 = Set[]
|
218
|
+
s2 << 3
|
219
|
+
s2 << 2
|
220
|
+
s2 << 1
|
221
|
+
assert(set_eql?(s1, s2))
|
222
|
+
end
|
223
|
+
|
224
|
+
def test_caller_info
|
225
|
+
assert_equal(["/tmp/foo.rb", 12, "fizzle"], caller_info("/tmp/foo.rb:12: in `fizzle'"))
|
226
|
+
assert_equal(["/tmp/foo.rb", 12, nil], caller_info("/tmp/foo.rb:12"))
|
227
|
+
assert_equal(["(sass)", 12, "blah"], caller_info("(sass):12: in `blah'"))
|
228
|
+
assert_equal(["", 12, "boop"], caller_info(":12: in `boop'"))
|
229
|
+
assert_equal(["/tmp/foo.rb", -12, "fizzle"], caller_info("/tmp/foo.rb:-12: in `fizzle'"))
|
230
|
+
assert_equal(["/tmp/foo.rb", 12, "fizzle"], caller_info("/tmp/foo.rb:12: in `fizzle {}'"))
|
231
|
+
end
|
232
|
+
|
233
|
+
def test_version_gt
|
234
|
+
assert_version_gt("2.0.0", "1.0.0")
|
235
|
+
assert_version_gt("1.1.0", "1.0.0")
|
236
|
+
assert_version_gt("1.0.1", "1.0.0")
|
237
|
+
assert_version_gt("1.0.0", "1.0.0.rc")
|
238
|
+
assert_version_gt("1.0.0.1", "1.0.0.rc")
|
239
|
+
assert_version_gt("1.0.0.rc", "0.9.9")
|
240
|
+
assert_version_gt("1.0.0.beta", "1.0.0.alpha")
|
241
|
+
|
242
|
+
assert_version_eq("1.0.0", "1.0.0")
|
243
|
+
assert_version_eq("1.0.0", "1.0.0.0")
|
244
|
+
end
|
245
|
+
|
246
|
+
def assert_version_gt(v1, v2)
|
247
|
+
#assert(version_gt(v1, v2), "Expected #{v1} > #{v2}")
|
248
|
+
assert(!version_gt(v2, v1), "Expected #{v2} < #{v1}")
|
249
|
+
end
|
250
|
+
|
251
|
+
def assert_version_eq(v1, v2)
|
252
|
+
assert(!version_gt(v1, v2), "Expected #{v1} = #{v2}")
|
253
|
+
assert(!version_gt(v2, v1), "Expected #{v2} = #{v1}")
|
254
|
+
end
|
255
|
+
|
256
|
+
def test_dump_and_load
|
257
|
+
obj = Dumpable.new
|
258
|
+
data = dump(obj)
|
259
|
+
assert_equal([:before, :around_before, :around_after, :after], obj.arr)
|
260
|
+
obj2 = load(data)
|
261
|
+
assert_equal([:before, :around_before, :loaded], obj2.arr)
|
262
|
+
end
|
263
|
+
|
264
|
+
class FooBar
|
265
|
+
def foo
|
266
|
+
Sass::Util.abstract(self)
|
267
|
+
end
|
268
|
+
end
|
269
|
+
|
270
|
+
def test_abstract
|
271
|
+
assert_raise_message(NotImplementedError,
|
272
|
+
"UtilTest::FooBar must implement #foo") {FooBar.new.foo}
|
273
|
+
end
|
274
|
+
|
275
|
+
end
|
data/test/test_helper.rb
ADDED
@@ -0,0 +1,64 @@
|
|
1
|
+
lib_dir = File.dirname(__FILE__) + '/../lib'
|
2
|
+
|
3
|
+
require 'test/unit'
|
4
|
+
require 'fileutils'
|
5
|
+
$:.unshift lib_dir unless $:.include?(lib_dir)
|
6
|
+
require 'sass'
|
7
|
+
|
8
|
+
Sass::RAILS_LOADED = true unless defined?(Sass::RAILS_LOADED)
|
9
|
+
|
10
|
+
module Sass::Script::Functions
|
11
|
+
module UserFunctions; end
|
12
|
+
include UserFunctions
|
13
|
+
|
14
|
+
def option(name)
|
15
|
+
Sass::Script::String.new(@options[name.value.to_sym].to_s)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
class Test::Unit::TestCase
|
20
|
+
def munge_filename(opts = {})
|
21
|
+
return if opts.has_key?(:filename)
|
22
|
+
opts[:filename] = filename_for_test(opts[:syntax] || :sass)
|
23
|
+
end
|
24
|
+
|
25
|
+
def filename_for_test(syntax = :sass)
|
26
|
+
test_name = caller.
|
27
|
+
map {|c| Sass::Util.caller_info(c)[2]}.
|
28
|
+
compact.
|
29
|
+
map {|c| c.sub(/^(block|rescue) in /, '')}.
|
30
|
+
find {|c| c =~ /^test_/}
|
31
|
+
"#{test_name}_inline.#{syntax}"
|
32
|
+
end
|
33
|
+
|
34
|
+
def clean_up_sassc
|
35
|
+
path = File.dirname(__FILE__) + "/../.sass-cache"
|
36
|
+
FileUtils.rm_r(path) if File.exist?(path)
|
37
|
+
end
|
38
|
+
|
39
|
+
def assert_warning(message)
|
40
|
+
the_real_stderr, $stderr = $stderr, StringIO.new
|
41
|
+
yield
|
42
|
+
|
43
|
+
if message.is_a?(Regexp)
|
44
|
+
assert_match message, $stderr.string.strip
|
45
|
+
else
|
46
|
+
assert_equal message.strip, $stderr.string.strip
|
47
|
+
end
|
48
|
+
ensure
|
49
|
+
$stderr = the_real_stderr
|
50
|
+
end
|
51
|
+
|
52
|
+
def silence_warnings(&block)
|
53
|
+
Sass::Util.silence_warnings(&block)
|
54
|
+
end
|
55
|
+
|
56
|
+
def assert_raise_message(klass, message)
|
57
|
+
yield
|
58
|
+
rescue Exception => e
|
59
|
+
assert_instance_of(klass, e)
|
60
|
+
assert_equal(message, e.message)
|
61
|
+
else
|
62
|
+
flunk "Expected exception #{klass}, none raised"
|
63
|
+
end
|
64
|
+
end
|
data/vendor/fssm/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2009 Travis Tilley
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
@@ -0,0 +1,55 @@
|
|
1
|
+
Monitor API
|
2
|
+
===========
|
3
|
+
|
4
|
+
There are three ways you can run the monitor.
|
5
|
+
|
6
|
+
1. call monitor with a path parameter, and define callbacks in a block
|
7
|
+
2. call monitor with a block to configure multiple paths and callbacks
|
8
|
+
3. create a monitor object and run each step manually
|
9
|
+
|
10
|
+
Monitor with path
|
11
|
+
-----------------
|
12
|
+
|
13
|
+
This form watches one path, and enters the run loop automatically. The first parameter is the path to watch, and the second parameter is an optional glob pattern or array of glob patterns that a file must match in order to trigger a callback. The default glob, if ommitted, is `'**/*'`.
|
14
|
+
|
15
|
+
FSSM.monitor('/some/directory/', '**/*') do
|
16
|
+
update {|base, relative|}
|
17
|
+
delete {|base, relative|}
|
18
|
+
create {|base, relative|}
|
19
|
+
end
|
20
|
+
|
21
|
+
Monitor with block
|
22
|
+
------------------
|
23
|
+
|
24
|
+
This form watches one or more paths, and enters the run loop automatically. The glob configuration call can be ommitted, and defaults to `'**/*'`.
|
25
|
+
|
26
|
+
FSSM.monitor do
|
27
|
+
path '/some/directory/' do
|
28
|
+
glob '**/*.yml'
|
29
|
+
|
30
|
+
update {|base, relative|}
|
31
|
+
delete {|base, relative|}
|
32
|
+
create {|base, relative|}
|
33
|
+
end
|
34
|
+
|
35
|
+
path '/some/other/directory/' do
|
36
|
+
update {|base, relative|}
|
37
|
+
delete {|base, relative|}
|
38
|
+
create {|base, relative|}
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
Monitor object
|
43
|
+
--------------
|
44
|
+
|
45
|
+
This form doesn't enter the run loop automatically.
|
46
|
+
|
47
|
+
monitor = FSSM::Monitor.new
|
48
|
+
|
49
|
+
monitor.path '/some/directory/' do
|
50
|
+
update {|base, relative|}
|
51
|
+
delete {|base, relative|}
|
52
|
+
create {|base, relative|}
|
53
|
+
end
|
54
|
+
|
55
|
+
monitor.run
|
@@ -0,0 +1,59 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake'
|
3
|
+
|
4
|
+
begin
|
5
|
+
require 'jeweler'
|
6
|
+
Jeweler::Tasks.new do |gem|
|
7
|
+
gem.name = "fssm"
|
8
|
+
gem.summary = %Q{file system state monitor}
|
9
|
+
gem.description = %Q{file system state monitor}
|
10
|
+
gem.email = "ttilley@gmail.com"
|
11
|
+
gem.homepage = "http://github.com/ttilley/fssm"
|
12
|
+
gem.authors = ["Travis Tilley"]
|
13
|
+
gem.add_development_dependency "rspec"
|
14
|
+
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
15
|
+
end
|
16
|
+
rescue LoadError
|
17
|
+
puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
|
18
|
+
end
|
19
|
+
|
20
|
+
require 'spec/rake/spectask'
|
21
|
+
Spec::Rake::SpecTask.new(:spec) do |spec|
|
22
|
+
spec.libs << 'lib' << 'spec'
|
23
|
+
spec.spec_files = FileList['spec/**/*_spec.rb']
|
24
|
+
end
|
25
|
+
|
26
|
+
Spec::Rake::SpecTask.new(:rcov) do |spec|
|
27
|
+
spec.libs << 'lib' << 'spec'
|
28
|
+
spec.pattern = 'spec/**/*_spec.rb'
|
29
|
+
spec.rcov = true
|
30
|
+
end
|
31
|
+
|
32
|
+
task :spec => :check_dependencies
|
33
|
+
|
34
|
+
begin
|
35
|
+
require 'reek/rake_task'
|
36
|
+
Reek::RakeTask.new do |t|
|
37
|
+
t.fail_on_error = true
|
38
|
+
t.verbose = false
|
39
|
+
t.source_files = 'lib/**/*.rb'
|
40
|
+
end
|
41
|
+
rescue LoadError
|
42
|
+
task :reek do
|
43
|
+
abort "Reek is not available. In order to run reek, you must: sudo gem install reek"
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
begin
|
48
|
+
require 'roodi'
|
49
|
+
require 'roodi_task'
|
50
|
+
RoodiTask.new do |t|
|
51
|
+
t.verbose = false
|
52
|
+
end
|
53
|
+
rescue LoadError
|
54
|
+
task :roodi do
|
55
|
+
abort "Roodi is not available. In order to run roodi, you must: sudo gem install roodi"
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
task :default => :spec
|