sass-embedded 0.7.28 → 0.9.0
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/Makefile +1 -1
- data/ext/sass/extconf.rb +172 -150
- 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 +46 -0
- data/lib/sass/embedded/platform.rb +55 -0
- data/lib/sass/embedded/result.rb +34 -0
- data/lib/sass/embedded/struct.rb +22 -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-embedded.rb +4 -0
- data/lib/sass.rb +8 -22
- metadata +33 -15
- data/ext/sass/dependencies.rb +0 -11
- data/lib/sass/compile.rb +0 -249
- 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 -133
- 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: c5bcaee2299b4f0b9d4d1d23b25773fdad87d1a294a4a34eeec0028d1f89a25c
|
4
|
+
data.tar.gz: 75ce2615300b0d59e73f715ae43007baf09a9818ea56d80b8be4d54b1f561c69
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 93cf20b2df8d4c363797df90e459f52c6dedf5e540cb5b6eb1cd110dded76477adf82f6c0bc0652f1b5201f535265053f7838654952a4bcc7f338bcc69c9464a
|
7
|
+
data.tar.gz: c4190c8fc8e60a37fa834dfdac6fe1842e66d39ac8d0ad9bc1c15ea5c18c16766f19e194be746fc963a5604c740f438c6371aa59c10dd59d452a526fea6cbf0d
|
data/ext/sass/Makefile
CHANGED
data/ext/sass/extconf.rb
CHANGED
@@ -1,202 +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 '
|
9
|
-
require_relative '../../lib/sass/platform'
|
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)
|
79
|
+
|
80
|
+
satisfied = lambda { |version|
|
81
|
+
Gem::Version.correct?(version) && requirements.satisfied_by?(Gem::Version.new(version))
|
82
|
+
}
|
83
|
+
|
84
|
+
headers = {}
|
85
|
+
headers['Authorization'] = "token #{ENV['GITHUB_TOKEN']}" if ENV['GITHUB_TOKEN']
|
77
86
|
|
78
|
-
if requirements == Gem::Requirement.default && gh_release
|
79
|
-
URI.parse("https://github.com/#{repo}/releases/latest").open do |file|
|
80
|
-
File.basename file.base_uri.to_s
|
81
|
-
end
|
82
|
-
else
|
83
87
|
begin
|
84
|
-
headers = {}
|
85
|
-
headers['Authorization'] = "token #{ENV['GITHUB_TOKEN']}" if ENV['GITHUB_TOKEN']
|
86
88
|
if gh_release
|
87
|
-
|
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
|
93
|
+
|
94
|
+
latest = File.basename file.base_uri.to_s
|
95
|
+
latest if satisfied.call latest
|
96
|
+
end
|
97
|
+
|
98
|
+
return tag_name unless tag_name.nil?
|
99
|
+
|
100
|
+
uri = "https://api.github.com/repos/#{repo}/releases?per_page=100"
|
101
|
+
tag_name = URI.parse(uri).open(headers) do |file|
|
88
102
|
JSON.parse(file.read).map { |release| release['tag_name'] }
|
89
103
|
end
|
104
|
+
.find(satisfied)&.peek
|
90
105
|
else
|
91
|
-
|
106
|
+
uri = "https://api.github.com/repos/#{repo}/tags?per_page=100"
|
107
|
+
tag_name = URI.parse(uri).open(headers) do |file|
|
92
108
|
JSON.parse(file.read).map { |tag| tag['name'] }
|
93
109
|
end
|
110
|
+
.find(satisfied)&.peek
|
94
111
|
end
|
95
|
-
|
96
|
-
|
97
|
-
|
112
|
+
|
113
|
+
return tag_name unless tag_name.nil?
|
114
|
+
rescue OpenURI::HTTPError => e
|
115
|
+
warn "WARNING: Error fetching #{uri}: #{e}"
|
98
116
|
end
|
99
|
-
|
100
|
-
|
117
|
+
|
118
|
+
requirements.requirements
|
119
|
+
.map { |requirement| requirement.last.to_s.gsub('.pre.', '-') }
|
120
|
+
.find(satisfied)&.peek
|
101
121
|
end
|
102
|
-
end
|
103
122
|
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
else
|
117
|
-
raise "Unsupported OS: #{Platform::OS}"
|
118
|
-
end
|
119
|
-
|
120
|
-
arch = case Platform::ARCH
|
121
|
-
when 'x86_64'
|
122
|
-
'x64'
|
123
|
-
when 'i386'
|
124
|
-
'ia32'
|
125
|
-
when 'aarch64'
|
126
|
-
raise "Unsupported Arch: #{Platform::ARCH}" unless Platform::OS == 'darwin'
|
127
|
-
|
128
|
-
'x64'
|
123
|
+
def default_sass_embedded
|
124
|
+
repo = 'sass/dart-sass-embedded'
|
125
|
+
|
126
|
+
tag_name = resolve_tag_name(repo, Compiler::REQUIREMENTS)
|
127
|
+
|
128
|
+
os = case Platform::OS
|
129
|
+
when 'darwin'
|
130
|
+
'macos'
|
131
|
+
when 'linux'
|
132
|
+
'linux'
|
133
|
+
when 'windows'
|
134
|
+
'windows'
|
129
135
|
else
|
130
|
-
raise "Unsupported
|
136
|
+
raise "Unsupported OS: #{Platform::OS}"
|
131
137
|
end
|
132
138
|
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
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'
|
139
146
|
|
140
|
-
|
141
|
-
|
147
|
+
'x64'
|
148
|
+
else
|
149
|
+
raise "Unsupported Arch: #{Platform::ARCH}"
|
150
|
+
end
|
142
151
|
|
143
|
-
|
144
|
-
|
152
|
+
ext = case os
|
153
|
+
when 'windows'
|
154
|
+
'zip'
|
155
|
+
else
|
156
|
+
'tar.gz'
|
157
|
+
end
|
158
|
+
|
159
|
+
"https://github.com/#{repo}/releases/download/#{tag_name}/sass_embedded-#{tag_name}-#{os}-#{arch}.#{ext}"
|
160
|
+
end
|
145
161
|
|
146
|
-
|
162
|
+
def default_protoc
|
163
|
+
repo = 'protocolbuffers/protobuf'
|
147
164
|
|
148
|
-
|
165
|
+
spec = Gem::Dependency.new('google-protobuf').to_spec
|
149
166
|
|
150
|
-
|
151
|
-
when 'darwin'
|
152
|
-
'osx'
|
153
|
-
when 'linux'
|
154
|
-
'linux'
|
155
|
-
when 'windows'
|
156
|
-
'win'
|
157
|
-
else
|
158
|
-
raise "Unsupported OS: #{Platform::OS}"
|
159
|
-
end
|
167
|
+
tag_name = "v#{spec.version}"
|
160
168
|
|
161
|
-
|
162
|
-
when '
|
163
|
-
|
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'
|
164
192
|
'x86_64'
|
193
|
+
when 'powerpc64'
|
194
|
+
'ppcle_64'
|
165
195
|
else
|
166
|
-
|
196
|
+
raise "Unsupported Arch: #{Platform::ARCH}"
|
167
197
|
end
|
168
|
-
when 'sparcv9'
|
169
|
-
's390'
|
170
|
-
when 'i386'
|
171
|
-
'x86_32'
|
172
|
-
when 'x86_64'
|
173
|
-
'x86_64'
|
174
|
-
when 'powerpc64'
|
175
|
-
'ppcle_64'
|
176
|
-
else
|
177
|
-
raise "Unsupported Arch: #{Platform::ARCH}"
|
178
|
-
end
|
179
198
|
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
199
|
+
os_arch = case os
|
200
|
+
when 'win'
|
201
|
+
os + arch.split('_').last
|
202
|
+
else
|
203
|
+
"#{os}-#{arch}"
|
204
|
+
end
|
186
205
|
|
187
|
-
|
206
|
+
ext = 'zip'
|
188
207
|
|
189
|
-
|
190
|
-
|
208
|
+
"https://github.com/#{repo}/releases/download/#{tag_name}/protoc-#{tag_name[1..]}-#{os_arch}.#{ext}"
|
209
|
+
end
|
191
210
|
|
192
|
-
|
193
|
-
|
211
|
+
def default_sass_embedded_protocol
|
212
|
+
repo = 'sass/embedded-protocol'
|
194
213
|
|
195
|
-
|
214
|
+
tag_name = IO.popen([Compiler::PATH, '--version']) do |file|
|
215
|
+
JSON.parse(file.read)['protocolVersion']
|
216
|
+
end
|
196
217
|
|
197
|
-
|
218
|
+
"https://raw.githubusercontent.com/#{repo}/#{tag_name}/embedded_sass.proto"
|
219
|
+
end
|
198
220
|
end
|
199
221
|
end
|
200
222
|
end
|
201
223
|
|
202
|
-
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 IOError
|
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
|