sass-embedded 1.69.6-aarch64-linux-android → 1.70.0-aarch64-linux-android
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/ext/sass/cli.rb +2 -2
- data/ext/sass/dart-sass/src/sass.snapshot +0 -0
- data/ext/sass/embedded_sass_pb.rb +1 -1
- data/lib/sass/calculation_value/calculation_operation.rb +2 -5
- data/lib/sass/calculation_value.rb +10 -4
- data/lib/sass/canonicalize_context.rb +3 -3
- data/lib/sass/compiler/dispatcher.rb +0 -28
- data/lib/sass/compiler/dispatcher_manager.rb +68 -0
- data/lib/sass/compiler/host/function_registry.rb +15 -13
- data/lib/sass/compiler/host/importer_registry.rb +17 -4
- data/lib/sass/compiler/host/logger_registry.rb +2 -2
- data/lib/sass/compiler/host/protofier.rb +358 -56
- data/lib/sass/compiler/host.rb +43 -6
- data/lib/sass/compiler.rb +7 -3
- data/lib/sass/elf.rb +2 -2
- data/lib/sass/embedded/version.rb +1 -1
- data/lib/sass/embedded.rb +1 -2
- data/lib/sass/exception.rb +7 -3
- data/lib/sass/fork_tracker.rb +1 -1
- data/lib/sass/logger/source_location.rb +4 -4
- data/lib/sass/logger/source_span.rb +6 -6
- data/lib/sass/serializer.rb +18 -55
- data/lib/sass/value/argument_list.rb +4 -4
- data/lib/sass/value/calculation.rb +3 -1
- data/lib/sass/value/function.rb +5 -3
- data/lib/sass/value/list.rb +5 -5
- data/lib/sass/value/number.rb +2 -2
- data/lib/sass/value/string.rb +5 -8
- data/lib/sass/value.rb +1 -8
- metadata +9 -8
- data/lib/sass/compiler/host/value_protofier.rb +0 -390
- data/lib/sass/compiler/resilient_dispatcher.rb +0 -41
data/lib/sass/serializer.rb
CHANGED
@@ -5,67 +5,30 @@ module Sass
|
|
5
5
|
module Serializer
|
6
6
|
module_function
|
7
7
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
8
|
+
CSS_ESCAPE = {
|
9
|
+
"\0" => "\uFFFD",
|
10
|
+
'\\' => '\\\\',
|
11
|
+
'"' => '\\"',
|
12
|
+
"'" => "\\'",
|
13
|
+
**[*"\x01".."\x08", *"\x0A".."\x1F", "\x7F"].product(
|
14
|
+
[*'0'..'9', *'a'..'f', *'A'..'F', "\t", ' ', nil]
|
15
|
+
).to_h do |c, x|
|
16
|
+
["#{c}#{x}".freeze, "\\#{c.ord.to_s(16)}#{" #{x}" if x}".freeze]
|
17
|
+
end
|
18
|
+
}.freeze
|
16
19
|
|
17
|
-
|
18
|
-
buffer << 34
|
19
|
-
when 39
|
20
|
-
return dump_double_quoted_string(string) if include_double_quote
|
20
|
+
private_constant :CSS_ESCAPE
|
21
21
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
buffer << 92 << 92
|
26
|
-
when 9
|
27
|
-
buffer << 9
|
28
|
-
else
|
29
|
-
if codepoint < 32 || codepoint > 126
|
30
|
-
buffer << 92
|
31
|
-
buffer.concat(codepoint.to_s(16).codepoints)
|
32
|
-
buffer << 32
|
33
|
-
else
|
34
|
-
buffer << codepoint
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
38
|
-
if include_double_quote
|
39
|
-
buffer[0] = 39
|
40
|
-
buffer << 39
|
22
|
+
def serialize_quoted_string(string)
|
23
|
+
if !string.include?('"') || string.include?("'")
|
24
|
+
%("#{string.gsub(/[\0\\"]|[\x01-\x08\x0A-\x1F\x7F][\h\t ]?/, CSS_ESCAPE)}")
|
41
25
|
else
|
42
|
-
|
26
|
+
%('#{string.gsub(/[\0\\']|[\x01-\x08\x0A-\x1F\x7F][\h\t ]?/, CSS_ESCAPE)}')
|
43
27
|
end
|
44
|
-
buffer.pack('U*')
|
45
28
|
end
|
46
29
|
|
47
|
-
def
|
48
|
-
|
49
|
-
string.each_codepoint do |codepoint|
|
50
|
-
case codepoint
|
51
|
-
when 34
|
52
|
-
buffer << 92 << 34
|
53
|
-
when 92
|
54
|
-
buffer << 92 << 92
|
55
|
-
when 9
|
56
|
-
buffer << 9
|
57
|
-
else
|
58
|
-
if codepoint < 32 || codepoint > 126
|
59
|
-
buffer << 92
|
60
|
-
buffer.concat(codepoint.to_s(16).codepoints)
|
61
|
-
buffer << 32
|
62
|
-
else
|
63
|
-
buffer << codepoint
|
64
|
-
end
|
65
|
-
end
|
66
|
-
end
|
67
|
-
buffer << 34
|
68
|
-
buffer.pack('U*')
|
30
|
+
def serialize_unquoted_string(string)
|
31
|
+
string.tr("\0", "\uFFFD").gsub(/\n */, ' ')
|
69
32
|
end
|
70
33
|
end
|
71
34
|
|
@@ -8,19 +8,19 @@ module Sass
|
|
8
8
|
# map as well as the positional arguments.
|
9
9
|
#
|
10
10
|
# @see https://sass-lang.com/documentation/js-api/classes/sassargumentlist/
|
11
|
-
class ArgumentList <
|
11
|
+
class ArgumentList < List
|
12
12
|
# @param contents [Array<Value>]
|
13
|
-
# @param keywords [Hash
|
13
|
+
# @param keywords [Hash<Symbol, Value>]
|
14
14
|
# @param separator [::String]
|
15
15
|
def initialize(contents = [], keywords = {}, separator = ',')
|
16
16
|
super(contents, separator:)
|
17
17
|
|
18
18
|
@id = 0
|
19
19
|
@keywords_accessed = false
|
20
|
-
@keywords = keywords.
|
20
|
+
@keywords = keywords.freeze
|
21
21
|
end
|
22
22
|
|
23
|
-
# @return [Hash
|
23
|
+
# @return [Hash<Symbol, Value>]
|
24
24
|
def keywords
|
25
25
|
@keywords_accessed = true
|
26
26
|
@keywords
|
data/lib/sass/value/function.rb
CHANGED
@@ -10,9 +10,11 @@ module Sass
|
|
10
10
|
|
11
11
|
# @param signature [::String]
|
12
12
|
# @param callback [Proc]
|
13
|
-
def initialize(signature, callback)
|
14
|
-
|
15
|
-
|
13
|
+
def initialize(signature, &callback)
|
14
|
+
raise Sass::ScriptError, 'no block given' unless signature.nil? || callback
|
15
|
+
|
16
|
+
@signature = signature.freeze
|
17
|
+
@callback = callback.freeze
|
16
18
|
end
|
17
19
|
|
18
20
|
# @return [Integer, nil]
|
data/lib/sass/value/list.rb
CHANGED
@@ -21,9 +21,6 @@ module Sass
|
|
21
21
|
@bracketed = bracketed.freeze
|
22
22
|
end
|
23
23
|
|
24
|
-
# @return [Array<Value>]
|
25
|
-
attr_reader :contents
|
26
|
-
|
27
24
|
# @return [::String, nil]
|
28
25
|
attr_reader :separator
|
29
26
|
|
@@ -35,7 +32,7 @@ module Sass
|
|
35
32
|
# @return [::Boolean]
|
36
33
|
def ==(other)
|
37
34
|
(other.is_a?(Sass::Value::List) &&
|
38
|
-
other.
|
35
|
+
other.to_a == to_a &&
|
39
36
|
other.separator == separator &&
|
40
37
|
other.bracketed? == bracketed?) ||
|
41
38
|
(to_a.empty? && other.is_a?(Sass::Value::Map) && other.to_a.empty?)
|
@@ -56,7 +53,10 @@ module Sass
|
|
56
53
|
@hash ||= contents.hash
|
57
54
|
end
|
58
55
|
|
59
|
-
|
56
|
+
# @return [Array<Value>]
|
57
|
+
def to_a
|
58
|
+
@contents
|
59
|
+
end
|
60
60
|
|
61
61
|
# @return [Map, nil]
|
62
62
|
def to_map
|
data/lib/sass/value/number.rb
CHANGED
@@ -63,8 +63,8 @@ module Sass
|
|
63
63
|
end
|
64
64
|
|
65
65
|
@value = value.freeze
|
66
|
-
@numerator_units = numerator_units.freeze
|
67
|
-
@denominator_units = denominator_units.freeze
|
66
|
+
@numerator_units = numerator_units.each(&:freeze).freeze
|
67
|
+
@denominator_units = denominator_units.each(&:freeze).freeze
|
68
68
|
end
|
69
69
|
|
70
70
|
# @return [Numeric]
|
data/lib/sass/value/string.rb
CHANGED
@@ -39,14 +39,6 @@ module Sass
|
|
39
39
|
self
|
40
40
|
end
|
41
41
|
|
42
|
-
# @return [CalculationValue]
|
43
|
-
# @raise [ScriptError]
|
44
|
-
def assert_calculation_value(name = nil)
|
45
|
-
raise Sass::ScriptError.new("Expected #{self} to be an unquoted string.", name) if quoted?
|
46
|
-
|
47
|
-
self
|
48
|
-
end
|
49
|
-
|
50
42
|
# @param sass_index [Number]
|
51
43
|
# @return [Integer]
|
52
44
|
def sass_index_to_string_index(sass_index, name = nil)
|
@@ -59,6 +51,11 @@ module Sass
|
|
59
51
|
|
60
52
|
index.negative? ? text.length + index : index - 1
|
61
53
|
end
|
54
|
+
|
55
|
+
# @return [String]
|
56
|
+
def to_s
|
57
|
+
@quoted ? Serializer.serialize_quoted_string(@text) : Serializer.serialize_unquoted_string(@text)
|
58
|
+
end
|
62
59
|
end
|
63
60
|
end
|
64
61
|
end
|
data/lib/sass/value.rb
CHANGED
@@ -1,7 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require_relative 'calculation_value'
|
4
|
-
|
5
3
|
module Sass
|
6
4
|
# The abstract base class of Sass's value types.
|
7
5
|
#
|
@@ -66,12 +64,6 @@ module Sass
|
|
66
64
|
raise Sass::ScriptError.new("#{self} is not a calculation", name)
|
67
65
|
end
|
68
66
|
|
69
|
-
# @return [CalculationValue]
|
70
|
-
# @raise [ScriptError]
|
71
|
-
def assert_calculation_value(name = nil)
|
72
|
-
raise Sass::ScriptError.new("#{self} is not a calculation value", name)
|
73
|
-
end
|
74
|
-
|
75
67
|
# @return [Color]
|
76
68
|
# @raise [ScriptError]
|
77
69
|
def assert_color(name = nil)
|
@@ -129,6 +121,7 @@ module Sass
|
|
129
121
|
end
|
130
122
|
end
|
131
123
|
|
124
|
+
require_relative 'calculation_value'
|
132
125
|
require_relative 'value/list'
|
133
126
|
require_relative 'value/argument_list'
|
134
127
|
require_relative 'value/boolean'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sass-embedded
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.70.0
|
5
5
|
platform: aarch64-linux-android
|
6
6
|
authors:
|
7
7
|
- なつき
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-01-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: google-protobuf
|
@@ -50,14 +50,13 @@ files:
|
|
50
50
|
- lib/sass/compiler.rb
|
51
51
|
- lib/sass/compiler/connection.rb
|
52
52
|
- lib/sass/compiler/dispatcher.rb
|
53
|
+
- lib/sass/compiler/dispatcher_manager.rb
|
53
54
|
- lib/sass/compiler/host.rb
|
54
55
|
- lib/sass/compiler/host/function_registry.rb
|
55
56
|
- lib/sass/compiler/host/importer_registry.rb
|
56
57
|
- lib/sass/compiler/host/logger_registry.rb
|
57
58
|
- lib/sass/compiler/host/protofier.rb
|
58
59
|
- lib/sass/compiler/host/structifier.rb
|
59
|
-
- lib/sass/compiler/host/value_protofier.rb
|
60
|
-
- lib/sass/compiler/resilient_dispatcher.rb
|
61
60
|
- lib/sass/compiler/varint.rb
|
62
61
|
- lib/sass/elf.rb
|
63
62
|
- lib/sass/embedded.rb
|
@@ -87,9 +86,11 @@ homepage: https://github.com/sass-contrib/sass-embedded-host-ruby
|
|
87
86
|
licenses:
|
88
87
|
- MIT
|
89
88
|
metadata:
|
90
|
-
|
91
|
-
|
89
|
+
bug_tracker_uri: https://github.com/sass-contrib/sass-embedded-host-ruby/issues
|
90
|
+
documentation_uri: https://rubydoc.info/gems/sass-embedded/1.70.0
|
91
|
+
source_code_uri: https://github.com/sass-contrib/sass-embedded-host-ruby/tree/v1.70.0
|
92
92
|
funding_uri: https://github.com/sponsors/ntkme
|
93
|
+
rubygems_mfa_required: 'true'
|
93
94
|
post_install_message:
|
94
95
|
rdoc_options: []
|
95
96
|
require_paths:
|
@@ -98,14 +99,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
98
99
|
requirements:
|
99
100
|
- - ">="
|
100
101
|
- !ruby/object:Gem::Version
|
101
|
-
version: 3.1.
|
102
|
+
version: 3.1.0
|
102
103
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
103
104
|
requirements:
|
104
105
|
- - ">="
|
105
106
|
- !ruby/object:Gem::Version
|
106
107
|
version: '0'
|
107
108
|
requirements: []
|
108
|
-
rubygems_version: 3.5.
|
109
|
+
rubygems_version: 3.5.4
|
109
110
|
signing_key:
|
110
111
|
specification_version: 4
|
111
112
|
summary: Use dart-sass with Ruby!
|
@@ -1,390 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Sass
|
4
|
-
class Compiler
|
5
|
-
class Host
|
6
|
-
# The {ValueProtofier} class.
|
7
|
-
#
|
8
|
-
# It converts Pure Ruby types and Protobuf Ruby types.
|
9
|
-
class ValueProtofier
|
10
|
-
def initialize(function_registry)
|
11
|
-
@function_registry = function_registry
|
12
|
-
end
|
13
|
-
|
14
|
-
def to_proto(obj)
|
15
|
-
case obj
|
16
|
-
when Sass::Value::String
|
17
|
-
EmbeddedProtocol::Value.new(
|
18
|
-
string: EmbeddedProtocol::Value::String.new(
|
19
|
-
text: obj.text,
|
20
|
-
quoted: obj.quoted?
|
21
|
-
)
|
22
|
-
)
|
23
|
-
when Sass::Value::Number
|
24
|
-
EmbeddedProtocol::Value.new(
|
25
|
-
number: Number.to_proto(obj)
|
26
|
-
)
|
27
|
-
when Sass::Value::Color
|
28
|
-
if obj.instance_eval { !defined?(@hue) }
|
29
|
-
EmbeddedProtocol::Value.new(
|
30
|
-
rgb_color: EmbeddedProtocol::Value::RgbColor.new(
|
31
|
-
red: obj.red,
|
32
|
-
green: obj.green,
|
33
|
-
blue: obj.blue,
|
34
|
-
alpha: obj.alpha.to_f
|
35
|
-
)
|
36
|
-
)
|
37
|
-
elsif obj.instance_eval { !defined?(@saturation) }
|
38
|
-
EmbeddedProtocol::Value.new(
|
39
|
-
hwb_color: EmbeddedProtocol::Value::HwbColor.new(
|
40
|
-
hue: obj.hue.to_f,
|
41
|
-
whiteness: obj.whiteness.to_f,
|
42
|
-
blackness: obj.blackness.to_f,
|
43
|
-
alpha: obj.alpha.to_f
|
44
|
-
)
|
45
|
-
)
|
46
|
-
else
|
47
|
-
EmbeddedProtocol::Value.new(
|
48
|
-
hsl_color: EmbeddedProtocol::Value::HslColor.new(
|
49
|
-
hue: obj.hue.to_f,
|
50
|
-
saturation: obj.saturation.to_f,
|
51
|
-
lightness: obj.lightness.to_f,
|
52
|
-
alpha: obj.alpha.to_f
|
53
|
-
)
|
54
|
-
)
|
55
|
-
end
|
56
|
-
when Sass::Value::ArgumentList
|
57
|
-
EmbeddedProtocol::Value.new(
|
58
|
-
argument_list: EmbeddedProtocol::Value::ArgumentList.new(
|
59
|
-
id: obj.instance_eval { @id },
|
60
|
-
contents: obj.contents.map { |element| to_proto(element) },
|
61
|
-
keywords: obj.keywords.transform_values { |value| to_proto(value) },
|
62
|
-
separator: ListSeparator.to_proto(obj.separator)
|
63
|
-
)
|
64
|
-
)
|
65
|
-
when Sass::Value::List
|
66
|
-
EmbeddedProtocol::Value.new(
|
67
|
-
list: EmbeddedProtocol::Value::List.new(
|
68
|
-
contents: obj.contents.map { |element| to_proto(element) },
|
69
|
-
separator: ListSeparator.to_proto(obj.separator),
|
70
|
-
has_brackets: obj.bracketed?
|
71
|
-
)
|
72
|
-
)
|
73
|
-
when Sass::Value::Map
|
74
|
-
EmbeddedProtocol::Value.new(
|
75
|
-
map: EmbeddedProtocol::Value::Map.new(
|
76
|
-
entries: obj.contents.map do |key, value|
|
77
|
-
EmbeddedProtocol::Value::Map::Entry.new(
|
78
|
-
key: to_proto(key),
|
79
|
-
value: to_proto(value)
|
80
|
-
)
|
81
|
-
end
|
82
|
-
)
|
83
|
-
)
|
84
|
-
when Sass::Value::Function
|
85
|
-
if obj.instance_eval { @id }
|
86
|
-
EmbeddedProtocol::Value.new(
|
87
|
-
compiler_function: EmbeddedProtocol::Value::CompilerFunction.new(
|
88
|
-
id: obj.instance_eval { @id }
|
89
|
-
)
|
90
|
-
)
|
91
|
-
else
|
92
|
-
EmbeddedProtocol::Value.new(
|
93
|
-
host_function: EmbeddedProtocol::Value::HostFunction.new(
|
94
|
-
id: @function_registry.register(obj.callback),
|
95
|
-
signature: obj.signature
|
96
|
-
)
|
97
|
-
)
|
98
|
-
end
|
99
|
-
when Sass::Value::Mixin
|
100
|
-
EmbeddedProtocol::Value.new(
|
101
|
-
compiler_mixin: EmbeddedProtocol::Value::CompilerMixin.new(
|
102
|
-
id: obj.instance_eval { @id }
|
103
|
-
)
|
104
|
-
)
|
105
|
-
when Sass::Value::Calculation
|
106
|
-
EmbeddedProtocol::Value.new(
|
107
|
-
calculation: Calculation.to_proto(obj)
|
108
|
-
)
|
109
|
-
when Sass::Value::Boolean
|
110
|
-
EmbeddedProtocol::Value.new(
|
111
|
-
singleton: obj.value ? :TRUE : :FALSE
|
112
|
-
)
|
113
|
-
when Sass::Value::Null
|
114
|
-
EmbeddedProtocol::Value.new(
|
115
|
-
singleton: :NULL
|
116
|
-
)
|
117
|
-
else
|
118
|
-
raise Sass::ScriptError, "Unknown Sass::Value #{obj}"
|
119
|
-
end
|
120
|
-
end
|
121
|
-
|
122
|
-
def from_proto(proto)
|
123
|
-
oneof = proto.value
|
124
|
-
obj = proto.public_send(oneof)
|
125
|
-
case oneof
|
126
|
-
when :string
|
127
|
-
Sass::Value::String.new(
|
128
|
-
obj.text,
|
129
|
-
quoted: obj.quoted
|
130
|
-
)
|
131
|
-
when :number
|
132
|
-
Number.from_proto(obj)
|
133
|
-
when :rgb_color
|
134
|
-
Sass::Value::Color.new(
|
135
|
-
red: obj.red,
|
136
|
-
green: obj.green,
|
137
|
-
blue: obj.blue,
|
138
|
-
alpha: obj.alpha
|
139
|
-
)
|
140
|
-
when :hsl_color
|
141
|
-
Sass::Value::Color.new(
|
142
|
-
hue: obj.hue,
|
143
|
-
saturation: obj.saturation,
|
144
|
-
lightness: obj.lightness,
|
145
|
-
alpha: obj.alpha
|
146
|
-
)
|
147
|
-
when :hwb_color
|
148
|
-
Sass::Value::Color.new(
|
149
|
-
hue: obj.hue,
|
150
|
-
whiteness: obj.whiteness,
|
151
|
-
blackness: obj.blackness,
|
152
|
-
alpha: obj.alpha
|
153
|
-
)
|
154
|
-
when :argument_list
|
155
|
-
Sass::Value::ArgumentList.new(
|
156
|
-
obj.contents.map do |element|
|
157
|
-
from_proto(element)
|
158
|
-
end,
|
159
|
-
obj.keywords.entries.to_h.transform_values! do |value|
|
160
|
-
from_proto(value)
|
161
|
-
end,
|
162
|
-
ListSeparator.from_proto(obj.separator)
|
163
|
-
).instance_eval do
|
164
|
-
@id = obj.id
|
165
|
-
self
|
166
|
-
end
|
167
|
-
when :list
|
168
|
-
Sass::Value::List.new(
|
169
|
-
obj.contents.map do |element|
|
170
|
-
from_proto(element)
|
171
|
-
end,
|
172
|
-
separator: ListSeparator.from_proto(obj.separator),
|
173
|
-
bracketed: obj.has_brackets
|
174
|
-
)
|
175
|
-
when :map
|
176
|
-
Sass::Value::Map.new(
|
177
|
-
obj.entries.to_h do |entry|
|
178
|
-
[from_proto(entry.key), from_proto(entry.value)]
|
179
|
-
end
|
180
|
-
)
|
181
|
-
when :compiler_function
|
182
|
-
Sass::Value::Function.new(nil, nil).instance_eval do
|
183
|
-
@id = obj.id
|
184
|
-
self
|
185
|
-
end
|
186
|
-
when :host_function
|
187
|
-
raise Sass::ScriptError, 'The compiler may not send Value.host_function to host'
|
188
|
-
when :compiler_mixin
|
189
|
-
Sass::Value::Mixin.send(:new).instance_eval do
|
190
|
-
@id = obj.id
|
191
|
-
self
|
192
|
-
end
|
193
|
-
when :calculation
|
194
|
-
Calculation.from_proto(obj)
|
195
|
-
when :singleton
|
196
|
-
case obj
|
197
|
-
when :TRUE
|
198
|
-
Sass::Value::Boolean::TRUE
|
199
|
-
when :FALSE
|
200
|
-
Sass::Value::Boolean::FALSE
|
201
|
-
when :NULL
|
202
|
-
Sass::Value::Null::NULL
|
203
|
-
else
|
204
|
-
raise Sass::ScriptError, "Unknown Value.singleton #{obj}"
|
205
|
-
end
|
206
|
-
else
|
207
|
-
raise Sass::ScriptError, "Unknown Value.value #{obj}"
|
208
|
-
end
|
209
|
-
end
|
210
|
-
|
211
|
-
# The {Number} Protofier.
|
212
|
-
module Number
|
213
|
-
module_function
|
214
|
-
|
215
|
-
def to_proto(obj)
|
216
|
-
EmbeddedProtocol::Value::Number.new(
|
217
|
-
value: obj.value.to_f,
|
218
|
-
numerators: obj.numerator_units,
|
219
|
-
denominators: obj.denominator_units
|
220
|
-
)
|
221
|
-
end
|
222
|
-
|
223
|
-
def from_proto(obj)
|
224
|
-
Sass::Value::Number.new(
|
225
|
-
obj.value, {
|
226
|
-
numerator_units: obj.numerators.to_a,
|
227
|
-
denominator_units: obj.denominators.to_a
|
228
|
-
}
|
229
|
-
)
|
230
|
-
end
|
231
|
-
end
|
232
|
-
|
233
|
-
private_constant :Number
|
234
|
-
|
235
|
-
# The {Calculation} Protofier.
|
236
|
-
module Calculation
|
237
|
-
module_function
|
238
|
-
|
239
|
-
def to_proto(obj)
|
240
|
-
EmbeddedProtocol::Value::Calculation.new(
|
241
|
-
name: obj.name,
|
242
|
-
arguments: obj.arguments.map { |argument| CalculationValue.to_proto(argument) }
|
243
|
-
)
|
244
|
-
end
|
245
|
-
|
246
|
-
def from_proto(obj)
|
247
|
-
Sass::Value::Calculation.send(
|
248
|
-
:new,
|
249
|
-
obj.name,
|
250
|
-
obj.arguments.map { |argument| CalculationValue.from_proto(argument) }
|
251
|
-
)
|
252
|
-
end
|
253
|
-
end
|
254
|
-
|
255
|
-
private_constant :Calculation
|
256
|
-
|
257
|
-
# The {CalculationValue} Protofier.
|
258
|
-
module CalculationValue
|
259
|
-
module_function
|
260
|
-
|
261
|
-
def to_proto(value)
|
262
|
-
case value
|
263
|
-
when Sass::Value::Number
|
264
|
-
EmbeddedProtocol::Value::Calculation::CalculationValue.new(
|
265
|
-
number: Number.to_proto(value)
|
266
|
-
)
|
267
|
-
when Sass::Value::Calculation
|
268
|
-
EmbeddedProtocol::Value::Calculation::CalculationValue.new(
|
269
|
-
calculation: Calculation.to_proto(value)
|
270
|
-
)
|
271
|
-
when Sass::Value::String
|
272
|
-
EmbeddedProtocol::Value::Calculation::CalculationValue.new(
|
273
|
-
string: value.text
|
274
|
-
)
|
275
|
-
when Sass::CalculationValue::CalculationOperation
|
276
|
-
EmbeddedProtocol::Value::Calculation::CalculationValue.new(
|
277
|
-
operation: EmbeddedProtocol::Value::Calculation::CalculationOperation.new(
|
278
|
-
operator: CalculationOperator.to_proto(value.operator),
|
279
|
-
left: to_proto(value.left),
|
280
|
-
right: to_proto(value.right)
|
281
|
-
)
|
282
|
-
)
|
283
|
-
else
|
284
|
-
raise Sass::ScriptError, "Unknown CalculationValue #{value}"
|
285
|
-
end
|
286
|
-
end
|
287
|
-
|
288
|
-
def from_proto(value)
|
289
|
-
oneof = value.value
|
290
|
-
obj = value.public_send(oneof)
|
291
|
-
case oneof
|
292
|
-
when :number
|
293
|
-
Number.from_proto(obj)
|
294
|
-
when :calculation
|
295
|
-
Calculation.from_proto(obj)
|
296
|
-
when :string
|
297
|
-
Sass::Value::String.new(obj, quoted: false)
|
298
|
-
when :operation
|
299
|
-
Sass::CalculationValue::CalculationOperation.new(
|
300
|
-
CalculationOperator.from_proto(obj.operator),
|
301
|
-
from_proto(obj.left),
|
302
|
-
from_proto(obj.right)
|
303
|
-
)
|
304
|
-
else
|
305
|
-
raise Sass::ScriptError, "Unknown CalculationValue #{value}"
|
306
|
-
end
|
307
|
-
end
|
308
|
-
end
|
309
|
-
|
310
|
-
private_constant :CalculationValue
|
311
|
-
|
312
|
-
# The {CalculationOperator} Protofier.
|
313
|
-
module CalculationOperator
|
314
|
-
module_function
|
315
|
-
|
316
|
-
def to_proto(operator)
|
317
|
-
case operator
|
318
|
-
when '+'
|
319
|
-
:PLUS
|
320
|
-
when '-'
|
321
|
-
:MINUS
|
322
|
-
when '*'
|
323
|
-
:TIMES
|
324
|
-
when '/'
|
325
|
-
:DIVIDE
|
326
|
-
else
|
327
|
-
raise Sass::ScriptError, "Unknown CalculationOperator #{separator}"
|
328
|
-
end
|
329
|
-
end
|
330
|
-
|
331
|
-
def from_proto(operator)
|
332
|
-
case operator
|
333
|
-
when :PLUS
|
334
|
-
'+'
|
335
|
-
when :MINUS
|
336
|
-
'-'
|
337
|
-
when :TIMES
|
338
|
-
'*'
|
339
|
-
when :DIVIDE
|
340
|
-
'/'
|
341
|
-
else
|
342
|
-
raise Sass::ScriptError, "Unknown CalculationOperator #{separator}"
|
343
|
-
end
|
344
|
-
end
|
345
|
-
end
|
346
|
-
|
347
|
-
private_constant :CalculationOperator
|
348
|
-
|
349
|
-
# The {ListSeparator} Protofier.
|
350
|
-
module ListSeparator
|
351
|
-
module_function
|
352
|
-
|
353
|
-
def to_proto(separator)
|
354
|
-
case separator
|
355
|
-
when ','
|
356
|
-
:COMMA
|
357
|
-
when ' '
|
358
|
-
:SPACE
|
359
|
-
when '/'
|
360
|
-
:SLASH
|
361
|
-
when nil
|
362
|
-
:UNDECIDED
|
363
|
-
else
|
364
|
-
raise Sass::ScriptError, "Unknown ListSeparator #{separator}"
|
365
|
-
end
|
366
|
-
end
|
367
|
-
|
368
|
-
def from_proto(separator)
|
369
|
-
case separator
|
370
|
-
when :COMMA
|
371
|
-
','
|
372
|
-
when :SPACE
|
373
|
-
' '
|
374
|
-
when :SLASH
|
375
|
-
'/'
|
376
|
-
when :UNDECIDED
|
377
|
-
nil
|
378
|
-
else
|
379
|
-
raise Sass::ScriptError, "Unknown ListSeparator #{separator}"
|
380
|
-
end
|
381
|
-
end
|
382
|
-
end
|
383
|
-
|
384
|
-
private_constant :ListSeparator
|
385
|
-
end
|
386
|
-
|
387
|
-
private_constant :ValueProtofier
|
388
|
-
end
|
389
|
-
end
|
390
|
-
end
|