sass-embedded 0.6.6 → 0.6.7

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: d4a71f28bfa6faf9c0e4d39587a78e05d18f907a412b689283fca8b8184195f5
4
- data.tar.gz: d7b2f473c517e43f104b81b7818ed709d74f20c8c833103df1a1c6bd3718a563
3
+ metadata.gz: 7b1b7d4e1bdfae2dbb2f99b43c42c0e06673a5f4f8c92b213efdfa4535a56b5b
4
+ data.tar.gz: 23fe4aeaeab07ddf717e7f2fad75d3fc9d9c82db4f4606763e52df8450113f59
5
5
  SHA512:
6
- metadata.gz: 74eb4043c28ddba5c4b189454872057cecccb9d536a637da8345f3b8934e2496cc7f5ff56d7371dda9d794e5610fbc1eda47f1dfde92e16d135f48c6a9f02f6a
7
- data.tar.gz: ad9631c22232163d842c5e7a688ea50fd990a54ef199dcb46893bdb6572622b6cc05e71b8f75b4108803cfeea8d00f96acc07825d7bd9de598d743c817e1ebef
6
+ metadata.gz: 13f8c565606af71bad343b5863ca3c792897d9a7bfea0071f17c510d99b6f0bf4d995441433572ba6aab2ca7489b9202c70fee3db4fc1c63fd15a5d4a5e8f593
7
+ data.tar.gz: a9bcd6caf920377fd86aa94f1ef536582f41483e0b0fca252718995af25037162eb2e77ee61cf6fc8d761195c10da48ebbf6dcb48de0c723cf0d01d46de0c1c6
data/lib/sass/info.rb CHANGED
@@ -2,10 +2,15 @@
2
2
 
3
3
  module Sass
4
4
  # The {Observer} for {Embedded#info}.
5
- class Version < Observer
5
+ class Version
6
+ include Observer
7
+
6
8
  def initialize(transport, id)
7
- super(transport, id)
8
- @transport.send EmbeddedProtocol::InboundMessage::VersionRequest.new(id: @id)
9
+ @id = id
10
+
11
+ super(transport)
12
+
13
+ send_message EmbeddedProtocol::InboundMessage::VersionRequest.new(id: @id)
9
14
  end
10
15
 
11
16
  def update(error, message)
data/lib/sass/observer.rb CHANGED
@@ -1,13 +1,10 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Sass
4
- # The {Observer} for receiving messages from {Transport}.
5
- class Observer
6
- def initialize(transport, id)
7
- raise NotImplementedError if instance_of? Observer
8
-
4
+ # The {Observer} module for receiving messages from {Transport}.
5
+ module Observer
6
+ def initialize(transport)
9
7
  @transport = transport
10
- @id = id
11
8
  @mutex = Mutex.new
12
9
  @condition_variable = ConditionVariable.new
13
10
  @error = nil
@@ -33,5 +30,11 @@ module Sass
33
30
  @condition_variable.broadcast
34
31
  end
35
32
  end
33
+
34
+ private
35
+
36
+ def send_message(message)
37
+ @transport.send_message(message)
38
+ end
36
39
  end
37
40
  end
data/lib/sass/render.rb CHANGED
@@ -2,7 +2,9 @@
2
2
 
3
3
  module Sass
4
4
  # The {Observer} for {Embedded#render}.
5
- class Render < Observer
5
+ class Render
6
+ include Observer
7
+
6
8
  def initialize(transport, id,
7
9
  data:,
8
10
  file:,
@@ -15,8 +17,7 @@ module Sass
15
17
  importer:)
16
18
  raise ArgumentError, 'either data or file must be set' if file.nil? && data.nil?
17
19
 
18
- super(transport, id)
19
-
20
+ @id = id
20
21
  @data = data
21
22
  @file = file
22
23
  @indented_syntax = indented_syntax
@@ -31,7 +32,9 @@ module Sass
31
32
  @importer = importer
32
33
  @import_responses = {}
33
34
 
34
- @transport.send compile_request
35
+ super(transport)
36
+
37
+ send_message compile_request
35
38
  end
36
39
 
37
40
  def update(error, message)
@@ -54,13 +57,13 @@ module Sass
54
57
  return unless message.compilation_id == @id
55
58
 
56
59
  Thread.new do
57
- @transport.send canonicalize_response message
60
+ send_message canonicalize_response message
58
61
  end
59
62
  when EmbeddedProtocol::OutboundMessage::ImportRequest
60
63
  return unless message.compilation_id == @id
61
64
 
62
65
  Thread.new do
63
- @transport.send import_response message
66
+ send_message import_response message
64
67
  end
65
68
  when EmbeddedProtocol::OutboundMessage::FileImportRequest
66
69
  raise NotImplementedError, 'FileImportRequest is not implemented'
@@ -68,7 +71,7 @@ module Sass
68
71
  return unless message.compilation_id == @id
69
72
 
70
73
  Thread.new do
71
- @transport.send function_call_response message
74
+ send_message function_call_response message
72
75
  end
73
76
  end
74
77
  rescue StandardError => e
@@ -5,7 +5,7 @@ require 'observer'
5
5
  require_relative '../../ext/embedded_sass_pb'
6
6
 
7
7
  module Sass
8
- # The {Observable} {Transport} for low level communication with
8
+ # The {::Observable} {Transport} for low level communication with
9
9
  # `dart-sass-embedded` using protocol buffers via stdio. Received messages
10
10
  # can be observed by an {Observer}.
11
11
  class Transport
@@ -29,7 +29,7 @@ module Sass
29
29
  @stdin_mutex = Mutex.new
30
30
  @stdin, @stdout, @stderr, @wait_thread = Open3.popen3(DART_SASS_EMBEDDED)
31
31
  pipe @stderr, $stderr
32
- receive
32
+ receive_message @stdout
33
33
  end
34
34
 
35
35
  def add_observer(*args)
@@ -38,7 +38,7 @@ module Sass
38
38
  end
39
39
  end
40
40
 
41
- def send(message)
41
+ def send_message(message)
42
42
  write EmbeddedProtocol::InboundMessage.new(
43
43
  ONEOF_MESSAGE[message.class.descriptor] => message
44
44
  ).to_proto
@@ -58,17 +58,17 @@ module Sass
58
58
 
59
59
  private
60
60
 
61
- def receive
61
+ def receive_message(readable)
62
62
  Thread.new do
63
63
  loop do
64
64
  bits = length = 0
65
65
  loop do
66
- byte = @stdout.readbyte
66
+ byte = readable.readbyte
67
67
  length += (byte & 0x7f) << bits
68
68
  bits += 7
69
69
  break if byte <= 0x7f
70
70
  end
71
- payload = @stdout.read length
71
+ payload = readable.read length
72
72
  message = EmbeddedProtocol::OutboundMessage.decode payload
73
73
  @observerable_mutex.synchronize do
74
74
  changed
@@ -87,7 +87,7 @@ module Sass
87
87
  def pipe(readable, writeable)
88
88
  Thread.new do
89
89
  loop do
90
- writeable.write readable.read
90
+ writeable.write readable.readline
91
91
  rescue Interrupt
92
92
  break
93
93
  rescue IOError => e
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.6.6'
4
+ VERSION = '0.6.7'
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.6.6
4
+ version: 0.6.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - なつき