sassc-embedded 0.1.2 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/lib/sassc/embedded/version.rb +1 -1
- data/lib/sassc/embedded.rb +26 -7
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9fa48bc9c63a5d180324a991c7b8ceb33889b158d96a46260d7426c393406ecd
|
4
|
+
data.tar.gz: 66e8b53ea62239dbcc8ddfb00a41b332d9569384b0275df0f0e572d3c4bb091c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 533e3f95958424301761fd4c599c59717c008307d0aea4fcdd2a12d89684369f590b8e003044ee967a8ac6aa21207eae530188802bd2c5c1a6a9c2efbf7e1289
|
7
|
+
data.tar.gz: a93ac934bd5229337a3a4daa2740624fd2d1e19c8b37764bc98cdb51f43ce964544487be3b184a962ca8c8f4c17061763d6bafb2f3daacd668c02af7e3e863ab
|
data/README.md
CHANGED
@@ -19,7 +19,7 @@ gem install sassc-embedded
|
|
19
19
|
This polyfill utilizes `sass-embedded` to allow you to compile SCSS or SASS syntax to CSS. To compile, use a `SassC::Engine`, e.g.:
|
20
20
|
|
21
21
|
``` ruby
|
22
|
-
require 'sassc
|
22
|
+
require 'sassc-embedded'
|
23
23
|
|
24
24
|
SassC::Engine.new(sass, style: :compressed).render
|
25
25
|
```
|
data/lib/sassc/embedded.rb
CHANGED
@@ -22,7 +22,7 @@ module SassC
|
|
22
22
|
syntax: syntax,
|
23
23
|
url: file_url,
|
24
24
|
|
25
|
-
source_map: !source_map_file.nil?,
|
25
|
+
source_map: source_map_embed? || !source_map_file.nil?,
|
26
26
|
source_map_include_sources: source_map_contents?,
|
27
27
|
style: output_style,
|
28
28
|
|
@@ -46,12 +46,19 @@ 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
|
+
def output_path
|
56
|
+
@output_path ||= @options.fetch(
|
57
|
+
:output_path,
|
58
|
+
("#{File.basename(filename, File.extname(filename))}.css" if filename)
|
59
|
+
)
|
60
|
+
end
|
61
|
+
|
55
62
|
def file_url
|
56
63
|
@file_url ||= Util.path_to_file_url(filename || 'stdin')
|
57
64
|
end
|
@@ -89,9 +96,17 @@ module SassC
|
|
89
96
|
|
90
97
|
data = JSON.parse(source_map)
|
91
98
|
|
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
|
106
|
+
|
92
107
|
data['sources'].map! do |source|
|
93
108
|
if source.start_with? 'file:'
|
94
|
-
relative_path(
|
109
|
+
relative_path(source_map_dir, Util.file_url_to_path(source))
|
95
110
|
else
|
96
111
|
source
|
97
112
|
end
|
@@ -106,7 +121,9 @@ module SassC
|
|
106
121
|
url = if source_map_embed?
|
107
122
|
"data:application/json;base64,#{Base64.strict_encode64(@source_map)}"
|
108
123
|
else
|
109
|
-
|
124
|
+
Util::URI_PARSER.escape(
|
125
|
+
relative_path(File.dirname(output_path || ''), source_map_file)
|
126
|
+
)
|
110
127
|
end
|
111
128
|
css += "\n/*# sourceMappingURL=#{url} */"
|
112
129
|
end
|
@@ -114,7 +131,7 @@ module SassC
|
|
114
131
|
end
|
115
132
|
|
116
133
|
def relative_path(from, to)
|
117
|
-
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
|
118
135
|
end
|
119
136
|
end
|
120
137
|
|
@@ -383,10 +400,12 @@ module SassC
|
|
383
400
|
module Util
|
384
401
|
module_function
|
385
402
|
|
403
|
+
URI_PARSER = URI::Parser.new({ RESERVED: ';/?:@&=+$,' })
|
404
|
+
|
386
405
|
def file_url_to_path(url)
|
387
406
|
return if url.nil?
|
388
407
|
|
389
|
-
path =
|
408
|
+
path = URI_PARSER.unescape(URI.parse(url).path)
|
390
409
|
path = path[1..] if Gem.win_platform? && path[0].chr == '/' && path[1].chr =~ /[a-z]/i && path[2].chr == ':'
|
391
410
|
path
|
392
411
|
end
|
@@ -396,7 +415,7 @@ module SassC
|
|
396
415
|
|
397
416
|
path = File.absolute_path(path)
|
398
417
|
path = "/#{path}" unless path.start_with? '/'
|
399
|
-
URI::File.build([nil,
|
418
|
+
URI::File.build([nil, URI_PARSER.escape(path)]).to_s
|
400
419
|
end
|
401
420
|
end
|
402
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: 0.1
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- なつき
|
@@ -30,14 +30,14 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '1.
|
33
|
+
version: '1.2'
|
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.
|
40
|
+
version: '1.2'
|
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/0.1
|
142
|
-
source_code_uri: https://github.com/ntkme/sassc-embedded-polyfill-ruby/tree/
|
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: []
|