sassc-embedded 1.4.0 → 1.5.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2c93f068bcc4406780bad76da750f2b265943a971456d3b56a14b0bdb2f0be8a
4
- data.tar.gz: c851519ef1b2f08fe4370f4669b9df263b7264844911df873de30273748b4675
3
+ metadata.gz: ae4ea5a6b743f50b8687316f4ff5492b91caa0e8672a7b85da21a7402e2e901d
4
+ data.tar.gz: c94a6a86fb24ee5d018feadfcc5d514fc60d3a77338fe0482f4d4451eafa4a54
5
5
  SHA512:
6
- metadata.gz: 14f22ec99ba45f9fddf083a1bccab5b34b3c48e745cfd30c53078c504d90d3e870c27effc1c9ae20b32ead54602dffadfa48b59993a61fa82991c9cafa1cd856
7
- data.tar.gz: 6a1d3fde2932a3c83932bb6601ad7e5ac0d945d69f69d0d5acf36c378401afdd3cbc7cb00dcb835b10be697fdbdb378bbcffd1e957e2995e686f3d10f546c6b7
6
+ metadata.gz: 42fa17dc23aa53fcfb091c5ad23d1d0e49c260dd914bab8c39ea3c15c9ae3a7e303c44e632f3088f5f4e42d1d6dd6881ec6451a3b5860adbb88e0adc12cc0d34
7
+ data.tar.gz: 35925d2e42085f78234223f56db9e406b95f6ff6541d98802ed5dc75056e4f1085a8f98efb1fe7233ce846b3c1ad8d45ec63255413a9a14191b4022b685ebeef
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.0'
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
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.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-02 00:00:00.000000000 Z
11
+ date: 2022-04-03 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.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.0
142
+ source_code_uri: https://github.com/ntkme/sassc-embedded-polyfill-ruby/tree/v1.5.0
143
143
  funding_uri: https://github.com/sponsors/ntkme
144
144
  post_install_message:
145
145
  rdoc_options: []