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.
Files changed (176) hide show
  1. checksums.yaml +4 -4
  2. data/MIT-LICENSE +1 -1
  3. data/README.md +50 -70
  4. data/Rakefile +5 -26
  5. data/VERSION +1 -1
  6. data/VERSION_NAME +1 -1
  7. data/bin/sass +1 -1
  8. data/bin/scss +1 -1
  9. data/lib/sass.rb +12 -19
  10. data/lib/sass/cache_stores/base.rb +2 -2
  11. data/lib/sass/cache_stores/chain.rb +1 -2
  12. data/lib/sass/cache_stores/filesystem.rb +5 -1
  13. data/lib/sass/cache_stores/memory.rb +1 -1
  14. data/lib/sass/cache_stores/null.rb +2 -2
  15. data/lib/sass/callbacks.rb +0 -1
  16. data/lib/sass/css.rb +13 -11
  17. data/lib/sass/engine.rb +173 -424
  18. data/lib/sass/environment.rb +58 -148
  19. data/lib/sass/error.rb +14 -11
  20. data/lib/sass/exec.rb +703 -5
  21. data/lib/sass/importers/base.rb +6 -49
  22. data/lib/sass/importers/filesystem.rb +19 -44
  23. data/lib/sass/logger.rb +4 -1
  24. data/lib/sass/logger/base.rb +4 -2
  25. data/lib/sass/logger/log_level.rb +7 -3
  26. data/lib/sass/media.rb +23 -20
  27. data/lib/sass/plugin.rb +7 -7
  28. data/lib/sass/plugin/compiler.rb +145 -304
  29. data/lib/sass/plugin/configuration.rb +23 -18
  30. data/lib/sass/plugin/merb.rb +1 -1
  31. data/lib/sass/plugin/staleness_checker.rb +3 -3
  32. data/lib/sass/repl.rb +3 -3
  33. data/lib/sass/script.rb +8 -35
  34. data/lib/sass/script/{value/arg_list.rb → arg_list.rb} +25 -9
  35. data/lib/sass/script/bool.rb +18 -0
  36. data/lib/sass/script/color.rb +606 -0
  37. data/lib/sass/script/css_lexer.rb +4 -8
  38. data/lib/sass/script/css_parser.rb +2 -5
  39. data/lib/sass/script/funcall.rb +245 -0
  40. data/lib/sass/script/functions.rb +408 -1491
  41. data/lib/sass/script/interpolation.rb +79 -0
  42. data/lib/sass/script/lexer.rb +68 -172
  43. data/lib/sass/script/list.rb +85 -0
  44. data/lib/sass/script/literal.rb +221 -0
  45. data/lib/sass/script/{tree/node.rb → node.rb} +12 -22
  46. data/lib/sass/script/{value/null.rb → null.rb} +7 -14
  47. data/lib/sass/script/{value/number.rb → number.rb} +75 -152
  48. data/lib/sass/script/{tree/operation.rb → operation.rb} +24 -17
  49. data/lib/sass/script/parser.rb +110 -245
  50. data/lib/sass/script/string.rb +51 -0
  51. data/lib/sass/script/{tree/string_interpolation.rb → string_interpolation.rb} +4 -5
  52. data/lib/sass/script/{tree/unary_operation.rb → unary_operation.rb} +6 -6
  53. data/lib/sass/script/variable.rb +58 -0
  54. data/lib/sass/scss/css_parser.rb +3 -9
  55. data/lib/sass/scss/parser.rb +421 -450
  56. data/lib/sass/scss/rx.rb +11 -19
  57. data/lib/sass/scss/static_parser.rb +7 -321
  58. data/lib/sass/selector.rb +194 -68
  59. data/lib/sass/selector/abstract_sequence.rb +14 -29
  60. data/lib/sass/selector/comma_sequence.rb +25 -108
  61. data/lib/sass/selector/sequence.rb +66 -159
  62. data/lib/sass/selector/simple.rb +25 -23
  63. data/lib/sass/selector/simple_sequence.rb +63 -173
  64. data/lib/sass/shared.rb +1 -1
  65. data/lib/sass/supports.rb +15 -13
  66. data/lib/sass/tree/charset_node.rb +1 -1
  67. data/lib/sass/tree/comment_node.rb +3 -3
  68. data/lib/sass/tree/css_import_node.rb +11 -11
  69. data/lib/sass/tree/debug_node.rb +2 -2
  70. data/lib/sass/tree/directive_node.rb +4 -21
  71. data/lib/sass/tree/each_node.rb +8 -8
  72. data/lib/sass/tree/extend_node.rb +7 -14
  73. data/lib/sass/tree/for_node.rb +4 -4
  74. data/lib/sass/tree/function_node.rb +4 -9
  75. data/lib/sass/tree/if_node.rb +1 -1
  76. data/lib/sass/tree/import_node.rb +5 -4
  77. data/lib/sass/tree/media_node.rb +14 -4
  78. data/lib/sass/tree/mixin_def_node.rb +4 -4
  79. data/lib/sass/tree/mixin_node.rb +8 -21
  80. data/lib/sass/tree/node.rb +12 -54
  81. data/lib/sass/tree/prop_node.rb +20 -39
  82. data/lib/sass/tree/return_node.rb +2 -3
  83. data/lib/sass/tree/root_node.rb +3 -19
  84. data/lib/sass/tree/rule_node.rb +22 -35
  85. data/lib/sass/tree/supports_node.rb +13 -0
  86. data/lib/sass/tree/trace_node.rb +1 -2
  87. data/lib/sass/tree/variable_node.rb +3 -9
  88. data/lib/sass/tree/visitors/base.rb +8 -5
  89. data/lib/sass/tree/visitors/check_nesting.rb +19 -49
  90. data/lib/sass/tree/visitors/convert.rb +56 -74
  91. data/lib/sass/tree/visitors/cssize.rb +74 -202
  92. data/lib/sass/tree/visitors/deep_copy.rb +5 -10
  93. data/lib/sass/tree/visitors/extend.rb +7 -7
  94. data/lib/sass/tree/visitors/perform.rb +185 -278
  95. data/lib/sass/tree/visitors/set_options.rb +6 -20
  96. data/lib/sass/tree/visitors/to_css.rb +81 -234
  97. data/lib/sass/tree/warn_node.rb +2 -2
  98. data/lib/sass/tree/while_node.rb +2 -2
  99. data/lib/sass/util.rb +152 -522
  100. data/lib/sass/util/multibyte_string_scanner.rb +0 -2
  101. data/lib/sass/util/subset_map.rb +3 -4
  102. data/lib/sass/util/test.rb +1 -0
  103. data/lib/sass/version.rb +22 -20
  104. data/test/Gemfile +3 -0
  105. data/test/Gemfile.lock +10 -0
  106. data/test/sass/cache_test.rb +20 -62
  107. data/test/sass/callbacks_test.rb +1 -1
  108. data/test/sass/conversion_test.rb +2 -296
  109. data/test/sass/css2sass_test.rb +4 -23
  110. data/test/sass/engine_test.rb +354 -411
  111. data/test/sass/exec_test.rb +2 -2
  112. data/test/sass/extend_test.rb +145 -324
  113. data/test/sass/functions_test.rb +86 -873
  114. data/test/sass/importer_test.rb +21 -241
  115. data/test/sass/logger_test.rb +1 -1
  116. data/test/sass/more_results/more_import.css +1 -1
  117. data/test/sass/plugin_test.rb +26 -16
  118. data/test/sass/results/compact.css +1 -1
  119. data/test/sass/results/complex.css +4 -4
  120. data/test/sass/results/expanded.css +1 -1
  121. data/test/sass/results/import.css +1 -1
  122. data/test/sass/results/import_charset_ibm866.css +2 -2
  123. data/test/sass/results/mixins.css +17 -17
  124. data/test/sass/results/nested.css +1 -1
  125. data/test/sass/results/parent_ref.css +2 -2
  126. data/test/sass/results/script.css +3 -3
  127. data/test/sass/results/scss_import.css +1 -1
  128. data/test/sass/script_conversion_test.rb +7 -36
  129. data/test/sass/script_test.rb +53 -485
  130. data/test/sass/scss/css_test.rb +28 -143
  131. data/test/sass/scss/rx_test.rb +4 -4
  132. data/test/sass/scss/scss_test.rb +325 -2119
  133. data/test/sass/templates/scss_import.scss +1 -2
  134. data/test/sass/test_helper.rb +1 -1
  135. data/test/sass/util/multibyte_string_scanner_test.rb +1 -1
  136. data/test/sass/util/subset_map_test.rb +2 -2
  137. data/test/sass/util_test.rb +1 -86
  138. data/test/test_helper.rb +8 -37
  139. metadata +19 -66
  140. data/lib/sass/exec/base.rb +0 -187
  141. data/lib/sass/exec/sass_convert.rb +0 -264
  142. data/lib/sass/exec/sass_scss.rb +0 -424
  143. data/lib/sass/features.rb +0 -47
  144. data/lib/sass/script/tree.rb +0 -16
  145. data/lib/sass/script/tree/funcall.rb +0 -306
  146. data/lib/sass/script/tree/interpolation.rb +0 -118
  147. data/lib/sass/script/tree/list_literal.rb +0 -77
  148. data/lib/sass/script/tree/literal.rb +0 -45
  149. data/lib/sass/script/tree/map_literal.rb +0 -64
  150. data/lib/sass/script/tree/selector.rb +0 -26
  151. data/lib/sass/script/tree/variable.rb +0 -57
  152. data/lib/sass/script/value.rb +0 -11
  153. data/lib/sass/script/value/base.rb +0 -240
  154. data/lib/sass/script/value/bool.rb +0 -35
  155. data/lib/sass/script/value/color.rb +0 -680
  156. data/lib/sass/script/value/helpers.rb +0 -262
  157. data/lib/sass/script/value/list.rb +0 -113
  158. data/lib/sass/script/value/map.rb +0 -70
  159. data/lib/sass/script/value/string.rb +0 -97
  160. data/lib/sass/selector/pseudo.rb +0 -256
  161. data/lib/sass/source/map.rb +0 -210
  162. data/lib/sass/source/position.rb +0 -39
  163. data/lib/sass/source/range.rb +0 -41
  164. data/lib/sass/stack.rb +0 -120
  165. data/lib/sass/tree/at_root_node.rb +0 -83
  166. data/lib/sass/tree/error_node.rb +0 -18
  167. data/lib/sass/tree/keyframe_rule_node.rb +0 -15
  168. data/lib/sass/util/cross_platform_random.rb +0 -19
  169. data/lib/sass/util/normalized_map.rb +0 -130
  170. data/lib/sass/util/ordered_hash.rb +0 -192
  171. data/test/sass/compiler_test.rb +0 -232
  172. data/test/sass/encoding_test.rb +0 -219
  173. data/test/sass/source_map_test.rb +0 -977
  174. data/test/sass/superselector_test.rb +0 -191
  175. data/test/sass/util/normalized_map_test.rb +0 -51
  176. data/test/sass/value_helpers_test.rb +0 -179
data/lib/sass/features.rb DELETED
@@ -1,47 +0,0 @@
1
- require 'set'
2
- module Sass
3
- # Provides `Sass.has_feature?` which allows for simple feature detection
4
- # by providing a feature name.
5
- module Features
6
- # This is the set of features that can be detected.
7
- #
8
- # When this is updated, the documentation of `feature-exists()` should be
9
- # updated as well.
10
- KNOWN_FEATURES = Set[*%w{
11
- global-variable-shadowing
12
- extend-selector-pseudoclass
13
- units-level-3
14
- at-error
15
- }]
16
-
17
- # Check if a feature exists by name. This is used to implement
18
- # the Sass function `feature-exists($feature)`
19
- #
20
- # @param feature_name [String] The case sensitive name of the feature to
21
- # check if it exists in this version of Sass.
22
- # @return [Boolean] whether the feature of that name exists.
23
- def has_feature?(feature_name)
24
- KNOWN_FEATURES.include?(feature_name)
25
- end
26
-
27
- # Add a feature to Sass. Plugins can use this to easily expose their
28
- # availability to end users. Plugins must prefix their feature
29
- # names with a dash to distinguish them from official features.
30
- #
31
- # @example
32
- # Sass.add_feature("-import-globbing")
33
- # Sass.add_feature("-math-cos")
34
- #
35
- #
36
- # @param feature_name [String] The case sensitive name of the feature to
37
- # to add to Sass. Must begin with a dash.
38
- def add_feature(feature_name)
39
- unless feature_name[0] == ?-
40
- raise ArgumentError.new("Plugin feature names must begin with a dash")
41
- end
42
- KNOWN_FEATURES << feature_name
43
- end
44
- end
45
-
46
- extend Features
47
- end
@@ -1,16 +0,0 @@
1
- # The module containing nodes in the SassScript parse tree. These nodes are
2
- # all subclasses of {Sass::Script::Tree::Node}.
3
- module Sass::Script::Tree
4
- end
5
-
6
- require 'sass/script/tree/node'
7
- require 'sass/script/tree/variable'
8
- require 'sass/script/tree/funcall'
9
- require 'sass/script/tree/operation'
10
- require 'sass/script/tree/unary_operation'
11
- require 'sass/script/tree/interpolation'
12
- require 'sass/script/tree/string_interpolation'
13
- require 'sass/script/tree/literal'
14
- require 'sass/script/tree/list_literal'
15
- require 'sass/script/tree/map_literal'
16
- require 'sass/script/tree/selector'
@@ -1,306 +0,0 @@
1
- require 'sass/script/functions'
2
- require 'sass/util/normalized_map'
3
-
4
- module Sass::Script::Tree
5
- # A SassScript parse node representing a function call.
6
- #
7
- # A function call either calls one of the functions in
8
- # {Sass::Script::Functions}, or if no function with the given name exists it
9
- # returns a string representation of the function call.
10
- class Funcall < Node
11
- # The name of the function.
12
- #
13
- # @return [String]
14
- attr_reader :name
15
-
16
- # The arguments to the function.
17
- #
18
- # @return [Array<Node>]
19
- attr_reader :args
20
-
21
- # The keyword arguments to the function.
22
- #
23
- # @return [Sass::Util::NormalizedMap<Node>]
24
- attr_reader :keywords
25
-
26
- # The first splat argument for this function, if one exists.
27
- #
28
- # This could be a list of positional arguments, a map of keyword
29
- # arguments, or an arglist containing both.
30
- #
31
- # @return [Node?]
32
- attr_accessor :splat
33
-
34
- # The second splat argument for this function, if one exists.
35
- #
36
- # If this exists, it's always a map of keyword arguments, and
37
- # \{#splat} is always either a list or an arglist.
38
- #
39
- # @return [Node?]
40
- attr_accessor :kwarg_splat
41
-
42
- # @param name [String] See \{#name}
43
- # @param args [Array<Node>] See \{#args}
44
- # @param keywords [Sass::Util::NormalizedMap<Node>] See \{#keywords}
45
- # @param splat [Node] See \{#splat}
46
- # @param kwarg_splat [Node] See \{#kwarg_splat}
47
- def initialize(name, args, keywords, splat, kwarg_splat)
48
- @name = name
49
- @args = args
50
- @keywords = keywords
51
- @splat = splat
52
- @kwarg_splat = kwarg_splat
53
- super()
54
- end
55
-
56
- # @return [String] A string representation of the function call
57
- def inspect
58
- args = @args.map {|a| a.inspect}.join(', ')
59
- keywords = Sass::Util.hash_to_a(@keywords.as_stored).
60
- map {|k, v| "$#{k}: #{v.inspect}"}.join(', ')
61
- # rubocop:disable RedundantSelf
62
- if self.splat
63
- splat = args.empty? && keywords.empty? ? "" : ", "
64
- splat = "#{splat}#{self.splat.inspect}..."
65
- splat = "#{splat}, #{kwarg_splat.inspect}..." if kwarg_splat
66
- end
67
- # rubocop:enable RedundantSelf
68
- "#{name}(#{args}#{', ' unless args.empty? || keywords.empty?}#{keywords}#{splat})"
69
- end
70
-
71
- # @see Node#to_sass
72
- def to_sass(opts = {})
73
- arg_to_sass = lambda do |arg|
74
- sass = arg.to_sass(opts)
75
- sass = "(#{sass})" if arg.is_a?(Sass::Script::Tree::ListLiteral) && arg.separator == :comma
76
- sass
77
- end
78
-
79
- args = @args.map(&arg_to_sass)
80
- keywords = Sass::Util.hash_to_a(@keywords.as_stored).
81
- map {|k, v| "$#{dasherize(k, opts)}: #{arg_to_sass[v]}"}
82
-
83
- # rubocop:disable RedundantSelf
84
- if self.splat
85
- splat = "#{arg_to_sass[self.splat]}..."
86
- kwarg_splat = "#{arg_to_sass[self.kwarg_splat]}..." if self.kwarg_splat
87
- end
88
- # rubocop:enable RedundantSelf
89
-
90
- arglist = [args, splat, keywords, kwarg_splat].flatten.compact.join(', ')
91
- "#{dasherize(name, opts)}(#{arglist})"
92
- end
93
-
94
- # Returns the arguments to the function.
95
- #
96
- # @return [Array<Node>]
97
- # @see Node#children
98
- def children
99
- res = @args + @keywords.values
100
- res << @splat if @splat
101
- res << @kwarg_splat if @kwarg_splat
102
- res
103
- end
104
-
105
- # @see Node#deep_copy
106
- def deep_copy
107
- node = dup
108
- node.instance_variable_set('@args', args.map {|a| a.deep_copy})
109
- copied_keywords = Sass::Util::NormalizedMap.new
110
- @keywords.as_stored.each {|k, v| copied_keywords[k] = v.deep_copy}
111
- node.instance_variable_set('@keywords', copied_keywords)
112
- node
113
- end
114
-
115
- protected
116
-
117
- # Evaluates the function call.
118
- #
119
- # @param environment [Sass::Environment] The environment in which to evaluate the SassScript
120
- # @return [Sass::Script::Value] The SassScript object that is the value of the function call
121
- # @raise [Sass::SyntaxError] if the function call raises an ArgumentError
122
- def _perform(environment)
123
- args = Sass::Util.enum_with_index(@args).
124
- map {|a, i| perform_arg(a, environment, signature && signature.args[i])}
125
- keywords = Sass::Util.map_hash(@keywords) do |k, v|
126
- [k, perform_arg(v, environment, k.tr('-', '_'))]
127
- end
128
- splat = Sass::Tree::Visitors::Perform.perform_splat(
129
- @splat, keywords, @kwarg_splat, environment)
130
- if (fn = environment.function(@name))
131
- return without_original(perform_sass_fn(fn, args, splat, environment))
132
- end
133
-
134
- args = construct_ruby_args(ruby_name, args, splat, environment)
135
-
136
- if Sass::Script::Functions.callable?(ruby_name)
137
- local_environment = Sass::Environment.new(environment.global_env, environment.options)
138
- local_environment.caller = Sass::ReadOnlyEnvironment.new(environment, environment.options)
139
- result = opts(Sass::Script::Functions::EvaluationContext.new(
140
- local_environment).send(ruby_name, *args))
141
- without_original(result)
142
- else
143
- opts(to_literal(args))
144
- end
145
- rescue ArgumentError => e
146
- reformat_argument_error(e)
147
- end
148
-
149
- # Compass historically overrode this before it changed name to {Funcall#to_value}.
150
- # We should get rid of it in the future.
151
- def to_literal(args)
152
- to_value(args)
153
- end
154
-
155
- # This method is factored out from `_perform` so that compass can override
156
- # it with a cross-browser implementation for functions that require vendor prefixes
157
- # in the generated css.
158
- def to_value(args)
159
- Sass::Script::Value::String.new("#{name}(#{args.join(', ')})")
160
- end
161
-
162
- private
163
-
164
- def ruby_name
165
- @ruby_name ||= @name.tr('-', '_')
166
- end
167
-
168
- def perform_arg(argument, environment, name)
169
- return argument if signature && signature.delayed_args.include?(name)
170
- argument.perform(environment)
171
- end
172
-
173
- def signature
174
- @signature ||= Sass::Script::Functions.signature(name.to_sym, @args.size, @keywords.size)
175
- end
176
-
177
- def without_original(value)
178
- return value unless value.is_a?(Sass::Script::Value::Number)
179
- value = value.dup
180
- value.original = nil
181
- value
182
- end
183
-
184
- def construct_ruby_args(name, args, splat, environment)
185
- args += splat.to_a if splat
186
-
187
- # All keywords are contained in splat.keywords for consistency,
188
- # even if there were no splats passed in.
189
- old_keywords_accessed = splat.keywords_accessed
190
- keywords = splat.keywords
191
- splat.keywords_accessed = old_keywords_accessed
192
-
193
- unless (signature = Sass::Script::Functions.signature(name.to_sym, args.size, keywords.size))
194
- return args if keywords.empty?
195
- raise Sass::SyntaxError.new("Function #{name} doesn't support keyword arguments")
196
- end
197
-
198
- # If the user passes more non-keyword args than the function expects,
199
- # but it does expect keyword args, Ruby's arg handling won't raise an error.
200
- # Since we don't want to make functions think about this,
201
- # we'll handle it for them here.
202
- if signature.var_kwargs && !signature.var_args && args.size > signature.args.size
203
- raise Sass::SyntaxError.new(
204
- "#{args[signature.args.size].inspect} is not a keyword argument for `#{name}'")
205
- elsif keywords.empty?
206
- return args
207
- end
208
-
209
- argnames = signature.args[args.size..-1] || []
210
- deprecated_argnames = (signature.deprecated && signature.deprecated[args.size..-1]) || []
211
- args = args + argnames.zip(deprecated_argnames).map do |(argname, deprecated_argname)|
212
- if keywords.has_key?(argname)
213
- keywords.delete(argname)
214
- elsif deprecated_argname && keywords.has_key?(deprecated_argname)
215
- deprecated_argname = keywords.denormalize(deprecated_argname)
216
- Sass::Util.sass_warn("DEPRECATION WARNING: The `$#{deprecated_argname}' argument for " +
217
- "`#{@name}()' has been renamed to `$#{argname}'.")
218
- keywords.delete(deprecated_argname)
219
- else
220
- raise Sass::SyntaxError.new("Function #{name} requires an argument named $#{argname}")
221
- end
222
- end
223
-
224
- if keywords.size > 0
225
- if signature.var_kwargs
226
- # Don't pass a NormalizedMap to a Ruby function.
227
- args << keywords.to_hash
228
- else
229
- argname = keywords.keys.sort.first
230
- if signature.args.include?(argname)
231
- raise Sass::SyntaxError.new(
232
- "Function #{name} was passed argument $#{argname} both by position and by name")
233
- else
234
- raise Sass::SyntaxError.new(
235
- "Function #{name} doesn't have an argument named $#{argname}")
236
- end
237
- end
238
- end
239
-
240
- args
241
- end
242
-
243
- def perform_sass_fn(function, args, splat, environment)
244
- Sass::Tree::Visitors::Perform.perform_arguments(function, args, splat) do |env|
245
- env.caller = Sass::Environment.new(environment)
246
-
247
- val = catch :_sass_return do
248
- function.tree.each {|c| Sass::Tree::Visitors::Perform.visit(c, env)}
249
- raise Sass::SyntaxError.new("Function #{@name} finished without @return")
250
- end
251
- val
252
- end
253
- end
254
-
255
- def reformat_argument_error(e)
256
- message = e.message
257
-
258
- # If this is a legitimate Ruby-raised argument error, re-raise it.
259
- # Otherwise, it's an error in the user's stylesheet, so wrap it.
260
- if Sass::Util.rbx?
261
- # Rubinius has a different error report string than vanilla Ruby. It
262
- # also doesn't put the actual method for which the argument error was
263
- # thrown in the backtrace, nor does it include `send`, so we look for
264
- # `_perform`.
265
- if e.message =~ /^method '([^']+)': given (\d+), expected (\d+)/
266
- error_name, given, expected = $1, $2, $3
267
- raise e if error_name != ruby_name || e.backtrace[0] !~ /:in `_perform'$/
268
- message = "wrong number of arguments (#{given} for #{expected})"
269
- end
270
- elsif Sass::Util.jruby?
271
- if Sass::Util.jruby1_6?
272
- should_maybe_raise = e.message =~ /^wrong number of arguments \((\d+) for (\d+)\)/ &&
273
- # The one case where JRuby does include the Ruby name of the function
274
- # is manually-thrown ArgumentErrors, which are indistinguishable from
275
- # legitimate ArgumentErrors. We treat both of these as
276
- # Sass::SyntaxErrors even though it can hide Ruby errors.
277
- e.backtrace[0] !~ /:in `(block in )?#{ruby_name}'$/
278
- else
279
- should_maybe_raise =
280
- e.message =~ /^wrong number of arguments calling `[^`]+` \((\d+) for (\d+)\)/
281
- given, expected = $1, $2
282
- end
283
-
284
- if should_maybe_raise
285
- # JRuby 1.7 includes __send__ before send and _perform.
286
- trace = e.backtrace.dup
287
- raise e if !Sass::Util.jruby1_6? && trace.shift !~ /:in `__send__'$/
288
-
289
- # JRuby (as of 1.7.2) doesn't put the actual method
290
- # for which the argument error was thrown in the backtrace, so we
291
- # detect whether our send threw an argument error.
292
- if !(trace[0] =~ /:in `send'$/ && trace[1] =~ /:in `_perform'$/)
293
- raise e
294
- elsif !Sass::Util.jruby1_6?
295
- # JRuby 1.7 doesn't use standard formatting for its ArgumentErrors.
296
- message = "wrong number of arguments (#{given} for #{expected})"
297
- end
298
- end
299
- elsif e.message =~ /^wrong number of arguments \(\d+ for \d+\)/ &&
300
- e.backtrace[0] !~ /:in `(block in )?#{ruby_name}'$/
301
- raise e
302
- end
303
- raise Sass::SyntaxError.new("#{message} for `#{name}'")
304
- end
305
- end
306
- end
@@ -1,118 +0,0 @@
1
- module Sass::Script::Tree
2
- # A SassScript object representing `#{}` interpolation outside a string.
3
- #
4
- # @see StringInterpolation
5
- class Interpolation < Node
6
- # @return [Node] The SassScript before the interpolation
7
- attr_reader :before
8
-
9
- # @return [Node] The SassScript within the interpolation
10
- attr_reader :mid
11
-
12
- # @return [Node] The SassScript after the interpolation
13
- attr_reader :after
14
-
15
- # @return [Boolean] Whether there was whitespace between `before` and `#{`
16
- attr_reader :whitespace_before
17
-
18
- # @return [Boolean] Whether there was whitespace between `}` and `after`
19
- attr_reader :whitespace_after
20
-
21
- # @return [Boolean] Whether the original format of the interpolation was
22
- # plain text, not an interpolation. This is used when converting back to
23
- # SassScript.
24
- attr_reader :originally_text
25
-
26
- # @return [Boolean] Whether a color value passed to the interpolation should
27
- # generate a warning.
28
- attr_reader :warn_for_color
29
-
30
- # Interpolation in a property is of the form `before #{mid} after`.
31
- #
32
- # @param before [Node] See {Interpolation#before}
33
- # @param mid [Node] See {Interpolation#mid}
34
- # @param after [Node] See {Interpolation#after}
35
- # @param wb [Boolean] See {Interpolation#whitespace_before}
36
- # @param wa [Boolean] See {Interpolation#whitespace_after}
37
- # @param originally_text [Boolean] See {Interpolation#originally_text}
38
- # @param warn_for_color [Boolean] See {Interpolation#warn_for_color}
39
- # @comment
40
- # rubocop:disable ParameterLists
41
- def initialize(before, mid, after, wb, wa, originally_text = false, warn_for_color = false)
42
- # rubocop:enable ParameterLists
43
- @before = before
44
- @mid = mid
45
- @after = after
46
- @whitespace_before = wb
47
- @whitespace_after = wa
48
- @originally_text = originally_text
49
- @warn_for_color = warn_for_color
50
- end
51
-
52
- # @return [String] A human-readable s-expression representation of the interpolation
53
- def inspect
54
- "(interpolation #{@before.inspect} #{@mid.inspect} #{@after.inspect})"
55
- end
56
-
57
- # @see Node#to_sass
58
- def to_sass(opts = {})
59
- res = ""
60
- res << @before.to_sass(opts) if @before
61
- res << ' ' if @before && @whitespace_before
62
- res << '#{' unless @originally_text
63
- res << @mid.to_sass(opts)
64
- res << '}' unless @originally_text
65
- res << ' ' if @after && @whitespace_after
66
- res << @after.to_sass(opts) if @after
67
- res
68
- end
69
-
70
- # Returns the three components of the interpolation, `before`, `mid`, and `after`.
71
- #
72
- # @return [Array<Node>]
73
- # @see #initialize
74
- # @see Node#children
75
- def children
76
- [@before, @mid, @after].compact
77
- end
78
-
79
- # @see Node#deep_copy
80
- def deep_copy
81
- node = dup
82
- node.instance_variable_set('@before', @before.deep_copy) if @before
83
- node.instance_variable_set('@mid', @mid.deep_copy)
84
- node.instance_variable_set('@after', @after.deep_copy) if @after
85
- node
86
- end
87
-
88
- protected
89
-
90
- # Evaluates the interpolation.
91
- #
92
- # @param environment [Sass::Environment] The environment in which to evaluate the SassScript
93
- # @return [Sass::Script::Value::String]
94
- # The SassScript string that is the value of the interpolation
95
- def _perform(environment)
96
- res = ""
97
- res << @before.perform(environment).to_s if @before
98
- res << " " if @before && @whitespace_before
99
-
100
- val = @mid.perform(environment)
101
- if @warn_for_color && val.is_a?(Sass::Script::Value::Color) && val.name
102
- alternative = Operation.new(Sass::Script::Value::String.new("", :string), @mid, :plus)
103
- Sass::Util.sass_warn <<MESSAGE
104
- WARNING on line #{line}, column #{source_range.start_pos.offset}#{" of #{filename}" if filename}:
105
- You probably don't mean to use the color value `#{val}' in interpolation here.
106
- It may end up represented as #{val.inspect}, which will likely produce invalid CSS.
107
- Always quote color names when using them as strings (for example, "#{val}").
108
- If you really want to use the color value here, use `#{alternative.to_sass}'.
109
- MESSAGE
110
- end
111
-
112
- res << val.to_s(:quote => :none)
113
- res << " " if @after && @whitespace_after
114
- res << @after.perform(environment).to_s if @after
115
- opts(Sass::Script::Value::String.new(res))
116
- end
117
- end
118
- end