sass-embedded 0.2.1 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -0
- data/ext/sass_embedded/extconf.rb +115 -103
- data/lib/sass.rb +1 -1
- data/lib/sass/embedded.rb +1 -0
- data/lib/sass/transport.rb +20 -19
- data/lib/sass/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6c14e0ab686080f404d76337be0b59768bb600c48850f817c168cf53929239d9
|
4
|
+
data.tar.gz: e707aa4c0e910e71d0a316e4d3f1609b4c3cc49e49107c42af31d1ba3f9d3b62
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c549da93d4a68fb330b1019c462c593d18630c028a7a3add53b13dc72f18918d0f7e815c5abc0612584e749a87752c0c56c71c43fbb477829d8063cdfbb16fa3
|
7
|
+
data.tar.gz: 0c0af0ff5e8d40ac6f4305eb04b268aaccb154526071ab5799f4dfdb148ef7cba1c39ff45c9eb5b274d7a9d5a6170fefaf60be86fdf8ce127d1167799e85da47
|
data/README.md
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
# Embedded Sass Host for Ruby
|
2
2
|
|
3
|
+
[![build](https://github.com/ntkme/embedded-host-ruby/actions/workflows/build.yml/badge.svg)](https://github.com/ntkme/embedded-host-ruby/actions/workflows/build.yml)
|
4
|
+
|
3
5
|
This is a Ruby library that implements the host side of the [Embedded Sass protocol](https://github.com/sass/sass-embedded-protocol).
|
4
6
|
|
5
7
|
It exposes a Ruby API for Sass that's backed by a native [Dart Sass](https://sass-lang.com/dart-sass) executable.
|
@@ -6,119 +6,131 @@ require 'json'
|
|
6
6
|
require 'open-uri'
|
7
7
|
require_relative '../../lib/sass/platform'
|
8
8
|
|
9
|
-
|
10
|
-
|
11
|
-
headers['Authorization'] = "token #{ENV['GITHUB_TOKEN']}" if ENV['GITHUB_TOKEN']
|
12
|
-
URI.parse(url).open(headers) do |file|
|
13
|
-
JSON.parse file.read
|
14
|
-
end
|
15
|
-
end
|
9
|
+
module Sass
|
10
|
+
class Extconf
|
16
11
|
|
17
|
-
def
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
rescue StandardError
|
24
|
-
raise "Failed to download: #{url}"
|
25
|
-
end
|
12
|
+
def initialize
|
13
|
+
system('make', '-C', __dir__, 'distclean')
|
14
|
+
download_sass_embedded
|
15
|
+
download_protoc
|
16
|
+
download_embedded_sass_proto
|
17
|
+
system('make', '-C', __dir__, 'install')
|
26
18
|
|
27
|
-
|
28
|
-
repo = 'sass/dart-sass-embedded'
|
29
|
-
|
30
|
-
release = api("https://api.github.com/repos/#{repo}/releases")[0]['tag_name']
|
31
|
-
|
32
|
-
os = case Sass::Platform::OS
|
33
|
-
when 'darwin'
|
34
|
-
'macos'
|
35
|
-
when 'linux'
|
36
|
-
'linux'
|
37
|
-
when 'windows'
|
38
|
-
'windows'
|
39
|
-
else
|
40
|
-
raise "Unsupported OS: #{Sass::Platform::OS}"
|
41
|
-
end
|
42
|
-
|
43
|
-
arch = case Sass::Platform::ARCH
|
44
|
-
when 'x86_64'
|
45
|
-
'x64'
|
46
|
-
when 'i386'
|
47
|
-
'ia32'
|
48
|
-
else
|
49
|
-
raise "Unsupported Arch: #{Sass::Platform::ARCH}"
|
50
|
-
end
|
51
|
-
|
52
|
-
ext = case os
|
53
|
-
when 'windows'
|
54
|
-
'zip'
|
55
|
-
else
|
56
|
-
'tar.gz'
|
57
|
-
end
|
19
|
+
File.open(File.absolute_path("sass_embedded.#{RbConfig::CONFIG['DLEXT']}", __dir__), 'w') {}
|
58
20
|
|
59
|
-
|
60
|
-
|
61
|
-
end
|
21
|
+
$makefile_created = true
|
22
|
+
end
|
62
23
|
|
63
|
-
|
64
|
-
repo = 'protocolbuffers/protobuf'
|
24
|
+
private
|
65
25
|
|
66
|
-
|
67
|
-
|
68
|
-
|
26
|
+
def api(url)
|
27
|
+
headers = {}
|
28
|
+
headers['Authorization'] = "token #{ENV['GITHUB_TOKEN']}" if ENV['GITHUB_TOKEN']
|
29
|
+
URI.parse(url).open(headers) do |file|
|
30
|
+
JSON.parse file.read
|
31
|
+
end
|
32
|
+
end
|
69
33
|
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
34
|
+
def download(url)
|
35
|
+
URI.parse(url).open do |source|
|
36
|
+
File.open(File.absolute_path(File.basename(url), __dir__), 'wb') do |destination|
|
37
|
+
destination.write source.read
|
38
|
+
end
|
39
|
+
end
|
40
|
+
rescue StandardError
|
41
|
+
raise "Failed to download: #{url}"
|
42
|
+
end
|
43
|
+
|
44
|
+
def download_sass_embedded
|
45
|
+
repo = 'sass/dart-sass-embedded'
|
46
|
+
|
47
|
+
release = api("https://api.github.com/repos/#{repo}/releases")[0]['tag_name']
|
48
|
+
|
49
|
+
os = case Sass::Platform::OS
|
50
|
+
when 'darwin'
|
51
|
+
'macos'
|
52
|
+
when 'linux'
|
53
|
+
'linux'
|
54
|
+
when 'windows'
|
55
|
+
'windows'
|
56
|
+
else
|
57
|
+
raise "Unsupported OS: #{Sass::Platform::OS}"
|
58
|
+
end
|
59
|
+
|
60
|
+
arch = case Sass::Platform::ARCH
|
61
|
+
when 'x86_64'
|
62
|
+
'x64'
|
63
|
+
when 'i386'
|
64
|
+
'ia32'
|
65
|
+
else
|
66
|
+
raise "Unsupported Arch: #{Sass::Platform::ARCH}"
|
67
|
+
end
|
68
|
+
|
69
|
+
ext = case os
|
70
|
+
when 'windows'
|
71
|
+
'zip'
|
101
72
|
else
|
102
|
-
|
73
|
+
'tar.gz'
|
103
74
|
end
|
104
75
|
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
download url
|
109
|
-
end
|
76
|
+
url = "https://github.com/#{repo}/releases/download/#{release}/sass_embedded-#{release}-#{os}-#{arch}.#{ext}"
|
77
|
+
download url
|
78
|
+
end
|
110
79
|
|
111
|
-
def
|
112
|
-
|
113
|
-
|
114
|
-
|
80
|
+
def download_protoc
|
81
|
+
repo = 'protocolbuffers/protobuf'
|
82
|
+
|
83
|
+
tag = URI.parse("https://github.com/#{repo}/releases/latest").open do |file|
|
84
|
+
File.basename file.base_uri.to_s
|
85
|
+
end
|
86
|
+
|
87
|
+
release = tag[1..-1]
|
88
|
+
|
89
|
+
os = case Sass::Platform::OS
|
90
|
+
when 'darwin'
|
91
|
+
'osx'
|
92
|
+
when 'linux'
|
93
|
+
'linux'
|
94
|
+
when 'windows'
|
95
|
+
'win'
|
96
|
+
else
|
97
|
+
raise "Unsupported OS: #{Sass::Platform::OS}"
|
98
|
+
end
|
99
|
+
|
100
|
+
arch = case Sass::Platform::ARCH
|
101
|
+
when 'aarch64'
|
102
|
+
'aarch_64'
|
103
|
+
when 'sparcv9'
|
104
|
+
's390'
|
105
|
+
when 'i386'
|
106
|
+
'x86_32'
|
107
|
+
when 'x86_64'
|
108
|
+
'x86_64'
|
109
|
+
when 'powerpc64'
|
110
|
+
'ppcle_64'
|
111
|
+
else
|
112
|
+
raise "Unsupported Arch: #{Sass::Platform::ARCH}"
|
113
|
+
end
|
114
|
+
|
115
|
+
os_arch = case os
|
116
|
+
when 'win'
|
117
|
+
os + arch.split('_').last
|
118
|
+
else
|
119
|
+
"#{os}-#{arch}"
|
120
|
+
end
|
121
|
+
|
122
|
+
ext = 'zip'
|
123
|
+
|
124
|
+
url = "https://github.com/#{repo}/releases/download/#{tag}/protoc-#{release}-#{os_arch}.#{ext}"
|
125
|
+
download url
|
126
|
+
end
|
115
127
|
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
system('make', '-C', __dir__, 'install')
|
128
|
+
def download_embedded_sass_proto
|
129
|
+
url = 'https://raw.githubusercontent.com/sass/embedded-protocol/HEAD/embedded_sass.proto'
|
130
|
+
download url
|
131
|
+
end
|
121
132
|
|
122
|
-
|
133
|
+
end
|
134
|
+
end
|
123
135
|
|
124
|
-
|
136
|
+
Sass::Extconf.new
|
data/lib/sass.rb
CHANGED
@@ -13,7 +13,7 @@ module Sass
|
|
13
13
|
# (semicolon-separated on Windows).
|
14
14
|
#
|
15
15
|
# @example
|
16
|
-
# Sass.include_paths << File.dirname(__FILE__ + '/sass'
|
16
|
+
# Sass.include_paths << File.dirname(__FILE__) + '/sass'
|
17
17
|
# @return [Array<String, Pathname>]
|
18
18
|
def self.include_paths
|
19
19
|
@include_paths ||= if ENV['SASS_PATH']
|
data/lib/sass/embedded.rb
CHANGED
data/lib/sass/transport.rb
CHANGED
@@ -95,6 +95,7 @@ module Sass
|
|
95
95
|
@stdin.close unless @stdin.closed?
|
96
96
|
@stdout.close unless @stdout.closed?
|
97
97
|
@stderr.close unless @stderr.closed?
|
98
|
+
nil
|
98
99
|
end
|
99
100
|
|
100
101
|
private
|
@@ -109,28 +110,28 @@ module Sass
|
|
109
110
|
@stdin.write proto
|
110
111
|
end
|
111
112
|
end
|
112
|
-
end
|
113
113
|
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
114
|
+
class MessageObserver
|
115
|
+
def initialize(obs, id, &block)
|
116
|
+
@obs = obs
|
117
|
+
@id = id
|
118
|
+
@block = block
|
119
|
+
@obs.add_observer self
|
120
|
+
end
|
121
121
|
|
122
|
-
|
123
|
-
|
124
|
-
@obs.delete_observer self
|
125
|
-
@block.call error, nil
|
126
|
-
elsif message.error&.id == Sass::Transport::PROTOCOL_ERROR_ID
|
127
|
-
@obs.delete_observer self
|
128
|
-
@block.call Sass::ProtocolError.new(message.error.message), nil
|
129
|
-
else
|
130
|
-
res = message[message.message.to_s]
|
131
|
-
if (res['compilation_id'] || res['id']) == @id
|
122
|
+
def update(error, message)
|
123
|
+
if error
|
132
124
|
@obs.delete_observer self
|
133
|
-
@block.call error,
|
125
|
+
@block.call error, nil
|
126
|
+
elsif message.error&.id == Sass::Transport::PROTOCOL_ERROR_ID
|
127
|
+
@obs.delete_observer self
|
128
|
+
@block.call Sass::ProtocolError.new(message.error.message), nil
|
129
|
+
else
|
130
|
+
res = message[message.message.to_s]
|
131
|
+
if (res['compilation_id'] || res['id']) == @id
|
132
|
+
@obs.delete_observer self
|
133
|
+
@block.call error, res
|
134
|
+
end
|
134
135
|
end
|
135
136
|
end
|
136
137
|
end
|
data/lib/sass/version.rb
CHANGED