sassc-embedded 1.4.0 → 1.5.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: 2c93f068bcc4406780bad76da750f2b265943a971456d3b56a14b0bdb2f0be8a
4
- data.tar.gz: c851519ef1b2f08fe4370f4669b9df263b7264844911df873de30273748b4675
3
+ metadata.gz: 34c4811b38299f8c49a35d9b8b87d23d610406fd94ce7f8075ac03313db70a23
4
+ data.tar.gz: 390d007373427c76c86c3bf4a9c7e8610dc99da6524bfc3546138b6f63b4fc83
5
5
  SHA512:
6
- metadata.gz: 14f22ec99ba45f9fddf083a1bccab5b34b3c48e745cfd30c53078c504d90d3e870c27effc1c9ae20b32ead54602dffadfa48b59993a61fa82991c9cafa1cd856
7
- data.tar.gz: 6a1d3fde2932a3c83932bb6601ad7e5ac0d945d69f69d0d5acf36c378401afdd3cbc7cb00dcb835b10be697fdbdb378bbcffd1e957e2995e686f3d10f546c6b7
6
+ metadata.gz: cc3c3f6ee78f82364b1ea56e44ae8e0006b9def7cf27492b7eb4a8e40fc47d7df99b2e10c125a285d19627964d7bb6f0f195049772351885df187725ed1fd14b
7
+ data.tar.gz: bbf300fce0ae4ea93219a10e321038fa22126f337303b02e2837dc808d2fc06a0ead8c733f2ee2591ee51c198037a9ef4d476772d1c723d58188f04e20b26f15
data/README.md CHANGED
@@ -7,6 +7,12 @@ Use `sass-embedded` with SassC Ruby!
7
7
 
8
8
  This library polyfills [`sassc`](https://github.com/sass/sassc-ruby) with the [`sass-embedded`](https://github.com/ntkme/sass-embedded-host-ruby) implementation.
9
9
 
10
+ It has been tested with:
11
+
12
+ - [`sassc`](https://github.com/sass/sassc-ruby)
13
+ - [`sassc-rails`](https://github.com/sass/sassc-rails)
14
+ - [`sprockets`](https://github.com/rails/sprockets)
15
+ - [`sprockets-rails`](https://github.com/rails/sprockets-rails)
10
16
 
11
17
  ## Install
12
18
 
@@ -43,12 +49,10 @@ See [rubydoc.info/gems/sassc](https://rubydoc.info/gems/sassc) for full API docu
43
49
 
44
50
  ## Behavioral Differences from SassC Ruby
45
51
 
46
- 1. Option `:style => :nested` behaves as `:expanded`.
47
-
48
- 2. Option `:style => :compact` behaves as `:compressed`.
52
+ 1. Option `:style => :nested` and `:style => :compact` behave as `:style => :expanded`.
49
53
 
50
- 3. Option `:precision` is ignored.
54
+ 2. Option `:precision` is ignored.
51
55
 
52
- 4. Option `:line_comments` is ignored.
56
+ 3. Option `:line_comments` is ignored.
53
57
 
54
58
  See [the dart-sass documentation](https://github.com/sass/dart-sass#behavioral-differences-from-ruby-sass) for other differences.
@@ -2,6 +2,6 @@
2
2
 
3
3
  module SassC
4
4
  module Embedded
5
- VERSION = '1.4.0'
5
+ VERSION = '1.5.2'
6
6
  end
7
7
  end
@@ -5,7 +5,6 @@ require 'sass-embedded'
5
5
 
6
6
  require 'base64'
7
7
  require 'json'
8
- require 'pathname'
9
8
  require 'uri'
10
9
 
11
10
  require_relative 'embedded/version'
@@ -46,8 +45,9 @@ module SassC
46
45
  line = e.span&.start&.line
47
46
  line += 1 unless line.nil?
48
47
  url = e.span&.url
49
- path = url&.start_with?('file:') ? URL.file_url_to_path(url) : nil
50
- path = relative_path(Dir.pwd, path) unless path.nil?
48
+ path = if url&.start_with?('file:')
49
+ URL.parse(url).route_from(URL.path_to_file_url("#{File.absolute_path('')}/"))
50
+ end
51
51
  raise SyntaxError.new(e.message, filename: path, line: line)
52
52
  end
53
53
 
@@ -64,6 +64,14 @@ module SassC
64
64
  )
65
65
  end
66
66
 
67
+ def output_url
68
+ @output_url ||= (URL.path_to_file_url(File.absolute_path(output_path)) if output_path)
69
+ end
70
+
71
+ def source_map_file_url
72
+ @source_map_file_url ||= (URL.path_to_file_url(File.absolute_path(source_map_file)) if source_map_file)
73
+ end
74
+
67
75
  def output_style
68
76
  @output_style ||= begin
69
77
  style = @options.fetch(:style, :sass_style_nested).to_s
@@ -72,10 +80,8 @@ module SassC
72
80
 
73
81
  style = style.delete_prefix('sass_style_').to_sym
74
82
  case style
75
- when :nested
83
+ when :nested, :compact
76
84
  :expanded
77
- when :compact
78
- :compressed
79
85
  else
80
86
  style
81
87
  end
@@ -99,15 +105,12 @@ module SassC
99
105
  def post_process_source_map(source_map)
100
106
  return unless source_map
101
107
 
108
+ url = URL.parse(source_map_file_url || file_url)
102
109
  data = JSON.parse(source_map)
103
-
104
- source_map_dir = File.dirname(source_map_file || '')
105
-
106
- data['file'] = URL.escape(relative_path(source_map_dir, output_path)) if output_path
107
-
110
+ data['file'] = URL.parse(output_url).route_from(url).to_s if output_url
108
111
  data['sources'].map! do |source|
109
112
  if source.start_with?('file:')
110
- relative_path(source_map_dir, URL.file_url_to_path(source))
113
+ URL.parse(source).route_from(url).to_s
111
114
  else
112
115
  source
113
116
  end
@@ -119,19 +122,16 @@ module SassC
119
122
  def post_process_css(css)
120
123
  css += "\n" unless css.empty?
121
124
  unless @source_map.nil? || omit_source_map_url?
122
- url = if source_map_embed?
123
- "data:application/json;base64,#{Base64.strict_encode64(@source_map)}"
124
- else
125
- URL.escape(relative_path(File.dirname(output_path || ''), source_map_file))
126
- end
127
- css += "\n/*# sourceMappingURL=#{url} */"
125
+ url = URL.parse(output_url || file_url)
126
+ source_mapping_url = if source_map_embed?
127
+ "data:application/json;base64,#{Base64.strict_encode64(@source_map)}"
128
+ else
129
+ URL.parse(source_map_file_url).route_from(url).to_s
130
+ end
131
+ css += "\n/*# sourceMappingURL=#{source_mapping_url} */"
128
132
  end
129
133
  css
130
134
  end
131
-
132
- def relative_path(from, to)
133
- Pathname.new(File.absolute_path(to)).relative_path_from(Pathname.new(File.absolute_path(from))).to_s
134
- end
135
135
  end
136
136
 
137
137
  class FunctionsHandler
@@ -297,7 +297,7 @@ module SassC
297
297
  return url if @importer_results.key?(url)
298
298
 
299
299
  path = URL.parse(url).route_from(@parent_urls.last).to_s
300
- resolved = resolve_path(path, URL.file_url_to_path(@parent_urls.last.to_s), from_import)
300
+ resolved = resolve_path(path, URL.file_url_to_path(@parent_urls.last), from_import)
301
301
  return resolved.nil? ? nil : URL.path_to_file_url(resolved)
302
302
  end
303
303
 
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.4.0
4
+ version: 1.5.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - なつき
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-04-02 00:00:00.000000000 Z
11
+ date: 2022-04-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sassc
@@ -30,14 +30,14 @@ dependencies:
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '1.2'
33
+ version: '1.3'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '1.2'
40
+ version: '1.3'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: minitest
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -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.4.0
142
- source_code_uri: https://github.com/ntkme/sassc-embedded-polyfill-ruby/tree/v1.4.0
141
+ documentation_uri: https://rubydoc.info/gems/sassc-embedded/1.5.2
142
+ source_code_uri: https://github.com/ntkme/sassc-embedded-polyfill-ruby/tree/v1.5.2
143
143
  funding_uri: https://github.com/sponsors/ntkme
144
144
  post_install_message:
145
145
  rdoc_options: []