sass-embedded 1.0.19 → 1.1.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b5254ca2c7b3c19b2ea114590c6e7ce58afb95943a7a3e9c43124cfd42e1db68
4
- data.tar.gz: 9469c9e41981803da8a50764a0db94b51035898a6d7892328ec96faafd1cfb10
3
+ metadata.gz: 105fb9a8f27198dc74d89911ec31eafc40e7cf786a9567d993f584c956169014
4
+ data.tar.gz: e381b1d5c74d5356dfa9c6085bc7f6ed088259c90a80051dc22cbdf975fc1642
5
5
  SHA512:
6
- metadata.gz: 530179e9bc1aa1e513b26fc56aeeb889236c689113ba1e7ca6d5b7a3e29b43e8078356ff1279bab315435553cb387fe4a988d4766f3c73270c0864d0b9053864
7
- data.tar.gz: 8f0605fcee9c7630be7e6babdd707edae0b9e310ac616eb4ebb8988a5bceb249da92034296ca62752b9adb4724152455513b280961ba7291a5ac5cbad8c034a5
6
+ metadata.gz: a33ebf10f59766f644e2c88be19ea2aa72bb78a45684f65092be5c386d977437f928fa5d63a9dde96d31f777e72a6a30b36be8959a22dbc4da02c090278ff01d
7
+ data.tar.gz: '096e8913f2d9d4f402625d2f479e68ca772fffeaa8135ef078538af43052765753339fe9c1e3f378464f8d26d5dcffb113f2783754cd17bb24e097343a12b8fb'
data/README.md CHANGED
@@ -35,6 +35,8 @@ result = Sass.compile_string('h1 { font-size: 40px; }')
35
35
  puts result.css
36
36
  ```
37
37
 
38
+ See [rubydoc.info/gems/sass-embedded](https://rubydoc.info/gems/sass-embedded) for full API documentation.
39
+
38
40
  ---
39
41
 
40
42
  Disclaimer: this is not an official Google product.
data/ext/sass/Rakefile CHANGED
@@ -111,6 +111,8 @@ module Configuration
111
111
  OS = case RbConfig::CONFIG['host_os'].downcase
112
112
  when /darwin/
113
113
  'darwin'
114
+ when /linux-musl/
115
+ 'linux-musl'
114
116
  when /linux/
115
117
  'linux'
116
118
  when *Gem::WIN_PATTERNS
@@ -119,23 +121,25 @@ module Configuration
119
121
  RbConfig::CONFIG['host_os'].downcase
120
122
  end
121
123
 
122
- ARCH = case RbConfig::CONFIG['host_cpu'].downcase
123
- when /amd64|x86_64|x64/
124
- 'x86_64'
125
- when /i\d86|x86|i86pc/
126
- 'i386'
127
- when /arm64|aarch64/
128
- 'aarch64'
129
- when /arm/
130
- # Ruby before 3.0 reports "arm" instead of "arm64" as host_cpu on darwin
131
- OS == 'darwin' ? 'aarch64' : 'arm'
132
- when /ppc64le|powerpc64le/
133
- 'powerpc64le'
134
- when /s390x/
135
- 's390x'
136
- else
137
- RbConfig::CONFIG['host_cpu']
138
- end
124
+ CPU = case RbConfig::CONFIG['host_cpu'].downcase
125
+ when /amd64|x86_64|x64/
126
+ 'x86_64'
127
+ when /i\d86|x86|i86pc/
128
+ 'i386'
129
+ when /arm64|aarch64/
130
+ 'aarch64'
131
+ when /arm/
132
+ # Ruby before 3.0 reports "arm" instead of "arm64" as host_cpu on darwin
133
+ OS == 'darwin' ? 'aarch64' : 'arm'
134
+ when /ppc64le|powerpc64le/
135
+ 'powerpc64le'
136
+ when /s390x/
137
+ 's390x'
138
+ else
139
+ RbConfig::CONFIG['host_cpu']
140
+ end
141
+
142
+ ARCH = "#{CPU}-#{OS}"
139
143
  end
140
144
 
141
145
  private_constant :Platform
@@ -151,7 +155,7 @@ module Configuration
151
155
 
152
156
  tag_name = spec['dependencies']['sass-embedded']
153
157
 
154
- message = "sass_embedded for #{Platform::OS}/#{Platform::ARCH} not available at #{repo}/releases/tag/#{tag_name}"
158
+ message = "sass_embedded for #{Platform::ARCH} not available at #{repo}/releases/tag/#{tag_name}"
155
159
 
156
160
  os = case Platform::OS
157
161
  when 'darwin'
@@ -164,20 +168,20 @@ module Configuration
164
168
  raise NotImplementedError, message
165
169
  end
166
170
 
167
- arch = case Platform::ARCH
168
- when 'i386'
169
- 'ia32'
170
- when 'x86_64'
171
- 'x64'
172
- when 'aarch64'
173
- Platform::OS == 'darwin' ? 'x64' : 'arm64'
174
- else
175
- raise NotImplementedError, message
176
- end
171
+ cpu = case Platform::CPU
172
+ when 'i386'
173
+ 'ia32'
174
+ when 'x86_64'
175
+ 'x64'
176
+ when 'aarch64'
177
+ Platform::OS == 'darwin' ? 'x64' : 'arm64'
178
+ else
179
+ raise NotImplementedError, message
180
+ end
177
181
 
178
182
  ext = Gem.win_platform? ? 'zip' : 'tar.gz'
179
183
 
180
- "#{repo}/releases/download/#{tag_name}/sass_embedded-#{tag_name}-#{os}-#{arch}.#{ext}"
184
+ "#{repo}/releases/download/#{tag_name}/sass_embedded-#{tag_name}-#{os}-#{cpu}.#{ext}"
181
185
  end
182
186
 
183
187
  def default_protoc
@@ -185,7 +189,7 @@ module Configuration
185
189
 
186
190
  version = Gem::Dependency.new('google-protobuf').to_spec.version
187
191
 
188
- message = "protoc for #{Platform::OS}/#{Platform::ARCH} not available at #{repo}/#{version}"
192
+ message = "protoc for #{Platform::ARCH} not available at #{repo}/#{version}"
189
193
 
190
194
  os = case Platform::OS
191
195
  when 'darwin'
@@ -198,22 +202,22 @@ module Configuration
198
202
  raise NotImplementedError, message
199
203
  end
200
204
 
201
- arch = case Platform::ARCH
202
- when 'i386'
203
- 'x86_32'
204
- when 'x86_64'
205
- 'x86_64'
206
- when 'aarch64'
207
- 'aarch_64'
208
- when 'powerpc64le'
209
- 'ppcle_64'
210
- when 's390x'
211
- 's390_64'
212
- else
213
- raise NotImplementedError, message
214
- end
215
-
216
- "#{repo}/#{version}/protoc-#{version}-#{os}-#{arch}.exe"
205
+ cpu = case Platform::CPU
206
+ when 'i386'
207
+ 'x86_32'
208
+ when 'x86_64'
209
+ 'x86_64'
210
+ when 'aarch64'
211
+ 'aarch_64'
212
+ when 'powerpc64le'
213
+ 'ppcle_64'
214
+ when 's390x'
215
+ 's390_64'
216
+ else
217
+ raise NotImplementedError, message
218
+ end
219
+
220
+ "#{repo}/#{version}/protoc-#{version}-#{os}-#{cpu}.exe"
217
221
  end
218
222
 
219
223
  def default_sass_embedded_protocol
@@ -69,17 +69,17 @@ module Sass
69
69
  end
70
70
 
71
71
  def receive_message(outbound_message)
72
- message = outbound_message.public_send(outbound_message.message)
73
-
74
- case outbound_message.message
72
+ oneof = outbound_message.message
73
+ message = outbound_message.public_send(oneof)
74
+ case oneof
75
75
  when :error
76
76
  half_close
77
- @observers[message.id]&.public_send(outbound_message.message, message)
77
+ @observers[message.id]&.public_send(oneof, message)
78
78
  when :compile_response, :version_response
79
- @observers[message.id].public_send(outbound_message.message, message)
79
+ @observers[message.id].public_send(oneof, message)
80
80
  when :log_event, :canonicalize_request, :import_request, :file_import_request, :function_call_request
81
81
  Thread.new(@observers[message.compilation_id]) do |observer|
82
- observer.public_send(outbound_message.message, message)
82
+ observer.public_send(oneof, message)
83
83
  end
84
84
  else
85
85
  raise ArgumentError, "Unknown OutboundMessage.message #{message}"
@@ -114,8 +114,9 @@ module Sass
114
114
  end
115
115
 
116
116
  def from_proto(proto)
117
- obj = proto.public_send(proto.value)
118
- case proto.value
117
+ oneof = proto.value
118
+ obj = proto.public_send(oneof)
119
+ case oneof
119
120
  when :string
120
121
  Sass::Value::String.new(
121
122
  obj.text,
@@ -123,9 +124,10 @@ module Sass
123
124
  )
124
125
  when :number
125
126
  Sass::Value::Number.new(
126
- obj.value,
127
- obj.numerators.to_a,
128
- obj.denominators.to_a
127
+ obj.value, {
128
+ numerator_units: obj.numerators.to_a,
129
+ denominator_units: obj.denominators.to_a
130
+ }
129
131
  )
130
132
  when :rgb_color
131
133
  Sass::Value::Color.new(
@@ -1,5 +1,10 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require_relative 'host/function_registry'
4
+ require_relative 'host/importer_registry'
5
+ require_relative 'host/logger_registry'
6
+ require_relative 'host/value_protofier'
7
+
3
8
  module Sass
4
9
  class Embedded
5
10
  # The {Host} class.
@@ -9,8 +9,9 @@ module Sass
9
9
  module_function
10
10
 
11
11
  def from_proto_compile_response(compile_response)
12
- result = compile_response.public_send(compile_response.result)
13
- case compile_response.result
12
+ oneof = compile_response.result
13
+ result = compile_response.public_send(oneof)
14
+ case oneof
14
15
  when :failure
15
16
  raise CompileError.new(
16
17
  result.message,
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Sass
4
4
  class Embedded
5
- VERSION = '1.0.19'
5
+ VERSION = '1.1.0'
6
6
  end
7
7
  end
data/lib/sass/embedded.rb CHANGED
@@ -9,30 +9,12 @@ require_relative 'embedded/channel'
9
9
  require_relative 'embedded/compiler'
10
10
  require_relative 'embedded/dispatcher'
11
11
  require_relative 'embedded/host'
12
- require_relative 'embedded/host/function_registry'
13
- require_relative 'embedded/host/importer_registry'
14
- require_relative 'embedded/host/logger_registry'
15
- require_relative 'embedded/host/value_protofier'
16
12
  require_relative 'embedded/protofier'
17
13
  require_relative 'embedded/structifier'
18
14
  require_relative 'embedded/varint'
19
15
  require_relative 'embedded/version'
20
16
  require_relative 'logger'
21
- require_relative 'logger/source_location'
22
- require_relative 'logger/source_span'
23
- require_relative 'script_error'
24
17
  require_relative 'value'
25
- require_relative 'value/list'
26
- require_relative 'value/argument_list'
27
- require_relative 'value/boolean'
28
- require_relative 'value/color'
29
- require_relative 'value/function'
30
- require_relative 'value/fuzzy_math'
31
- require_relative 'value/map'
32
- require_relative 'value/null'
33
- require_relative 'value/number'
34
- require_relative 'value/number/unit'
35
- require_relative 'value/string'
36
18
 
37
19
  module Sass
38
20
  # The {Embedded} host for using dart-sass-embedded. Each instance creates
data/lib/sass/logger.rb CHANGED
@@ -1,5 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require_relative 'logger/source_location'
4
+ require_relative 'logger/source_span'
5
+
3
6
  module Sass
4
7
  # A namespace for built-in Loggers.
5
8
  #
@@ -1,5 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Sass
4
+ # An exception thrown by Sass Script.
4
5
  class ScriptError < StandardError; end
5
6
  end
@@ -8,8 +8,11 @@ module Sass
8
8
  class Function
9
9
  include Value
10
10
 
11
- # @param id_or_signature [Numeric, ::String]
12
- # @param callback [Proc]
11
+ # @overload initialize(id)
12
+ # @param id [Numeric]
13
+ # @overload initialize(signature, callback)
14
+ # @param signature [::String]
15
+ # @param callback [Proc]
13
16
  def initialize(id_or_signature, callback = nil)
14
17
  if id_or_signature.is_a? Numeric
15
18
  @id = id_or_signature
@@ -1,5 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require_relative 'number/unit'
4
+
3
5
  module Sass
4
6
  module Value
5
7
  # Sass's number type.
@@ -9,11 +11,26 @@ module Sass
9
11
  include Value
10
12
 
11
13
  # @param value [Numeric]
12
- # @param numerator_units [Array<::String>, ::String]
13
- # @param denominator_units [Array<::String>, ::String]
14
- def initialize(value, numerator_units = [], denominator_units = [])
15
- numerator_units = [numerator_units] if numerator_units.is_a?(::String)
16
- denominator_units = [denominator_units] if denominator_units.is_a?(::String)
14
+ # @param unit [::String, Hash]
15
+ # @option unit [Array<::String>] :numerator_units
16
+ # @option unit [Array<::String>] :denominator_units
17
+ def initialize(value, unit = nil)
18
+ case unit
19
+ when nil
20
+ numerator_units = []
21
+ denominator_units = []
22
+ when ::String
23
+ numerator_units = [unit]
24
+ denominator_units = []
25
+ when ::Hash
26
+ numerator_units = unit.fetch(:numerator_units, [])
27
+ raise error "invalid numerator_units #{numerator_units.inspect}" unless numerator_units.is_a? Array
28
+
29
+ denominator_units = unit.fetch(:denominator_units, [])
30
+ raise error "invalid denominator_units #{denominator_units.inspect}" unless denominator_units.is_a? Array
31
+ else
32
+ raise error "invalid unit #{unit.inspect}"
33
+ end
17
34
 
18
35
  unless denominator_units.empty? && numerator_units.empty?
19
36
  value = value.dup
@@ -159,8 +176,10 @@ module Sass
159
176
  # @param new_denominator_units [Array<::String>]
160
177
  # @return [Number]
161
178
  def convert(new_numerator_units, new_denominator_units, name = nil)
162
- Number.new(convert_value(new_numerator_units, new_denominator_units, name), new_numerator_units,
163
- new_denominator_units)
179
+ Number.new(convert_value(new_numerator_units, new_denominator_units, name), {
180
+ numerator_units: new_numerator_units,
181
+ denominator_units: new_denominator_units
182
+ })
164
183
  end
165
184
 
166
185
  # @param new_numerator_units [Array<::String>]
@@ -175,7 +194,10 @@ module Sass
175
194
  # @param other [Number]
176
195
  # @return [Number]
177
196
  def convert_to_match(other, name = nil, other_name = nil)
178
- Number.new(convert_value_to_match(other, name, other_name), other.numerator_units, other.denominator_units)
197
+ Number.new(convert_value_to_match(other, name, other_name), {
198
+ numerator_units: other.numerator_units,
199
+ denominator_units: other.denominator_units
200
+ })
179
201
  end
180
202
 
181
203
  # @param other [Number]
@@ -192,8 +214,10 @@ module Sass
192
214
  # @param new_denominator_units [Array<::String>]
193
215
  # @return [Number]
194
216
  def coerce(new_numerator_units, new_denominator_units, name = nil)
195
- Number.new(coerce_value(new_numerator_units, new_denominator_units, name), new_numerator_units,
196
- new_denominator_units)
217
+ Number.new(coerce_value(new_numerator_units, new_denominator_units, name), {
218
+ numerator_units: new_numerator_units,
219
+ denominator_units: new_denominator_units
220
+ })
197
221
  end
198
222
 
199
223
  # @param new_numerator_units [Array<::String>]
@@ -214,7 +238,10 @@ module Sass
214
238
  # @param other [Number]
215
239
  # @return [Number]
216
240
  def coerce_to_match(other, name = nil, other_name = nil)
217
- Number.new(coerce_value_to_match(other, name, other_name), other.numerator_units, other.denominator_units)
241
+ Number.new(coerce_value_to_match(other, name, other_name), {
242
+ numerator_units: other.numerator_units,
243
+ denominator_units: other.denominator_units
244
+ })
218
245
  end
219
246
 
220
247
  # @param other [Number]
@@ -9,7 +9,7 @@ module Sass
9
9
  include Value
10
10
 
11
11
  # @param text [::String]
12
- # @param quoted: [::Boolean]
12
+ # @param quoted [::Boolean]
13
13
  def initialize(text = '', quoted: true)
14
14
  @text = text.freeze
15
15
  @quoted = quoted
data/lib/sass/value.rb CHANGED
@@ -1,5 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require_relative 'script_error'
4
+
3
5
  module Sass
4
6
  # The abstract base class of Sass's value types.
5
7
  #
@@ -117,3 +119,14 @@ module Sass
117
119
  end
118
120
  end
119
121
  end
122
+
123
+ require_relative 'value/list'
124
+ require_relative 'value/argument_list'
125
+ require_relative 'value/boolean'
126
+ require_relative 'value/color'
127
+ require_relative 'value/function'
128
+ require_relative 'value/fuzzy_math'
129
+ require_relative 'value/map'
130
+ require_relative 'value/null'
131
+ require_relative 'value/number'
132
+ require_relative 'value/string'
data/lib/sass.rb CHANGED
@@ -13,21 +13,27 @@ require_relative 'sass/embedded'
13
13
  # Sass.compile_string('h1 { font-size: 40px; }')
14
14
  module Sass
15
15
  class << self
16
- # @return [CompileResult]
17
- # @raise [CompileError]
16
+ # Compiles the Sass file at +path+ to CSS.
17
+ # @param (see Embedded#compile)
18
+ # @return (see Embedded#compile)
19
+ # @raise (see Embedded#compile)
18
20
  # @see Embedded#compile
19
21
  def compile(path, **kwargs)
20
22
  instance.compile(path, **kwargs)
21
23
  end
22
24
 
23
- # @return [CompileResult]
24
- # @raise [CompileError]
25
+ # Compiles a stylesheet whose contents is +source+ to CSS.
26
+ # @param (see Embedded#compile_string)
27
+ # @return (see Embedded#compile_string)
28
+ # @raise (see Embedded#compile_string)
25
29
  # @see Embedded#compile_string
26
30
  def compile_string(source, **kwargs)
27
31
  instance.compile_string(source, **kwargs)
28
32
  end
29
33
 
30
- # @return [String]
34
+ # @param (see Embedded#info)
35
+ # @return (see Embedded#info)
36
+ # @raise (see Embedded#info)
31
37
  # @see Embedded#info
32
38
  def info
33
39
  instance.info
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.0.19
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - なつき
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-03-13 00:00:00.000000000 Z
11
+ date: 2022-03-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: google-protobuf
@@ -160,8 +160,8 @@ homepage: https://github.com/ntkme/sass-embedded-host-ruby
160
160
  licenses:
161
161
  - MIT
162
162
  metadata:
163
- documentation_uri: https://www.rubydoc.info/gems/sass-embedded/1.0.19
164
- source_code_uri: https://github.com/ntkme/sass-embedded-host-ruby/tree/v1.0.19
163
+ documentation_uri: https://rubydoc.info/gems/sass-embedded/1.1.0
164
+ source_code_uri: https://github.com/ntkme/sass-embedded-host-ruby/tree/v1.1.0
165
165
  funding_uri: https://github.com/sponsors/ntkme
166
166
  post_install_message:
167
167
  rdoc_options: []