sassc-embedded 1.0.1 → 1.0.2

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: 9fa48bc9c63a5d180324a991c7b8ceb33889b158d96a46260d7426c393406ecd
4
- data.tar.gz: 66e8b53ea62239dbcc8ddfb00a41b332d9569384b0275df0f0e572d3c4bb091c
3
+ metadata.gz: 5243561e8643bea221f2541af3faf2e00fb28c4d54842ee582f97f3e9784275d
4
+ data.tar.gz: cfc193f4fbf98a125bd410578d228612ccd2974e76f40668366a389333ae1020
5
5
  SHA512:
6
- metadata.gz: 533e3f95958424301761fd4c599c59717c008307d0aea4fcdd2a12d89684369f590b8e003044ee967a8ac6aa21207eae530188802bd2c5c1a6a9c2efbf7e1289
7
- data.tar.gz: a93ac934bd5229337a3a4daa2740624fd2d1e19c8b37764bc98cdb51f43ce964544487be3b184a962ca8c8f4c17061763d6bafb2f3daacd668c02af7e3e863ab
6
+ metadata.gz: 92f34277c63720d77ebf60655e50472d26a5511dbd4d3f67a2dbf35ec459decd97764f1e6f72efcceca09c1fcb067ca4763690b287326f7f13383d930711ea3d
7
+ data.tar.gz: 2369e12515b4609d0c38ccca4493b94eba2255783046dbaa1611ef21fb97e5ac8f6de5d8aac6ef3fea266642e5e0cf117407881c6e58f7a6328bcfc13d40f7ac
@@ -2,6 +2,6 @@
2
2
 
3
3
  module SassC
4
4
  module Embedded
5
- VERSION = '1.0.1'
5
+ VERSION = '1.0.2'
6
6
  end
7
7
  end
@@ -98,11 +98,7 @@ module SassC
98
98
 
99
99
  source_map_dir = File.dirname(source_map_file || '')
100
100
 
101
- if output_path
102
- data['file'] = Util::URI_PARSER.escape(
103
- relative_path(source_map_dir, output_path)
104
- )
105
- end
101
+ data['file'] = Util::URI_PARSER.escape(relative_path(source_map_dir, output_path)) if output_path
106
102
 
107
103
  data['sources'].map! do |source|
108
104
  if source.start_with? 'file:'
@@ -112,7 +108,7 @@ module SassC
112
108
  end
113
109
  end
114
110
 
115
- -JSON.generate(data)
111
+ JSON.generate(data)
116
112
  end
117
113
 
118
114
  def post_process_css(css)
@@ -121,13 +117,11 @@ module SassC
121
117
  url = if source_map_embed?
122
118
  "data:application/json;base64,#{Base64.strict_encode64(@source_map)}"
123
119
  else
124
- Util::URI_PARSER.escape(
125
- relative_path(File.dirname(output_path || ''), source_map_file)
126
- )
120
+ Util::URI_PARSER.escape(relative_path(File.dirname(output_path || ''), source_map_file))
127
121
  end
128
122
  css += "\n/*# sourceMappingURL=#{url} */"
129
123
  end
130
- -css
124
+ css
131
125
  end
132
126
 
133
127
  def relative_path(from, to)
@@ -170,7 +164,7 @@ module SassC
170
164
 
171
165
  def arguments_from_native_list(native_argument_list)
172
166
  native_argument_list.map do |embedded_value|
173
- Script::ValueConversion.from_native embedded_value
167
+ Script::ValueConversion.from_native embedded_value, @options
174
168
  end
175
169
  end
176
170
 
@@ -229,7 +223,7 @@ module SassC
229
223
  return canonical_url
230
224
  end
231
225
 
232
- canonical_url = "sass-importer-shim:#{canonical_url}"
226
+ canonical_url = "sassc-embedded:#{canonical_url}"
233
227
 
234
228
  imports = @importer.imports path, @importer.options[:filename]
235
229
  unless imports.is_a? Array
@@ -239,20 +233,17 @@ module SassC
239
233
  end
240
234
 
241
235
  contents = imports.map do |import|
242
- import_path = File.absolute_path(import.path)
243
- import_url = Util.path_to_file_url(import_path)
236
+ import_url = Util.path_to_file_url(File.absolute_path(import.path))
244
237
  @importer_results[import_url] = if import.source
245
238
  {
246
239
  contents: import.source,
247
240
  syntax: case import.path
248
- when /\.scss$/i
249
- :scss
250
241
  when /\.sass$/i
251
242
  :indented
252
243
  when /\.css$/i
253
244
  :css
254
245
  else
255
- raise ArgumentError
246
+ :scss
256
247
  end,
257
248
  source_map_url: if import.source_map_path
258
249
  Util.path_to_file_url(
@@ -282,6 +273,61 @@ module SassC
282
273
 
283
274
  module Script
284
275
  module ValueConversion
276
+ def self.from_native(value, options)
277
+ case value
278
+ when ::Sass::Value::Null::NULL
279
+ nil
280
+ when ::Sass::Value::Boolean
281
+ ::SassC::Script::Value::Bool.new(value.to_bool)
282
+ when ::Sass::Value::Color
283
+ if value.instance_eval { defined? @hue }
284
+ ::SassC::Script::Value::Color.new(
285
+ hue: value.hue,
286
+ saturation: value.saturation,
287
+ lightness: value.lightness,
288
+ alpha: value.alpha
289
+ )
290
+ else
291
+ ::SassC::Script::Value::Color.new(
292
+ red: value.red,
293
+ green: value.green,
294
+ blue: value.blue,
295
+ alpha: value.alpha
296
+ )
297
+ end
298
+ when ::Sass::Value::List
299
+ ::SassC::Script::Value::List.new(
300
+ value.to_a.map { |element| from_native(element, options) },
301
+ separator: case value.separator
302
+ when ','
303
+ :comma
304
+ when ' '
305
+ :space
306
+ else
307
+ raise UnsupportedValue, "Sass list separator #{value.separator} unsupported"
308
+ end,
309
+ bracketed: value.bracketed?
310
+ )
311
+ when ::Sass::Value::Map
312
+ ::SassC::Script::Value::Map.new(
313
+ value.contents.to_a.to_h { |k, v| [from_native(k, options), from_native(v, options)] }
314
+ )
315
+ when ::Sass::Value::Number
316
+ ::SassC::Script::Value::Number.new(
317
+ value.value,
318
+ value.numerator_units,
319
+ value.denominator_units
320
+ )
321
+ when ::Sass::Value::String
322
+ ::SassC::Script::Value::String.new(
323
+ value.text,
324
+ value.quoted? ? :string : :identifier
325
+ )
326
+ else
327
+ raise UnsupportedValue, "Sass argument of type #{value.class.name.split('::').last} unsupported"
328
+ end
329
+ end
330
+
285
331
  def self.to_native(value)
286
332
  case value
287
333
  when nil
@@ -304,7 +350,7 @@ module SassC
304
350
  alpha: value.alpha
305
351
  )
306
352
  else
307
- raise ArgumentError
353
+ raise UnsupportedValue, "Sass color mode #{value.instance_eval { @mode }} unsupported"
308
354
  end
309
355
  when ::SassC::Script::Value::List
310
356
  ::Sass::Value::List.new(
@@ -315,7 +361,7 @@ module SassC
315
361
  when :space
316
362
  ' '
317
363
  else
318
- raise ArgumentError
364
+ raise UnsupportedValue, "Sass list separator #{value.separator} unsupported"
319
365
  end,
320
366
  bracketed: value.bracketed
321
367
  )
@@ -336,62 +382,7 @@ module SassC
336
382
  quoted: value.type != :identifier
337
383
  )
338
384
  else
339
- raise ArgumentError
340
- end
341
- end
342
-
343
- def self.from_native(value)
344
- case value
345
- when ::Sass::Value::Null::NULL
346
- nil
347
- when ::Sass::Value::Boolean
348
- ::SassC::Script::Value::Bool.new(value.to_bool)
349
- when ::Sass::Value::Color
350
- if value.instance_eval { defined? @hue }
351
- ::SassC::Script::Value::Color.new(
352
- hue: value.hue,
353
- saturation: value.saturation,
354
- lightness: value.lightness,
355
- alpha: value.alpha
356
- )
357
- else
358
- ::SassC::Script::Value::Color.new(
359
- red: value.red,
360
- green: value.green,
361
- blue: value.blue,
362
- alpha: value.alpha
363
- )
364
- end
365
- when ::Sass::Value::List
366
- ::SassC::Script::Value::List.new(
367
- value.to_a.map { |element| from_native(element) },
368
- separator: case value.separator
369
- when ','
370
- :comma
371
- when ' '
372
- :space
373
- else
374
- raise ArgumentError
375
- end,
376
- bracketed: value.bracketed?
377
- )
378
- when ::Sass::Value::Map
379
- ::SassC::Script::Value::Map.new(
380
- value.contents.to_a.to_h { |k, v| [from_native(k), from_native(v)] }
381
- )
382
- when ::Sass::Value::Number
383
- ::SassC::Script::Value::Number.new(
384
- value.value,
385
- value.numerator_units,
386
- value.denominator_units
387
- )
388
- when ::Sass::Value::String
389
- ::SassC::Script::Value::String.new(
390
- value.text,
391
- value.quoted? ? :string : :identifier
392
- )
393
- else
394
- raise ArgumentError
385
+ raise UnsupportedValue, "Sass return type #{value.class.name.split('::').last} unsupported"
395
386
  end
396
387
  end
397
388
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sassc-embedded
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - なつき
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-03-21 00:00:00.000000000 Z
11
+ date: 2022-03-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sassc
@@ -138,8 +138,8 @@ homepage: https://github.com/ntkme/sassc-embedded-polyfill-ruby
138
138
  licenses:
139
139
  - MIT
140
140
  metadata:
141
- documentation_uri: https://rubydoc.info/gems/sassc-embedded/1.0.1
142
- source_code_uri: https://github.com/ntkme/sassc-embedded-polyfill-ruby/tree/v1.0.1
141
+ documentation_uri: https://rubydoc.info/gems/sassc-embedded/1.0.2
142
+ source_code_uri: https://github.com/ntkme/sassc-embedded-polyfill-ruby/tree/v1.0.2
143
143
  funding_uri: https://github.com/sponsors/ntkme
144
144
  post_install_message:
145
145
  rdoc_options: []