oreorenasass 3.4.4 → 3.4.5
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.
- checksums.yaml +4 -4
- data/MIT-LICENSE +1 -1
- data/README.md +50 -70
- data/Rakefile +5 -26
- data/VERSION +1 -1
- data/VERSION_NAME +1 -1
- data/bin/sass +1 -1
- data/bin/scss +1 -1
- data/lib/sass.rb +12 -19
- data/lib/sass/cache_stores/base.rb +2 -2
- data/lib/sass/cache_stores/chain.rb +1 -2
- data/lib/sass/cache_stores/filesystem.rb +5 -1
- data/lib/sass/cache_stores/memory.rb +1 -1
- data/lib/sass/cache_stores/null.rb +2 -2
- data/lib/sass/callbacks.rb +0 -1
- data/lib/sass/css.rb +13 -11
- data/lib/sass/engine.rb +173 -424
- data/lib/sass/environment.rb +58 -148
- data/lib/sass/error.rb +14 -11
- data/lib/sass/exec.rb +703 -5
- data/lib/sass/importers/base.rb +6 -49
- data/lib/sass/importers/filesystem.rb +19 -44
- data/lib/sass/logger.rb +4 -1
- data/lib/sass/logger/base.rb +4 -2
- data/lib/sass/logger/log_level.rb +7 -3
- data/lib/sass/media.rb +23 -20
- data/lib/sass/plugin.rb +7 -7
- data/lib/sass/plugin/compiler.rb +145 -304
- data/lib/sass/plugin/configuration.rb +23 -18
- data/lib/sass/plugin/merb.rb +1 -1
- data/lib/sass/plugin/staleness_checker.rb +3 -3
- data/lib/sass/repl.rb +3 -3
- data/lib/sass/script.rb +8 -35
- data/lib/sass/script/{value/arg_list.rb → arg_list.rb} +25 -9
- data/lib/sass/script/bool.rb +18 -0
- data/lib/sass/script/color.rb +606 -0
- data/lib/sass/script/css_lexer.rb +4 -8
- data/lib/sass/script/css_parser.rb +2 -5
- data/lib/sass/script/funcall.rb +245 -0
- data/lib/sass/script/functions.rb +408 -1491
- data/lib/sass/script/interpolation.rb +79 -0
- data/lib/sass/script/lexer.rb +68 -172
- data/lib/sass/script/list.rb +85 -0
- data/lib/sass/script/literal.rb +221 -0
- data/lib/sass/script/{tree/node.rb → node.rb} +12 -22
- data/lib/sass/script/{value/null.rb → null.rb} +7 -14
- data/lib/sass/script/{value/number.rb → number.rb} +75 -152
- data/lib/sass/script/{tree/operation.rb → operation.rb} +24 -17
- data/lib/sass/script/parser.rb +110 -245
- data/lib/sass/script/string.rb +51 -0
- data/lib/sass/script/{tree/string_interpolation.rb → string_interpolation.rb} +4 -5
- data/lib/sass/script/{tree/unary_operation.rb → unary_operation.rb} +6 -6
- data/lib/sass/script/variable.rb +58 -0
- data/lib/sass/scss/css_parser.rb +3 -9
- data/lib/sass/scss/parser.rb +421 -450
- data/lib/sass/scss/rx.rb +11 -19
- data/lib/sass/scss/static_parser.rb +7 -321
- data/lib/sass/selector.rb +194 -68
- data/lib/sass/selector/abstract_sequence.rb +14 -29
- data/lib/sass/selector/comma_sequence.rb +25 -108
- data/lib/sass/selector/sequence.rb +66 -159
- data/lib/sass/selector/simple.rb +25 -23
- data/lib/sass/selector/simple_sequence.rb +63 -173
- data/lib/sass/shared.rb +1 -1
- data/lib/sass/supports.rb +15 -13
- data/lib/sass/tree/charset_node.rb +1 -1
- data/lib/sass/tree/comment_node.rb +3 -3
- data/lib/sass/tree/css_import_node.rb +11 -11
- data/lib/sass/tree/debug_node.rb +2 -2
- data/lib/sass/tree/directive_node.rb +4 -21
- data/lib/sass/tree/each_node.rb +8 -8
- data/lib/sass/tree/extend_node.rb +7 -14
- data/lib/sass/tree/for_node.rb +4 -4
- data/lib/sass/tree/function_node.rb +4 -9
- data/lib/sass/tree/if_node.rb +1 -1
- data/lib/sass/tree/import_node.rb +5 -4
- data/lib/sass/tree/media_node.rb +14 -4
- data/lib/sass/tree/mixin_def_node.rb +4 -4
- data/lib/sass/tree/mixin_node.rb +8 -21
- data/lib/sass/tree/node.rb +12 -54
- data/lib/sass/tree/prop_node.rb +20 -39
- data/lib/sass/tree/return_node.rb +2 -3
- data/lib/sass/tree/root_node.rb +3 -19
- data/lib/sass/tree/rule_node.rb +22 -35
- data/lib/sass/tree/supports_node.rb +13 -0
- data/lib/sass/tree/trace_node.rb +1 -2
- data/lib/sass/tree/variable_node.rb +3 -9
- data/lib/sass/tree/visitors/base.rb +8 -5
- data/lib/sass/tree/visitors/check_nesting.rb +19 -49
- data/lib/sass/tree/visitors/convert.rb +56 -74
- data/lib/sass/tree/visitors/cssize.rb +74 -202
- data/lib/sass/tree/visitors/deep_copy.rb +5 -10
- data/lib/sass/tree/visitors/extend.rb +7 -7
- data/lib/sass/tree/visitors/perform.rb +185 -278
- data/lib/sass/tree/visitors/set_options.rb +6 -20
- data/lib/sass/tree/visitors/to_css.rb +81 -234
- data/lib/sass/tree/warn_node.rb +2 -2
- data/lib/sass/tree/while_node.rb +2 -2
- data/lib/sass/util.rb +152 -522
- data/lib/sass/util/multibyte_string_scanner.rb +0 -2
- data/lib/sass/util/subset_map.rb +3 -4
- data/lib/sass/util/test.rb +1 -0
- data/lib/sass/version.rb +22 -20
- data/test/Gemfile +3 -0
- data/test/Gemfile.lock +10 -0
- data/test/sass/cache_test.rb +20 -62
- data/test/sass/callbacks_test.rb +1 -1
- data/test/sass/conversion_test.rb +2 -296
- data/test/sass/css2sass_test.rb +4 -23
- data/test/sass/engine_test.rb +354 -411
- data/test/sass/exec_test.rb +2 -2
- data/test/sass/extend_test.rb +145 -324
- data/test/sass/functions_test.rb +86 -873
- data/test/sass/importer_test.rb +21 -241
- data/test/sass/logger_test.rb +1 -1
- data/test/sass/more_results/more_import.css +1 -1
- data/test/sass/plugin_test.rb +26 -16
- data/test/sass/results/compact.css +1 -1
- data/test/sass/results/complex.css +4 -4
- data/test/sass/results/expanded.css +1 -1
- data/test/sass/results/import.css +1 -1
- data/test/sass/results/import_charset_ibm866.css +2 -2
- data/test/sass/results/mixins.css +17 -17
- data/test/sass/results/nested.css +1 -1
- data/test/sass/results/parent_ref.css +2 -2
- data/test/sass/results/script.css +3 -3
- data/test/sass/results/scss_import.css +1 -1
- data/test/sass/script_conversion_test.rb +7 -36
- data/test/sass/script_test.rb +53 -485
- data/test/sass/scss/css_test.rb +28 -143
- data/test/sass/scss/rx_test.rb +4 -4
- data/test/sass/scss/scss_test.rb +325 -2119
- data/test/sass/templates/scss_import.scss +1 -2
- data/test/sass/test_helper.rb +1 -1
- data/test/sass/util/multibyte_string_scanner_test.rb +1 -1
- data/test/sass/util/subset_map_test.rb +2 -2
- data/test/sass/util_test.rb +1 -86
- data/test/test_helper.rb +8 -37
- metadata +19 -66
- data/lib/sass/exec/base.rb +0 -187
- data/lib/sass/exec/sass_convert.rb +0 -264
- data/lib/sass/exec/sass_scss.rb +0 -424
- data/lib/sass/features.rb +0 -47
- data/lib/sass/script/tree.rb +0 -16
- data/lib/sass/script/tree/funcall.rb +0 -306
- data/lib/sass/script/tree/interpolation.rb +0 -118
- data/lib/sass/script/tree/list_literal.rb +0 -77
- data/lib/sass/script/tree/literal.rb +0 -45
- data/lib/sass/script/tree/map_literal.rb +0 -64
- data/lib/sass/script/tree/selector.rb +0 -26
- data/lib/sass/script/tree/variable.rb +0 -57
- data/lib/sass/script/value.rb +0 -11
- data/lib/sass/script/value/base.rb +0 -240
- data/lib/sass/script/value/bool.rb +0 -35
- data/lib/sass/script/value/color.rb +0 -680
- data/lib/sass/script/value/helpers.rb +0 -262
- data/lib/sass/script/value/list.rb +0 -113
- data/lib/sass/script/value/map.rb +0 -70
- data/lib/sass/script/value/string.rb +0 -97
- data/lib/sass/selector/pseudo.rb +0 -256
- data/lib/sass/source/map.rb +0 -210
- data/lib/sass/source/position.rb +0 -39
- data/lib/sass/source/range.rb +0 -41
- data/lib/sass/stack.rb +0 -120
- data/lib/sass/tree/at_root_node.rb +0 -83
- data/lib/sass/tree/error_node.rb +0 -18
- data/lib/sass/tree/keyframe_rule_node.rb +0 -15
- data/lib/sass/util/cross_platform_random.rb +0 -19
- data/lib/sass/util/normalized_map.rb +0 -130
- data/lib/sass/util/ordered_hash.rb +0 -192
- data/test/sass/compiler_test.rb +0 -232
- data/test/sass/encoding_test.rb +0 -219
- data/test/sass/source_map_test.rb +0 -977
- data/test/sass/superselector_test.rb +0 -191
- data/test/sass/util/normalized_map_test.rb +0 -51
- data/test/sass/value_helpers_test.rb +0 -179
@@ -1,192 +0,0 @@
|
|
1
|
-
# Copyright (c) 2005-2013 David Heinemeier Hansson
|
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.
|
21
|
-
|
22
|
-
# This class was copied from an old version of ActiveSupport.
|
23
|
-
class OrderedHash < ::Hash
|
24
|
-
# In MRI the Hash class is core and written in C. In particular, methods are
|
25
|
-
# programmed with explicit C function calls and polymorphism is not honored.
|
26
|
-
#
|
27
|
-
# For example, []= is crucial in this implementation to maintain the @keys
|
28
|
-
# array but hash.c invokes rb_hash_aset() originally. This prevents method
|
29
|
-
# reuse through inheritance and forces us to reimplement stuff.
|
30
|
-
#
|
31
|
-
# For instance, we cannot use the inherited #merge! because albeit the algorithm
|
32
|
-
# itself would work, our []= is not being called at all by the C code.
|
33
|
-
|
34
|
-
def initialize(*args)
|
35
|
-
super
|
36
|
-
@keys = []
|
37
|
-
end
|
38
|
-
|
39
|
-
def self.[](*args)
|
40
|
-
ordered_hash = new
|
41
|
-
|
42
|
-
if args.length == 1 && args.first.is_a?(Array)
|
43
|
-
args.first.each do |key_value_pair|
|
44
|
-
next unless key_value_pair.is_a?(Array)
|
45
|
-
ordered_hash[key_value_pair[0]] = key_value_pair[1]
|
46
|
-
end
|
47
|
-
|
48
|
-
return ordered_hash
|
49
|
-
end
|
50
|
-
|
51
|
-
unless args.size.even?
|
52
|
-
raise ArgumentError.new("odd number of arguments for Hash")
|
53
|
-
end
|
54
|
-
|
55
|
-
args.each_with_index do |val, ind|
|
56
|
-
next if ind.odd?
|
57
|
-
ordered_hash[val] = args[ind + 1]
|
58
|
-
end
|
59
|
-
|
60
|
-
ordered_hash
|
61
|
-
end
|
62
|
-
|
63
|
-
def initialize_copy(other)
|
64
|
-
super
|
65
|
-
# make a deep copy of keys
|
66
|
-
@keys = other.keys
|
67
|
-
end
|
68
|
-
|
69
|
-
def []=(key, value)
|
70
|
-
@keys << key unless has_key?(key)
|
71
|
-
super
|
72
|
-
end
|
73
|
-
|
74
|
-
def delete(key)
|
75
|
-
if has_key? key
|
76
|
-
index = @keys.index(key)
|
77
|
-
@keys.delete_at index
|
78
|
-
end
|
79
|
-
super
|
80
|
-
end
|
81
|
-
|
82
|
-
def delete_if
|
83
|
-
super
|
84
|
-
sync_keys!
|
85
|
-
self
|
86
|
-
end
|
87
|
-
|
88
|
-
def reject!
|
89
|
-
super
|
90
|
-
sync_keys!
|
91
|
-
self
|
92
|
-
end
|
93
|
-
|
94
|
-
def reject
|
95
|
-
dup.reject! {|h, k| yield h, k}
|
96
|
-
end
|
97
|
-
|
98
|
-
def keys
|
99
|
-
@keys.dup
|
100
|
-
end
|
101
|
-
|
102
|
-
def values
|
103
|
-
@keys.map {|key| self[key]}
|
104
|
-
end
|
105
|
-
|
106
|
-
def to_hash
|
107
|
-
self
|
108
|
-
end
|
109
|
-
|
110
|
-
def to_a
|
111
|
-
@keys.map {|key| [key, self[key]]}
|
112
|
-
end
|
113
|
-
|
114
|
-
def each_key
|
115
|
-
return to_enum(:each_key) unless block_given?
|
116
|
-
@keys.each {|key| yield key}
|
117
|
-
self
|
118
|
-
end
|
119
|
-
|
120
|
-
def each_value
|
121
|
-
return to_enum(:each_value) unless block_given?
|
122
|
-
@keys.each {|key| yield self[key]}
|
123
|
-
self
|
124
|
-
end
|
125
|
-
|
126
|
-
def each
|
127
|
-
return to_enum(:each) unless block_given?
|
128
|
-
@keys.each {|key| yield [key, self[key]]}
|
129
|
-
self
|
130
|
-
end
|
131
|
-
|
132
|
-
def each_pair
|
133
|
-
return to_enum(:each_pair) unless block_given?
|
134
|
-
@keys.each {|key| yield key, self[key]}
|
135
|
-
self
|
136
|
-
end
|
137
|
-
|
138
|
-
alias_method :select, :find_all
|
139
|
-
|
140
|
-
def clear
|
141
|
-
super
|
142
|
-
@keys.clear
|
143
|
-
self
|
144
|
-
end
|
145
|
-
|
146
|
-
def shift
|
147
|
-
k = @keys.first
|
148
|
-
v = delete(k)
|
149
|
-
[k, v]
|
150
|
-
end
|
151
|
-
|
152
|
-
def merge!(other_hash)
|
153
|
-
if block_given?
|
154
|
-
other_hash.each {|k, v| self[k] = key?(k) ? yield(k, self[k], v) : v}
|
155
|
-
else
|
156
|
-
other_hash.each {|k, v| self[k] = v}
|
157
|
-
end
|
158
|
-
self
|
159
|
-
end
|
160
|
-
|
161
|
-
alias_method :update, :merge!
|
162
|
-
|
163
|
-
def merge(other_hash)
|
164
|
-
if block_given?
|
165
|
-
dup.merge!(other_hash) {|k, v1, v2| yield k, v1, v2}
|
166
|
-
else
|
167
|
-
dup.merge!(other_hash)
|
168
|
-
end
|
169
|
-
end
|
170
|
-
|
171
|
-
# When replacing with another hash, the initial order of our keys must come from the other hash --
|
172
|
-
# ordered or not.
|
173
|
-
def replace(other)
|
174
|
-
super
|
175
|
-
@keys = other.keys
|
176
|
-
self
|
177
|
-
end
|
178
|
-
|
179
|
-
def invert
|
180
|
-
OrderedHash[to_a.map! {|key_value_pair| key_value_pair.reverse}]
|
181
|
-
end
|
182
|
-
|
183
|
-
def inspect
|
184
|
-
"#<OrderedHash #{super}>"
|
185
|
-
end
|
186
|
-
|
187
|
-
private
|
188
|
-
|
189
|
-
def sync_keys!
|
190
|
-
@keys.delete_if {|k| !has_key?(k)}
|
191
|
-
end
|
192
|
-
end
|
data/test/sass/compiler_test.rb
DELETED
@@ -1,232 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
require 'minitest/autorun'
|
3
|
-
require File.dirname(__FILE__) + '/../test_helper'
|
4
|
-
require 'sass/plugin'
|
5
|
-
require 'sass/plugin/compiler'
|
6
|
-
|
7
|
-
class CompilerTest < MiniTest::Test
|
8
|
-
class FakeListener
|
9
|
-
attr_accessor :options
|
10
|
-
attr_accessor :directories
|
11
|
-
attr_reader :start_called
|
12
|
-
attr_reader :thread
|
13
|
-
|
14
|
-
def initialize(*args, &on_filesystem_event)
|
15
|
-
self.options = args.last.is_a?(Hash) ? args.pop : {}
|
16
|
-
self.directories = args
|
17
|
-
@on_filesystem_event = on_filesystem_event
|
18
|
-
@start_called = false
|
19
|
-
reset_events!
|
20
|
-
end
|
21
|
-
|
22
|
-
def fire_events!(*args)
|
23
|
-
@on_filesystem_event.call(@modified, @added, @removed)
|
24
|
-
reset_events!
|
25
|
-
end
|
26
|
-
|
27
|
-
def changed(filename)
|
28
|
-
@modified << File.expand_path(filename)
|
29
|
-
end
|
30
|
-
|
31
|
-
def added(filename)
|
32
|
-
@added << File.expand_path(filename)
|
33
|
-
end
|
34
|
-
|
35
|
-
def removed(filename)
|
36
|
-
@removed << File.expand_path(filename)
|
37
|
-
end
|
38
|
-
|
39
|
-
def on_start!(&run_during_start)
|
40
|
-
@run_during_start = run_during_start
|
41
|
-
end
|
42
|
-
|
43
|
-
# used for Listen < 2.0
|
44
|
-
def start!
|
45
|
-
@run_during_start.call(self) if @run_during_start
|
46
|
-
end
|
47
|
-
|
48
|
-
# used for Listen >= 2.0
|
49
|
-
def start
|
50
|
-
@thread = Thread.new {@run_during_start.call(self) if @run_during_start}
|
51
|
-
end
|
52
|
-
|
53
|
-
def stop
|
54
|
-
end
|
55
|
-
|
56
|
-
def reset_events!
|
57
|
-
@modified = []
|
58
|
-
@added = []
|
59
|
-
@removed = []
|
60
|
-
end
|
61
|
-
end
|
62
|
-
|
63
|
-
module MockWatcher
|
64
|
-
attr_accessor :run_during_start
|
65
|
-
attr_accessor :update_stylesheets_times
|
66
|
-
attr_accessor :update_stylesheets_called_with
|
67
|
-
attr_accessor :deleted_css_files
|
68
|
-
|
69
|
-
def fake_listener
|
70
|
-
@fake_listener
|
71
|
-
end
|
72
|
-
|
73
|
-
def update_stylesheets(individual_files)
|
74
|
-
@update_stylesheets_times ||= 0
|
75
|
-
@update_stylesheets_times += 1
|
76
|
-
(@update_stylesheets_called_with ||= []) << individual_files
|
77
|
-
end
|
78
|
-
|
79
|
-
def try_delete_css(css_filename)
|
80
|
-
(@deleted_css_files ||= []) << css_filename
|
81
|
-
end
|
82
|
-
|
83
|
-
private
|
84
|
-
def create_listener(*args, &on_filesystem_event)
|
85
|
-
if Sass::Util.listen_geq_2?
|
86
|
-
options = args.pop if args.last.is_a?(Hash)
|
87
|
-
args.map do |dir|
|
88
|
-
@fake_listener = FakeListener.new(*args, &on_filesystem_event)
|
89
|
-
@fake_listener.on_start!(&run_during_start)
|
90
|
-
@fake_listener
|
91
|
-
end
|
92
|
-
else
|
93
|
-
@fake_listener = FakeListener.new(*args, &on_filesystem_event)
|
94
|
-
@fake_listener.on_start!(&run_during_start)
|
95
|
-
@fake_listener
|
96
|
-
end
|
97
|
-
end
|
98
|
-
end
|
99
|
-
|
100
|
-
def test_initialize
|
101
|
-
watcher
|
102
|
-
end
|
103
|
-
|
104
|
-
def test_watch_starts_the_listener
|
105
|
-
start_called = false
|
106
|
-
c = watcher do |listener|
|
107
|
-
start_called = true
|
108
|
-
end
|
109
|
-
c.watch
|
110
|
-
assert start_called, "start! was not called"
|
111
|
-
end
|
112
|
-
|
113
|
-
def test_sass_callbacks_fire_from_listener_events
|
114
|
-
c = watcher do |listener|
|
115
|
-
listener.changed "changed.scss"
|
116
|
-
listener.added "added.scss"
|
117
|
-
listener.removed "removed.scss"
|
118
|
-
listener.fire_events!
|
119
|
-
end
|
120
|
-
|
121
|
-
modified_fired = false
|
122
|
-
c.on_template_modified do |sass_file|
|
123
|
-
modified_fired = true
|
124
|
-
assert_equal "changed.scss", sass_file
|
125
|
-
end
|
126
|
-
|
127
|
-
added_fired = false
|
128
|
-
c.on_template_created do |sass_file|
|
129
|
-
added_fired = true
|
130
|
-
assert_equal "added.scss", sass_file
|
131
|
-
end
|
132
|
-
|
133
|
-
removed_fired = false
|
134
|
-
c.on_template_deleted do |sass_file|
|
135
|
-
removed_fired = true
|
136
|
-
assert_equal "removed.scss", sass_file
|
137
|
-
end
|
138
|
-
|
139
|
-
c.watch
|
140
|
-
|
141
|
-
assert_equal 2, c.update_stylesheets_times
|
142
|
-
assert modified_fired
|
143
|
-
assert added_fired
|
144
|
-
assert removed_fired
|
145
|
-
end
|
146
|
-
|
147
|
-
def test_removing_a_sass_file_removes_corresponding_css_file
|
148
|
-
c = watcher do |listener|
|
149
|
-
listener.removed "remove_me.scss"
|
150
|
-
listener.fire_events!
|
151
|
-
end
|
152
|
-
|
153
|
-
c.watch
|
154
|
-
|
155
|
-
assert_equal "./remove_me.css", c.deleted_css_files.first
|
156
|
-
end
|
157
|
-
|
158
|
-
def test_an_importer_can_watch_an_image
|
159
|
-
image_importer = Sass::Importers::Filesystem.new(".")
|
160
|
-
class << image_importer
|
161
|
-
def watched_file?(filename)
|
162
|
-
filename =~ /\.png$/
|
163
|
-
end
|
164
|
-
end
|
165
|
-
c = watcher(:load_paths => [image_importer]) do |listener|
|
166
|
-
listener.changed "image.png"
|
167
|
-
listener.fire_events!
|
168
|
-
end
|
169
|
-
|
170
|
-
modified_fired = false
|
171
|
-
c.on_template_modified do |f|
|
172
|
-
modified_fired = true
|
173
|
-
assert_equal "image.png", f
|
174
|
-
end
|
175
|
-
|
176
|
-
c.watch
|
177
|
-
|
178
|
-
assert_equal 2, c.update_stylesheets_times
|
179
|
-
assert modified_fired
|
180
|
-
end
|
181
|
-
|
182
|
-
def test_watching_specific_files_and_one_is_deleted
|
183
|
-
directories = nil
|
184
|
-
c = watcher do |listener|
|
185
|
-
directories = listener.directories
|
186
|
-
listener.removed File.expand_path("./foo.scss")
|
187
|
-
listener.fire_events!
|
188
|
-
end
|
189
|
-
c.watch([[File.expand_path("./foo.scss"), File.expand_path("./foo.css"), nil]])
|
190
|
-
assert directories.include?(File.expand_path(".")), directories.inspect
|
191
|
-
assert_equal File.expand_path("./foo.css"), c.deleted_css_files.first, "the corresponding css file was not deleted"
|
192
|
-
assert_equal [], c.update_stylesheets_called_with[1], "the sass file should not have been compiled"
|
193
|
-
end
|
194
|
-
|
195
|
-
def test_watched_directories_are_dedupped
|
196
|
-
directories = nil
|
197
|
-
c = watcher(:load_paths => [".", "./foo", "."]) do |listener|
|
198
|
-
directories = listener.directories
|
199
|
-
end
|
200
|
-
c.watch
|
201
|
-
assert_equal [File.expand_path(".")], directories
|
202
|
-
end
|
203
|
-
|
204
|
-
def test_a_changed_css_in_a_watched_directory_does_not_force_a_compile
|
205
|
-
c = watcher do |listener|
|
206
|
-
listener.changed "foo.css"
|
207
|
-
listener.fire_events!
|
208
|
-
end
|
209
|
-
|
210
|
-
c.on_template_modified do |f|
|
211
|
-
assert false, "Should not have been called"
|
212
|
-
end
|
213
|
-
|
214
|
-
c.watch
|
215
|
-
|
216
|
-
assert_equal 1, c.update_stylesheets_times
|
217
|
-
end
|
218
|
-
|
219
|
-
private
|
220
|
-
|
221
|
-
def default_options
|
222
|
-
{:template_location => [[".","."]]}
|
223
|
-
end
|
224
|
-
|
225
|
-
def watcher(options = {}, &run_during_start)
|
226
|
-
options = default_options.merge(options)
|
227
|
-
watcher = Sass::Plugin::Compiler.new(options)
|
228
|
-
watcher.extend(MockWatcher)
|
229
|
-
watcher.run_during_start = run_during_start
|
230
|
-
watcher
|
231
|
-
end
|
232
|
-
end
|
data/test/sass/encoding_test.rb
DELETED
@@ -1,219 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
# -*- coding: utf-8 -*-
|
3
|
-
require File.dirname(__FILE__) + '/../test_helper'
|
4
|
-
require File.dirname(__FILE__) + '/test_helper'
|
5
|
-
require 'sass/util/test'
|
6
|
-
|
7
|
-
class EncodingTest < MiniTest::Test
|
8
|
-
include Sass::Util::Test
|
9
|
-
|
10
|
-
def test_encoding_error
|
11
|
-
return skip "Can't be run on Ruby 1.8." if Sass::Util.ruby1_8?
|
12
|
-
|
13
|
-
render("foo\nbar\nb\xFEaz".force_encoding("utf-8"))
|
14
|
-
assert(false, "Expected exception")
|
15
|
-
rescue Sass::SyntaxError => e
|
16
|
-
assert_equal(3, e.sass_line)
|
17
|
-
assert_equal('Invalid UTF-8 character "\xFE"', e.message)
|
18
|
-
end
|
19
|
-
|
20
|
-
def test_ascii_incompatible_encoding_error
|
21
|
-
return skip "Can't be run on Ruby 1.8." if Sass::Util.ruby1_8?
|
22
|
-
|
23
|
-
template = "foo\nbar\nb_z".encode("utf-16le")
|
24
|
-
template[9] = "\xFE".force_encoding("utf-16le")
|
25
|
-
render(template)
|
26
|
-
assert(false, "Expected exception")
|
27
|
-
rescue Sass::SyntaxError => e
|
28
|
-
assert_equal(3, e.sass_line)
|
29
|
-
assert_equal('Invalid UTF-16LE character "\xFE"', e.message)
|
30
|
-
end
|
31
|
-
|
32
|
-
def test_prefers_charset_to_ruby_encoding
|
33
|
-
return skip "Can't be run on Ruby 1.8." if Sass::Util.ruby1_8?
|
34
|
-
|
35
|
-
assert_renders_encoded(<<CSS, <<SASS.encode("IBM866").force_encoding("UTF-8"))
|
36
|
-
@charset "UTF-8";
|
37
|
-
fЖЖ {
|
38
|
-
a: b; }
|
39
|
-
CSS
|
40
|
-
@charset "ibm866"
|
41
|
-
fЖЖ
|
42
|
-
a: b
|
43
|
-
SASS
|
44
|
-
end
|
45
|
-
|
46
|
-
def test_uses_ruby_encoding_without_charset
|
47
|
-
return skip "Can't be run on Ruby 1.8." if Sass::Util.ruby1_8?
|
48
|
-
|
49
|
-
assert_renders_encoded(<<CSS, <<SASS.encode("IBM866"))
|
50
|
-
@charset "UTF-8";
|
51
|
-
тАЬ {
|
52
|
-
a: b; }
|
53
|
-
CSS
|
54
|
-
тАЬ
|
55
|
-
a: b
|
56
|
-
SASS
|
57
|
-
end
|
58
|
-
|
59
|
-
def test_multibyte_charset_without_bom_declared_as_binary
|
60
|
-
return skip "Can't be run on Ruby 1.8." if Sass::Util.ruby1_8?
|
61
|
-
|
62
|
-
engine = Sass::Engine.new(<<SASS.encode("UTF-16LE").force_encoding("BINARY"))
|
63
|
-
@charset "utf-16le"
|
64
|
-
fóó
|
65
|
-
a: b
|
66
|
-
SASS
|
67
|
-
# Since multibyte encodings' @charset declarations aren't
|
68
|
-
# ASCII-compatible, we have to interpret the files as UTF-8 which will
|
69
|
-
# inevitably fail.
|
70
|
-
assert_raise_message(Sass::SyntaxError, "Invalid UTF-8 character \"\\xF3\"") {engine.render}
|
71
|
-
end
|
72
|
-
|
73
|
-
def test_multibyte_charset_without_bom_declared_as_utf_8
|
74
|
-
return skip "Can't be run on Ruby 1.8." if Sass::Util.ruby1_8?
|
75
|
-
|
76
|
-
engine = Sass::Engine.new(<<SASS.encode("UTF-16LE").force_encoding("UTF-8"))
|
77
|
-
@charset "utf-16le"
|
78
|
-
fóó
|
79
|
-
a: b
|
80
|
-
SASS
|
81
|
-
# Since multibyte encodings' @charset declarations aren't
|
82
|
-
# ASCII-compatible, we have to interpret the files as UTF-8 which will
|
83
|
-
# inevitably fail.
|
84
|
-
assert_raise_message(Sass::SyntaxError, "Invalid UTF-8 character \"\\xF3\"") {engine.render}
|
85
|
-
end
|
86
|
-
|
87
|
-
def test_utf_16le_with_bom
|
88
|
-
return skip "Can't be run on Ruby 1.8." if Sass::Util.ruby1_8?
|
89
|
-
|
90
|
-
assert_renders_encoded(<<CSS, <<SASS.encode("UTF-16LE").force_encoding("BINARY"))
|
91
|
-
@charset "UTF-8";
|
92
|
-
fóó {
|
93
|
-
a: b; }
|
94
|
-
CSS
|
95
|
-
\uFEFFfóó
|
96
|
-
a: b
|
97
|
-
SASS
|
98
|
-
end
|
99
|
-
|
100
|
-
def test_utf_16be_with_bom
|
101
|
-
return skip "Can't be run on Ruby 1.8." if Sass::Util.ruby1_8?
|
102
|
-
|
103
|
-
assert_renders_encoded(<<CSS, <<SASS.encode("UTF-16BE").force_encoding("BINARY"))
|
104
|
-
@charset "UTF-8";
|
105
|
-
fóó {
|
106
|
-
a: b; }
|
107
|
-
CSS
|
108
|
-
\uFEFFfóó
|
109
|
-
a: b
|
110
|
-
SASS
|
111
|
-
end
|
112
|
-
|
113
|
-
def test_utf_8_with_bom
|
114
|
-
return skip "Can't be run on Ruby 1.8." if Sass::Util.ruby1_8?
|
115
|
-
|
116
|
-
assert_renders_encoded(<<CSS, <<SASS.force_encoding("BINARY"))
|
117
|
-
@charset "UTF-8";
|
118
|
-
fóó {
|
119
|
-
a: b; }
|
120
|
-
CSS
|
121
|
-
\uFEFFfóó
|
122
|
-
a: b
|
123
|
-
SASS
|
124
|
-
end
|
125
|
-
|
126
|
-
def test_charset_with_multibyte_encoding
|
127
|
-
return skip "Can't be run on Ruby 1.8." if Sass::Util.ruby1_8?
|
128
|
-
|
129
|
-
engine = Sass::Engine.new(<<SASS)
|
130
|
-
@charset "utf-32be"
|
131
|
-
fóó
|
132
|
-
a: b
|
133
|
-
SASS
|
134
|
-
# The charset declaration is just false here, so we should get an
|
135
|
-
# encoding error.
|
136
|
-
assert_raise_message(Sass::SyntaxError, "Invalid UTF-32BE character \"\\xC3\"") {engine.render}
|
137
|
-
end
|
138
|
-
|
139
|
-
def test_charset_with_special_case_encoding
|
140
|
-
return skip "Can't be run on Ruby 1.8." if Sass::Util.ruby1_8?
|
141
|
-
|
142
|
-
# For some reason, a file with an ASCII-compatible UTF-16 charset
|
143
|
-
# declaration is specced to be parsed as UTF-8.
|
144
|
-
assert_renders_encoded(<<CSS, <<SASS.force_encoding("BINARY"))
|
145
|
-
@charset "UTF-8";
|
146
|
-
fóó {
|
147
|
-
a: b; }
|
148
|
-
CSS
|
149
|
-
@charset "utf-16"
|
150
|
-
fóó
|
151
|
-
a: b
|
152
|
-
SASS
|
153
|
-
end
|
154
|
-
|
155
|
-
def test_compressed_output_uses_bom
|
156
|
-
return skip "Can't be run on Ruby 1.8." if Sass::Util.ruby1_8?
|
157
|
-
|
158
|
-
assert_equal("\uFEFFfóó{a:b}\n", render(<<SASS, :style => :compressed))
|
159
|
-
fóó
|
160
|
-
a: b
|
161
|
-
SASS
|
162
|
-
end
|
163
|
-
|
164
|
-
def test_newline_normalization
|
165
|
-
assert_equal("/* foo\nbar\nbaz\nbang\nqux */\n",
|
166
|
-
render("/* foo\nbar\r\nbaz\fbang\rqux */", :syntax => :scss))
|
167
|
-
end
|
168
|
-
|
169
|
-
def test_null_normalization
|
170
|
-
return skip "Can't be run on Ruby 1.8." if Sass::Util.ruby1_8?
|
171
|
-
|
172
|
-
assert_equal(<<CSS, render("/* foo\x00bar\x00baz */", :syntax => :scss))
|
173
|
-
#{"@charset \"UTF-8\";\n" unless Sass::Util.ruby1_8?
|
174
|
-
}/* foo�bar�baz */
|
175
|
-
CSS
|
176
|
-
end
|
177
|
-
|
178
|
-
# Regression
|
179
|
-
|
180
|
-
def test_multibyte_prop_name
|
181
|
-
return skip "Can't be run on Ruby 1.8." if Sass::Util.ruby1_8?
|
182
|
-
|
183
|
-
assert_equal(<<CSS, render(<<SASS))
|
184
|
-
@charset "UTF-8";
|
185
|
-
#bar {
|
186
|
-
cölor: blue; }
|
187
|
-
CSS
|
188
|
-
#bar
|
189
|
-
cölor: blue
|
190
|
-
SASS
|
191
|
-
end
|
192
|
-
|
193
|
-
def test_multibyte_and_interpolation
|
194
|
-
return skip "Can't be run on Ruby 1.8." if Sass::Util.ruby1_8?
|
195
|
-
|
196
|
-
assert_equal(<<CSS, render(<<SCSS, :syntax => :scss))
|
197
|
-
#bar {
|
198
|
-
background: a 0%; }
|
199
|
-
CSS
|
200
|
-
#bar {
|
201
|
-
//
|
202
|
-
background: \#{a} 0%;
|
203
|
-
}
|
204
|
-
SCSS
|
205
|
-
end
|
206
|
-
|
207
|
-
private
|
208
|
-
|
209
|
-
def assert_renders_encoded(css, sass)
|
210
|
-
result = render(sass)
|
211
|
-
assert_equal css.encoding, result.encoding
|
212
|
-
assert_equal css, result
|
213
|
-
end
|
214
|
-
|
215
|
-
def render(sass, options = {})
|
216
|
-
munge_filename options
|
217
|
-
Sass::Engine.new(sass, options).render
|
218
|
-
end
|
219
|
-
end
|