sass4 4.0.0

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 (147) hide show
  1. checksums.yaml +7 -0
  2. data/.yardopts +13 -0
  3. data/AGENTS.md +534 -0
  4. data/CODE_OF_CONDUCT.md +10 -0
  5. data/CONTRIBUTING.md +148 -0
  6. data/MIT-LICENSE +20 -0
  7. data/README.md +242 -0
  8. data/VERSION +1 -0
  9. data/VERSION_NAME +1 -0
  10. data/bin/sass +13 -0
  11. data/bin/sass-convert +12 -0
  12. data/bin/scss +13 -0
  13. data/extra/sass-spec-ref.sh +40 -0
  14. data/extra/update_watch.rb +13 -0
  15. data/init.rb +18 -0
  16. data/lib/sass/cache_stores/base.rb +88 -0
  17. data/lib/sass/cache_stores/chain.rb +34 -0
  18. data/lib/sass/cache_stores/filesystem.rb +60 -0
  19. data/lib/sass/cache_stores/memory.rb +46 -0
  20. data/lib/sass/cache_stores/null.rb +25 -0
  21. data/lib/sass/cache_stores.rb +15 -0
  22. data/lib/sass/callbacks.rb +67 -0
  23. data/lib/sass/css.rb +407 -0
  24. data/lib/sass/deprecation.rb +55 -0
  25. data/lib/sass/engine.rb +1236 -0
  26. data/lib/sass/environment.rb +236 -0
  27. data/lib/sass/error.rb +198 -0
  28. data/lib/sass/exec/base.rb +188 -0
  29. data/lib/sass/exec/sass_convert.rb +283 -0
  30. data/lib/sass/exec/sass_scss.rb +436 -0
  31. data/lib/sass/exec.rb +9 -0
  32. data/lib/sass/features.rb +48 -0
  33. data/lib/sass/importers/base.rb +182 -0
  34. data/lib/sass/importers/deprecated_path.rb +51 -0
  35. data/lib/sass/importers/filesystem.rb +221 -0
  36. data/lib/sass/importers.rb +23 -0
  37. data/lib/sass/logger/base.rb +47 -0
  38. data/lib/sass/logger/delayed.rb +50 -0
  39. data/lib/sass/logger/log_level.rb +45 -0
  40. data/lib/sass/logger.rb +17 -0
  41. data/lib/sass/media.rb +210 -0
  42. data/lib/sass/plugin/compiler.rb +552 -0
  43. data/lib/sass/plugin/configuration.rb +134 -0
  44. data/lib/sass/plugin/generic.rb +15 -0
  45. data/lib/sass/plugin/merb.rb +48 -0
  46. data/lib/sass/plugin/rack.rb +60 -0
  47. data/lib/sass/plugin/rails.rb +47 -0
  48. data/lib/sass/plugin/staleness_checker.rb +199 -0
  49. data/lib/sass/plugin.rb +134 -0
  50. data/lib/sass/railtie.rb +10 -0
  51. data/lib/sass/repl.rb +57 -0
  52. data/lib/sass/root.rb +7 -0
  53. data/lib/sass/script/css_lexer.rb +33 -0
  54. data/lib/sass/script/css_parser.rb +36 -0
  55. data/lib/sass/script/functions.rb +3103 -0
  56. data/lib/sass/script/lexer.rb +518 -0
  57. data/lib/sass/script/parser.rb +1164 -0
  58. data/lib/sass/script/tree/funcall.rb +314 -0
  59. data/lib/sass/script/tree/interpolation.rb +220 -0
  60. data/lib/sass/script/tree/list_literal.rb +119 -0
  61. data/lib/sass/script/tree/literal.rb +49 -0
  62. data/lib/sass/script/tree/map_literal.rb +64 -0
  63. data/lib/sass/script/tree/node.rb +119 -0
  64. data/lib/sass/script/tree/operation.rb +149 -0
  65. data/lib/sass/script/tree/selector.rb +26 -0
  66. data/lib/sass/script/tree/string_interpolation.rb +125 -0
  67. data/lib/sass/script/tree/unary_operation.rb +69 -0
  68. data/lib/sass/script/tree/variable.rb +57 -0
  69. data/lib/sass/script/tree.rb +16 -0
  70. data/lib/sass/script/value/arg_list.rb +36 -0
  71. data/lib/sass/script/value/base.rb +258 -0
  72. data/lib/sass/script/value/bool.rb +35 -0
  73. data/lib/sass/script/value/callable.rb +25 -0
  74. data/lib/sass/script/value/color.rb +704 -0
  75. data/lib/sass/script/value/function.rb +19 -0
  76. data/lib/sass/script/value/helpers.rb +298 -0
  77. data/lib/sass/script/value/list.rb +135 -0
  78. data/lib/sass/script/value/map.rb +70 -0
  79. data/lib/sass/script/value/null.rb +44 -0
  80. data/lib/sass/script/value/number.rb +564 -0
  81. data/lib/sass/script/value/string.rb +138 -0
  82. data/lib/sass/script/value.rb +13 -0
  83. data/lib/sass/script.rb +66 -0
  84. data/lib/sass/scss/css_parser.rb +61 -0
  85. data/lib/sass/scss/parser.rb +1343 -0
  86. data/lib/sass/scss/rx.rb +134 -0
  87. data/lib/sass/scss/static_parser.rb +351 -0
  88. data/lib/sass/scss.rb +14 -0
  89. data/lib/sass/selector/abstract_sequence.rb +112 -0
  90. data/lib/sass/selector/comma_sequence.rb +195 -0
  91. data/lib/sass/selector/pseudo.rb +291 -0
  92. data/lib/sass/selector/sequence.rb +661 -0
  93. data/lib/sass/selector/simple.rb +124 -0
  94. data/lib/sass/selector/simple_sequence.rb +348 -0
  95. data/lib/sass/selector.rb +327 -0
  96. data/lib/sass/shared.rb +76 -0
  97. data/lib/sass/source/map.rb +209 -0
  98. data/lib/sass/source/position.rb +39 -0
  99. data/lib/sass/source/range.rb +41 -0
  100. data/lib/sass/stack.rb +140 -0
  101. data/lib/sass/supports.rb +225 -0
  102. data/lib/sass/tree/at_root_node.rb +83 -0
  103. data/lib/sass/tree/charset_node.rb +22 -0
  104. data/lib/sass/tree/comment_node.rb +82 -0
  105. data/lib/sass/tree/content_node.rb +9 -0
  106. data/lib/sass/tree/css_import_node.rb +68 -0
  107. data/lib/sass/tree/debug_node.rb +18 -0
  108. data/lib/sass/tree/directive_node.rb +59 -0
  109. data/lib/sass/tree/each_node.rb +24 -0
  110. data/lib/sass/tree/error_node.rb +18 -0
  111. data/lib/sass/tree/extend_node.rb +43 -0
  112. data/lib/sass/tree/for_node.rb +36 -0
  113. data/lib/sass/tree/function_node.rb +44 -0
  114. data/lib/sass/tree/if_node.rb +52 -0
  115. data/lib/sass/tree/import_node.rb +75 -0
  116. data/lib/sass/tree/keyframe_rule_node.rb +15 -0
  117. data/lib/sass/tree/media_node.rb +48 -0
  118. data/lib/sass/tree/mixin_def_node.rb +38 -0
  119. data/lib/sass/tree/mixin_node.rb +52 -0
  120. data/lib/sass/tree/node.rb +240 -0
  121. data/lib/sass/tree/prop_node.rb +162 -0
  122. data/lib/sass/tree/return_node.rb +19 -0
  123. data/lib/sass/tree/root_node.rb +44 -0
  124. data/lib/sass/tree/rule_node.rb +153 -0
  125. data/lib/sass/tree/supports_node.rb +38 -0
  126. data/lib/sass/tree/trace_node.rb +33 -0
  127. data/lib/sass/tree/variable_node.rb +36 -0
  128. data/lib/sass/tree/visitors/base.rb +72 -0
  129. data/lib/sass/tree/visitors/check_nesting.rb +173 -0
  130. data/lib/sass/tree/visitors/convert.rb +350 -0
  131. data/lib/sass/tree/visitors/cssize.rb +362 -0
  132. data/lib/sass/tree/visitors/deep_copy.rb +107 -0
  133. data/lib/sass/tree/visitors/extend.rb +64 -0
  134. data/lib/sass/tree/visitors/perform.rb +572 -0
  135. data/lib/sass/tree/visitors/set_options.rb +139 -0
  136. data/lib/sass/tree/visitors/to_css.rb +440 -0
  137. data/lib/sass/tree/warn_node.rb +18 -0
  138. data/lib/sass/tree/while_node.rb +18 -0
  139. data/lib/sass/util/multibyte_string_scanner.rb +151 -0
  140. data/lib/sass/util/normalized_map.rb +122 -0
  141. data/lib/sass/util/subset_map.rb +109 -0
  142. data/lib/sass/util/test.rb +9 -0
  143. data/lib/sass/util.rb +1137 -0
  144. data/lib/sass/version.rb +120 -0
  145. data/lib/sass.rb +102 -0
  146. data/rails/init.rb +1 -0
  147. metadata +283 -0
@@ -0,0 +1,258 @@
1
+ module Sass::Script::Value
2
+ # The abstract superclass for SassScript objects.
3
+ #
4
+ # Many of these methods, especially the ones that correspond to SassScript operations,
5
+ # are designed to be overridden by subclasses which may change the semantics somewhat.
6
+ # The operations listed here are just the defaults.
7
+ class Base
8
+ # Returns the Ruby value of the value.
9
+ # The type of this value varies based on the subclass.
10
+ #
11
+ # @return [Object]
12
+ attr_reader :value
13
+
14
+ # The source range in the document on which this node appeared.
15
+ #
16
+ # @return [Sass::Source::Range]
17
+ attr_accessor :source_range
18
+
19
+ # Creates a new value.
20
+ #
21
+ # @param value [Object] The object for \{#value}
22
+ def initialize(value = nil)
23
+ value.freeze unless value.nil? || value == true || value == false
24
+ @value = value
25
+ @options = nil
26
+ end
27
+
28
+ # Sets the options hash for this node,
29
+ # as well as for all child nodes.
30
+ # See {file:SASS_REFERENCE.md#Options the Sass options documentation}.
31
+ #
32
+ # @param options [{Symbol => Object}] The options
33
+ attr_writer :options
34
+
35
+ # Returns the options hash for this node.
36
+ #
37
+ # @return [{Symbol => Object}]
38
+ # @raise [Sass::SyntaxError] if the options hash hasn't been set.
39
+ # This should only happen when the value was created
40
+ # outside of the parser and \{#to\_s} was called on it
41
+ def options
42
+ return @options if @options
43
+ raise Sass::SyntaxError.new(<<MSG)
44
+ The #options attribute is not set on this #{self.class}.
45
+ This error is probably occurring because #to_s was called
46
+ on this value within a custom Sass function without first
47
+ setting the #options attribute.
48
+ MSG
49
+ end
50
+
51
+ # The SassScript `==` operation.
52
+ # **Note that this returns a {Sass::Script::Value::Bool} object,
53
+ # not a Ruby boolean**.
54
+ #
55
+ # @param other [Value] The right-hand side of the operator
56
+ # @return [Sass::Script::Value::Bool] True if this value is the same as the other,
57
+ # false otherwise
58
+ def eq(other)
59
+ Sass::Script::Value::Bool.new(self.class == other.class && value == other.value)
60
+ end
61
+
62
+ # The SassScript `!=` operation.
63
+ # **Note that this returns a {Sass::Script::Value::Bool} object,
64
+ # not a Ruby boolean**.
65
+ #
66
+ # @param other [Value] The right-hand side of the operator
67
+ # @return [Sass::Script::Value::Bool] False if this value is the same as the other,
68
+ # true otherwise
69
+ def neq(other)
70
+ Sass::Script::Value::Bool.new(!eq(other).to_bool)
71
+ end
72
+
73
+ # The SassScript `==` operation.
74
+ # **Note that this returns a {Sass::Script::Value::Bool} object,
75
+ # not a Ruby boolean**.
76
+ #
77
+ # @param other [Value] The right-hand side of the operator
78
+ # @return [Sass::Script::Value::Bool] True if this value is the same as the other,
79
+ # false otherwise
80
+ def unary_not
81
+ Sass::Script::Value::Bool.new(!to_bool)
82
+ end
83
+
84
+ # The SassScript `=` operation
85
+ # (used for proprietary MS syntax like `alpha(opacity=20)`).
86
+ #
87
+ # @param other [Value] The right-hand side of the operator
88
+ # @return [Script::Value::String] A string containing both values
89
+ # separated by `"="`
90
+ def single_eq(other)
91
+ Sass::Script::Value::String.new("#{self}=#{other}")
92
+ end
93
+
94
+ # The SassScript `+` operation.
95
+ #
96
+ # @param other [Value] The right-hand side of the operator
97
+ # @return [Script::Value::String] A string containing both values
98
+ # without any separation
99
+ def plus(other)
100
+ type = other.is_a?(Sass::Script::Value::String) ? other.type : :identifier
101
+ Sass::Script::Value::String.new(to_s(:quote => :none) + other.to_s(:quote => :none), type)
102
+ end
103
+
104
+ # The SassScript `-` operation.
105
+ #
106
+ # @param other [Value] The right-hand side of the operator
107
+ # @return [Script::Value::String] A string containing both values
108
+ # separated by `"-"`
109
+ def minus(other)
110
+ Sass::Script::Value::String.new("#{self}-#{other}")
111
+ end
112
+
113
+ # The SassScript `/` operation.
114
+ #
115
+ # @param other [Value] The right-hand side of the operator
116
+ # @return [Script::Value::String] A string containing both values
117
+ # separated by `"/"`
118
+ def div(other)
119
+ Sass::Script::Value::String.new("#{self}/#{other}")
120
+ end
121
+
122
+ # The SassScript unary `+` operation (e.g. `+$a`).
123
+ #
124
+ # @param other [Value] The right-hand side of the operator
125
+ # @return [Script::Value::String] A string containing the value
126
+ # preceded by `"+"`
127
+ def unary_plus
128
+ Sass::Script::Value::String.new("+#{self}")
129
+ end
130
+
131
+ # The SassScript unary `-` operation (e.g. `-$a`).
132
+ #
133
+ # @param other [Value] The right-hand side of the operator
134
+ # @return [Script::Value::String] A string containing the value
135
+ # preceded by `"-"`
136
+ def unary_minus
137
+ Sass::Script::Value::String.new("-#{self}")
138
+ end
139
+
140
+ # The SassScript unary `/` operation (e.g. `/$a`).
141
+ #
142
+ # @param other [Value] The right-hand side of the operator
143
+ # @return [Script::Value::String] A string containing the value
144
+ # preceded by `"/"`
145
+ def unary_div
146
+ Sass::Script::Value::String.new("/#{self}")
147
+ end
148
+
149
+ # Returns the hash code of this value. Two objects' hash codes should be
150
+ # equal if the objects are equal.
151
+ #
152
+ # @return [Integer for Ruby 2.4.0+, Fixnum for earlier Ruby versions] The hash code.
153
+ def hash
154
+ value.hash
155
+ end
156
+
157
+ def eql?(other)
158
+ self == other
159
+ end
160
+
161
+ # @return [String] A readable representation of the value
162
+ def inspect
163
+ value.inspect
164
+ end
165
+
166
+ # @return [Boolean] `true` (the Ruby boolean value)
167
+ def to_bool
168
+ true
169
+ end
170
+
171
+ # Compares this object with another.
172
+ #
173
+ # @param other [Object] The object to compare with
174
+ # @return [Boolean] Whether or not this value is equivalent to `other`
175
+ def ==(other)
176
+ eq(other).to_bool
177
+ end
178
+
179
+ # @return [Integer] The integer value of this value
180
+ # @raise [Sass::SyntaxError] if this value isn't an integer
181
+ def to_i
182
+ raise Sass::SyntaxError.new("#{inspect} is not an integer.")
183
+ end
184
+
185
+ # @raise [Sass::SyntaxError] if this value isn't an integer
186
+ def assert_int!; to_i; end
187
+
188
+ # Returns the separator for this value. For non-list-like values or the
189
+ # empty list, this will be `nil`. For lists or maps, it will be `:space` or
190
+ # `:comma`.
191
+ #
192
+ # @return [Symbol]
193
+ def separator; nil; end
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
+
201
+ # Returns the value of this value as a list.
202
+ # Single values are considered the same as single-element lists.
203
+ #
204
+ # @return [Array<Value>] This value as a list
205
+ def to_a
206
+ [self]
207
+ end
208
+
209
+ # Returns the value of this value as a hash. Most values don't have hash
210
+ # representations, but [Map]s and empty [List]s do.
211
+ #
212
+ # @return [Hash<Value, Value>] This value as a hash
213
+ # @raise [Sass::SyntaxError] if this value doesn't have a hash representation
214
+ def to_h
215
+ raise Sass::SyntaxError.new("#{inspect} is not a map.")
216
+ end
217
+
218
+ # Returns the string representation of this value
219
+ # as it would be output to the CSS document.
220
+ #
221
+ # @options opts :quote [String]
222
+ # The preferred quote style for quoted strings. If `:none`, strings are
223
+ # always emitted unquoted.
224
+ # @return [String]
225
+ def to_s(opts = {})
226
+ Sass::Util.abstract(self)
227
+ end
228
+ alias_method :to_sass, :to_s
229
+
230
+ # Returns whether or not this object is null.
231
+ #
232
+ # @return [Boolean] `false`
233
+ def null?
234
+ false
235
+ end
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
+
248
+ protected
249
+
250
+ # Evaluates the value.
251
+ #
252
+ # @param environment [Sass::Environment] The environment in which to evaluate the SassScript
253
+ # @return [Value] This value
254
+ def _perform(environment)
255
+ self
256
+ end
257
+ end
258
+ end
@@ -0,0 +1,35 @@
1
+ module Sass::Script::Value
2
+ # A SassScript object representing a boolean (true or false) value.
3
+ class Bool < Base
4
+ # The true value in SassScript.
5
+ #
6
+ # This is assigned before new is overridden below so that we use the default implementation.
7
+ TRUE = new(true)
8
+
9
+ # The false value in SassScript.
10
+ #
11
+ # This is assigned before new is overridden below so that we use the default implementation.
12
+ FALSE = new(false)
13
+
14
+ # We override object creation so that users of the core API
15
+ # will not need to know that booleans are specific constants.
16
+ #
17
+ # @param value A ruby value that will be tested for truthiness.
18
+ # @return [Bool] TRUE if value is truthy, FALSE if value is falsey
19
+ def self.new(value)
20
+ value ? TRUE : FALSE
21
+ end
22
+
23
+ # The Ruby value of the boolean.
24
+ #
25
+ # @return [Boolean]
26
+ attr_reader :value
27
+ alias_method :to_bool, :value
28
+
29
+ # @return [String] "true" or "false"
30
+ def to_s(opts = {})
31
+ @value.to_s
32
+ end
33
+ alias_method :to_sass, :to_s
34
+ end
35
+ end
@@ -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