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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: edeb1d7a1a3ba0d1485671e579478b4b1bc5d372350a25869cd4b0305bd2f356
4
- data.tar.gz: 9eda21b2bdb2d7f278d03c9e5091eeec13956d9e0216ebb4a415988f8ac90b62
3
+ metadata.gz: 6c14e0ab686080f404d76337be0b59768bb600c48850f817c168cf53929239d9
4
+ data.tar.gz: e707aa4c0e910e71d0a316e4d3f1609b4c3cc49e49107c42af31d1ba3f9d3b62
5
5
  SHA512:
6
- metadata.gz: 2cc608b5597a0c820633f1dc386de5e9125b00ed99004c5237e0223d5a181d4782da4b2025983f86fad47409ef738e1a5954e810f35e9f443dd319035b2aa4dc
7
- data.tar.gz: a45ad64a3670c8d6f2136a287773eed2f77abaeb6911173931af8570fa1edeeed53a747ebc747288dc5b1941c08eb9ddc5c410ede3c536c380dd3297e0bf8092
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
- def api(url)
10
- headers = {}
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 download(url)
18
- URI.parse(url).open do |source|
19
- File.open(File.absolute_path(File.basename(url), __dir__), 'wb') do |destination|
20
- destination.write source.read
21
- end
22
- end
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
- def download_sass_embedded
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
- url = "https://github.com/#{repo}/releases/download/#{release}/sass_embedded-#{release}-#{os}-#{arch}.#{ext}"
60
- download url
61
- end
21
+ $makefile_created = true
22
+ end
62
23
 
63
- def download_protoc
64
- repo = 'protocolbuffers/protobuf'
24
+ private
65
25
 
66
- tag = URI.parse("https://github.com/#{repo}/releases/latest").open do |file|
67
- File.basename file.base_uri.to_s
68
- end
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
- release = tag[1..-1]
71
-
72
- os = case Sass::Platform::OS
73
- when 'darwin'
74
- 'osx'
75
- when 'linux'
76
- 'linux'
77
- when 'windows'
78
- 'win'
79
- else
80
- raise "Unsupported OS: #{Sass::Platform::OS}"
81
- end
82
-
83
- arch = case Sass::Platform::ARCH
84
- when 'aarch64'
85
- 'aarch_64'
86
- when 'sparcv9'
87
- 's390'
88
- when 'i386'
89
- 'x86_32'
90
- when 'x86_64'
91
- 'x86_64'
92
- when 'powerpc64'
93
- 'ppcle_64'
94
- else
95
- raise "Unsupported Arch: #{Sass::Platform::ARCH}"
96
- end
97
-
98
- os_arch = case os
99
- when 'win'
100
- os + arch.split('_').last
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
- "#{os}-#{arch}"
73
+ 'tar.gz'
103
74
  end
104
75
 
105
- ext = 'zip'
106
-
107
- url = "https://github.com/#{repo}/releases/download/#{tag}/protoc-#{release}-#{os_arch}.#{ext}"
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 download_embedded_sass_proto
112
- url = 'https://raw.githubusercontent.com/sass/embedded-protocol/HEAD/embedded_sass.proto'
113
- download url
114
- end
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
- system('make', '-C', __dir__, 'distclean')
117
- download_sass_embedded
118
- download_protoc
119
- download_embedded_sass_proto
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
- File.open(File.absolute_path("sass_embedded.#{RbConfig::CONFIG['DLEXT']}", __dir__), 'w') {}
133
+ end
134
+ end
123
135
 
124
- $makefile_created = true
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
@@ -209,6 +209,7 @@ module Sass
209
209
 
210
210
  def close
211
211
  @transport.close
212
+ nil
212
213
  end
213
214
 
214
215
  private
@@ -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
- class MessageObserver
115
- def initialize(obs, id, &block)
116
- @obs = obs
117
- @id = id
118
- @block = block
119
- @obs.add_observer self
120
- end
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
- def update(error, message)
123
- if error
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, res
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Sass
4
- VERSION = '0.2.1'
4
+ VERSION = '0.2.2'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sass-embedded
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - なつき