sass 3.4.25 → 3.5.0.pre.rc.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (156) hide show
  1. checksums.yaml +4 -4
  2. data/.yardopts +1 -1
  3. data/README.md +1 -1
  4. data/Rakefile +13 -157
  5. data/VERSION +1 -1
  6. data/VERSION_DATE +1 -1
  7. data/VERSION_NAME +1 -1
  8. data/lib/sass.rb +3 -10
  9. data/lib/sass/cache_stores/filesystem.rb +1 -1
  10. data/lib/sass/css.rb +2 -3
  11. data/lib/sass/engine.rb +46 -32
  12. data/lib/sass/environment.rb +27 -6
  13. data/lib/sass/error.rb +5 -5
  14. data/lib/sass/exec/base.rb +3 -12
  15. data/lib/sass/features.rb +1 -0
  16. data/lib/sass/importers/filesystem.rb +2 -2
  17. data/lib/sass/plugin.rb +1 -1
  18. data/lib/sass/plugin/compiler.rb +21 -51
  19. data/lib/sass/plugin/configuration.rb +1 -1
  20. data/lib/sass/plugin/rack.rb +3 -3
  21. data/lib/sass/plugin/staleness_checker.rb +3 -3
  22. data/lib/sass/railtie.rb +1 -1
  23. data/lib/sass/script.rb +3 -3
  24. data/lib/sass/script/functions.rb +238 -47
  25. data/lib/sass/script/lexer.rb +8 -6
  26. data/lib/sass/script/parser.rb +76 -75
  27. data/lib/sass/script/tree/funcall.rb +35 -30
  28. data/lib/sass/script/tree/list_literal.rb +23 -8
  29. data/lib/sass/script/tree/map_literal.rb +2 -2
  30. data/lib/sass/script/tree/node.rb +2 -10
  31. data/lib/sass/script/tree/operation.rb +16 -50
  32. data/lib/sass/script/value.rb +2 -0
  33. data/lib/sass/script/value/arg_list.rb +1 -1
  34. data/lib/sass/script/value/base.rb +20 -3
  35. data/lib/sass/script/value/callable.rb +25 -0
  36. data/lib/sass/script/value/color.rb +10 -10
  37. data/lib/sass/script/value/function.rb +19 -0
  38. data/lib/sass/script/value/helpers.rb +16 -7
  39. data/lib/sass/script/value/list.rb +33 -12
  40. data/lib/sass/script/value/map.rb +2 -2
  41. data/lib/sass/script/value/number.rb +3 -3
  42. data/lib/sass/script/value/string.rb +12 -5
  43. data/lib/sass/scss/parser.rb +101 -45
  44. data/lib/sass/scss/rx.rb +5 -11
  45. data/lib/sass/scss/static_parser.rb +0 -7
  46. data/lib/sass/selector.rb +4 -0
  47. data/lib/sass/selector/abstract_sequence.rb +5 -5
  48. data/lib/sass/selector/comma_sequence.rb +3 -15
  49. data/lib/sass/selector/pseudo.rb +4 -0
  50. data/lib/sass/selector/sequence.rb +30 -3
  51. data/lib/sass/selector/simple.rb +13 -7
  52. data/lib/sass/selector/simple_sequence.rb +1 -1
  53. data/lib/sass/shared.rb +3 -5
  54. data/lib/sass/source/map.rb +4 -4
  55. data/lib/sass/source/position.rb +4 -4
  56. data/lib/sass/stack.rb +21 -1
  57. data/lib/sass/tree/charset_node.rb +1 -1
  58. data/lib/sass/tree/comment_node.rb +1 -1
  59. data/lib/sass/tree/node.rb +3 -3
  60. data/lib/sass/tree/prop_node.rb +46 -54
  61. data/lib/sass/tree/rule_node.rb +7 -15
  62. data/lib/sass/tree/visitors/check_nesting.rb +1 -1
  63. data/lib/sass/tree/visitors/convert.rb +2 -3
  64. data/lib/sass/tree/visitors/cssize.rb +1 -10
  65. data/lib/sass/tree/visitors/deep_copy.rb +2 -2
  66. data/lib/sass/tree/visitors/perform.rb +23 -12
  67. data/lib/sass/tree/visitors/set_options.rb +1 -1
  68. data/lib/sass/tree/visitors/to_css.rb +46 -12
  69. data/lib/sass/util.rb +16 -321
  70. data/lib/sass/util/multibyte_string_scanner.rb +127 -131
  71. data/lib/sass/util/normalized_map.rb +1 -8
  72. data/lib/sass/version.rb +2 -2
  73. data/test/sass-spec.yml +1 -1
  74. data/test/sass/compiler_test.rb +4 -14
  75. data/test/sass/conversion_test.rb +113 -162
  76. data/test/sass/css2sass_test.rb +17 -19
  77. data/test/sass/css_variable_test.rb +176 -70
  78. data/test/sass/encoding_test.rb +2 -32
  79. data/test/sass/engine_test.rb +114 -65
  80. data/test/sass/extend_test.rb +37 -51
  81. data/test/sass/functions_test.rb +57 -15
  82. data/test/sass/importer_test.rb +2 -2
  83. data/test/sass/more_templates/more1.sass +10 -10
  84. data/test/sass/more_templates/more_import.sass +2 -2
  85. data/test/sass/plugin_test.rb +9 -12
  86. data/test/sass/script_conversion_test.rb +9 -0
  87. data/test/sass/script_test.rb +38 -48
  88. data/test/sass/scss/css_test.rb +5 -19
  89. data/test/sass/scss/scss_test.rb +58 -39
  90. data/test/sass/source_map_test.rb +26 -28
  91. data/test/sass/templates/_partial.sass +1 -1
  92. data/test/sass/templates/basic.sass +10 -10
  93. data/test/sass/templates/bork1.sass +1 -1
  94. data/test/sass/templates/bork5.sass +1 -1
  95. data/test/sass/templates/compact.sass +10 -10
  96. data/test/sass/templates/complex.sass +187 -187
  97. data/test/sass/templates/compressed.sass +10 -10
  98. data/test/sass/templates/expanded.sass +10 -10
  99. data/test/sass/templates/import.sass +2 -2
  100. data/test/sass/templates/importee.sass +3 -3
  101. data/test/sass/templates/mixins.sass +22 -22
  102. data/test/sass/templates/multiline.sass +4 -4
  103. data/test/sass/templates/nested.sass +13 -13
  104. data/test/sass/templates/parent_ref.sass +12 -12
  105. data/test/sass/templates/script.sass +70 -70
  106. data/test/sass/templates/subdir/nested_subdir/_nested_partial.sass +1 -1
  107. data/test/sass/templates/subdir/nested_subdir/nested_subdir.sass +2 -2
  108. data/test/sass/templates/subdir/subdir.sass +3 -3
  109. data/test/sass/templates/units.sass +10 -10
  110. data/test/sass/util/multibyte_string_scanner_test.rb +139 -149
  111. data/test/sass/util_test.rb +0 -36
  112. data/test/test_helper.rb +39 -0
  113. metadata +30 -57
  114. data/extra/sass-spec-ref.sh +0 -32
  115. data/lib/sass/deprecation.rb +0 -55
  116. data/lib/sass/script/css_variable_warning.rb +0 -52
  117. data/lib/sass/util/cross_platform_random.rb +0 -19
  118. data/lib/sass/util/ordered_hash.rb +0 -192
  119. data/test/sass/results/import_charset_1_8.css +0 -5
  120. data/test/sass/templates/import_charset_1_8.sass +0 -6
  121. data/vendor/listen/CHANGELOG.md +0 -1
  122. data/vendor/listen/CONTRIBUTING.md +0 -38
  123. data/vendor/listen/Gemfile +0 -20
  124. data/vendor/listen/Guardfile +0 -8
  125. data/vendor/listen/LICENSE +0 -20
  126. data/vendor/listen/README.md +0 -349
  127. data/vendor/listen/Rakefile +0 -5
  128. data/vendor/listen/Vagrantfile +0 -96
  129. data/vendor/listen/lib/listen.rb +0 -54
  130. data/vendor/listen/lib/listen/adapter.rb +0 -327
  131. data/vendor/listen/lib/listen/adapters/bsd.rb +0 -75
  132. data/vendor/listen/lib/listen/adapters/darwin.rb +0 -48
  133. data/vendor/listen/lib/listen/adapters/linux.rb +0 -81
  134. data/vendor/listen/lib/listen/adapters/polling.rb +0 -58
  135. data/vendor/listen/lib/listen/adapters/windows.rb +0 -91
  136. data/vendor/listen/lib/listen/directory_record.rb +0 -406
  137. data/vendor/listen/lib/listen/listener.rb +0 -323
  138. data/vendor/listen/lib/listen/turnstile.rb +0 -32
  139. data/vendor/listen/lib/listen/version.rb +0 -3
  140. data/vendor/listen/listen.gemspec +0 -28
  141. data/vendor/listen/spec/listen/adapter_spec.rb +0 -149
  142. data/vendor/listen/spec/listen/adapters/bsd_spec.rb +0 -36
  143. data/vendor/listen/spec/listen/adapters/darwin_spec.rb +0 -37
  144. data/vendor/listen/spec/listen/adapters/linux_spec.rb +0 -47
  145. data/vendor/listen/spec/listen/adapters/polling_spec.rb +0 -68
  146. data/vendor/listen/spec/listen/adapters/windows_spec.rb +0 -30
  147. data/vendor/listen/spec/listen/directory_record_spec.rb +0 -1250
  148. data/vendor/listen/spec/listen/listener_spec.rb +0 -258
  149. data/vendor/listen/spec/listen/turnstile_spec.rb +0 -56
  150. data/vendor/listen/spec/listen_spec.rb +0 -67
  151. data/vendor/listen/spec/spec_helper.rb +0 -25
  152. data/vendor/listen/spec/support/adapter_helper.rb +0 -666
  153. data/vendor/listen/spec/support/directory_record_helper.rb +0 -57
  154. data/vendor/listen/spec/support/fixtures_helper.rb +0 -29
  155. data/vendor/listen/spec/support/listeners_helper.rb +0 -179
  156. data/vendor/listen/spec/support/platform_helper.rb +0 -15
@@ -13,13 +13,20 @@ module Sass::Script::Tree
13
13
  # @return [Symbol]
14
14
  attr_reader :separator
15
15
 
16
+ # Whether the list is surrounded by square brackets.
17
+ #
18
+ # @return [Boolean]
19
+ attr_reader :bracketed
20
+
16
21
  # Creates a new list literal.
17
22
  #
18
23
  # @param elements [Array<Node>] See \{#elements}
19
24
  # @param separator [Symbol] See \{#separator}
20
- def initialize(elements, separator)
25
+ # @param bracketed [Boolean] See \{#bracketed}
26
+ def initialize(elements, separator: nil, bracketed: false)
21
27
  @elements = elements
22
28
  @separator = separator
29
+ @bracketed = bracketed
23
30
  end
24
31
 
25
32
  # @see Node#children
@@ -27,7 +34,7 @@ module Sass::Script::Tree
27
34
 
28
35
  # @see Value#to_sass
29
36
  def to_sass(opts = {})
30
- return "()" if elements.empty?
37
+ return bracketed ? "[]" : "()" if elements.empty?
31
38
  members = elements.map do |v|
32
39
  if element_needs_parens?(v)
33
40
  "(#{v.to_sass(opts)})"
@@ -36,9 +43,12 @@ module Sass::Script::Tree
36
43
  end
37
44
  end
38
45
 
39
- return "(#{members.first},)" if separator == :comma && members.length == 1
46
+ if separator == :comma && members.length == 1
47
+ return "#{bracketed ? '[' : '('}#{members.first},#{bracketed ? ']' : ')'}"
48
+ end
40
49
 
41
- members.join(sep_str(nil))
50
+ contents = members.join(sep_str(nil))
51
+ bracketed ? "[#{contents}]" : contents
42
52
  end
43
53
 
44
54
  # @see Node#deep_copy
@@ -49,7 +59,9 @@ module Sass::Script::Tree
49
59
  end
50
60
 
51
61
  def inspect
52
- "(#{elements.map {|e| e.inspect}.join(separator == :space ? ' ' : ', ')})"
62
+ (bracketed ? '[' : '(') +
63
+ elements.map {|e| e.inspect}.join(separator == :space ? ' ' : ', ') +
64
+ (bracketed ? ']' : ')')
53
65
  end
54
66
 
55
67
  def force_division!
@@ -61,7 +73,8 @@ module Sass::Script::Tree
61
73
  def _perform(environment)
62
74
  list = Sass::Script::Value::List.new(
63
75
  elements.map {|e| e.perform(environment)},
64
- separator)
76
+ separator: separator,
77
+ bracketed: bracketed)
65
78
  list.source_range = source_range
66
79
  list.options = options
67
80
  list
@@ -73,8 +86,10 @@ module Sass::Script::Tree
73
86
  # when serialized to Sass.
74
87
  def element_needs_parens?(element)
75
88
  if element.is_a?(ListLiteral)
76
- return Sass::Script::Parser.precedence_of(element.separator) <=
77
- Sass::Script::Parser.precedence_of(separator)
89
+ return false if element.elements.length < 2
90
+ return false if element.bracketed
91
+ return Sass::Script::Parser.precedence_of(element.separator || :space) <=
92
+ Sass::Script::Parser.precedence_of(separator || :space)
78
93
  end
79
94
 
80
95
  return false unless separator == :space
@@ -49,14 +49,14 @@ module Sass::Script::Tree
49
49
  # @see Node#_perform
50
50
  def _perform(environment)
51
51
  keys = Set.new
52
- map = Sass::Script::Value::Map.new(Sass::Util.to_hash(pairs.map do |(k, v)|
52
+ map = Sass::Script::Value::Map.new(Hash[pairs.map do |(k, v)|
53
53
  k, v = k.perform(environment), v.perform(environment)
54
54
  if keys.include?(k)
55
55
  raise Sass::SyntaxError.new("Duplicate key #{k.inspect} in map #{to_sass}.")
56
56
  end
57
57
  keys << k
58
58
  [k, v]
59
- end))
59
+ end])
60
60
  map.options = options
61
61
  map
62
62
  end
@@ -10,7 +10,7 @@ module Sass::Script::Tree
10
10
 
11
11
  # The line of the document on which this node appeared.
12
12
  #
13
- # @return [Integer]
13
+ # @return [Fixnum]
14
14
  attr_accessor :line
15
15
 
16
16
  # The source range in the document on which this node appeared.
@@ -23,17 +23,9 @@ module Sass::Script::Tree
23
23
  # @return [String]
24
24
  attr_accessor :filename
25
25
 
26
- # The warning that this node should emit if it executes in a way that's not
27
- # safe for a CSS variable value.
28
- #
29
- # This is `nil` if this is not in a CSS variable value.
30
- #
31
- # @return [Sass::Script::CssVariableWarning]
32
- attr_accessor :css_variable_warning
33
-
34
26
  # Sets the options hash for this node,
35
27
  # as well as for all child nodes.
36
- # See {file:SASS_REFERENCE.md#Options the Sass options documentation}.
28
+ # See {file:SASS_REFERENCE.md#options the Sass options documentation}.
37
29
  #
38
30
  # @param options [{Symbol => Object}] The options
39
31
  def options=(options)
@@ -2,9 +2,6 @@ module Sass::Script::Tree
2
2
  # A SassScript parse node representing a binary operation,
3
3
  # such as `$a + $b` or `"foo" + 1`.
4
4
  class Operation < Node
5
- @@color_arithmetic_deprecation = Sass::Deprecation.new
6
- @@unitless_equals_deprecation = Sass::Deprecation.new
7
-
8
5
  attr_reader :operand1
9
6
  attr_reader :operand2
10
7
  attr_reader :operator
@@ -81,13 +78,6 @@ module Sass::Script::Tree
81
78
  "Invalid null operation: \"#{value1.inspect} #{@operator} #{value2.inspect}\".")
82
79
  end
83
80
 
84
- if css_variable_warning && @operator == :div &&
85
- !(value1.is_a?(Sass::Script::Value::Number) && value1.original &&
86
- value2.is_a?(Sass::Script::Value::Number) && value2.original) &&
87
- !(value1.is_a?(Sass::Script::Value::String) && value2.is_a?(Sass::Script::Value::String))
88
- css_variable_warning.warn!
89
- end
90
-
91
81
  begin
92
82
  result = opts(value1.send(@operator, value2))
93
83
  rescue NoMethodError => e
@@ -95,52 +85,28 @@ module Sass::Script::Tree
95
85
  raise Sass::SyntaxError.new("Undefined operation: \"#{value1} #{@operator} #{value2}\".")
96
86
  end
97
87
 
98
- warn_for_color_arithmetic(value1, value2)
99
- warn_for_unitless_equals(value1, value2, result)
88
+ if (@operator == :eq || @operator == :neq) && value1.is_a?(Sass::Script::Value::Number) &&
89
+ value2.is_a?(Sass::Script::Value::Number) && value1.unitless? != value2.unitless? &&
90
+ result == (if @operator == :eq
91
+ Sass::Script::Value::Bool::TRUE
92
+ else
93
+ Sass::Script::Value::Bool::FALSE
94
+ end)
95
+
96
+ operation = "#{value1.to_sass} #{@operator == :eq ? '==' : '!='} #{value2.to_sass}"
97
+ future_value = @operator == :neq
98
+ Sass::Util.sass_warn <<WARNING
99
+ DEPRECATION WARNING on line #{line}#{" of #{filename}" if filename}:
100
+ The result of `#{operation}` will be `#{future_value}` in future releases of Sass.
101
+ Unitless numbers will no longer be equal to the same numbers with units.
102
+ WARNING
103
+ end
100
104
 
101
105
  result
102
106
  end
103
107
 
104
108
  private
105
109
 
106
- def warn_for_color_arithmetic(value1, value2)
107
- return unless @operator == :plus || @operator == :times || @operator == :minus ||
108
- @operator == :div || @operator == :mod
109
-
110
- if value1.is_a?(Sass::Script::Value::Number)
111
- return unless value2.is_a?(Sass::Script::Value::Color)
112
- elsif value1.is_a?(Sass::Script::Value::Color)
113
- return unless value2.is_a?(Sass::Script::Value::Color) || value2.is_a?(Sass::Script::Value::Number)
114
- else
115
- return
116
- end
117
-
118
- @@color_arithmetic_deprecation.warn(filename, line, <<WARNING)
119
- The operation `#{value1} #{@operator} #{value2}` is deprecated and will be an error in future versions.
120
- Consider using Sass's color functions instead.
121
- http://sass-lang.com/documentation/Sass/Script/Functions.html#other_color_functions
122
- WARNING
123
- end
124
-
125
- def warn_for_unitless_equals(value1, value2, result)
126
- return unless @operator == :eq || @operator == :neq
127
- return unless value1.is_a?(Sass::Script::Value::Number)
128
- return unless value2.is_a?(Sass::Script::Value::Number)
129
- return unless value1.unitless? != value2.unitless?
130
- return unless result == (if @operator == :eq
131
- Sass::Script::Value::Bool::TRUE
132
- else
133
- Sass::Script::Value::Bool::FALSE
134
- end)
135
-
136
- operation = "#{value1.to_sass} #{@operator == :eq ? '==' : '!='} #{value2.to_sass}"
137
- future_value = @operator == :neq
138
- @@unitless_equals_deprecation.warn(filename, line, <<WARNING)
139
- The result of `#{operation}` will be `#{future_value}` in future releases of Sass.
140
- Unitless numbers will no longer be equal to the same numbers with units.
141
- WARNING
142
- end
143
-
144
110
  def operand_to_sass(op, side, opts)
145
111
  return "(#{op.to_sass(opts)})" if op.is_a?(Sass::Script::Tree::ListLiteral)
146
112
  return op.to_sass(opts) unless op.is_a?(Operation)
@@ -9,3 +9,5 @@ require 'sass/script/value/null'
9
9
  require 'sass/script/value/list'
10
10
  require 'sass/script/value/arg_list'
11
11
  require 'sass/script/value/map'
12
+ require 'sass/script/value/callable'
13
+ require 'sass/script/value/function'
@@ -17,7 +17,7 @@ module Sass::Script::Value
17
17
  # @param keywords [Hash<String, Value>, NormalizedMap<Value>] See \{#keywords}
18
18
  # @param separator [String] See \{List#separator}.
19
19
  def initialize(value, keywords, separator)
20
- super(value, separator)
20
+ super(value, separator: separator)
21
21
  if keywords.is_a?(Sass::Util::NormalizedMap)
22
22
  @keywords = keywords
23
23
  else
@@ -27,7 +27,7 @@ module Sass::Script::Value
27
27
 
28
28
  # Sets the options hash for this node,
29
29
  # as well as for all child nodes.
30
- # See {file:SASS_REFERENCE.md#Options the Sass options documentation}.
30
+ # See {file:SASS_REFERENCE.md#options the Sass options documentation}.
31
31
  #
32
32
  # @param options [{Symbol => Object}] The options
33
33
  attr_writer :options
@@ -149,7 +149,7 @@ MSG
149
149
  # Returns the hash code of this value. Two objects' hash codes should be
150
150
  # equal if the objects are equal.
151
151
  #
152
- # @return [Integer for Ruby 2.4.0+, Fixnum for earlier Ruby versions] The hash code.
152
+ # @return [Fixnum] The hash code.
153
153
  def hash
154
154
  value.hash
155
155
  end
@@ -176,7 +176,7 @@ MSG
176
176
  eq(other).to_bool
177
177
  end
178
178
 
179
- # @return [Integer] The integer value of this value
179
+ # @return [Fixnum] The integer value of this value
180
180
  # @raise [Sass::SyntaxError] if this value isn't an integer
181
181
  def to_i
182
182
  raise Sass::SyntaxError.new("#{inspect} is not an integer.")
@@ -192,6 +192,12 @@ MSG
192
192
  # @return [Symbol]
193
193
  def separator; nil; end
194
194
 
195
+ # Whether the value is surrounded by square brackets. For non-list values,
196
+ # this will be `false`.
197
+ #
198
+ # @return [Boolean]
199
+ def bracketed; false; end
200
+
195
201
  # Returns the value of this value as a list.
196
202
  # Single values are considered the same as single-element lists.
197
203
  #
@@ -228,6 +234,17 @@ MSG
228
234
  false
229
235
  end
230
236
 
237
+ # Creates a new list containing `contents` but with the same brackets and
238
+ # separators as this object, when interpreted as a list.
239
+ #
240
+ # @param contents [Array<Value>] The contents of the new list.
241
+ # @param separator [Symbol] The separator of the new list. Defaults to \{#separator}.
242
+ # @param bracketed [Boolean] Whether the new list is bracketed. Defaults to \{#bracketed}.
243
+ # @return [Sass::Script::Value::List]
244
+ def with_contents(contents, separator: self.separator, bracketed: self.bracketed)
245
+ Sass::Script::Value::List.new(contents, separator: separator, bracketed: bracketed)
246
+ end
247
+
231
248
  protected
232
249
 
233
250
  # Evaluates the value.
@@ -0,0 +1,25 @@
1
+ module Sass::Script::Value
2
+ # A SassScript object representing a null value.
3
+ class Callable < Base
4
+ # Constructs a Callable value for use in SassScript.
5
+ #
6
+ # @param callable [Sass::Callable] The callable to be used when the
7
+ # callable is called.
8
+ def initialize(callable)
9
+ super(callable)
10
+ end
11
+
12
+ def to_s(opts = {})
13
+ raise Sass::SyntaxError.new("#{to_sass} isn't a valid CSS value.")
14
+ end
15
+
16
+ def inspect
17
+ to_sass
18
+ end
19
+
20
+ # @abstract
21
+ def to_sass
22
+ Sass::Util.abstract(self)
23
+ end
24
+ end
25
+ end
@@ -17,8 +17,8 @@ module Sass::Script::Value
17
17
  # @private
18
18
  #
19
19
  # Convert a ruby integer to a rgba components
20
- # @param color [Integer]
21
- # @return [Array<Integer>] Array of 4 numbers representing r,g,b and alpha
20
+ # @param color [Fixnum]
21
+ # @return [Array<Fixnum>] Array of 4 numbers representing r,g,b and alpha
22
22
  def self.int_to_rgba(color)
23
23
  rgba = (0..3).map {|n| color >> (n << 3) & 0xff}.reverse
24
24
  rgba[-1] = rgba[-1] / 255.0
@@ -293,7 +293,7 @@ module Sass::Script::Value
293
293
 
294
294
  # The red component of the color.
295
295
  #
296
- # @return [Integer]
296
+ # @return [Fixnum]
297
297
  def red
298
298
  hsl_to_rgb!
299
299
  @attrs[:red]
@@ -301,7 +301,7 @@ module Sass::Script::Value
301
301
 
302
302
  # The green component of the color.
303
303
  #
304
- # @return [Integer]
304
+ # @return [Fixnum]
305
305
  def green
306
306
  hsl_to_rgb!
307
307
  @attrs[:green]
@@ -309,7 +309,7 @@ module Sass::Script::Value
309
309
 
310
310
  # The blue component of the color.
311
311
  #
312
- # @return [Integer]
312
+ # @return [Fixnum]
313
313
  def blue
314
314
  hsl_to_rgb!
315
315
  @attrs[:blue]
@@ -342,7 +342,7 @@ module Sass::Script::Value
342
342
  # The alpha channel (opacity) of the color.
343
343
  # This is 1 unless otherwise defined.
344
344
  #
345
- # @return [Integer]
345
+ # @return [Fixnum]
346
346
  def alpha
347
347
  @attrs[:alpha].to_f
348
348
  end
@@ -357,7 +357,7 @@ module Sass::Script::Value
357
357
 
358
358
  # Returns the red, green, and blue components of the color.
359
359
  #
360
- # @return [Array<Integer>] A frozen three-element array of the red, green, and blue
360
+ # @return [Array<Fixnum>] A frozen three-element array of the red, green, and blue
361
361
  # values (respectively) of the color
362
362
  def rgb
363
363
  [red, green, blue].freeze
@@ -365,7 +365,7 @@ module Sass::Script::Value
365
365
 
366
366
  # Returns the red, green, blue, and alpha components of the color.
367
367
  #
368
- # @return [Array<Integer>] A frozen four-element array of the red, green,
368
+ # @return [Array<Fixnum>] A frozen four-element array of the red, green,
369
369
  # blue, and alpha values (respectively) of the color
370
370
  def rgba
371
371
  [red, green, blue, alpha].freeze
@@ -373,7 +373,7 @@ module Sass::Script::Value
373
373
 
374
374
  # Returns the hue, saturation, and lightness components of the color.
375
375
  #
376
- # @return [Array<Integer>] A frozen three-element array of the
376
+ # @return [Array<Fixnum>] A frozen three-element array of the
377
377
  # hue, saturation, and lightness values (respectively) of the color
378
378
  def hsl
379
379
  [hue, saturation, lightness].freeze
@@ -381,7 +381,7 @@ module Sass::Script::Value
381
381
 
382
382
  # Returns the hue, saturation, lightness, and alpha components of the color.
383
383
  #
384
- # @return [Array<Integer>] A frozen four-element array of the hue,
384
+ # @return [Array<Fixnum>] A frozen four-element array of the hue,
385
385
  # saturation, lightness, and alpha values (respectively) of the color
386
386
  def hsla
387
387
  [hue, saturation, lightness, alpha].freeze
@@ -0,0 +1,19 @@
1
+ module Sass::Script::Value
2
+ # A SassScript object representing a function.
3
+ class Function < Callable
4
+ # Constructs a Function value for use in SassScript.
5
+ #
6
+ # @param function [Sass::Callable] The callable to be used when the
7
+ # function is invoked.
8
+ def initialize(function)
9
+ unless function.type == "function"
10
+ raise ArgumentError.new("A callable of type function was expected.")
11
+ end
12
+ super
13
+ end
14
+
15
+ def to_sass
16
+ %{get-function("#{value.name}")}
17
+ end
18
+ end
19
+ end
@@ -68,26 +68,35 @@ module Sass::Script::Value
68
68
  Number.new(number, *parse_unit_string(unit_string))
69
69
  end
70
70
 
71
- # @overload list(*elements, separator)
71
+ # @overload list(*elements, separator:, bracketed: false)
72
72
  # Create a space-separated list from the arguments given.
73
73
  # @param elements [Array<Sass::Script::Value::Base>] Each argument will be a list element.
74
74
  # @param separator [Symbol] Either :space or :comma.
75
+ # @param bracketed [Boolean] Whether the list uses square brackets.
75
76
  # @return [Sass::Script::Value::List] The space separated list.
76
77
  #
77
- # @overload list(array, separator)
78
+ # @overload list(array, separator:, bracketed: false)
78
79
  # Create a space-separated list from the array given.
79
80
  # @param array [Array<Sass::Script::Value::Base>] A ruby array of Sass values
80
81
  # to make into a list.
82
+ # @param separator [Symbol] Either :space or :comma.
83
+ # @param bracketed [Boolean] Whether the list uses square brackets.
81
84
  # @return [Sass::Script::Value::List] The space separated list.
82
- def list(*elements)
83
- unless elements.last.is_a?(Symbol)
84
- raise ArgumentError.new("A list type of :space or :comma must be specified.")
85
+ def list(*elements, separator: nil, bracketed: false)
86
+ # Support passing separator as the last value in elements for
87
+ # backwards-compatibility.
88
+ if separator.nil?
89
+ if elements.last.is_a?(Symbol)
90
+ separator = elements.pop
91
+ else
92
+ raise ArgumentError.new("A separator of :space or :comma must be specified.")
93
+ end
85
94
  end
86
- separator = elements.pop
95
+
87
96
  if elements.size == 1 && elements.first.is_a?(Array)
88
97
  elements = elements.first
89
98
  end
90
- Sass::Script::Value::List.new(elements, separator)
99
+ Sass::Script::Value::List.new(elements, separator: separator, bracketed: bracketed)
91
100
  end
92
101
 
93
102
  # Construct a Sass map.