sass 3.4.22 → 3.4.24
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.yardopts +1 -1
- data/CONTRIBUTING.md +23 -0
- data/README.md +8 -8
- data/Rakefile +2 -10
- data/VERSION +1 -1
- data/VERSION_DATE +1 -1
- data/extra/sass-spec-ref.sh +32 -0
- data/lib/sass/cache_stores/filesystem.rb +1 -1
- data/lib/sass/engine.rb +3 -3
- data/lib/sass/error.rb +3 -3
- data/lib/sass/exec/base.rb +1 -1
- data/lib/sass/logger/base.rb +8 -2
- data/lib/sass/logger/delayed.rb +50 -0
- data/lib/sass/logger.rb +8 -3
- data/lib/sass/plugin/rack.rb +1 -1
- data/lib/sass/plugin/staleness_checker.rb +2 -2
- data/lib/sass/script/functions.rb +10 -7
- data/lib/sass/script/lexer.rb +5 -5
- data/lib/sass/script/parser.rb +17 -11
- data/lib/sass/script/tree/node.rb +1 -1
- data/lib/sass/script/value/base.rb +2 -2
- data/lib/sass/script/value/color.rb +10 -10
- data/lib/sass/script/value/number.rb +11 -9
- data/lib/sass/script.rb +2 -2
- data/lib/sass/scss/parser.rb +26 -8
- data/lib/sass/scss/rx.rb +1 -1
- data/lib/sass/selector/abstract_sequence.rb +5 -5
- data/lib/sass/selector/sequence.rb +2 -2
- data/lib/sass/selector/simple.rb +4 -4
- data/lib/sass/shared.rb +1 -1
- data/lib/sass/source/map.rb +5 -3
- data/lib/sass/source/position.rb +4 -4
- data/lib/sass/tree/comment_node.rb +1 -1
- data/lib/sass/tree/node.rb +1 -1
- data/lib/sass/tree/prop_node.rb +1 -1
- data/lib/sass/tree/rule_node.rb +1 -1
- data/lib/sass/tree/visitors/convert.rb +3 -1
- data/lib/sass/tree/visitors/to_css.rb +1 -1
- data/lib/sass/util.rb +33 -8
- data/lib/sass/version.rb +2 -2
- data/test/sass/conversion_test.rb +17 -0
- data/test/sass/extend_test.rb +38 -18
- data/test/sass/script_test.rb +3 -3
- data/test/sass/scss/scss_test.rb +33 -0
- metadata +28 -26
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 798967a96737a6978563e8b46a97cf3254d1bd54
|
4
|
+
data.tar.gz: 57ed07a4077a5d81a9b821da7b7f4dcffb939fd2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a86659601d7713959b8213d53a09ced83a3d3eb09eb64fdcab54fcba0e3f4b05477db9ded2f30c7e77a44f078115ee9b6efed016f868b40e725e40d7bb4a1d3e
|
7
|
+
data.tar.gz: 42da27fb2cd7325d5df8404ea20bd6e4d57f926ee835f266120dc2fbd2beee43a7dc2e8932d136365c43f26a66fe019457a46afe376578ce11a8abc2316625cc
|
data/.yardopts
CHANGED
data/CONTRIBUTING.md
CHANGED
@@ -37,6 +37,29 @@ branch, but don't worry about it too much; if you make a request against the
|
|
37
37
|
wrong branch, the maintainer will take responsibility for rebasing it before
|
38
38
|
merging.
|
39
39
|
|
40
|
+
### Testing
|
41
|
+
|
42
|
+
Tests for changes to the Sass language go in
|
43
|
+
[sass-spec](https://github.com/sass/sass-spec) so that other
|
44
|
+
implementations (E.g. libSass) can be tested against the same test
|
45
|
+
suite. The sass-spec repo follows a "trunk development" model in that
|
46
|
+
the tests there test against different version of the Sass language (as
|
47
|
+
opposed to having branches that track different Sass versions). When
|
48
|
+
contributing changes to Sass, update the Gemfile to use sass-spec from a
|
49
|
+
branch or fork that has the new tests. When the feature lands in Sass,
|
50
|
+
the committer will also merge the corresponding sass-spec changes.
|
51
|
+
|
52
|
+
The [documentation of
|
53
|
+
sass-spec](https://github.com/sass/sass-spec/blob/master/README.md)
|
54
|
+
explains how to run sass-spec and contribute changes. In development,
|
55
|
+
Change the Gemfile(s) to use the `:path` option against the sass-spec gem
|
56
|
+
to link your local checkout of sass and sass-spec together in one or
|
57
|
+
both directions.
|
58
|
+
|
59
|
+
Changes to Sass internals or Ruby Sass specific features (E.g.
|
60
|
+
the `sass-convert` tool) should always have tests in the Sass `test`
|
61
|
+
directory following the conventions you see there.
|
62
|
+
|
40
63
|
### Feature Branches
|
41
64
|
|
42
65
|
Sometimes it won't be possible to merge a new feature into `next` or `master`
|
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Sass [](http://badge.fury.io/rb/sass) [](http://inch-ci.org/github/sass/sass)
|
2
2
|
|
3
3
|
**Sass makes CSS fun again**. Sass is an extension of CSS,
|
4
4
|
adding nested rules, variables, mixins, selector inheritance, and more.
|
@@ -184,7 +184,7 @@ See `sass-convert --help` for further information and options.
|
|
184
184
|
To run the Sass executables from a source checkout instead of from rubygems:
|
185
185
|
|
186
186
|
```
|
187
|
-
$ cd
|
187
|
+
$ cd sass
|
188
188
|
$ bundle
|
189
189
|
$ bundle exec sass ...
|
190
190
|
$ bundle exec scss ...
|
@@ -199,12 +199,12 @@ and now occasionally consults on the language issues. Hampton lives in San
|
|
199
199
|
Francisco, California and works as VP of Technology
|
200
200
|
at [Moovweb](http://www.moovweb.com/).
|
201
201
|
|
202
|
-
[Natalie Weizenbaum](https://twitter.com/nex3) is the primary developer and
|
203
|
-
Sass. Her hard work has kept the project alive by endlessly
|
204
|
-
posts, fixing bugs, refactoring, finding speed improvements,
|
205
|
-
documentation, implementing new features, and
|
206
|
-
|
207
|
-
|
202
|
+
[Natalie Weizenbaum](https://twitter.com/nex3) is the primary developer and
|
203
|
+
architect of Sass. Her hard work has kept the project alive by endlessly
|
204
|
+
answering forum posts, fixing bugs, refactoring, finding speed improvements,
|
205
|
+
writing documentation, implementing new features, and designing the language.
|
206
|
+
Natalie lives in Seattle, Washington and works on [Dart](http://dartlang.org)
|
207
|
+
application libraries at Google.
|
208
208
|
|
209
209
|
[Chris Eppstein](http://twitter.com/chriseppstein) is a core contributor to
|
210
210
|
Sass and the creator of [Compass](http://compass-style.org/), the first Sass-based framework, and
|
data/Rakefile
CHANGED
@@ -48,8 +48,8 @@ namespace :test do
|
|
48
48
|
end
|
49
49
|
default_options = {
|
50
50
|
:spec_directory => SassSpec::SPEC_DIR,
|
51
|
-
:engine_adapter => SassEngineAdapter.new
|
52
|
-
:generate =>
|
51
|
+
:engine_adapter => SassEngineAdapter.new,
|
52
|
+
:generate => false,
|
53
53
|
:tap => false,
|
54
54
|
:skip => false,
|
55
55
|
:verbose => false,
|
@@ -57,14 +57,6 @@ namespace :test do
|
|
57
57
|
:limit => -1,
|
58
58
|
:unexpected_pass => false,
|
59
59
|
:nuke => false,
|
60
|
-
|
61
|
-
# Constants
|
62
|
-
:output_styles => ["nested"],
|
63
|
-
:input_files => ["input.scss", "input.sass"],
|
64
|
-
:nested_output_file => 'expected_output',
|
65
|
-
:compressed_output_file => 'expected.compressed',
|
66
|
-
:expanded_output_file => 'expected.expanded',
|
67
|
-
:compact_output_file => 'expected.compact'
|
68
60
|
}
|
69
61
|
SassSpec::Runner.new(default_options.merge(sass_spec_options)).run || exit(1)
|
70
62
|
ensure
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
3.4.
|
1
|
+
3.4.24
|
data/VERSION_DATE
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
19 May 2017 00:01:41 UTC
|
@@ -0,0 +1,32 @@
|
|
1
|
+
#!/bin/bash -e
|
2
|
+
# Copyright 2016 Google Inc. Use of this source code is governed by an MIT-style
|
3
|
+
# license that can be found in the LICENSE file or at
|
4
|
+
# https://opensource.org/licenses/MIT.
|
5
|
+
|
6
|
+
# Echoes the sass-spec Git ref that should be checked out for the current Travis
|
7
|
+
# run. If we're running specs for a pull request which refers to a sass-spec
|
8
|
+
# pull request, we'll run against the latter rather than sass-spec master.
|
9
|
+
|
10
|
+
default=master
|
11
|
+
|
12
|
+
if [ "$TRAVIS_PULL_REQUEST" == "false" ]; then
|
13
|
+
>&2 echo "TRAVIS_PULL_REQUEST: $TRAVIS_PULL_REQUEST."
|
14
|
+
>&2 echo "Ref: $default."
|
15
|
+
echo "$default"
|
16
|
+
exit 0
|
17
|
+
fi
|
18
|
+
|
19
|
+
>&2 echo "Fetching pull request $TRAVIS_PULL_REQUEST..."
|
20
|
+
|
21
|
+
JSON=$(curl -L -sS https://api.github.com/repos/sass/sass/pulls/$TRAVIS_PULL_REQUEST)
|
22
|
+
|
23
|
+
RE_SPEC_PR="sass\/sass-spec(#|\/pull\/)([0-9]+)"
|
24
|
+
|
25
|
+
if [[ $JSON =~ $RE_SPEC_PR ]]; then
|
26
|
+
ref="pull/${BASH_REMATCH[2]}/head"
|
27
|
+
>&2 echo "Ref: $ref."
|
28
|
+
echo "$ref"
|
29
|
+
else
|
30
|
+
>&2 echo "Ref: $default."
|
31
|
+
echo "$default"
|
32
|
+
fi
|
@@ -36,7 +36,7 @@ module Sass
|
|
36
36
|
def _store(key, version, sha, contents)
|
37
37
|
compiled_filename = path_to(key)
|
38
38
|
FileUtils.mkdir_p(File.dirname(compiled_filename))
|
39
|
-
Sass::Util.atomic_create_and_write_file(compiled_filename
|
39
|
+
Sass::Util.atomic_create_and_write_file(compiled_filename) do |f|
|
40
40
|
f.puts(version)
|
41
41
|
f.puts(sha)
|
42
42
|
f.write(contents)
|
data/lib/sass/engine.rb
CHANGED
@@ -94,13 +94,13 @@ module Sass
|
|
94
94
|
# `text`: `String`
|
95
95
|
# : The text in the line, without any whitespace at the beginning or end.
|
96
96
|
#
|
97
|
-
# `tabs`: `
|
97
|
+
# `tabs`: `Integer`
|
98
98
|
# : The level of indentation of the line.
|
99
99
|
#
|
100
|
-
# `index`: `
|
100
|
+
# `index`: `Integer`
|
101
101
|
# : The line number in the original document.
|
102
102
|
#
|
103
|
-
# `offset`: `
|
103
|
+
# `offset`: `Integer`
|
104
104
|
# : The number of bytes in on the line that the text begins.
|
105
105
|
# This ends up being the number of bytes of leading whitespace.
|
106
106
|
#
|
data/lib/sass/error.rb
CHANGED
@@ -69,14 +69,14 @@ module Sass
|
|
69
69
|
# The name of the mixin in which the error occurred.
|
70
70
|
# This could be `nil` if the error occurred outside a mixin.
|
71
71
|
#
|
72
|
-
# @return [
|
72
|
+
# @return [String]
|
73
73
|
def sass_mixin
|
74
74
|
sass_backtrace.first[:mixin]
|
75
75
|
end
|
76
76
|
|
77
77
|
# The line of the Sass template on which the error occurred.
|
78
78
|
#
|
79
|
-
# @return [
|
79
|
+
# @return [Integer]
|
80
80
|
def sass_line
|
81
81
|
sass_backtrace.first[:line]
|
82
82
|
end
|
@@ -153,7 +153,7 @@ module Sass
|
|
153
153
|
# Returns an error report for an exception in CSS format.
|
154
154
|
#
|
155
155
|
# @param e [Exception]
|
156
|
-
# @param line_offset [
|
156
|
+
# @param line_offset [Integer] The number of the first line of the Sass template.
|
157
157
|
# @return [String] The error report
|
158
158
|
# @raise [Exception] `e`, if the
|
159
159
|
# {file:SASS_REFERENCE.md#full_exception-option `:full_exception`} option
|
data/lib/sass/exec/base.rb
CHANGED
@@ -23,7 +23,7 @@ module Sass::Exec
|
|
23
23
|
# at_exit is a bit of a hack, but it allows us to rethrow when --trace
|
24
24
|
# is active and get both the built-in exception formatting and the
|
25
25
|
# correct exit code.
|
26
|
-
at_exit {exit 65} if e.is_a?(Sass::SyntaxError)
|
26
|
+
at_exit {exit Sass::Util.windows? ? 13 : 65} if e.is_a?(Sass::SyntaxError)
|
27
27
|
|
28
28
|
raise e if @options[:trace] || e.is_a?(SystemExit)
|
29
29
|
|
data/lib/sass/logger/base.rb
CHANGED
@@ -5,6 +5,7 @@ class Sass::Logger::Base
|
|
5
5
|
|
6
6
|
attr_accessor :log_level
|
7
7
|
attr_accessor :disabled
|
8
|
+
attr_accessor :io
|
8
9
|
|
9
10
|
log_level :trace
|
10
11
|
log_level :debug
|
@@ -12,8 +13,9 @@ class Sass::Logger::Base
|
|
12
13
|
log_level :warn
|
13
14
|
log_level :error
|
14
15
|
|
15
|
-
def initialize(log_level = :debug)
|
16
|
+
def initialize(log_level = :debug, io = nil)
|
16
17
|
self.log_level = log_level
|
18
|
+
self.io = io
|
17
19
|
end
|
18
20
|
|
19
21
|
def logging_level?(level)
|
@@ -25,6 +27,10 @@ class Sass::Logger::Base
|
|
25
27
|
end
|
26
28
|
|
27
29
|
def _log(level, message)
|
28
|
-
|
30
|
+
if io
|
31
|
+
io.puts(message)
|
32
|
+
else
|
33
|
+
Kernel.warn(message)
|
34
|
+
end
|
29
35
|
end
|
30
36
|
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
require 'sass/logger/log_level'
|
2
|
+
|
3
|
+
# A logger that delays messages until they're explicitly flushed to an inner
|
4
|
+
# logger.
|
5
|
+
#
|
6
|
+
# This can be installed around the current logger by calling \{#install!}, and
|
7
|
+
# the original logger can be replaced by calling \{#uninstall!}. The log
|
8
|
+
# messages can be flushed by calling \{#flush}.
|
9
|
+
class Sass::Logger::Delayed < Sass::Logger::Base
|
10
|
+
# Installs a new delayed logger as the current Sass logger, wrapping the
|
11
|
+
# original logger.
|
12
|
+
#
|
13
|
+
# This can be undone by calling \{#uninstall!}.
|
14
|
+
#
|
15
|
+
# @return [Sass::Logger::Delayed] The newly-created logger.
|
16
|
+
def self.install!
|
17
|
+
logger = Sass::Logger::Delayed.new(Sass.logger)
|
18
|
+
Sass.logger = logger
|
19
|
+
logger
|
20
|
+
end
|
21
|
+
|
22
|
+
# Creates a delayed logger wrapping `inner`.
|
23
|
+
#
|
24
|
+
# @param inner [Sass::Logger::Base] The wrapped logger.
|
25
|
+
def initialize(inner)
|
26
|
+
self.log_level = inner.log_level
|
27
|
+
@inner = inner
|
28
|
+
@messages = []
|
29
|
+
end
|
30
|
+
|
31
|
+
# Flushes all queued logs to the wrapped logger.
|
32
|
+
def flush
|
33
|
+
@messages.each {|(l, m)| @inner.log(l, m)}
|
34
|
+
end
|
35
|
+
|
36
|
+
# Uninstalls this logger from \{Sass.logger\}. This should only be called if
|
37
|
+
# the logger was installed using \{#install!}
|
38
|
+
def uninstall!
|
39
|
+
if Sass.logger != self
|
40
|
+
throw Exception.new("Can't uninstall a logger that's not currently installed.")
|
41
|
+
end
|
42
|
+
|
43
|
+
@inner.log_level = log_level
|
44
|
+
Sass.logger = @inner
|
45
|
+
end
|
46
|
+
|
47
|
+
def _log(level, message)
|
48
|
+
@messages << [level, message]
|
49
|
+
end
|
50
|
+
end
|
data/lib/sass/logger.rb
CHANGED
@@ -2,11 +2,16 @@ module Sass::Logger; end
|
|
2
2
|
|
3
3
|
require "sass/logger/log_level"
|
4
4
|
require "sass/logger/base"
|
5
|
+
require "sass/logger/delayed"
|
5
6
|
|
6
7
|
module Sass
|
7
8
|
class << self
|
8
|
-
|
9
|
-
|
9
|
+
def logger=(l)
|
10
|
+
Thread.current[:sass_logger] = l
|
11
|
+
end
|
10
12
|
|
11
|
-
|
13
|
+
def logger
|
14
|
+
Thread.current[:sass_logger] ||= Sass::Logger::Base.new
|
15
|
+
end
|
16
|
+
end
|
12
17
|
end
|
data/lib/sass/plugin/rack.rb
CHANGED
@@ -72,7 +72,7 @@ module Sass
|
|
72
72
|
# Returns whether a Sass or SCSS stylesheet has been modified since a given time.
|
73
73
|
#
|
74
74
|
# @param template_file [String] The location of the Sass or SCSS template.
|
75
|
-
# @param mtime [
|
75
|
+
# @param mtime [Time] The modification time to check against.
|
76
76
|
# @param importer [Sass::Importers::Base] The importer used to locate the stylesheet.
|
77
77
|
# Defaults to the filesystem importer.
|
78
78
|
# @return [Boolean] Whether the stylesheet has been modified.
|
@@ -103,7 +103,7 @@ module Sass
|
|
103
103
|
# so it's better to use when checking multiple stylesheets at once.
|
104
104
|
#
|
105
105
|
# @param template_file [String] The location of the Sass or SCSS template.
|
106
|
-
# @param mtime [
|
106
|
+
# @param mtime [Time] The modification time to check against.
|
107
107
|
# @param importer [Sass::Importers::Base] The importer used to locate the stylesheet.
|
108
108
|
# Defaults to the filesystem importer.
|
109
109
|
# @return [Boolean] Whether the stylesheet has been modified.
|
@@ -431,8 +431,8 @@ module Sass::Script
|
|
431
431
|
# If no signatures match, the first signature is returned for error messaging.
|
432
432
|
#
|
433
433
|
# @param method_name [Symbol] The name of the Ruby function to be called.
|
434
|
-
# @param arg_arity [
|
435
|
-
# @param kwarg_arity [
|
434
|
+
# @param arg_arity [Integer] The number of unnamed arguments the function was passed.
|
435
|
+
# @param kwarg_arity [Integer] The number of keyword arguments the function was passed.
|
436
436
|
#
|
437
437
|
# @return [{Symbol => Object}, nil]
|
438
438
|
# The signature options for the matching signature,
|
@@ -1305,7 +1305,7 @@ module Sass::Script
|
|
1305
1305
|
# @param $color1 [Sass::Script::Value::Color]
|
1306
1306
|
# @param $color2 [Sass::Script::Value::Color]
|
1307
1307
|
# @param $weight [Sass::Script::Value::Number] The relative weight of each
|
1308
|
-
# color. Closer to `
|
1308
|
+
# color. Closer to `100%` gives more weight to `$color1`, closer to `0%`
|
1309
1309
|
# gives more weight to `$color2`
|
1310
1310
|
# @return [Sass::Script::Value::Color]
|
1311
1311
|
# @raise [ArgumentError] if `$weight` is out of bounds or any parameter is
|
@@ -1546,7 +1546,7 @@ MESSAGE
|
|
1546
1546
|
# @param $start-at [Sass::Script::Value::Number] The index of the first
|
1547
1547
|
# character of the substring. If this is negative, it counts from the end
|
1548
1548
|
# of `$string`
|
1549
|
-
# @param $end-
|
1549
|
+
# @param $end-at [Sass::Script::Value::Number] The index of the last
|
1550
1550
|
# character of the substring. If this is negative, it counts from the end
|
1551
1551
|
# of `$string`. Defaults to -1
|
1552
1552
|
# @return [Sass::Script::Value::String] The substring. This will be quoted
|
@@ -1565,7 +1565,7 @@ MESSAGE
|
|
1565
1565
|
s = string.value.length + s if s < 0
|
1566
1566
|
s = 0 if s < 0
|
1567
1567
|
e = string.value.length + e if e < 0
|
1568
|
-
|
1568
|
+
return Sass::Script::Value::String.new("", string.type) if e < 0
|
1569
1569
|
extracted = string.value.slice(s..e)
|
1570
1570
|
Sass::Script::Value::String.new(extracted || "", string.type)
|
1571
1571
|
end
|
@@ -1583,7 +1583,7 @@ MESSAGE
|
|
1583
1583
|
# @raise [ArgumentError] if `$string` isn't a string
|
1584
1584
|
def to_upper_case(string)
|
1585
1585
|
assert_type string, :String, :string
|
1586
|
-
Sass::Script::Value::String.new(string.value
|
1586
|
+
Sass::Script::Value::String.new(Sass::Util.upcase(string.value), string.type)
|
1587
1587
|
end
|
1588
1588
|
declare :to_upper_case, [:string]
|
1589
1589
|
|
@@ -1598,7 +1598,7 @@ MESSAGE
|
|
1598
1598
|
# @raise [ArgumentError] if `$string` isn't a string
|
1599
1599
|
def to_lower_case(string)
|
1600
1600
|
assert_type string, :String, :string
|
1601
|
-
Sass::Script::Value::String.new(string.value
|
1601
|
+
Sass::Script::Value::String.new(Sass::Util.downcase(string.value), string.type)
|
1602
1602
|
end
|
1603
1603
|
declare :to_lower_case, [:string]
|
1604
1604
|
|
@@ -1611,6 +1611,7 @@ MESSAGE
|
|
1611
1611
|
# type-of(true) => bool
|
1612
1612
|
# type-of(#fff) => color
|
1613
1613
|
# type-of(blue) => color
|
1614
|
+
# type-of(null) => null
|
1614
1615
|
# @overload type_of($value)
|
1615
1616
|
# @param $value [Sass::Script::Value::Base] The value to inspect
|
1616
1617
|
# @return [Sass::Script::Value::String] The unquoted string name of the
|
@@ -2263,6 +2264,7 @@ MESSAGE
|
|
2263
2264
|
# @example
|
2264
2265
|
# $a-false-value: false;
|
2265
2266
|
# variable-exists(a-false-value) => true
|
2267
|
+
# variable-exists(a-null-value) => true
|
2266
2268
|
#
|
2267
2269
|
# variable-exists(nonexistent) => false
|
2268
2270
|
#
|
@@ -2283,6 +2285,7 @@ MESSAGE
|
|
2283
2285
|
# @example
|
2284
2286
|
# $a-false-value: false;
|
2285
2287
|
# global-variable-exists(a-false-value) => true
|
2288
|
+
# global-variable-exists(a-null-value) => true
|
2286
2289
|
#
|
2287
2290
|
# .foo {
|
2288
2291
|
# $some-var: false;
|
data/lib/sass/script/lexer.rb
CHANGED
@@ -19,13 +19,13 @@ module Sass
|
|
19
19
|
# `source_range`: \[`Sass::Source::Range`\]
|
20
20
|
# : The range in the source file in which the token appeared.
|
21
21
|
#
|
22
|
-
# `pos`: \[`
|
22
|
+
# `pos`: \[`Integer`\]
|
23
23
|
# : The scanner position at which the SassScript token appeared.
|
24
24
|
Token = Struct.new(:type, :value, :source_range, :pos)
|
25
25
|
|
26
26
|
# The line number of the lexer's current position.
|
27
27
|
#
|
28
|
-
# @return [
|
28
|
+
# @return [Integer]
|
29
29
|
def line
|
30
30
|
return @line unless @tok
|
31
31
|
@tok.source_range.start_pos.line
|
@@ -34,7 +34,7 @@ module Sass
|
|
34
34
|
# The number of bytes into the current line
|
35
35
|
# of the lexer's current position (1-based).
|
36
36
|
#
|
37
|
-
# @return [
|
37
|
+
# @return [Integer]
|
38
38
|
def offset
|
39
39
|
return @offset unless @tok
|
40
40
|
@tok.source_range.start_pos.offset
|
@@ -142,9 +142,9 @@ module Sass
|
|
142
142
|
}
|
143
143
|
|
144
144
|
# @param str [String, StringScanner] The source text to lex
|
145
|
-
# @param line [
|
145
|
+
# @param line [Integer] The 1-based line on which the SassScript appears.
|
146
146
|
# Used for error reporting and sourcemap building
|
147
|
-
# @param offset [
|
147
|
+
# @param offset [Integer] The 1-based character (not byte) offset in the line in the source.
|
148
148
|
# Used for error reporting and sourcemap building
|
149
149
|
# @param options [{Symbol => Object}] An options hash;
|
150
150
|
# see {file:SASS_REFERENCE.md#sass_options the Sass options documentation}
|
data/lib/sass/script/parser.rb
CHANGED
@@ -8,22 +8,22 @@ module Sass
|
|
8
8
|
class Parser
|
9
9
|
# The line number of the parser's current position.
|
10
10
|
#
|
11
|
-
# @return [
|
11
|
+
# @return [Integer]
|
12
12
|
def line
|
13
13
|
@lexer.line
|
14
14
|
end
|
15
15
|
|
16
16
|
# The column number of the parser's current position.
|
17
17
|
#
|
18
|
-
# @return [
|
18
|
+
# @return [Integer]
|
19
19
|
def offset
|
20
20
|
@lexer.offset
|
21
21
|
end
|
22
22
|
|
23
23
|
# @param str [String, StringScanner] The source text to parse
|
24
|
-
# @param line [
|
24
|
+
# @param line [Integer] The line on which the SassScript appears.
|
25
25
|
# Used for error reporting and sourcemap building
|
26
|
-
# @param offset [
|
26
|
+
# @param offset [Integer] The character (not byte) offset where the script starts in the line.
|
27
27
|
# Used for error reporting and sourcemap building
|
28
28
|
# @param options [{Symbol => Object}] An options hash; see
|
29
29
|
# {file:SASS_REFERENCE.md#sass_options the Sass options documentation}.
|
@@ -471,18 +471,24 @@ RUBY
|
|
471
471
|
# `expr`).
|
472
472
|
# @return [Boolean]
|
473
473
|
def is_unsafe_before?(expr, char_before)
|
474
|
-
|
475
|
-
# unless it was wrapped in parentheses.
|
476
|
-
if expr.is_a?(Script::Tree::Literal) &&
|
477
|
-
(expr.value.is_a?(Script::Value::Number) ||
|
478
|
-
(expr.value.is_a?(Script::Value::String) && expr.value.type == :identifier))
|
479
|
-
return char_before == ')'
|
480
|
-
end
|
474
|
+
return char_before == ')' if is_safe_value?(expr)
|
481
475
|
|
482
476
|
# Otherwise, it's only safe if it was another interpolation.
|
483
477
|
!expr.is_a?(Script::Tree::Interpolation)
|
484
478
|
end
|
485
479
|
|
480
|
+
# Returns whether `expr` is safe as the value immediately before an
|
481
|
+
# interpolation.
|
482
|
+
#
|
483
|
+
# It's safe as long as the previous expression is an identifier or number,
|
484
|
+
# or a list whose last element is also safe.
|
485
|
+
def is_safe_value?(expr)
|
486
|
+
return is_safe_value?(expr.elements.last) if expr.is_a?(Script::Tree::ListLiteral)
|
487
|
+
return false unless expr.is_a?(Script::Tree::Literal)
|
488
|
+
expr.value.is_a?(Script::Value::Number) ||
|
489
|
+
(expr.value.is_a?(Script::Value::String) && expr.value.type == :identifier)
|
490
|
+
end
|
491
|
+
|
486
492
|
def space
|
487
493
|
start_pos = source_position
|
488
494
|
e = or_expr
|
@@ -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 [Fixnum] The hash code.
|
152
|
+
# @return [Integer for Ruby 2.4.0+, Fixnum for earlier Ruby versions] 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 [
|
179
|
+
# @return [Integer] 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.")
|
@@ -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 [
|
21
|
-
# @return [Array<
|
20
|
+
# @param color [Integer]
|
21
|
+
# @return [Array<Integer>] 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 [
|
296
|
+
# @return [Integer]
|
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 [
|
304
|
+
# @return [Integer]
|
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 [
|
312
|
+
# @return [Integer]
|
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 [
|
345
|
+
# @return [Integer]
|
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<
|
360
|
+
# @return [Array<Integer>] 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<
|
368
|
+
# @return [Array<Integer>] 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<
|
376
|
+
# @return [Array<Integer>] 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<
|
384
|
+
# @return [Array<Integer>] 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
|