sassc-embedded 1.0.0 → 1.0.1

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: ab0678b3173a808bb49c1772c1188fa5401989602679332cda0b016d98252dfe
4
- data.tar.gz: 280d458c11585dcdfe5915ad55a2079b323d6b520dd54c6b4f716fcddcfd8c3c
3
+ metadata.gz: 9fa48bc9c63a5d180324a991c7b8ceb33889b158d96a46260d7426c393406ecd
4
+ data.tar.gz: 66e8b53ea62239dbcc8ddfb00a41b332d9569384b0275df0f0e572d3c4bb091c
5
5
  SHA512:
6
- metadata.gz: a636e215cd5db491aedf47b256b6f4111e14933a8ac299b74001a18a90e5d4f8b27f554a5667d419b28b7c5fa4288ef03ec4263dd0388b1aedc8698b357b5c4e
7
- data.tar.gz: da72a50497341ff4a461e9d0f946a885eb516a18961b25a68176b2abf5e82116077bc92d0e57a34b7c6d33f6b0e7304b7d66333d7f21e7ac961b412062e19465
6
+ metadata.gz: 533e3f95958424301761fd4c599c59717c008307d0aea4fcdd2a12d89684369f590b8e003044ee967a8ac6aa21207eae530188802bd2c5c1a6a9c2efbf7e1289
7
+ data.tar.gz: a93ac934bd5229337a3a4daa2740624fd2d1e19c8b37764bc98cdb51f43ce964544487be3b184a962ca8c8f4c17061763d6bafb2f3daacd668c02af7e3e863ab
@@ -2,6 +2,6 @@
2
2
 
3
3
  module SassC
4
4
  module Embedded
5
- VERSION = '1.0.0'
5
+ VERSION = '1.0.1'
6
6
  end
7
7
  end
@@ -46,14 +46,17 @@ module SassC
46
46
  line = e.span&.start&.line
47
47
  line += 1 unless line.nil?
48
48
  path = Util.file_url_to_path(e.span&.url)
49
- path = relative_path(Dir.pwd, path)
49
+ path = relative_path(Dir.pwd, path) unless path.nil?
50
50
  raise SyntaxError.new(e.message, filename: path, line: line)
51
51
  end
52
52
 
53
53
  private
54
54
 
55
55
  def output_path
56
- @options[:output_path]
56
+ @output_path ||= @options.fetch(
57
+ :output_path,
58
+ ("#{File.basename(filename, File.extname(filename))}.css" if filename)
59
+ )
57
60
  end
58
61
 
59
62
  def file_url
@@ -93,11 +96,17 @@ module SassC
93
96
 
94
97
  data = JSON.parse(source_map)
95
98
 
96
- data['file'] = URI::DEFAULT_PARSER.escape(output_path) if output_path
99
+ source_map_dir = File.dirname(source_map_file || '')
100
+
101
+ if output_path
102
+ data['file'] = Util::URI_PARSER.escape(
103
+ relative_path(source_map_dir, output_path)
104
+ )
105
+ end
97
106
 
98
107
  data['sources'].map! do |source|
99
108
  if source.start_with? 'file:'
100
- relative_path(Dir.pwd, Util.file_url_to_path(source))
109
+ relative_path(source_map_dir, Util.file_url_to_path(source))
101
110
  else
102
111
  source
103
112
  end
@@ -112,7 +121,9 @@ module SassC
112
121
  url = if source_map_embed?
113
122
  "data:application/json;base64,#{Base64.strict_encode64(@source_map)}"
114
123
  else
115
- URI::DEFAULT_PARSER.escape(source_map_file)
124
+ Util::URI_PARSER.escape(
125
+ relative_path(File.dirname(output_path || ''), source_map_file)
126
+ )
116
127
  end
117
128
  css += "\n/*# sourceMappingURL=#{url} */"
118
129
  end
@@ -120,7 +131,7 @@ module SassC
120
131
  end
121
132
 
122
133
  def relative_path(from, to)
123
- Pathname.new(to).relative_path_from(Pathname.new(from)).to_s
134
+ Pathname.new(File.absolute_path(to)).relative_path_from(Pathname.new(File.absolute_path(from))).to_s
124
135
  end
125
136
  end
126
137
 
@@ -389,10 +400,12 @@ module SassC
389
400
  module Util
390
401
  module_function
391
402
 
403
+ URI_PARSER = URI::Parser.new({ RESERVED: ';/?:@&=+$,' })
404
+
392
405
  def file_url_to_path(url)
393
406
  return if url.nil?
394
407
 
395
- path = URI::DEFAULT_PARSER.unescape(URI.parse(url).path)
408
+ path = URI_PARSER.unescape(URI.parse(url).path)
396
409
  path = path[1..] if Gem.win_platform? && path[0].chr == '/' && path[1].chr =~ /[a-z]/i && path[2].chr == ':'
397
410
  path
398
411
  end
@@ -402,7 +415,7 @@ module SassC
402
415
 
403
416
  path = File.absolute_path(path)
404
417
  path = "/#{path}" unless path.start_with? '/'
405
- URI::File.build([nil, URI::DEFAULT_PARSER.escape(path)]).to_s
418
+ URI::File.build([nil, URI_PARSER.escape(path)]).to_s
406
419
  end
407
420
  end
408
421
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sassc-embedded
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - なつき
@@ -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.0
142
- source_code_uri: https://github.com/ntkme/sassc-embedded-polyfill-ruby/tree/v1.0.0
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
143
143
  funding_uri: https://github.com/sponsors/ntkme
144
144
  post_install_message:
145
145
  rdoc_options: []