sass-embedded 1.0.4 → 1.0.7

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: 5c43ad7fb335b99c12bdc65c8a37af7a239a737f4c8655590ce35ea6be51ca3d
4
- data.tar.gz: cbc99b11c3330928a9582cb8befba681fd49db77868e0acdbadde4c7ba14a6ec
3
+ metadata.gz: 718b7021e9040b444532d9f407d51dd343589e923bd5aa2c600056b36dc87c73
4
+ data.tar.gz: 4708668171bfbce7dc2d2abae14fcb46bdb8ebe58c402d5dac796fbd74e3b463
5
5
  SHA512:
6
- metadata.gz: a77c23cd962c9936b9474f9ea0402095b2c65d0e4fca6bc848364d17211f37947e87ccfdf0db3dfff14477bcf6d3a2dadbf1dcc6ed127b6c1424e33b80cb3920
7
- data.tar.gz: 64bb51ebf0b1d6dadd39ceb73be714ed1090478dcafa43a34a465032a189a3ac6389aa035d3d0420cd9a243f2b2164d1e9e4b122d5e7f67c8bdd877b455aa1f1
6
+ metadata.gz: f234ef59479a2ab9c9f3bc4cc7eab30a38f66fd167cf3c1eaa18ab9ef47973b20d16fdbed6b88363b7ff59a7d6128912ca05f92aeeee7d4ebcb640bb522e6ae5
7
+ data.tar.gz: 40a42868098e31367adbae680344250632ffc00cf3d8878dd7d71e3060a16564e809c01d01fd80fa519dc3569ded826c4723ea7d829e9aca429a32746c7d1ac8
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
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
@@ -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
+ }
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Sass
4
4
  class Embedded
5
- VERSION = '1.0.4'
5
+ VERSION = '1.0.7'
6
6
  end
7
7
  end
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
4
+ version: 1.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - なつき
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-02-28 00:00:00.000000000 Z
11
+ date: 2022-03-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: google-protobuf
@@ -100,28 +100,29 @@ dependencies:
100
100
  requirements:
101
101
  - - "~>"
102
102
  - !ruby/object:Gem::Version
103
- version: 2.8.0
103
+ version: 2.9.0
104
104
  type: :development
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
108
  - - "~>"
109
109
  - !ruby/object:Gem::Version
110
- version: 2.8.0
110
+ version: 2.9.0
111
111
  description: A Ruby library that will communicate with Embedded Dart Sass using the
112
112
  Embedded Sass protocol.
113
113
  email:
114
114
  - i@ntk.me
115
115
  executables: []
116
116
  extensions:
117
- - ext/sass/extconf.rb
117
+ - ext/sass/mkrf_conf.rb
118
118
  extra_rdoc_files: []
119
119
  files:
120
120
  - LICENSE
121
121
  - README.md
122
- - ext/sass/Makefile
123
- - ext/sass/extconf.rb
122
+ - ext/sass/Rakefile
123
+ - ext/sass/mkrf_conf.rb
124
124
  - ext/sass/package.json
125
+ - ext/sass/unzip.ps1
125
126
  - ext/sass/unzip.vbs
126
127
  - lib/sass-embedded.rb
127
128
  - lib/sass.rb
@@ -162,8 +163,8 @@ homepage: https://github.com/ntkme/sass-embedded-host-ruby
162
163
  licenses:
163
164
  - MIT
164
165
  metadata:
165
- documentation_uri: https://www.rubydoc.info/gems/sass-embedded/1.0.4
166
- source_code_uri: https://github.com/ntkme/sass-embedded-host-ruby/tree/v1.0.4
166
+ documentation_uri: https://www.rubydoc.info/gems/sass-embedded/1.0.7
167
+ source_code_uri: https://github.com/ntkme/sass-embedded-host-ruby/tree/v1.0.7
167
168
  funding_uri: https://github.com/sponsors/ntkme
168
169
  post_install_message:
169
170
  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,241 +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
- raise if uri.instance_of?(URI::Generic) && !File.file?(path)
112
- rescue StandardError
113
- raise unless File.file?(uri_or_path)
114
-
115
- uri = nil
116
- path = uri_or_path
117
- end
118
-
119
- dest = File.absolute_path(File.basename(path), __dir__)
120
-
121
- if uri.nil? || uri.is_a?(URI::File) || uri.instance_of?(URI::Generic)
122
- puts "cp -- #{path} #{dest}"
123
- FileUtils.copy_file(path, dest)
124
- elsif uri.respond_to?(:open)
125
- puts "curl -fsSLo #{dest} -- #{uri}"
126
- uri.open do |stream|
127
- File.binwrite(dest, stream.read)
128
- end
129
- else
130
- raise
131
- end
132
- rescue StandardError
133
- raise "Failed to fetch #{uri_or_path}"
134
- end
135
-
136
- def default_sass_embedded
137
- repo = 'sass/dart-sass-embedded'
138
-
139
- spec = JSON.parse(File.read(File.absolute_path('package.json', __dir__)))
140
-
141
- tag_name = spec['dependencies']['sass-embedded']
142
-
143
- os = case Platform::OS
144
- when 'darwin'
145
- 'macos'
146
- when 'linux'
147
- 'linux'
148
- when 'windows'
149
- 'windows'
150
- else
151
- raise "Unsupported OS: #{Platform::OS}"
152
- end
153
-
154
- arch = case Platform::ARCH
155
- when 'x86_64'
156
- 'x64'
157
- when 'i386'
158
- 'ia32'
159
- when 'aarch64'
160
- raise "Unsupported Arch: #{Platform::ARCH}" unless Platform::OS == 'darwin'
161
-
162
- 'x64'
163
- else
164
- raise "Unsupported Arch: #{Platform::ARCH}"
165
- end
166
-
167
- ext = case os
168
- when 'windows'
169
- 'zip'
170
- else
171
- 'tar.gz'
172
- end
173
-
174
- "https://github.com/#{repo}/releases/download/#{tag_name}/sass_embedded-#{tag_name}-#{os}-#{arch}.#{ext}"
175
- end
176
-
177
- def default_protoc
178
- repo = 'protocolbuffers/protobuf'
179
-
180
- spec = Gem::Dependency.new('google-protobuf').to_spec
181
-
182
- tag_name = "v#{spec.version}"
183
-
184
- os = case Platform::OS
185
- when 'darwin'
186
- 'osx'
187
- when 'linux'
188
- 'linux'
189
- when 'windows'
190
- 'win'
191
- else
192
- raise "Unsupported OS: #{Platform::OS}"
193
- end
194
-
195
- arch = case Platform::ARCH
196
- when 'aarch64'
197
- if Platform::OS == 'darwin'
198
- 'x86_64'
199
- else
200
- 'aarch_64'
201
- end
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 "Unsupported Arch: #{Platform::ARCH}"
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-#{tag_name.delete_prefix('v')}-#{os_arch}.#{ext}"
224
- end
225
-
226
- def default_sass_embedded_protocol
227
- repo = 'sass/embedded-protocol'
228
-
229
- stdout, stderr, status = Open3.capture3(Compiler::PATH, '--version')
230
-
231
- raise stderr unless status.success?
232
-
233
- tag_name = JSON.parse(stdout)['protocolVersion']
234
-
235
- "https://raw.githubusercontent.com/#{repo}/#{tag_name}/embedded_sass.proto"
236
- end
237
- end
238
- end
239
- end
240
-
241
- Sass::Embedded::Extconf.new