sass 3.5.2 → 3.7.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (163) hide show
  1. checksums.yaml +4 -4
  2. data/CODE_OF_CONDUCT.md +1 -1
  3. data/CONTRIBUTING.md +3 -3
  4. data/README.md +17 -9
  5. data/VERSION +1 -1
  6. data/VERSION_DATE +1 -1
  7. data/extra/sass-spec-ref.sh +9 -1
  8. data/lib/sass/engine.rb +1 -9
  9. data/lib/sass/exec/base.rb +0 -2
  10. data/lib/sass/exec/sass_scss.rb +1 -5
  11. data/lib/sass/importers/filesystem.rb +4 -2
  12. data/lib/sass/logger/base.rb +11 -0
  13. data/lib/sass/script/css_parser.rb +4 -1
  14. data/lib/sass/script/functions.rb +76 -41
  15. data/lib/sass/script/lexer.rb +62 -19
  16. data/lib/sass/script/parser.rb +260 -93
  17. data/lib/sass/script/tree/funcall.rb +0 -4
  18. data/lib/sass/script/tree/interpolation.rb +0 -3
  19. data/lib/sass/script/tree/operation.rb +1 -1
  20. data/lib/sass/script/value/color.rb +3 -2
  21. data/lib/sass/script/value/helpers.rb +8 -2
  22. data/lib/sass/script/value/number.rb +2 -1
  23. data/lib/sass/scss/css_parser.rb +6 -1
  24. data/lib/sass/scss/parser.rb +48 -18
  25. data/lib/sass/scss/rx.rb +1 -1
  26. data/lib/sass/scss/static_parser.rb +15 -18
  27. data/lib/sass/selector/comma_sequence.rb +2 -1
  28. data/lib/sass/selector/pseudo.rb +1 -1
  29. data/lib/sass/selector/sequence.rb +0 -4
  30. data/lib/sass/source/map.rb +0 -4
  31. data/lib/sass/tree/rule_node.rb +3 -6
  32. data/lib/sass/tree/visitors/perform.rb +2 -6
  33. data/lib/sass/tree/visitors/to_css.rb +4 -11
  34. data/lib/sass/util.rb +60 -20
  35. data/lib/sass/version.rb +0 -2
  36. metadata +38 -162
  37. data/Rakefile +0 -338
  38. data/lib/test.css +0 -4
  39. data/lib/test.css.map +0 -7
  40. data/test/sass-spec.yml +0 -3
  41. data/test/sass/cache_test.rb +0 -130
  42. data/test/sass/callbacks_test.rb +0 -60
  43. data/test/sass/compiler_test.rb +0 -225
  44. data/test/sass/conversion_test.rb +0 -2138
  45. data/test/sass/css2sass_test.rb +0 -523
  46. data/test/sass/css_variable_test.rb +0 -237
  47. data/test/sass/data/hsl-rgb.txt +0 -319
  48. data/test/sass/encoding_test.rb +0 -188
  49. data/test/sass/engine_test.rb +0 -3499
  50. data/test/sass/exec_test.rb +0 -95
  51. data/test/sass/extend_test.rb +0 -1678
  52. data/test/sass/fixtures/test_staleness_check_across_importers.css +0 -1
  53. data/test/sass/fixtures/test_staleness_check_across_importers.scss +0 -1
  54. data/test/sass/functions_test.rb +0 -2021
  55. data/test/sass/importer_test.rb +0 -420
  56. data/test/sass/logger_test.rb +0 -57
  57. data/test/sass/mock_importer.rb +0 -49
  58. data/test/sass/more_results/more1.css +0 -9
  59. data/test/sass/more_results/more1_with_line_comments.css +0 -26
  60. data/test/sass/more_results/more_import.css +0 -29
  61. data/test/sass/more_templates/_more_partial.sass +0 -2
  62. data/test/sass/more_templates/more1.sass +0 -23
  63. data/test/sass/more_templates/more_import.sass +0 -11
  64. data/test/sass/plugin_test.rb +0 -552
  65. data/test/sass/results/alt.css +0 -4
  66. data/test/sass/results/basic.css +0 -9
  67. data/test/sass/results/cached_import_option.css +0 -3
  68. data/test/sass/results/compact.css +0 -5
  69. data/test/sass/results/complex.css +0 -86
  70. data/test/sass/results/compressed.css +0 -1
  71. data/test/sass/results/expanded.css +0 -19
  72. data/test/sass/results/filename_fn.css +0 -3
  73. data/test/sass/results/if.css +0 -3
  74. data/test/sass/results/import.css +0 -31
  75. data/test/sass/results/import_charset.css +0 -5
  76. data/test/sass/results/import_charset_ibm866.css +0 -5
  77. data/test/sass/results/import_content.css +0 -1
  78. data/test/sass/results/line_numbers.css +0 -49
  79. data/test/sass/results/mixins.css +0 -95
  80. data/test/sass/results/multiline.css +0 -24
  81. data/test/sass/results/nested.css +0 -22
  82. data/test/sass/results/options.css +0 -1
  83. data/test/sass/results/parent_ref.css +0 -13
  84. data/test/sass/results/script.css +0 -16
  85. data/test/sass/results/scss_import.css +0 -31
  86. data/test/sass/results/scss_importee.css +0 -2
  87. data/test/sass/results/subdir/nested_subdir/nested_subdir.css +0 -1
  88. data/test/sass/results/subdir/subdir.css +0 -3
  89. data/test/sass/results/units.css +0 -11
  90. data/test/sass/results/warn.css +0 -0
  91. data/test/sass/results/warn_imported.css +0 -0
  92. data/test/sass/script_conversion_test.rb +0 -365
  93. data/test/sass/script_test.rb +0 -1429
  94. data/test/sass/scss/css_test.rb +0 -1266
  95. data/test/sass/scss/rx_test.rb +0 -159
  96. data/test/sass/scss/scss_test.rb +0 -4238
  97. data/test/sass/scss/test_helper.rb +0 -37
  98. data/test/sass/source_map_test.rb +0 -1052
  99. data/test/sass/superselector_test.rb +0 -209
  100. data/test/sass/templates/_cached_import_option_partial.scss +0 -1
  101. data/test/sass/templates/_double_import_loop2.sass +0 -1
  102. data/test/sass/templates/_filename_fn_import.scss +0 -11
  103. data/test/sass/templates/_imported_charset_ibm866.sass +0 -4
  104. data/test/sass/templates/_imported_charset_utf8.sass +0 -4
  105. data/test/sass/templates/_imported_content.sass +0 -3
  106. data/test/sass/templates/_partial.sass +0 -2
  107. data/test/sass/templates/_same_name_different_partiality.scss +0 -1
  108. data/test/sass/templates/alt.sass +0 -16
  109. data/test/sass/templates/basic.sass +0 -23
  110. data/test/sass/templates/bork1.sass +0 -2
  111. data/test/sass/templates/bork2.sass +0 -2
  112. data/test/sass/templates/bork3.sass +0 -2
  113. data/test/sass/templates/bork4.sass +0 -2
  114. data/test/sass/templates/bork5.sass +0 -3
  115. data/test/sass/templates/cached_import_option.scss +0 -3
  116. data/test/sass/templates/compact.sass +0 -17
  117. data/test/sass/templates/complex.sass +0 -305
  118. data/test/sass/templates/compressed.sass +0 -15
  119. data/test/sass/templates/double_import_loop1.sass +0 -1
  120. data/test/sass/templates/expanded.sass +0 -17
  121. data/test/sass/templates/filename_fn.scss +0 -18
  122. data/test/sass/templates/if.sass +0 -11
  123. data/test/sass/templates/import.sass +0 -12
  124. data/test/sass/templates/import_charset.sass +0 -9
  125. data/test/sass/templates/import_charset_ibm866.sass +0 -11
  126. data/test/sass/templates/import_content.sass +0 -4
  127. data/test/sass/templates/importee.less +0 -2
  128. data/test/sass/templates/importee.sass +0 -19
  129. data/test/sass/templates/line_numbers.sass +0 -13
  130. data/test/sass/templates/mixin_bork.sass +0 -5
  131. data/test/sass/templates/mixins.sass +0 -76
  132. data/test/sass/templates/multiline.sass +0 -20
  133. data/test/sass/templates/nested.sass +0 -25
  134. data/test/sass/templates/nested_bork1.sass +0 -2
  135. data/test/sass/templates/nested_bork2.sass +0 -2
  136. data/test/sass/templates/nested_bork3.sass +0 -2
  137. data/test/sass/templates/nested_bork4.sass +0 -2
  138. data/test/sass/templates/nested_import.sass +0 -2
  139. data/test/sass/templates/nested_mixin_bork.sass +0 -6
  140. data/test/sass/templates/options.sass +0 -2
  141. data/test/sass/templates/parent_ref.sass +0 -25
  142. data/test/sass/templates/same_name_different_ext.sass +0 -2
  143. data/test/sass/templates/same_name_different_ext.scss +0 -1
  144. data/test/sass/templates/same_name_different_partiality.scss +0 -1
  145. data/test/sass/templates/script.sass +0 -101
  146. data/test/sass/templates/scss_import.scss +0 -12
  147. data/test/sass/templates/scss_importee.scss +0 -1
  148. data/test/sass/templates/single_import_loop.sass +0 -1
  149. data/test/sass/templates/subdir/import_up1.scss +0 -1
  150. data/test/sass/templates/subdir/import_up2.scss +0 -1
  151. data/test/sass/templates/subdir/nested_subdir/_nested_partial.sass +0 -2
  152. data/test/sass/templates/subdir/nested_subdir/nested_subdir.sass +0 -3
  153. data/test/sass/templates/subdir/subdir.sass +0 -6
  154. data/test/sass/templates/units.sass +0 -11
  155. data/test/sass/templates/warn.sass +0 -3
  156. data/test/sass/templates/warn_imported.sass +0 -4
  157. data/test/sass/test_helper.rb +0 -8
  158. data/test/sass/util/multibyte_string_scanner_test.rb +0 -152
  159. data/test/sass/util/normalized_map_test.rb +0 -50
  160. data/test/sass/util/subset_map_test.rb +0 -90
  161. data/test/sass/util_test.rb +0 -403
  162. data/test/sass/value_helpers_test.rb +0 -178
  163. data/test/test_helper.rb +0 -149
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f8bc006450eec1decf66c14cd5291f0bba21ee98
4
- data.tar.gz: 215e6234472577c8fad6f03375426b8c4c845f5e
3
+ metadata.gz: 6442c161b5fc7709753d4bdc2a134f340af6d908
4
+ data.tar.gz: '0946cacd17612b438ce689b86cce9fa6a90bc208'
5
5
  SHA512:
6
- metadata.gz: b26dc35c34da276b1be99f68c12731b4c74d219216e6e8353ef52d12f2f0317e5d10d0823268c054925b4eea746570ca281ddb15938201433e3451233ac1d17b
7
- data.tar.gz: 247f868f376a2d6c99c0e58aa2a8be7d4db58f0d45c5144febec4cd3a84d22cd2f3e8f50053c3540310ceee87165b92f8f064d7c655b70f7bd858fc28dd69932
6
+ metadata.gz: 87b7eb8440a85957deaf8b83549d60fdb86f8c5f865aab9db67bee7ba8cd5c0985f05018c9a7ff18e1ea514aa2beb8dbca238257f76e6db14b9f6b1793bf4388
7
+ data.tar.gz: 5c786b64db488ba61d018257943aeb1ab9365c2e7069201ae0a5759fdbe6576f36d57a885ea690824d15d398d2c8c656fb21be0460ca5f6b088f2e10cfd1edee
@@ -7,4 +7,4 @@ fair place to play.
7
7
 
8
8
  [The full community guidelines can be found on the Sass website.][link]
9
9
 
10
- [link]: http://sass-lang.com/community-guidelines
10
+ [link]: https://sass-lang.com/community-guidelines
@@ -1,6 +1,6 @@
1
1
  Contributions are welcomed. Please see the following site for guidelines:
2
2
 
3
- [http://sass-lang.com/community#Contribute](http://sass-lang.com/community#Contribute)
3
+ [https://sass-lang.com/community#Contribute](https://sass-lang.com/community#Contribute)
4
4
 
5
5
  * [Branches](#main-development-branches)
6
6
  * [Feature Branches](#feature-branches)
@@ -18,7 +18,7 @@ is regularly merged into the one below: `stable` into `next`, `next` into
18
18
  `master`.
19
19
 
20
20
  * The `stable` branch is the default—it's what GitHub shows if you go to
21
- [sass/sass](https://github.com/sass/sass), and it's the default place for pull
21
+ [sass/ruby-sass](https://github.com/sass/ruby-sass), and it's the default place for pull
22
22
  requests to go. This branch is where we work on the next patch release. Bug
23
23
  fixes and documentation improvements belong here, but not new features.
24
24
 
@@ -100,7 +100,7 @@ like [`Sass::Engine`][Sass::Engine] stable, we don't have a strong distinction
100
100
  between public and private APIs and we need to be able to freely refactor our
101
101
  code.
102
102
 
103
- [Sass::Engine]: http://sass-lang.com/documentation/Sass/Engine.html
103
+ [Sass::Engine]: https://sass-lang.com/documentation/Sass/Engine.html
104
104
 
105
105
  ### Making Breaking Changes
106
106
 
data/README.md CHANGED
@@ -1,4 +1,12 @@
1
- # Sass [![Travis Build Status](https://travis-ci.org/sass/sass.svg?branch=next)](https://travis-ci.org/sass/sass) [![Gem Version](https://badge.fury.io/rb/sass.svg)](http://badge.fury.io/rb/sass) [![Inline docs](http://inch-ci.org/github/sass/sass.svg)](http://inch-ci.org/github/sass/sass)
1
+ ## Ruby Sass Has Reached End-of-Life
2
+
3
+ Ruby Sass should no longer be used, and will no longer be receiving any updates.
4
+ See [the Sass blog][], and consider switching to the [`sassc` gem].
5
+
6
+ [the Sass blog]: https://sass-lang.com/blog/posts/7828841
7
+ [`sassc` gem]: https://rubygems.org/gems/sassc
8
+
9
+ # Sass [![Travis Build Status](https://travis-ci.org/sass/ruby-sass.svg?branch=next)](https://travis-ci.org/sass/ruby-sass) [![Gem Version](https://badge.fury.io/rb/sass.svg)](http://badge.fury.io/rb/sass) [![Inline docs](http://inch-ci.org/github/sass/sass.svg)](http://inch-ci.org/github/sass/sass)
2
10
 
3
11
  **Sass makes CSS fun again**. Sass is an extension of CSS,
4
12
  adding nested rules, variables, mixins, selector inheritance, and more.
@@ -44,7 +52,7 @@ In Rails 3, add `gem "sass"` to your Gemfile instead.
44
52
  where they'll be automatically compiled
45
53
  to corresponding CSS files in `public/stylesheets` when needed
46
54
  (the Sass template directory is customizable...
47
- see [the Sass reference](http://sass-lang.com/docs/yardoc/file.SASS_REFERENCE.html#template_location-option) for details).
55
+ see [the Sass reference](https://sass-lang.com/docs/yardoc/file.SASS_REFERENCE.html#template_location-option) for details).
48
56
 
49
57
  Sass can also be used with any Rack-enabled web framework.
50
58
  To do so, just add
@@ -59,7 +67,7 @@ Then any Sass files in `public/stylesheets/sass`
59
67
  will be compiled into CSS files in `public/stylesheets` on every request.
60
68
 
61
69
  To use Sass programmatically,
62
- check out the [YARD documentation](http://sass-lang.com/documentation/file.SASS_REFERENCE.html#using_sass).
70
+ check out the [YARD documentation](https://sass-lang.com/documentation/file.SASS_REFERENCE.html#using_sass).
63
71
 
64
72
  ## Formatting
65
73
 
@@ -73,10 +81,10 @@ and get small stylesheets up and running quickly,
73
81
  particularly with the help of
74
82
  [the Compass style library](http://compass-style.org).
75
83
 
76
- [vars]: http://sass-lang.com/documentation/file.SASS_REFERENCE.html#variables_
77
- [nested]: http://sass-lang.com/documentation/file.SASS_REFERENCE.html#nested_rules
78
- [mixins]: http://sass-lang.com/documentation/file.SASS_REFERENCE.html#mixins
79
- [imports]: http://sass-lang.com/documentation/file.SASS_REFERENCE.html#import
84
+ [vars]: https://sass-lang.com/documentation/file.SASS_REFERENCE.html#variables_
85
+ [nested]: https://sass-lang.com/documentation/file.SASS_REFERENCE.html#nested_rules
86
+ [mixins]: https://sass-lang.com/documentation/file.SASS_REFERENCE.html#mixins
87
+ [imports]: https://sass-lang.com/documentation/file.SASS_REFERENCE.html#import
80
88
 
81
89
  Sass has two syntaxes.
82
90
  The one presented here, known as "SCSS" (for "Sassy CSS"),
@@ -85,7 +93,7 @@ The other (older) syntax, known as the indented syntax or just "Sass",
85
93
  is whitespace-sensitive and indentation-based.
86
94
  For more information, see the [reference documentation][syntax].
87
95
 
88
- [syntax]: http://sass-lang.com/documentation/file.SASS_REFERENCE.html#syntax
96
+ [syntax]: https://sass-lang.com/documentation/file.SASS_REFERENCE.html#syntax
89
97
 
90
98
  To run the following examples and see the CSS they produce,
91
99
  put them in a file called `test.scss` and run `sass test.scss`.
@@ -160,7 +168,7 @@ You can even give them arguments.
160
168
  ```
161
169
 
162
170
  A comprehensive list of features is available
163
- in the [Sass reference](http://sass-lang.com/documentation/file.SASS_REFERENCE.html).
171
+ in the [Sass reference](https://sass-lang.com/documentation/file.SASS_REFERENCE.html).
164
172
 
165
173
  ## Executables
166
174
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 3.5.2
1
+ 3.7.4
@@ -1 +1 @@
1
- 04 October 2017 22:22:40 UTC
1
+ 04 April 2019 00:49:58 UTC
@@ -18,7 +18,15 @@ fi
18
18
 
19
19
  >&2 echo "Fetching pull request $TRAVIS_PULL_REQUEST..."
20
20
 
21
- JSON=$(curl -L -sS https://api.github.com/repos/sass/sass/pulls/$TRAVIS_PULL_REQUEST)
21
+ url=https://api.github.com/repos/sass/ruby-sass/pulls/$TRAVIS_PULL_REQUEST
22
+ if [ -z "$GITHUB_AUTH" ]; then
23
+ >&2 echo "Fetching pull request info without authentication"
24
+ JSON=$(curl -L -sS $url)
25
+ else
26
+ >&2 echo "Fetching pull request info as sassbot"
27
+ JSON=$(curl -u "sassbot:$GITHUB_AUTH" -L -sS $url)
28
+ fi
29
+ >&2 echo "$JSON"
22
30
 
23
31
  RE_SPEC_PR="sass\/sass-spec(#|\/pull\/)([0-9]+)"
24
32
 
@@ -375,7 +375,7 @@ Error generating source map: couldn't determine public URL for "#{filename}".
375
375
  Without a public URL, there's nothing for the source map to link to.
376
376
  An importer was not set for this file.
377
377
  ERR
378
- elsif Sass::Util.silence_warnings do
378
+ elsif Sass::Util.silence_sass_warnings do
379
379
  sourcemap_dir = nil if @options[:sourcemap] == :file
380
380
  importer.public_url(filename, sourcemap_dir).nil?
381
381
  end
@@ -499,7 +499,6 @@ END
499
499
  lines
500
500
  end
501
501
 
502
- # @comment
503
502
  def try_comment(line, last, tab_str, comment_tab_str, index)
504
503
  return unless last && last.comment?
505
504
  # Nested comment stuff must be at least one whitespace char deeper
@@ -726,10 +725,7 @@ WARNING
726
725
  end
727
726
  end
728
727
 
729
- # @comment
730
- # rubocop:disable ParameterLists
731
728
  def parse_property(name, parsed_name, value, prop, line, start_offset)
732
- # rubocop:enable ParameterLists
733
729
 
734
730
  if name.start_with?('--')
735
731
  unless line.children.empty?
@@ -1038,8 +1034,6 @@ WARNING
1038
1034
  values
1039
1035
  end
1040
1036
 
1041
- # @comment
1042
- # rubocop:disable MethodLength
1043
1037
  def parse_import_arg(scanner, offset)
1044
1038
  return if scanner.eos?
1045
1039
 
@@ -1114,8 +1108,6 @@ WARNING
1114
1108
  end
1115
1109
  node
1116
1110
  end
1117
- # @comment
1118
- # rubocop:enable MethodLength
1119
1111
 
1120
1112
  def parse_mixin_directive(parent, line, root, value, offset)
1121
1113
  parse_mixin_definition(line)
@@ -14,7 +14,6 @@ module Sass::Exec
14
14
  #
15
15
  # @see #parse
16
16
  def parse!
17
- # rubocop:disable RescueException
18
17
  begin
19
18
  parse
20
19
  rescue Exception => e
@@ -38,7 +37,6 @@ module Sass::Exec
38
37
  exit 1
39
38
  end
40
39
  exit 0
41
- # rubocop:enable RescueException
42
40
  end
43
41
 
44
42
  # Parses the command-line arguments and runs the executable.
@@ -92,7 +92,7 @@ END
92
92
  end
93
93
 
94
94
  opts.on("-v", "--version", "Print the Sass version.") do
95
- puts("Sass #{Sass.version[:string]}")
95
+ puts("Ruby Sass #{Sass.version[:string]}")
96
96
  exit
97
97
  end
98
98
  end
@@ -256,8 +256,6 @@ MESSAGE
256
256
  Sass::Repl.new(@options).run
257
257
  end
258
258
 
259
- # @comment
260
- # rubocop:disable MethodLength
261
259
  def watch_or_update
262
260
  require 'sass/plugin'
263
261
  Sass::Plugin.options.merge! @options[:for_engine]
@@ -359,8 +357,6 @@ WARNING
359
357
 
360
358
  Sass::Plugin.watch(files)
361
359
  end
362
- # @comment
363
- # rubocop:enable MethodLength
364
360
 
365
361
  def run
366
362
  input = @options[:input]
@@ -154,7 +154,9 @@ module Sass
154
154
  [Sass::Util.cleanpath(full_path).to_s, s]
155
155
  end
156
156
  end.flatten(1)
157
- return if found.empty?
157
+ if found.empty? && split(name)[2].nil? && File.directory?("#{dir}/#{name}")
158
+ return find_real_file("#{dir}/#{name}", "index", options)
159
+ end
158
160
 
159
161
  if found.size > 1 && !@same_name_warnings.include?(found.first.first)
160
162
  found.each {|(f, _)| @same_name_warnings << f}
@@ -202,7 +204,7 @@ WARNING
202
204
 
203
205
  def _find(dir, name, options)
204
206
  full_filename, syntax = Sass::Util.destructure(find_real_file(dir, name, options))
205
- return unless full_filename && File.readable?(full_filename)
207
+ return unless full_filename && File.file?(full_filename) && File.readable?(full_filename)
206
208
 
207
209
  # TODO: this preserves historical behavior, but it's possible
208
210
  # :filename should be either normalized to the native format
@@ -22,6 +22,17 @@ class Sass::Logger::Base
22
22
  !disabled && self.class.log_level?(level, log_level)
23
23
  end
24
24
 
25
+ # Captures all logger messages emitted during a block and returns them as a
26
+ # string.
27
+ def capture
28
+ old_io = io
29
+ self.io = StringIO.new
30
+ yield
31
+ io.string
32
+ ensure
33
+ self.io = old_io
34
+ end
35
+
25
36
  def log(level, message)
26
37
  _log(level, message) if logging_level?(level)
27
38
  end
@@ -24,7 +24,10 @@ module Sass
24
24
  end
25
25
 
26
26
  # Short-circuit all the SassScript-only productions
27
- alias_method :interpolation, :space
27
+ def interpolation(first: nil, inner: :space)
28
+ first || send(inner)
29
+ end
30
+
28
31
  alias_method :or_expr, :div
29
32
  alias_method :unary_div, :ident
30
33
  alias_method :paren, :string
@@ -1,9 +1,7 @@
1
1
  require 'sass/script/value/helpers'
2
2
 
3
3
  module Sass::Script
4
- # @comment
5
4
  # YARD can't handle some multiline tags, and we need really long tags for function declarations.
6
- # rubocop:disable LineLength
7
5
  # Methods in this module are accessible from the SassScript context.
8
6
  # For example, you can write
9
7
  #
@@ -364,9 +362,6 @@ module Sass::Script
364
362
  # representation) on those objects without first setting {Tree::Node#options=
365
363
  # the #options attribute}.
366
364
  #
367
- # @comment
368
- # rubocop:enable LineLength
369
- # rubocop:disable ModuleLength
370
365
  module Functions
371
366
  @signatures = {}
372
367
 
@@ -653,7 +648,15 @@ module Sass::Script
653
648
  # inclusive
654
649
  # @return [Sass::Script::Value::Color]
655
650
  # @raise [ArgumentError] if any parameter is the wrong type or out of bounds
656
- def rgb(red, green, blue)
651
+ def rgb(red, green = nil, blue = nil)
652
+ if green.nil?
653
+ return unquoted_string("rgb(#{red})") if var?(red)
654
+ raise ArgumentError.new("wrong number of arguments (1 for 3)")
655
+ elsif blue.nil?
656
+ return unquoted_string("rgb(#{red}, #{green})") if var?(red) || var?(green)
657
+ raise ArgumentError.new("wrong number of arguments (2 for 3)")
658
+ end
659
+
657
660
  if special_number?(red) || special_number?(green) || special_number?(blue)
658
661
  return unquoted_string("rgb(#{red}, #{green}, #{blue})")
659
662
  end
@@ -661,15 +664,11 @@ module Sass::Script
661
664
  assert_type green, :Number, :green
662
665
  assert_type blue, :Number, :blue
663
666
 
664
- color_attrs = [red, green, blue].map do |c|
665
- if c.is_unit?("%")
666
- c.value * 255 / 100.0
667
- elsif c.unitless?
668
- c.value
669
- else
670
- raise ArgumentError.new("Expected #{c} to be unitless or have a unit of % but got #{c}")
671
- end
672
- end
667
+ color_attrs = [
668
+ percentage_or_unitless(red, 255, "red"),
669
+ percentage_or_unitless(green, 255, "green"),
670
+ percentage_or_unitless(blue, 255, "blue")
671
+ ]
673
672
 
674
673
  # Don't store the string representation for function-created colors, both
675
674
  # because it's not very useful and because some functions aren't supported
@@ -677,6 +676,8 @@ module Sass::Script
677
676
  Sass::Script::Value::Color.new(color_attrs)
678
677
  end
679
678
  declare :rgb, [:red, :green, :blue]
679
+ declare :rgb, [:red, :green]
680
+ declare :rgb, [:red]
680
681
 
681
682
  # Creates a {Sass::Script::Value::Color Color} from red, green, blue, and
682
683
  # alpha values.
@@ -711,16 +712,34 @@ module Sass::Script
711
712
  # is the wrong type
712
713
  def rgba(*args)
713
714
  case args.size
715
+ when 1
716
+ return unquoted_string("rgba(#{args.first})") if var?(args.first)
717
+ raise ArgumentError.new("wrong number of arguments (1 for 4)")
714
718
  when 2
715
719
  color, alpha = args
716
720
 
721
+ if var?(color)
722
+ return unquoted_string("rgba(#{color}, #{alpha})")
723
+ elsif var?(alpha)
724
+ if color.is_a?(Sass::Script::Value::Color)
725
+ return unquoted_string("rgba(#{color.red}, #{color.green}, #{color.blue}, #{alpha})")
726
+ else
727
+ return unquoted_string("rgba(#{color}, #{alpha})")
728
+ end
729
+ end
730
+
717
731
  assert_type color, :Color, :color
718
732
  if special_number?(alpha)
719
733
  unquoted_string("rgba(#{color.red}, #{color.green}, #{color.blue}, #{alpha})")
720
734
  else
721
735
  assert_type alpha, :Number, :alpha
722
- check_alpha_unit alpha, 'rgba'
723
- color.with(:alpha => alpha.value)
736
+ color.with(:alpha => percentage_or_unitless(alpha, 1, "alpha"))
737
+ end
738
+ when 3
739
+ if var?(args[0]) || var?(args[1]) || var?(args[2])
740
+ unquoted_string("rgba(#{args.join(', ')})")
741
+ else
742
+ raise ArgumentError.new("wrong number of arguments (3 for 4)")
724
743
  end
725
744
  when 4
726
745
  red, green, blue, alpha = args
@@ -735,7 +754,9 @@ module Sass::Script
735
754
  end
736
755
  end
737
756
  declare :rgba, [:red, :green, :blue, :alpha]
757
+ declare :rgba, [:red, :green, :blue]
738
758
  declare :rgba, [:color, :alpha]
759
+ declare :rgba, [:red]
739
760
 
740
761
  # Creates a {Sass::Script::Value::Color Color} from hue, saturation, and
741
762
  # lightness values. Uses the algorithm from the [CSS3 spec][].
@@ -753,7 +774,15 @@ module Sass::Script
753
774
  # @return [Sass::Script::Value::Color]
754
775
  # @raise [ArgumentError] if `$saturation` or `$lightness` are out of bounds
755
776
  # or any parameter is the wrong type
756
- def hsl(hue, saturation, lightness)
777
+ def hsl(hue, saturation = nil, lightness = nil)
778
+ if saturation.nil?
779
+ return unquoted_string("hsl(#{hue})") if var?(hue)
780
+ raise ArgumentError.new("wrong number of arguments (1 for 3)")
781
+ elsif lightness.nil?
782
+ return unquoted_string("hsl(#{hue}, #{saturation})") if var?(hue) || var?(saturation)
783
+ raise ArgumentError.new("wrong number of arguments (2 for 3)")
784
+ end
785
+
757
786
  if special_number?(hue) || special_number?(saturation) || special_number?(lightness)
758
787
  unquoted_string("hsl(#{hue}, #{saturation}, #{lightness})")
759
788
  else
@@ -761,6 +790,8 @@ module Sass::Script
761
790
  end
762
791
  end
763
792
  declare :hsl, [:hue, :saturation, :lightness]
793
+ declare :hsl, [:hue, :saturation]
794
+ declare :hsl, [:hue]
764
795
 
765
796
  # Creates a {Sass::Script::Value::Color Color} from hue,
766
797
  # saturation, lightness, and alpha values. Uses the algorithm from
@@ -781,7 +812,21 @@ module Sass::Script
781
812
  # @return [Sass::Script::Value::Color]
782
813
  # @raise [ArgumentError] if `$saturation`, `$lightness`, or `$alpha` are out
783
814
  # of bounds or any parameter is the wrong type
784
- def hsla(hue, saturation, lightness, alpha)
815
+ def hsla(hue, saturation = nil, lightness = nil, alpha = nil)
816
+ if saturation.nil?
817
+ return unquoted_string("hsla(#{hue})") if var?(hue)
818
+ raise ArgumentError.new("wrong number of arguments (1 for 4)")
819
+ elsif lightness.nil?
820
+ return unquoted_string("hsla(#{hue}, #{saturation})") if var?(hue) || var?(saturation)
821
+ raise ArgumentError.new("wrong number of arguments (2 for 4)")
822
+ elsif alpha.nil?
823
+ if var?(hue) || var?(saturation) || var?(lightness)
824
+ return unquoted_string("hsla(#{hue}, #{saturation}, #{lightness})")
825
+ else
826
+ raise ArgumentError.new("wrong number of arguments (2 for 4)")
827
+ end
828
+ end
829
+
785
830
  if special_number?(hue) || special_number?(saturation) ||
786
831
  special_number?(lightness) || special_number?(alpha)
787
832
  return unquoted_string("hsla(#{hue}, #{saturation}, #{lightness}, #{alpha})")
@@ -790,7 +835,6 @@ module Sass::Script
790
835
  assert_type saturation, :Number, :saturation
791
836
  assert_type lightness, :Number, :lightness
792
837
  assert_type alpha, :Number, :alpha
793
- check_alpha_unit alpha, 'hsla'
794
838
 
795
839
  h = hue.value
796
840
  s = saturation.value
@@ -800,9 +844,13 @@ module Sass::Script
800
844
  # because it's not very useful and because some functions aren't supported
801
845
  # on older browsers.
802
846
  Sass::Script::Value::Color.new(
803
- :hue => h, :saturation => s, :lightness => l, :alpha => alpha.value)
847
+ :hue => h, :saturation => s, :lightness => l,
848
+ :alpha => percentage_or_unitless(alpha, 1, "alpha"))
804
849
  end
805
850
  declare :hsla, [:hue, :saturation, :lightness, :alpha]
851
+ declare :hsla, [:hue, :saturation, :lightness]
852
+ declare :hsla, [:hue, :saturation]
853
+ declare :hsla, [:hue]
806
854
 
807
855
  # Gets the red component of a color. Calculated from HSL where necessary via
808
856
  # [this algorithm][hsl-to-rgb].
@@ -1442,13 +1490,11 @@ module Sass::Script
1442
1490
  def unquote(string)
1443
1491
  unless string.is_a?(Sass::Script::Value::String)
1444
1492
  # Don't warn multiple times for the same source line.
1445
- # rubocop:disable GlobalVars
1446
1493
  $_sass_warned_for_unquote ||= Set.new
1447
1494
  frame = environment.stack.frames.last
1448
1495
  key = [frame.filename, frame.line] if frame
1449
1496
  return string if frame && $_sass_warned_for_unquote.include?(key)
1450
1497
  $_sass_warned_for_unquote << key if frame
1451
- # rubocop:enable GlobalVars
1452
1498
 
1453
1499
  Sass::Util.sass_warn(<<MESSAGE.strip)
1454
1500
  DEPRECATION WARNING: Passing #{string.to_sass}, a non-string value, to unquote()
@@ -2007,12 +2053,9 @@ MESSAGE
2007
2053
  # will be bracketed. If this is `auto` (the default), the separator is
2008
2054
  # determined as explained above.
2009
2055
  # @return [Sass::Script::Value::List]
2010
- # @comment
2011
- # rubocop:disable ParameterLists
2012
2056
  def join(list1, list2,
2013
2057
  separator = identifier("auto"), bracketed = identifier("auto"),
2014
2058
  kwargs = nil, *rest)
2015
- # rubocop:enable ParameterLists
2016
2059
  if separator.is_a?(Hash)
2017
2060
  kwargs = separator
2018
2061
  separator = identifier("auto")
@@ -2855,10 +2898,7 @@ WARNING
2855
2898
  yield(value.value), value.numerator_units, value.denominator_units)
2856
2899
  end
2857
2900
 
2858
- # @comment
2859
- # rubocop:disable ParameterLists
2860
2901
  def _adjust(color, amount, attr, range, op, units = "")
2861
- # rubocop:enable ParameterLists
2862
2902
  assert_type color, :Color, :color
2863
2903
  assert_type amount, :Number, :amount
2864
2904
  Sass::Util.check_range('Amount', range, amount, units)
@@ -2866,19 +2906,14 @@ WARNING
2866
2906
  color.with(attr => color.send(attr).send(op, amount.value))
2867
2907
  end
2868
2908
 
2869
- def check_alpha_unit(alpha, function)
2870
- return if alpha.unitless?
2871
-
2872
- if alpha.is_unit?("%")
2873
- Sass::Util.sass_warn(<<WARNING)
2874
- DEPRECATION WARNING: Passing a percentage as the alpha value to #{function}() will be
2875
- interpreted differently in future versions of Sass. For now, use #{alpha.value} instead.
2876
- WARNING
2909
+ def percentage_or_unitless(number, max, name)
2910
+ if number.unitless?
2911
+ number.value
2912
+ elsif number.is_unit?("%")
2913
+ max * number.value / 100.0;
2877
2914
  else
2878
- Sass::Util.sass_warn(<<WARNING)
2879
- DEPRECATION WARNING: Passing a number with units as the alpha value to #{function}() is
2880
- deprecated and will be an error in future versions of Sass. Use #{alpha.value} instead.
2881
- WARNING
2915
+ raise ArgumentError.new(
2916
+ "$#{name}: Expected #{number} to have no units or \"%\"");
2882
2917
  end
2883
2918
  end
2884
2919
  end