sass-embedded 0.8.1 → 0.9.2
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/extconf.rb +172 -169
- data/lib/sass/embedded/channel.rb +62 -0
- data/lib/sass/embedded/compile_context.rb +254 -0
- data/lib/sass/embedded/compiler/path.rb +13 -0
- data/lib/sass/embedded/compiler/requirements.rb +9 -0
- data/lib/sass/embedded/compiler.rb +156 -0
- data/lib/sass/embedded/error.rb +29 -0
- data/lib/sass/embedded/observer.rb +47 -0
- data/lib/sass/embedded/platform.rb +55 -0
- data/lib/sass/embedded/result.rb +28 -0
- data/lib/sass/embedded/util.rb +33 -0
- data/lib/sass/{version.rb → embedded/version.rb} +3 -1
- data/lib/sass/embedded/version_context.rb +36 -0
- data/lib/sass/embedded.rb +21 -16
- data/lib/sass/embedded_protocol.rb +9 -0
- data/lib/sass.rb +15 -24
- metadata +23 -21
- data/lib/sass/compile.rb +0 -249
- data/lib/sass/compiler.rb +0 -13
- data/lib/sass/error.rb +0 -27
- data/lib/sass/info.rb +0 -33
- data/lib/sass/observer.rb +0 -40
- data/lib/sass/platform.rb +0 -53
- data/lib/sass/result.rb +0 -30
- data/lib/sass/struct.rb +0 -20
- data/lib/sass/transport.rb +0 -127
- data/lib/sass/util.rb +0 -31
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4bb434b577a1d5faadc9e9d9edb6c8ecaa2ded93cb620cd36b219c5b4792236b
|
4
|
+
data.tar.gz: 48b8a5013737d1d4a3fd68155f919538acb3d0d7522d85172ca2476b0dfbfc2e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0baea25cfe10f0af7dd6c86415bd7a9c9332e32c238fd68877214cb14432d7868645d35315f28b410168380b8c3f7f35a05a747fb258c0ca781d34d28c3fa9b6
|
7
|
+
data.tar.gz: 5eb83255303cd791c51cf86ba1aa49e54d739ee19d045978f5dfd2c46f69d76c27c22f664d845784f226b1ec3a086bc8dc86a7a7c22a091af85df39f50f56147
|
data/ext/sass/extconf.rb
CHANGED
@@ -1,221 +1,224 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
# frozen_string_literal: true
|
3
3
|
|
4
|
-
require '
|
4
|
+
require 'fileutils'
|
5
5
|
require 'json'
|
6
|
+
require 'mkmf'
|
6
7
|
require 'open-uri'
|
7
|
-
|
8
|
-
require_relative '../../lib/sass/
|
9
|
-
require_relative '../../lib/sass/
|
8
|
+
require_relative '../../lib/sass/embedded/compiler/path'
|
9
|
+
require_relative '../../lib/sass/embedded/compiler/requirements'
|
10
|
+
require_relative '../../lib/sass/embedded/platform'
|
10
11
|
|
11
12
|
module Sass
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
13
|
+
class Embedded
|
14
|
+
# The dependency downloader. This downloads all the dependencies during gem
|
15
|
+
# installation. The companion Makefile then unpacks all downloaded
|
16
|
+
# dependencies. By default it downloads the release of each dependency
|
17
|
+
# from GitHub releases.
|
18
|
+
#
|
19
|
+
# It is possible to specify an alternative source or version of each
|
20
|
+
# dependency. Local sources can be used for offline installation.
|
21
|
+
#
|
22
|
+
# @example
|
23
|
+
# gem install sass-embedded -- \
|
24
|
+
# --with-protoc=file:///path/to/protoc-*.zip \
|
25
|
+
# --with-sass-embedded=file:///path/to/sass_embedded-*.(tar.gz|zip) \
|
26
|
+
# --with-sass-embedded-protocol=file:///path/to/embedded_sass.proto
|
27
|
+
# @example
|
28
|
+
# bundle config build.sass-embedded \
|
29
|
+
# --with-protoc=file:///path/to/protoc-*.zip \
|
30
|
+
# --with-sass-embedded=file:///path/to/sass_embedded-*.(tar.gz|zip) \
|
31
|
+
# --with-sass-embedded-protocol=file:///path/to/embedded_sass.proto
|
32
|
+
class Extconf
|
33
|
+
def initialize
|
34
|
+
fetch_with_config('protoc', false) { default_protoc }
|
35
|
+
fetch_with_config('sass-embedded', false) { default_sass_embedded }
|
36
|
+
fetch_with_config('sass-embedded-protocol', false) { default_sass_embedded_protocol }
|
37
|
+
end
|
36
38
|
|
37
|
-
|
39
|
+
private
|
38
40
|
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
41
|
+
def fetch_with_config(config, default)
|
42
|
+
val = with_config(config, default)
|
43
|
+
case val
|
44
|
+
when true
|
45
|
+
if block_given?
|
46
|
+
fetch yield
|
47
|
+
else
|
48
|
+
fetch default
|
49
|
+
end
|
50
|
+
when false
|
51
|
+
nil
|
45
52
|
else
|
46
|
-
fetch
|
53
|
+
fetch val
|
47
54
|
end
|
48
|
-
when false
|
49
|
-
nil
|
50
|
-
else
|
51
|
-
fetch val
|
52
55
|
end
|
53
|
-
end
|
54
56
|
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
57
|
+
def fetch(uri_s)
|
58
|
+
uri = URI.parse(uri_s)
|
59
|
+
path = File.absolute_path(File.basename(uri.path), __dir__)
|
60
|
+
if uri.is_a?(URI::File) || uri.instance_of?(URI::Generic)
|
61
|
+
FileUtils.copy_file uri.path, path
|
62
|
+
elsif uri.respond_to? :open
|
63
|
+
puts "curl -fsSLo #{path} -- #{uri}"
|
64
|
+
uri.open do |source|
|
65
|
+
File.open(path, 'wb') do |destination|
|
66
|
+
destination.write source.read
|
67
|
+
end
|
65
68
|
end
|
69
|
+
else
|
70
|
+
raise
|
66
71
|
end
|
67
|
-
|
72
|
+
rescue StandardError
|
73
|
+
warn "ERROR: Error fetching #{uri_s}:"
|
68
74
|
raise
|
69
75
|
end
|
70
|
-
rescue StandardError
|
71
|
-
warn "ERROR: Error fetching #{uri_s}:"
|
72
|
-
raise
|
73
|
-
end
|
74
76
|
|
75
|
-
|
76
|
-
|
77
|
+
def resolve_tag_name(repo, *requirements, gh_release: true)
|
78
|
+
requirements = Gem::Requirement.create(*requirements)
|
77
79
|
|
78
|
-
|
79
|
-
|
80
|
-
|
80
|
+
satisfied = lambda { |version|
|
81
|
+
Gem::Version.correct?(version) && requirements.satisfied_by?(Gem::Version.new(version))
|
82
|
+
}
|
81
83
|
|
82
|
-
|
83
|
-
|
84
|
+
headers = {}
|
85
|
+
headers['Authorization'] = "token #{ENV['GITHUB_TOKEN']}" if ENV['GITHUB_TOKEN']
|
84
86
|
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
87
|
+
begin
|
88
|
+
if gh_release
|
89
|
+
releases_uri = "https://github.com/#{repo}/releases"
|
90
|
+
uri = "#{releases_uri}/latest"
|
91
|
+
tag_name = URI.parse(uri).open do |file|
|
92
|
+
return nil if file.base_uri == releases_uri
|
91
93
|
|
92
|
-
|
93
|
-
|
94
|
-
|
94
|
+
latest = File.basename file.base_uri.to_s
|
95
|
+
latest if satisfied.call latest
|
96
|
+
end
|
95
97
|
|
96
|
-
|
98
|
+
return tag_name unless tag_name.nil?
|
97
99
|
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
100
|
+
uri = "https://api.github.com/repos/#{repo}/releases?per_page=100"
|
101
|
+
tag_name = URI.parse(uri).open(headers) do |file|
|
102
|
+
JSON.parse(file.read).map { |release| release['tag_name'] }
|
103
|
+
end
|
104
|
+
.find(satisfied)&.peek
|
105
|
+
else
|
106
|
+
uri = "https://api.github.com/repos/#{repo}/tags?per_page=100"
|
107
|
+
tag_name = URI.parse(uri).open(headers) do |file|
|
108
|
+
JSON.parse(file.read).map { |tag| tag['name'] }
|
109
|
+
end
|
110
|
+
.find(satisfied)&.peek
|
107
111
|
end
|
108
|
-
|
112
|
+
|
113
|
+
return tag_name unless tag_name.nil?
|
114
|
+
rescue OpenURI::HTTPError => e
|
115
|
+
warn "WARNING: Error fetching #{uri}: #{e}"
|
109
116
|
end
|
110
117
|
|
111
|
-
|
112
|
-
|
113
|
-
|
118
|
+
requirements.requirements
|
119
|
+
.map { |requirement| requirement.last.to_s.gsub('.pre.', '-') }
|
120
|
+
.find(satisfied)&.peek
|
114
121
|
end
|
115
122
|
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
123
|
+
def default_sass_embedded
|
124
|
+
repo = 'sass/dart-sass-embedded'
|
125
|
+
|
126
|
+
tag_name = resolve_tag_name(repo, Compiler::REQUIREMENTS)
|
120
127
|
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
'macos'
|
129
|
-
when 'linux'
|
130
|
-
'linux'
|
131
|
-
when 'windows'
|
132
|
-
'windows'
|
133
|
-
else
|
134
|
-
raise "Unsupported OS: #{Platform::OS}"
|
135
|
-
end
|
136
|
-
|
137
|
-
arch = case Platform::ARCH
|
138
|
-
when 'x86_64'
|
139
|
-
'x64'
|
140
|
-
when 'i386'
|
141
|
-
'ia32'
|
142
|
-
when 'aarch64'
|
143
|
-
raise "Unsupported Arch: #{Platform::ARCH}" unless Platform::OS == 'darwin'
|
144
|
-
|
145
|
-
'x64'
|
128
|
+
os = case Platform::OS
|
129
|
+
when 'darwin'
|
130
|
+
'macos'
|
131
|
+
when 'linux'
|
132
|
+
'linux'
|
133
|
+
when 'windows'
|
134
|
+
'windows'
|
146
135
|
else
|
147
|
-
raise "Unsupported
|
136
|
+
raise "Unsupported OS: #{Platform::OS}"
|
148
137
|
end
|
149
138
|
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
139
|
+
arch = case Platform::ARCH
|
140
|
+
when 'x86_64'
|
141
|
+
'x64'
|
142
|
+
when 'i386'
|
143
|
+
'ia32'
|
144
|
+
when 'aarch64'
|
145
|
+
raise "Unsupported Arch: #{Platform::ARCH}" unless Platform::OS == 'darwin'
|
156
146
|
|
157
|
-
|
158
|
-
|
147
|
+
'x64'
|
148
|
+
else
|
149
|
+
raise "Unsupported Arch: #{Platform::ARCH}"
|
150
|
+
end
|
159
151
|
|
160
|
-
|
161
|
-
|
152
|
+
ext = case os
|
153
|
+
when 'windows'
|
154
|
+
'zip'
|
155
|
+
else
|
156
|
+
'tar.gz'
|
157
|
+
end
|
162
158
|
|
163
|
-
|
159
|
+
"https://github.com/#{repo}/releases/download/#{tag_name}/sass_embedded-#{tag_name}-#{os}-#{arch}.#{ext}"
|
160
|
+
end
|
164
161
|
|
165
|
-
|
162
|
+
def default_protoc
|
163
|
+
repo = 'protocolbuffers/protobuf'
|
166
164
|
|
167
|
-
|
168
|
-
when 'darwin'
|
169
|
-
'osx'
|
170
|
-
when 'linux'
|
171
|
-
'linux'
|
172
|
-
when 'windows'
|
173
|
-
'win'
|
174
|
-
else
|
175
|
-
raise "Unsupported OS: #{Platform::OS}"
|
176
|
-
end
|
165
|
+
spec = Gem::Dependency.new('google-protobuf').to_spec
|
177
166
|
|
178
|
-
|
179
|
-
|
180
|
-
|
167
|
+
tag_name = "v#{spec.version}"
|
168
|
+
|
169
|
+
os = case Platform::OS
|
170
|
+
when 'darwin'
|
171
|
+
'osx'
|
172
|
+
when 'linux'
|
173
|
+
'linux'
|
174
|
+
when 'windows'
|
175
|
+
'win'
|
176
|
+
else
|
177
|
+
raise "Unsupported OS: #{Platform::OS}"
|
178
|
+
end
|
179
|
+
|
180
|
+
arch = case Platform::ARCH
|
181
|
+
when 'aarch64'
|
182
|
+
if Platform::OS == 'darwin'
|
183
|
+
'x86_64'
|
184
|
+
else
|
185
|
+
'aarch_64'
|
186
|
+
end
|
187
|
+
when 'sparcv9'
|
188
|
+
's390'
|
189
|
+
when 'i386'
|
190
|
+
'x86_32'
|
191
|
+
when 'x86_64'
|
181
192
|
'x86_64'
|
193
|
+
when 'powerpc64'
|
194
|
+
'ppcle_64'
|
182
195
|
else
|
183
|
-
|
196
|
+
raise "Unsupported Arch: #{Platform::ARCH}"
|
184
197
|
end
|
185
|
-
when 'sparcv9'
|
186
|
-
's390'
|
187
|
-
when 'i386'
|
188
|
-
'x86_32'
|
189
|
-
when 'x86_64'
|
190
|
-
'x86_64'
|
191
|
-
when 'powerpc64'
|
192
|
-
'ppcle_64'
|
193
|
-
else
|
194
|
-
raise "Unsupported Arch: #{Platform::ARCH}"
|
195
|
-
end
|
196
198
|
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
199
|
+
os_arch = case os
|
200
|
+
when 'win'
|
201
|
+
os + arch.split('_').last
|
202
|
+
else
|
203
|
+
"#{os}-#{arch}"
|
204
|
+
end
|
203
205
|
|
204
|
-
|
206
|
+
ext = 'zip'
|
205
207
|
|
206
|
-
|
207
|
-
|
208
|
+
"https://github.com/#{repo}/releases/download/#{tag_name}/protoc-#{tag_name[1..]}-#{os_arch}.#{ext}"
|
209
|
+
end
|
208
210
|
|
209
|
-
|
210
|
-
|
211
|
+
def default_sass_embedded_protocol
|
212
|
+
repo = 'sass/embedded-protocol'
|
211
213
|
|
212
|
-
|
213
|
-
|
214
|
-
|
214
|
+
tag_name = IO.popen([Compiler::PATH, '--version']) do |file|
|
215
|
+
JSON.parse(file.read)['protocolVersion']
|
216
|
+
end
|
215
217
|
|
216
|
-
|
218
|
+
"https://raw.githubusercontent.com/#{repo}/#{tag_name}/embedded_sass.proto"
|
219
|
+
end
|
217
220
|
end
|
218
221
|
end
|
219
222
|
end
|
220
223
|
|
221
|
-
Sass::Extconf.new
|
224
|
+
Sass::Embedded::Extconf.new
|
@@ -0,0 +1,62 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'compiler'
|
4
|
+
|
5
|
+
module Sass
|
6
|
+
class Embedded
|
7
|
+
# The {Channel} for {Compiler} calls. Each instance creates its own
|
8
|
+
# {Compiler}. A new {Compiler} is automatically created when the existing
|
9
|
+
# {Compiler} runs out of unique request id.
|
10
|
+
class Channel
|
11
|
+
def initialize
|
12
|
+
@mutex = Mutex.new
|
13
|
+
@compiler = Compiler.new
|
14
|
+
end
|
15
|
+
|
16
|
+
def close
|
17
|
+
@mutex.synchronize do
|
18
|
+
@compiler.close
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def closed?
|
23
|
+
@mutex.synchronize do
|
24
|
+
@compiler.closed?
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def subscribe(observer)
|
29
|
+
@mutex.synchronize do
|
30
|
+
begin
|
31
|
+
id = @compiler.add_observer(observer)
|
32
|
+
rescue ProtocolError
|
33
|
+
@compiler = Compiler.new
|
34
|
+
id = @compiler.add_observer(observer)
|
35
|
+
end
|
36
|
+
Subscription.new @compiler, observer, id
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
# The {Subscription} between {Compiler} and {Observer}.
|
41
|
+
class Subscription
|
42
|
+
attr_reader :id
|
43
|
+
|
44
|
+
def initialize(compiler, observer, id)
|
45
|
+
@compiler = compiler
|
46
|
+
@observer = observer
|
47
|
+
@id = id
|
48
|
+
end
|
49
|
+
|
50
|
+
def unsubscribe
|
51
|
+
@compiler.delete_observer(@observer)
|
52
|
+
end
|
53
|
+
|
54
|
+
def send_message(*args)
|
55
|
+
@compiler.send_message(*args)
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
private_constant :Subscription
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|