sass-embedded 1.0.5 → 1.0.8
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 +4 -4
- data/ext/sass/Rakefile +245 -0
- data/ext/sass/mkrf_conf.rb +2 -0
- data/ext/sass/unzip.ps1 +13 -0
- data/lib/sass/embedded/version.rb +1 -1
- metadata +24 -9
- data/ext/sass/Makefile +0 -51
- data/ext/sass/extconf.rb +0 -244
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 79aa99df78a2f126a39e870eff649dcad3dc0aa65eab3c1ad3c23f6f0075d4fc
|
4
|
+
data.tar.gz: aaa926824f1b40a5d0471b06d20617ee86e78d28896918dce5ee871b8702a925
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3ace91c8fb581c92ad264f9b9bd5ea0fe9dfa99dfbac3d773a6374cb2e9c1cf07e919a2d15cf75621eaa1cd3475b10b284737f14e803778f285a20447b37c070
|
7
|
+
data.tar.gz: 74f456b0b6a50886e508b2dda49a5e91d714d170f3a221b3e174c6ce186fed9fd382ce271edb55a85e02d223413a78bca3a324fa9f974b9781bcb9bb3750a9a3
|
data/ext/sass/Rakefile
ADDED
@@ -0,0 +1,245 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'json'
|
4
|
+
require 'open-uri'
|
5
|
+
require 'open3'
|
6
|
+
require 'rake/clean'
|
7
|
+
|
8
|
+
task default: %i[install clean]
|
9
|
+
|
10
|
+
task install: %w[sass_embedded embedded_sass_pb.rb]
|
11
|
+
|
12
|
+
CLEAN.include %w[protoc *.proto *.tar.gz *.zip]
|
13
|
+
|
14
|
+
CLOBBER.include %w[sass_embedded embedded_sass_pb.rb]
|
15
|
+
|
16
|
+
file 'protoc' do |t|
|
17
|
+
archive = fetch(ENV.fetch(t.name.upcase) { Configuration.default_protoc })
|
18
|
+
unzip archive, t.name
|
19
|
+
rm archive
|
20
|
+
end
|
21
|
+
|
22
|
+
file 'sass_embedded' do |t|
|
23
|
+
archive = fetch(ENV.fetch(t.name.upcase) { Configuration.default_sass_embedded })
|
24
|
+
if Gem.win_platform?
|
25
|
+
unzip archive
|
26
|
+
else
|
27
|
+
sh 'tar', '-vxzf', archive
|
28
|
+
end
|
29
|
+
rm archive
|
30
|
+
end
|
31
|
+
|
32
|
+
file 'embedded_sass.proto' => %w[sass_embedded] do |t|
|
33
|
+
fetch(ENV.fetch('sass_embedded_protocol'.upcase) { Configuration.default_sass_embedded_protocol }, t.name)
|
34
|
+
end
|
35
|
+
|
36
|
+
rule '_pb.rb' => %w[.proto protoc] do |t|
|
37
|
+
sh './protoc/bin/protoc', '--ruby_out=.', t.source
|
38
|
+
end
|
39
|
+
|
40
|
+
# This is a FileUtils extension that defines several additional commands to be
|
41
|
+
# added to the FileUtils utility functions.
|
42
|
+
module FileUtils
|
43
|
+
def unzip(archive, dest = '.')
|
44
|
+
if Gem.win_platform?
|
45
|
+
sh 'powershell', '-File', 'unzip.ps1', '-Archive', archive, '-DestinationPath', dest
|
46
|
+
else
|
47
|
+
sh 'unzip', '-od', dest, archive
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
def fetch(uri_or_path, dest = nil)
|
52
|
+
begin
|
53
|
+
uri = URI.parse(uri_or_path)
|
54
|
+
path = URI::DEFAULT_PARSER.unescape(uri.path)
|
55
|
+
if uri.instance_of?(URI::File) || uri.instance_of?(URI::Generic)
|
56
|
+
path = path.delete_prefix('/') if Gem.win_platform? && !File.file?(path)
|
57
|
+
raise unless File.file?(path)
|
58
|
+
end
|
59
|
+
rescue StandardError
|
60
|
+
raise unless File.file?(uri_or_path)
|
61
|
+
|
62
|
+
uri = nil
|
63
|
+
path = uri_or_path
|
64
|
+
end
|
65
|
+
|
66
|
+
dest = File.basename(path) if dest.nil?
|
67
|
+
|
68
|
+
if uri.nil? || uri.instance_of?(URI::File) || uri.instance_of?(URI::Generic)
|
69
|
+
cp path, dest
|
70
|
+
elsif uri.respond_to?(:open)
|
71
|
+
Rake.rake_output_message "curl -fsSLo #{dest} -- #{uri}" if Rake::FileUtilsExt.verbose_flag
|
72
|
+
unless Rake::FileUtilsExt.nowrite_flag
|
73
|
+
uri.open do |stream|
|
74
|
+
File.binwrite(dest, stream.read)
|
75
|
+
end
|
76
|
+
end
|
77
|
+
else
|
78
|
+
raise
|
79
|
+
end
|
80
|
+
|
81
|
+
dest
|
82
|
+
rescue StandardError
|
83
|
+
raise "Failed to fetch #{uri_or_path}"
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
# The {Configuration} module.
|
88
|
+
module Configuration
|
89
|
+
module Platform
|
90
|
+
OS = case RbConfig::CONFIG['host_os'].downcase
|
91
|
+
when /linux/
|
92
|
+
'linux'
|
93
|
+
when /darwin/
|
94
|
+
'darwin'
|
95
|
+
when /freebsd/
|
96
|
+
'freebsd'
|
97
|
+
when /netbsd/
|
98
|
+
'netbsd'
|
99
|
+
when /openbsd/
|
100
|
+
'openbsd'
|
101
|
+
when /dragonfly/
|
102
|
+
'dragonflybsd'
|
103
|
+
when /sunos|solaris/
|
104
|
+
'solaris'
|
105
|
+
when *Gem::WIN_PATTERNS
|
106
|
+
'windows'
|
107
|
+
else
|
108
|
+
RbConfig::CONFIG['host_os'].downcase
|
109
|
+
end
|
110
|
+
|
111
|
+
OSVERSION = RbConfig::CONFIG['host_os'].gsub(/[^\d]/, '').to_i
|
112
|
+
|
113
|
+
CPU = RbConfig::CONFIG['host_cpu']
|
114
|
+
|
115
|
+
ARCH = case CPU.downcase
|
116
|
+
when /amd64|x86_64|x64/
|
117
|
+
'x86_64'
|
118
|
+
when /i\d86|x86|i86pc/
|
119
|
+
'i386'
|
120
|
+
when /ppc64|powerpc64/
|
121
|
+
'powerpc64'
|
122
|
+
when /ppc|powerpc/
|
123
|
+
'powerpc'
|
124
|
+
when /sparcv9|sparc64/
|
125
|
+
'sparcv9'
|
126
|
+
when /arm64|aarch64/ # MacOS calls it "arm64", other operating systems "aarch64"
|
127
|
+
'aarch64'
|
128
|
+
when /^arm/
|
129
|
+
if OS == 'darwin' # Ruby before 3.0 reports "arm" instead of "arm64" as host_cpu on darwin
|
130
|
+
'aarch64'
|
131
|
+
else
|
132
|
+
'arm'
|
133
|
+
end
|
134
|
+
else
|
135
|
+
RbConfig::CONFIG['host_cpu']
|
136
|
+
end
|
137
|
+
end
|
138
|
+
|
139
|
+
private_constant :Platform
|
140
|
+
|
141
|
+
class << self
|
142
|
+
def default_sass_embedded
|
143
|
+
repo = 'sass/dart-sass-embedded'
|
144
|
+
|
145
|
+
spec = JSON.parse(File.read(File.absolute_path('package.json', __dir__)))
|
146
|
+
|
147
|
+
tag_name = spec['dependencies']['sass-embedded']
|
148
|
+
|
149
|
+
os = case Platform::OS
|
150
|
+
when 'darwin'
|
151
|
+
'macos'
|
152
|
+
when 'linux'
|
153
|
+
'linux'
|
154
|
+
when 'windows'
|
155
|
+
'windows'
|
156
|
+
else
|
157
|
+
raise release_asset_not_available_error(repo, tag_name)
|
158
|
+
end
|
159
|
+
|
160
|
+
arch = case Platform::ARCH
|
161
|
+
when 'x86_64'
|
162
|
+
'x64'
|
163
|
+
when 'i386'
|
164
|
+
'ia32'
|
165
|
+
when 'aarch64'
|
166
|
+
Platform::OS == 'darwin' ? 'x64' : 'arm64'
|
167
|
+
else
|
168
|
+
raise release_asset_not_available_error(repo, tag_name)
|
169
|
+
end
|
170
|
+
|
171
|
+
ext = case os
|
172
|
+
when 'windows'
|
173
|
+
'zip'
|
174
|
+
else
|
175
|
+
'tar.gz'
|
176
|
+
end
|
177
|
+
|
178
|
+
"https://github.com/#{repo}/releases/download/#{tag_name}/sass_embedded-#{tag_name}-#{os}-#{arch}.#{ext}"
|
179
|
+
end
|
180
|
+
|
181
|
+
def default_protoc
|
182
|
+
repo = 'protocolbuffers/protobuf'
|
183
|
+
|
184
|
+
version = Gem::Dependency.new('google-protobuf').to_spec.version
|
185
|
+
|
186
|
+
tag_name = "v#{version}"
|
187
|
+
|
188
|
+
os = case Platform::OS
|
189
|
+
when 'darwin'
|
190
|
+
'osx'
|
191
|
+
when 'linux'
|
192
|
+
'linux'
|
193
|
+
when 'windows'
|
194
|
+
'win'
|
195
|
+
else
|
196
|
+
raise release_asset_not_available_error(repo, tag_name)
|
197
|
+
end
|
198
|
+
|
199
|
+
arch = case Platform::ARCH
|
200
|
+
when 'aarch64'
|
201
|
+
Platform::OS == 'darwin' ? 'x86_64' : 'aarch_64'
|
202
|
+
when 'sparcv9'
|
203
|
+
's390'
|
204
|
+
when 'i386'
|
205
|
+
'x86_32'
|
206
|
+
when 'x86_64'
|
207
|
+
'x86_64'
|
208
|
+
when 'powerpc64'
|
209
|
+
'ppcle_64'
|
210
|
+
else
|
211
|
+
raise release_asset_not_available_error(repo, tag_name)
|
212
|
+
end
|
213
|
+
|
214
|
+
os_arch = case os
|
215
|
+
when 'win'
|
216
|
+
os + arch.split('_').last
|
217
|
+
else
|
218
|
+
"#{os}-#{arch}"
|
219
|
+
end
|
220
|
+
|
221
|
+
ext = 'zip'
|
222
|
+
|
223
|
+
"https://github.com/#{repo}/releases/download/#{tag_name}/protoc-#{version}-#{os_arch}.#{ext}"
|
224
|
+
end
|
225
|
+
|
226
|
+
def default_sass_embedded_protocol
|
227
|
+
stdout, stderr, status = Open3.capture3(
|
228
|
+
File.absolute_path("sass_embedded/dart-sass-embedded#{Gem.win_platform? ? '.bat' : ''}", __dir__), '--version'
|
229
|
+
)
|
230
|
+
raise stderr unless status.success?
|
231
|
+
|
232
|
+
tag_name = JSON.parse(stdout)['protocolVersion']
|
233
|
+
"https://github.com/sass/embedded-protocol/raw/#{tag_name}/embedded_sass.proto"
|
234
|
+
end
|
235
|
+
|
236
|
+
private
|
237
|
+
|
238
|
+
def release_asset_not_available_error(repo, tag_name)
|
239
|
+
NotImplementedError.new(
|
240
|
+
"Release asset for #{Platform::OS} #{Platform::ARCH} "\
|
241
|
+
"not available at https://github.com/#{repo}/releases/tag/#{tag_name}"
|
242
|
+
)
|
243
|
+
end
|
244
|
+
end
|
245
|
+
end
|
data/ext/sass/unzip.ps1
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
Param(
|
2
|
+
[Parameter(Mandatory)]
|
3
|
+
[ValidateNotNullOrEmpty()]
|
4
|
+
[string]$Archive,
|
5
|
+
[Parameter(Mandatory)]
|
6
|
+
[ValidateNotNullOrEmpty()]
|
7
|
+
[string]$DestinationPath
|
8
|
+
)
|
9
|
+
if (Get-Command Expand-Archive -ErrorAction SilentlyContinue) {
|
10
|
+
Get-Item $Archive | Expand-Archive -DestinationPath $DestinationPath -Force
|
11
|
+
} else {
|
12
|
+
cscript.exe unzip.vbs $Archive $DestinationPath
|
13
|
+
}
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sass-embedded
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- なつき
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-03-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: google-protobuf
|
@@ -24,6 +24,20 @@ dependencies:
|
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: 3.19.0
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
27
41
|
- !ruby/object:Gem::Dependency
|
28
42
|
name: rake
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -100,28 +114,29 @@ dependencies:
|
|
100
114
|
requirements:
|
101
115
|
- - "~>"
|
102
116
|
- !ruby/object:Gem::Version
|
103
|
-
version: 2.
|
117
|
+
version: 2.9.0
|
104
118
|
type: :development
|
105
119
|
prerelease: false
|
106
120
|
version_requirements: !ruby/object:Gem::Requirement
|
107
121
|
requirements:
|
108
122
|
- - "~>"
|
109
123
|
- !ruby/object:Gem::Version
|
110
|
-
version: 2.
|
124
|
+
version: 2.9.0
|
111
125
|
description: A Ruby library that will communicate with Embedded Dart Sass using the
|
112
126
|
Embedded Sass protocol.
|
113
127
|
email:
|
114
128
|
- i@ntk.me
|
115
129
|
executables: []
|
116
130
|
extensions:
|
117
|
-
- ext/sass/
|
131
|
+
- ext/sass/mkrf_conf.rb
|
118
132
|
extra_rdoc_files: []
|
119
133
|
files:
|
120
134
|
- LICENSE
|
121
135
|
- README.md
|
122
|
-
- ext/sass/
|
123
|
-
- ext/sass/
|
136
|
+
- ext/sass/Rakefile
|
137
|
+
- ext/sass/mkrf_conf.rb
|
124
138
|
- ext/sass/package.json
|
139
|
+
- ext/sass/unzip.ps1
|
125
140
|
- ext/sass/unzip.vbs
|
126
141
|
- lib/sass-embedded.rb
|
127
142
|
- lib/sass.rb
|
@@ -162,8 +177,8 @@ homepage: https://github.com/ntkme/sass-embedded-host-ruby
|
|
162
177
|
licenses:
|
163
178
|
- MIT
|
164
179
|
metadata:
|
165
|
-
documentation_uri: https://www.rubydoc.info/gems/sass-embedded/1.0.
|
166
|
-
source_code_uri: https://github.com/ntkme/sass-embedded-host-ruby/tree/v1.0.
|
180
|
+
documentation_uri: https://www.rubydoc.info/gems/sass-embedded/1.0.8
|
181
|
+
source_code_uri: https://github.com/ntkme/sass-embedded-host-ruby/tree/v1.0.8
|
167
182
|
funding_uri: https://github.com/sponsors/ntkme
|
168
183
|
post_install_message:
|
169
184
|
rdoc_options: []
|
data/ext/sass/Makefile
DELETED
@@ -1,51 +0,0 @@
|
|
1
|
-
ifeq ($(OS),Windows_NT)
|
2
|
-
RM = powershell -c "cmd.exe /c del /f /q /s"
|
3
|
-
else
|
4
|
-
RM = rm -fr
|
5
|
-
endif
|
6
|
-
EXTCONF = ruby -- extconf.rb
|
7
|
-
|
8
|
-
.PHONY: all
|
9
|
-
all: embedded_sass_pb.rb sass_embedded
|
10
|
-
|
11
|
-
.PHONY: install
|
12
|
-
install: distclean
|
13
|
-
|
14
|
-
.PHONY: clean
|
15
|
-
clean:
|
16
|
-
$(RM) embedded_sass_pb.rb sass_embedded
|
17
|
-
|
18
|
-
.PHONY: distclean
|
19
|
-
distclean:
|
20
|
-
$(RM) embedded_sass.proto protoc protoc-* sass_embedded-*
|
21
|
-
|
22
|
-
ifeq ($(OS),Windows_NT)
|
23
|
-
sass_embedded-*.zip:
|
24
|
-
else
|
25
|
-
sass_embedded-*.tar.gz:
|
26
|
-
endif
|
27
|
-
$(EXTCONF) --with-sass-embedded
|
28
|
-
|
29
|
-
ifeq ($(OS),Windows_NT)
|
30
|
-
sass_embedded: sass_embedded-*.zip
|
31
|
-
powershell -c "if (Get-Command Expand-Archive -ErrorAction SilentlyContinue) { Get-Item $< | Expand-Archive -DestinationPath . -Force } else { cscript.exe unzip.vbs $< . }"
|
32
|
-
else
|
33
|
-
sass_embedded: sass_embedded-*.tar.gz
|
34
|
-
tar -vxzf $<
|
35
|
-
endif
|
36
|
-
|
37
|
-
protoc-*.zip:
|
38
|
-
$(EXTCONF) --with-protoc
|
39
|
-
|
40
|
-
protoc: protoc-*.zip
|
41
|
-
ifeq ($(OS),Windows_NT)
|
42
|
-
powershell -c "if (Get-Command Expand-Archive -ErrorAction SilentlyContinue) { Get-Item $< | Expand-Archive -DestinationPath $@ -Force } else { cscript.exe unzip.vbs $< $@ }"
|
43
|
-
else
|
44
|
-
unzip -od $@ $<
|
45
|
-
endif
|
46
|
-
|
47
|
-
embedded_sass.proto: sass_embedded
|
48
|
-
$(EXTCONF) --with-sass-embedded-protocol
|
49
|
-
|
50
|
-
%_pb.rb: %.proto protoc
|
51
|
-
./protoc/bin/protoc --ruby_out=. $<
|
data/ext/sass/extconf.rb
DELETED
@@ -1,244 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
# frozen_string_literal: true
|
3
|
-
|
4
|
-
require 'fileutils'
|
5
|
-
require 'json'
|
6
|
-
require 'mkmf'
|
7
|
-
require 'open-uri'
|
8
|
-
require_relative '../../lib/sass/embedded/compiler'
|
9
|
-
|
10
|
-
module Sass
|
11
|
-
class Embedded
|
12
|
-
module Platform
|
13
|
-
OS = case RbConfig::CONFIG['host_os'].downcase
|
14
|
-
when /linux/
|
15
|
-
'linux'
|
16
|
-
when /darwin/
|
17
|
-
'darwin'
|
18
|
-
when /freebsd/
|
19
|
-
'freebsd'
|
20
|
-
when /netbsd/
|
21
|
-
'netbsd'
|
22
|
-
when /openbsd/
|
23
|
-
'openbsd'
|
24
|
-
when /dragonfly/
|
25
|
-
'dragonflybsd'
|
26
|
-
when /sunos|solaris/
|
27
|
-
'solaris'
|
28
|
-
when *Gem::WIN_PATTERNS
|
29
|
-
'windows'
|
30
|
-
else
|
31
|
-
RbConfig::CONFIG['host_os'].downcase
|
32
|
-
end
|
33
|
-
|
34
|
-
OSVERSION = RbConfig::CONFIG['host_os'].gsub(/[^\d]/, '').to_i
|
35
|
-
|
36
|
-
CPU = RbConfig::CONFIG['host_cpu']
|
37
|
-
|
38
|
-
ARCH = case CPU.downcase
|
39
|
-
when /amd64|x86_64|x64/
|
40
|
-
'x86_64'
|
41
|
-
when /i\d86|x86|i86pc/
|
42
|
-
'i386'
|
43
|
-
when /ppc64|powerpc64/
|
44
|
-
'powerpc64'
|
45
|
-
when /ppc|powerpc/
|
46
|
-
'powerpc'
|
47
|
-
when /sparcv9|sparc64/
|
48
|
-
'sparcv9'
|
49
|
-
when /arm64|aarch64/ # MacOS calls it "arm64", other operating systems "aarch64"
|
50
|
-
'aarch64'
|
51
|
-
when /^arm/
|
52
|
-
if OS == 'darwin' # Ruby before 3.0 reports "arm" instead of "arm64" as host_cpu on darwin
|
53
|
-
'aarch64'
|
54
|
-
else
|
55
|
-
'arm'
|
56
|
-
end
|
57
|
-
else
|
58
|
-
RbConfig::CONFIG['host_cpu']
|
59
|
-
end
|
60
|
-
end
|
61
|
-
|
62
|
-
private_constant :Platform
|
63
|
-
|
64
|
-
# The dependency downloader. This downloads all the dependencies during gem
|
65
|
-
# installation. The companion Makefile then unpacks all downloaded
|
66
|
-
# dependencies. By default it downloads the release of each dependency
|
67
|
-
# from GitHub releases.
|
68
|
-
#
|
69
|
-
# It is possible to specify an alternative source or version of each
|
70
|
-
# dependency. Local sources can be used for offline installation.
|
71
|
-
#
|
72
|
-
# @example
|
73
|
-
# gem install sass-embedded -- \
|
74
|
-
# --with-protoc=file:///path/to/protoc-*.zip \
|
75
|
-
# --with-sass-embedded=file:///path/to/sass_embedded-*.(tar.gz|zip) \
|
76
|
-
# --with-sass-embedded-protocol=file:///path/to/embedded_sass.proto
|
77
|
-
# @example
|
78
|
-
# bundle config build.sass-embedded \
|
79
|
-
# --with-protoc=file:///path/to/protoc-*.zip \
|
80
|
-
# --with-sass-embedded=file:///path/to/sass_embedded-*.(tar.gz|zip) \
|
81
|
-
# --with-sass-embedded-protocol=file:///path/to/embedded_sass.proto
|
82
|
-
class Extconf
|
83
|
-
def initialize
|
84
|
-
fetch_with_config('protoc', false) { default_protoc }
|
85
|
-
fetch_with_config('sass-embedded', false) { default_sass_embedded }
|
86
|
-
fetch_with_config('sass-embedded-protocol', false) { default_sass_embedded_protocol }
|
87
|
-
end
|
88
|
-
|
89
|
-
private
|
90
|
-
|
91
|
-
def fetch_with_config(config, default)
|
92
|
-
val = with_config(config, default)
|
93
|
-
case val
|
94
|
-
when true
|
95
|
-
if block_given?
|
96
|
-
fetch yield
|
97
|
-
else
|
98
|
-
fetch default
|
99
|
-
end
|
100
|
-
when false
|
101
|
-
nil
|
102
|
-
else
|
103
|
-
fetch val
|
104
|
-
end
|
105
|
-
end
|
106
|
-
|
107
|
-
def fetch(uri_or_path)
|
108
|
-
begin
|
109
|
-
uri = URI.parse(uri_or_path)
|
110
|
-
path = URI::DEFAULT_PARSER.unescape(uri.path)
|
111
|
-
if uri.instance_of?(URI::File) || uri.instance_of?(URI::Generic)
|
112
|
-
path = path.delete_prefix('/') if Platform::OS == 'windows' && !File.file?(path)
|
113
|
-
raise unless File.file?(path)
|
114
|
-
end
|
115
|
-
rescue StandardError
|
116
|
-
raise unless File.file?(uri_or_path)
|
117
|
-
|
118
|
-
uri = nil
|
119
|
-
path = uri_or_path
|
120
|
-
end
|
121
|
-
|
122
|
-
dest = File.absolute_path(File.basename(path), __dir__)
|
123
|
-
|
124
|
-
if uri.nil? || uri.instance_of?(URI::File) || uri.instance_of?(URI::Generic)
|
125
|
-
puts "cp -- #{path} #{dest}"
|
126
|
-
FileUtils.copy_file(path, dest)
|
127
|
-
elsif uri.respond_to?(:open)
|
128
|
-
puts "curl -fsSLo #{dest} -- #{uri}"
|
129
|
-
uri.open do |stream|
|
130
|
-
File.binwrite(dest, stream.read)
|
131
|
-
end
|
132
|
-
else
|
133
|
-
raise
|
134
|
-
end
|
135
|
-
rescue StandardError
|
136
|
-
raise "Failed to fetch #{uri_or_path}"
|
137
|
-
end
|
138
|
-
|
139
|
-
def default_sass_embedded
|
140
|
-
repo = 'sass/dart-sass-embedded'
|
141
|
-
|
142
|
-
spec = JSON.parse(File.read(File.absolute_path('package.json', __dir__)))
|
143
|
-
|
144
|
-
tag_name = spec['dependencies']['sass-embedded']
|
145
|
-
|
146
|
-
os = case Platform::OS
|
147
|
-
when 'darwin'
|
148
|
-
'macos'
|
149
|
-
when 'linux'
|
150
|
-
'linux'
|
151
|
-
when 'windows'
|
152
|
-
'windows'
|
153
|
-
else
|
154
|
-
raise "Unsupported OS: #{Platform::OS}"
|
155
|
-
end
|
156
|
-
|
157
|
-
arch = case Platform::ARCH
|
158
|
-
when 'x86_64'
|
159
|
-
'x64'
|
160
|
-
when 'i386'
|
161
|
-
'ia32'
|
162
|
-
when 'aarch64'
|
163
|
-
raise "Unsupported Arch: #{Platform::ARCH}" unless Platform::OS == 'darwin'
|
164
|
-
|
165
|
-
'x64'
|
166
|
-
else
|
167
|
-
raise "Unsupported Arch: #{Platform::ARCH}"
|
168
|
-
end
|
169
|
-
|
170
|
-
ext = case os
|
171
|
-
when 'windows'
|
172
|
-
'zip'
|
173
|
-
else
|
174
|
-
'tar.gz'
|
175
|
-
end
|
176
|
-
|
177
|
-
"https://github.com/#{repo}/releases/download/#{tag_name}/sass_embedded-#{tag_name}-#{os}-#{arch}.#{ext}"
|
178
|
-
end
|
179
|
-
|
180
|
-
def default_protoc
|
181
|
-
repo = 'protocolbuffers/protobuf'
|
182
|
-
|
183
|
-
spec = Gem::Dependency.new('google-protobuf').to_spec
|
184
|
-
|
185
|
-
tag_name = "v#{spec.version}"
|
186
|
-
|
187
|
-
os = case Platform::OS
|
188
|
-
when 'darwin'
|
189
|
-
'osx'
|
190
|
-
when 'linux'
|
191
|
-
'linux'
|
192
|
-
when 'windows'
|
193
|
-
'win'
|
194
|
-
else
|
195
|
-
raise "Unsupported OS: #{Platform::OS}"
|
196
|
-
end
|
197
|
-
|
198
|
-
arch = case Platform::ARCH
|
199
|
-
when 'aarch64'
|
200
|
-
if Platform::OS == 'darwin'
|
201
|
-
'x86_64'
|
202
|
-
else
|
203
|
-
'aarch_64'
|
204
|
-
end
|
205
|
-
when 'sparcv9'
|
206
|
-
's390'
|
207
|
-
when 'i386'
|
208
|
-
'x86_32'
|
209
|
-
when 'x86_64'
|
210
|
-
'x86_64'
|
211
|
-
when 'powerpc64'
|
212
|
-
'ppcle_64'
|
213
|
-
else
|
214
|
-
raise "Unsupported Arch: #{Platform::ARCH}"
|
215
|
-
end
|
216
|
-
|
217
|
-
os_arch = case os
|
218
|
-
when 'win'
|
219
|
-
os + arch.split('_').last
|
220
|
-
else
|
221
|
-
"#{os}-#{arch}"
|
222
|
-
end
|
223
|
-
|
224
|
-
ext = 'zip'
|
225
|
-
|
226
|
-
"https://github.com/#{repo}/releases/download/#{tag_name}/protoc-#{tag_name.delete_prefix('v')}-#{os_arch}.#{ext}"
|
227
|
-
end
|
228
|
-
|
229
|
-
def default_sass_embedded_protocol
|
230
|
-
repo = 'sass/embedded-protocol'
|
231
|
-
|
232
|
-
stdout, stderr, status = Open3.capture3(Compiler::PATH, '--version')
|
233
|
-
|
234
|
-
raise stderr unless status.success?
|
235
|
-
|
236
|
-
tag_name = JSON.parse(stdout)['protocolVersion']
|
237
|
-
|
238
|
-
"https://raw.githubusercontent.com/#{repo}/#{tag_name}/embedded_sass.proto"
|
239
|
-
end
|
240
|
-
end
|
241
|
-
end
|
242
|
-
end
|
243
|
-
|
244
|
-
Sass::Embedded::Extconf.new
|