sassc-embedded 1.5.6 → 1.6.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: 464d4f9326ea315b791701d5ff9ca9a06201b9bbdccc920aba591ea5764f9cba
4
- data.tar.gz: c149398af2d50cad3659f680d1f10a053e7290457340e02758fa4235a2f7ba34
3
+ metadata.gz: 59a845230e544276ea6eb32db4a12a9612d2e14b6f25bd4e0031806ceb6f5eb4
4
+ data.tar.gz: 1716cb7bdb3d8bf99564bff6802f995802399bb22ee347ae2028c8d0729c5218
5
5
  SHA512:
6
- metadata.gz: 7b9e55b5db011df6ee7befabb77a6e74934ed7addf4bedcc8ebcf831ca38a7cdeff2b2d2f34ce7326f83cd97f52d8f19f79f1229882f8a436dd533243ad207db
7
- data.tar.gz: 506cf7f45c08fc2e7f82e1d6675fb2d9cf9b36a66d098ae5fc43e6ea0c997b2fe4f442caa4cbdb1b442132768c32c35e83e2457da40ff2a8baff29cb9e05a60c
6
+ metadata.gz: 2bb616946d32c4a71a939d1e723dc11dcb7c7b02fb1ebc1236865e7badc53ad8dc9fc320706b7b3119e0d2d0e1bccad55665e95dd3ede0b6ce715226d0d31dfb
7
+ data.tar.gz: 5fefa20e790fbbc14368e1ae5111d2f1621e9f58c58d5a206f9799ecd2a046c15039082c25aabadcdb539fb51a7b9525305221db8b96d9b25d0f79ba881d2a03
@@ -2,6 +2,6 @@
2
2
 
3
3
  module SassC
4
4
  module Embedded
5
- VERSION = '1.5.6'
5
+ VERSION = '1.6.0'
6
6
  end
7
7
  end
@@ -26,7 +26,7 @@ module SassC
26
26
  style: output_style,
27
27
 
28
28
  functions: functions_handler.setup(nil, functions: @functions),
29
- importers: [],
29
+ importers: @options.fetch(:importers, []),
30
30
 
31
31
  alert_ascii: @options.fetch(:alert_ascii, false),
32
32
  alert_color: @options.fetch(:alert_color, nil),
@@ -293,55 +293,45 @@ module SassC
293
293
  end
294
294
 
295
295
  def canonicalize(url, from_import:)
296
- return url if url.start_with?(Protocol::LOADED)
297
-
298
296
  if url.start_with?(Protocol::IMPORT)
299
- url = @canonical_urls.delete(url.delete_prefix(Protocol::IMPORT))
300
- return url if @importer_results.key?(url)
301
-
297
+ canonical_url = @canonical_urls.delete(url.delete_prefix(Protocol::IMPORT))
298
+ unless @importer_results.key?(canonical_url)
299
+ canonical_url = resolve_file_url(canonical_url, @parent_urls.last, from_import)
300
+ end
301
+ @parent_urls.push(canonical_url)
302
+ canonical_url
303
+ elsif url.start_with?(Protocol::FILE)
302
304
  path = URL.parse(url).route_from(@parent_urls.last).to_s
303
- resolved = resolve_path(path, URL.file_url_to_path(@parent_urls.last), from_import)
304
- return URL.path_to_file_url(resolved) unless resolved.nil?
305
+ parent_path = URL.file_url_to_path(@parent_urls.last)
305
306
 
306
- return
307
- end
308
-
309
- return unless url.start_with?(Protocol::FILE)
310
-
311
- path = URL.parse(url).route_from(@parent_urls.last).to_s
312
- parent_path = URL.file_url_to_path(@parent_urls.last)
307
+ imports = @importer.imports(path, parent_path)
308
+ imports = [SassC::Importer::Import.new(path)] if imports.nil?
309
+ imports = [imports] unless imports.is_a?(Array)
310
+ imports.each do |import|
311
+ import.path = File.absolute_path(import.path, File.dirname(parent_path))
312
+ end
313
313
 
314
- imports = @importer.imports(path, parent_path)
315
- imports = [SassC::Importer::Import.new(path)] if imports.nil?
316
- imports = [imports] unless imports.is_a?(Array)
317
- imports.each do |import|
318
- import.path = File.absolute_path(import.path, File.dirname(parent_path))
314
+ canonical_url = "#{Protocol::IMPORT}#{next_id}"
315
+ @importer_results[canonical_url] = imports_to_native(imports)
316
+ canonical_url
317
+ elsif url.start_with?(Protocol::LOADED)
318
+ canonical_url = Protocol::LOADED
319
+ @parent_urls.pop
320
+ canonical_url
319
321
  end
320
-
321
- id = next_id
322
- canonical_url = "#{Protocol::IMPORT}#{id}"
323
- @canonical_urls[id] = canonical_url
324
- @importer_results[canonical_url] = imports_to_native(imports)
325
- canonical_url
326
322
  end
327
323
 
328
324
  def load(canonical_url)
329
- if canonical_url.start_with?(Protocol::IMPORT)
325
+ if @importer_results.key?(canonical_url)
330
326
  @importer_results.delete(canonical_url)
331
327
  elsif canonical_url.start_with?(Protocol::FILE)
332
- @parent_urls.push(canonical_url)
333
- if @importer_results.key?(canonical_url)
334
- @importer_results.delete(canonical_url)
335
- else
336
- path = URL.file_url_to_path(canonical_url)
337
- {
338
- contents: File.read(path),
339
- syntax: syntax(path),
340
- source_map_url: canonical_url
341
- }
342
- end
328
+ path = URL.file_url_to_path(canonical_url)
329
+ {
330
+ contents: File.read(path),
331
+ syntax: syntax(path),
332
+ source_map_url: canonical_url
333
+ }
343
334
  elsif canonical_url.start_with?(Protocol::LOADED)
344
- @parent_urls.pop
345
335
  {
346
336
  contents: '',
347
337
  syntax: :scss
@@ -355,10 +345,12 @@ module SassC
355
345
  @load_paths ||= (@importer.options[:load_paths] || []) + SassC.load_paths
356
346
  end
357
347
 
358
- def resolve_path(path, parent_path, from_import)
348
+ def resolve_file_url(url, parent_url, from_import)
349
+ path = URL.parse(url).route_from(parent_url).to_s
350
+ parent_path = URL.file_url_to_path(parent_url)
359
351
  [File.dirname(parent_path)].concat(load_paths).each do |load_path|
360
352
  resolved = FileImporter.resolve_path(File.absolute_path(path, load_path), from_import)
361
- return resolved unless resolved.nil?
353
+ return URL.path_to_file_url(resolved) unless resolved.nil?
362
354
  end
363
355
  nil
364
356
  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.5.6
4
+ version: 1.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - なつき
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-04-06 00:00:00.000000000 Z
11
+ date: 2022-04-07 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.5.6
142
- source_code_uri: https://github.com/ntkme/sassc-embedded-polyfill-ruby/tree/v1.5.6
141
+ documentation_uri: https://rubydoc.info/gems/sassc-embedded/1.6.0
142
+ source_code_uri: https://github.com/ntkme/sassc-embedded-polyfill-ruby/tree/v1.6.0
143
143
  funding_uri: https://github.com/sponsors/ntkme
144
144
  post_install_message:
145
145
  rdoc_options: []