sass-embedded 1.69.3-aarch64-linux-musl → 1.69.4-aarch64-linux-musl
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/ext/sass/dart-sass/src/sass.snapshot +0 -0
- data/lib/sass/embedded/connection.rb +27 -30
- data/lib/sass/embedded/dispatcher.rb +28 -33
- data/lib/sass/embedded/host/protofier.rb +88 -0
- data/lib/sass/embedded/host/structifier.rb +37 -0
- data/lib/sass/embedded/host.rb +3 -1
- data/lib/sass/embedded/resilient_dispatcher.rb +0 -4
- data/lib/sass/embedded/varint.rb +2 -4
- data/lib/sass/embedded/version.rb +1 -1
- data/lib/sass/embedded.rb +0 -3
- metadata +7 -7
- data/lib/sass/embedded/protofier.rb +0 -86
- data/lib/sass/embedded/structifier.rb +0 -35
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ec3f8a749ffe893613007f0afc8237e70035faeb128990452ab11075e204aaaa
|
4
|
+
data.tar.gz: a882319b094ec533f56233a17ca2a50f4afc9b09ce8f0e0ceee916e829e815a7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b22ae563c2eefef825475635d0c7cd9a6c5f933531adf52af4afe0076c19bcbcc067425342e127e526f1e258c89d55cc1e86b30c3c52d5d2218b5542a794b68b
|
7
|
+
data.tar.gz: e28458aa85a660cfecedb34e1622b04d2435dc8b106d3d0b13fdcd7bed6a7b502639930af59aa63f3a12cd7a480b366f6ec7f3d66458aa717e7a38529000b947
|
Binary file
|
@@ -2,14 +2,16 @@
|
|
2
2
|
|
3
3
|
require 'open3'
|
4
4
|
|
5
|
+
require_relative '../../../ext/sass/cli'
|
6
|
+
|
5
7
|
module Sass
|
6
8
|
class Embedded
|
7
9
|
# The stdio based {Connection} between the {Dispatcher} and the compiler.
|
8
10
|
#
|
9
11
|
# It runs the `sass --embedded` command.
|
10
12
|
class Connection
|
11
|
-
def initialize
|
12
|
-
@stdin,
|
13
|
+
def initialize(dispatcher)
|
14
|
+
@stdin, stdout, stderr, @wait_thread = begin
|
13
15
|
Open3.popen3(*CLI::COMMAND, '--embedded', chdir: __dir__)
|
14
16
|
rescue Errno::ENOENT
|
15
17
|
require_relative '../elf'
|
@@ -18,51 +20,46 @@ module Sass
|
|
18
20
|
|
19
21
|
Open3.popen3(ELF::INTERPRETER, *CLI::COMMAND, '--embedded', chdir: __dir__)
|
20
22
|
end
|
21
|
-
|
22
23
|
@stdin.binmode
|
23
|
-
|
24
|
-
|
25
|
-
|
24
|
+
|
25
|
+
Thread.new do
|
26
|
+
stdout.binmode
|
27
|
+
loop do
|
28
|
+
length = Varint.read(stdout)
|
29
|
+
id = Varint.read(stdout)
|
30
|
+
proto = stdout.read(length - Varint.length(id))
|
31
|
+
dispatcher.receive_proto(id, proto)
|
32
|
+
rescue IOError, Errno::EBADF, Errno::EPROTO => e
|
33
|
+
dispatcher.error(e)
|
34
|
+
break
|
35
|
+
end
|
36
|
+
stdout.close
|
37
|
+
end
|
26
38
|
|
27
39
|
Thread.new do
|
28
40
|
loop do
|
29
|
-
warn(
|
41
|
+
warn(stderr.readline, uplevel: 1)
|
30
42
|
rescue IOError, Errno::EBADF
|
31
43
|
break
|
32
44
|
end
|
45
|
+
stderr.close
|
33
46
|
end
|
34
47
|
end
|
35
48
|
|
36
49
|
def close
|
37
|
-
@
|
38
|
-
|
39
|
-
@wait_thread.join
|
40
|
-
@stdout.close
|
41
|
-
@stderr.close
|
42
|
-
end
|
50
|
+
@stdin.close
|
51
|
+
@wait_thread.join
|
43
52
|
end
|
44
53
|
|
45
54
|
def closed?
|
46
|
-
@
|
47
|
-
@stdin.closed?
|
48
|
-
end
|
55
|
+
@stdin.closed? && !@wait_thread.alive?
|
49
56
|
end
|
50
57
|
|
51
58
|
def write(id, proto)
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
end
|
57
|
-
end
|
58
|
-
|
59
|
-
def read
|
60
|
-
@stdout_mutex.synchronize do
|
61
|
-
length = Varint.read(@stdout)
|
62
|
-
id = Varint.read(@stdout)
|
63
|
-
proto = @stdout.read(length - Varint.length(id))
|
64
|
-
return id, proto
|
65
|
-
end
|
59
|
+
buffer = []
|
60
|
+
Varint.write(buffer, Varint.length(id) + proto.length)
|
61
|
+
Varint.write(buffer, id)
|
62
|
+
@stdin.write(buffer.pack('C*'), proto)
|
66
63
|
end
|
67
64
|
end
|
68
65
|
|
@@ -6,33 +6,16 @@ module Sass
|
|
6
6
|
#
|
7
7
|
# It dispatches messages between mutliple instances of {Host} and a single {Connection} to the compiler.
|
8
8
|
class Dispatcher
|
9
|
-
UINT_MAX = 0xffffffff
|
10
|
-
|
11
9
|
def initialize
|
12
|
-
@connection = Connection.new
|
13
|
-
@observers = {}
|
14
10
|
@id = 1
|
11
|
+
@observers = {}
|
15
12
|
@mutex = Mutex.new
|
16
|
-
|
17
|
-
Thread.new do
|
18
|
-
loop do
|
19
|
-
receive_proto
|
20
|
-
rescue IOError, Errno::EBADF, Errno::EPROTO => e
|
21
|
-
values = @mutex.synchronize do
|
22
|
-
@id = UINT_MAX
|
23
|
-
@observers.values
|
24
|
-
end
|
25
|
-
values.each do |observer|
|
26
|
-
observer.error(e)
|
27
|
-
end
|
28
|
-
break
|
29
|
-
end
|
30
|
-
end
|
13
|
+
@connection = Connection.new(self)
|
31
14
|
end
|
32
15
|
|
33
16
|
def subscribe(observer)
|
34
17
|
@mutex.synchronize do
|
35
|
-
raise Errno::EBUSY if @id ==
|
18
|
+
raise Errno::EBUSY if @id == 0xffffffff
|
36
19
|
|
37
20
|
id = @id
|
38
21
|
@id = id.next
|
@@ -47,7 +30,7 @@ module Sass
|
|
47
30
|
|
48
31
|
return unless @observers.empty?
|
49
32
|
|
50
|
-
if @id ==
|
33
|
+
if @id == 0xffffffff
|
51
34
|
Thread.new do
|
52
35
|
close
|
53
36
|
end
|
@@ -69,29 +52,31 @@ module Sass
|
|
69
52
|
@connection.closed?
|
70
53
|
end
|
71
54
|
|
72
|
-
def error
|
73
|
-
@mutex.synchronize do
|
74
|
-
@id =
|
55
|
+
def error(error)
|
56
|
+
observers = @mutex.synchronize do
|
57
|
+
@id = 0xffffffff
|
58
|
+
@observers.values
|
75
59
|
end
|
76
|
-
end
|
77
60
|
|
78
|
-
|
79
|
-
|
61
|
+
if observers.empty?
|
62
|
+
close
|
63
|
+
else
|
64
|
+
observers.each do |observer|
|
65
|
+
observer.error(error)
|
66
|
+
end
|
67
|
+
end
|
80
68
|
end
|
81
69
|
|
82
|
-
|
83
|
-
|
84
|
-
def receive_proto
|
85
|
-
id, proto = @connection.read
|
70
|
+
def receive_proto(id, proto)
|
86
71
|
case id
|
87
|
-
when 1...
|
72
|
+
when 1...0xffffffff
|
88
73
|
@mutex.synchronize { @observers[id] }.receive_proto(proto)
|
89
74
|
when 0
|
90
75
|
outbound_message = EmbeddedProtocol::OutboundMessage.decode(proto)
|
91
76
|
oneof = outbound_message.message
|
92
77
|
message = outbound_message.public_send(oneof)
|
93
78
|
@mutex.synchronize { @observers[message.id] }.public_send(oneof, message)
|
94
|
-
when
|
79
|
+
when 0xffffffff
|
95
80
|
outbound_message = EmbeddedProtocol::OutboundMessage.decode(proto)
|
96
81
|
oneof = outbound_message.message
|
97
82
|
message = outbound_message.public_send(oneof)
|
@@ -101,6 +86,10 @@ module Sass
|
|
101
86
|
end
|
102
87
|
end
|
103
88
|
|
89
|
+
def send_proto(...)
|
90
|
+
@connection.write(...)
|
91
|
+
end
|
92
|
+
|
104
93
|
# The {Channel} between {Dispatcher} and {Host}.
|
105
94
|
class Channel
|
106
95
|
attr_reader :id
|
@@ -114,6 +103,12 @@ module Sass
|
|
114
103
|
@dispatcher.unsubscribe(id)
|
115
104
|
end
|
116
105
|
|
106
|
+
def error(...)
|
107
|
+
Thread.new do
|
108
|
+
@dispatcher.error(...)
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
117
112
|
def send_proto(...)
|
118
113
|
@dispatcher.send_proto(...)
|
119
114
|
end
|
@@ -0,0 +1,88 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Sass
|
4
|
+
class Embedded
|
5
|
+
class Host
|
6
|
+
# The {Protofier} module.
|
7
|
+
#
|
8
|
+
# It converts Pure Ruby types and Protobuf Ruby types.
|
9
|
+
module Protofier
|
10
|
+
module_function
|
11
|
+
|
12
|
+
def from_proto_canonicalize_context(canonicalize_request)
|
13
|
+
CanonicalizeContext.new(
|
14
|
+
canonicalize_request.containing_url == '' ? nil : canonicalize_request.containing_url,
|
15
|
+
canonicalize_request.from_import
|
16
|
+
)
|
17
|
+
end
|
18
|
+
|
19
|
+
def from_proto_compile_response(compile_response)
|
20
|
+
oneof = compile_response.result
|
21
|
+
result = compile_response.public_send(oneof)
|
22
|
+
case oneof
|
23
|
+
when :failure
|
24
|
+
raise CompileError.new(
|
25
|
+
result.message,
|
26
|
+
result.formatted == '' ? nil : result.formatted,
|
27
|
+
result.stack_trace == '' ? nil : result.stack_trace,
|
28
|
+
from_proto_source_span(result.span),
|
29
|
+
compile_response.loaded_urls
|
30
|
+
)
|
31
|
+
when :success
|
32
|
+
CompileResult.new(
|
33
|
+
result.css,
|
34
|
+
result.source_map == '' ? nil : result.source_map,
|
35
|
+
compile_response.loaded_urls
|
36
|
+
)
|
37
|
+
else
|
38
|
+
raise ArgumentError, "Unknown CompileResponse.result #{result}"
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
def from_proto_source_span(source_span)
|
43
|
+
return if source_span.nil?
|
44
|
+
|
45
|
+
Logger::SourceSpan.new(from_proto_source_location(source_span.start),
|
46
|
+
from_proto_source_location(source_span.end),
|
47
|
+
source_span.text,
|
48
|
+
source_span.url == '' ? nil : source_span.url,
|
49
|
+
source_span.context == '' ? nil : source_span.context)
|
50
|
+
end
|
51
|
+
|
52
|
+
def from_proto_source_location(source_location)
|
53
|
+
return if source_location.nil?
|
54
|
+
|
55
|
+
Logger::SourceLocation.new(source_location.offset,
|
56
|
+
source_location.line,
|
57
|
+
source_location.column)
|
58
|
+
end
|
59
|
+
|
60
|
+
def to_proto_syntax(syntax)
|
61
|
+
case syntax&.to_sym
|
62
|
+
when :scss
|
63
|
+
EmbeddedProtocol::Syntax::SCSS
|
64
|
+
when :indented
|
65
|
+
EmbeddedProtocol::Syntax::INDENTED
|
66
|
+
when :css
|
67
|
+
EmbeddedProtocol::Syntax::CSS
|
68
|
+
else
|
69
|
+
raise ArgumentError, 'syntax must be one of :scss, :indented, :css'
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
def to_proto_output_style(style)
|
74
|
+
case style&.to_sym
|
75
|
+
when :expanded
|
76
|
+
EmbeddedProtocol::OutputStyle::EXPANDED
|
77
|
+
when :compressed
|
78
|
+
EmbeddedProtocol::OutputStyle::COMPRESSED
|
79
|
+
else
|
80
|
+
raise ArgumentError, 'style must be one of :expanded, :compressed'
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
private_constant :Protofier
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Sass
|
4
|
+
class Embedded
|
5
|
+
class Host
|
6
|
+
# The {Structifier} module.
|
7
|
+
#
|
8
|
+
# It converts {::Hash} to {Struct}-like objects.
|
9
|
+
module Structifier
|
10
|
+
module_function
|
11
|
+
|
12
|
+
def to_struct(obj, *symbols)
|
13
|
+
return obj unless obj.is_a? Hash
|
14
|
+
|
15
|
+
struct = Object.new
|
16
|
+
symbols.each do |key|
|
17
|
+
next unless obj.key?(key)
|
18
|
+
|
19
|
+
value = obj[key]
|
20
|
+
if value.respond_to? :call
|
21
|
+
struct.define_singleton_method key do |*args, **kwargs|
|
22
|
+
value.call(*args, **kwargs)
|
23
|
+
end
|
24
|
+
else
|
25
|
+
struct.define_singleton_method key do
|
26
|
+
value
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
struct
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
private_constant :Structifier
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
data/lib/sass/embedded/host.rb
CHANGED
@@ -3,6 +3,8 @@
|
|
3
3
|
require_relative 'host/function_registry'
|
4
4
|
require_relative 'host/importer_registry'
|
5
5
|
require_relative 'host/logger_registry'
|
6
|
+
require_relative 'host/protofier'
|
7
|
+
require_relative 'host/structifier'
|
6
8
|
require_relative 'host/value_protofier'
|
7
9
|
|
8
10
|
module Sass
|
@@ -88,8 +90,8 @@ module Sass
|
|
88
90
|
def error(message)
|
89
91
|
case message
|
90
92
|
when EmbeddedProtocol::ProtocolError
|
91
|
-
@dispatcher.error
|
92
93
|
@error = Errno::EPROTO.new(message.message)
|
94
|
+
@channel.error(@error)
|
93
95
|
else
|
94
96
|
@error ||= message
|
95
97
|
end
|
data/lib/sass/embedded/varint.rb
CHANGED
@@ -26,13 +26,11 @@ module Sass
|
|
26
26
|
end
|
27
27
|
|
28
28
|
def write(writeable, value)
|
29
|
-
bytes = []
|
30
29
|
until value < 0x80
|
31
|
-
|
30
|
+
writeable << ((value & 0x7f) | 0x80)
|
32
31
|
value >>= 7
|
33
32
|
end
|
34
|
-
|
35
|
-
writeable.write bytes.pack('C*')
|
33
|
+
writeable << value
|
36
34
|
end
|
37
35
|
end
|
38
36
|
|
data/lib/sass/embedded.rb
CHANGED
@@ -1,15 +1,12 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require_relative '../../ext/sass/cli'
|
4
3
|
require_relative 'canonicalize_context'
|
5
4
|
require_relative 'compile_error'
|
6
5
|
require_relative 'compile_result'
|
7
6
|
require_relative 'embedded/connection'
|
8
7
|
require_relative 'embedded/dispatcher'
|
9
8
|
require_relative 'embedded/host'
|
10
|
-
require_relative 'embedded/protofier'
|
11
9
|
require_relative 'embedded/resilient_dispatcher'
|
12
|
-
require_relative 'embedded/structifier'
|
13
10
|
require_relative 'embedded/varint'
|
14
11
|
require_relative 'embedded/version'
|
15
12
|
require_relative 'embedded_protocol'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sass-embedded
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.69.
|
4
|
+
version: 1.69.4
|
5
5
|
platform: aarch64-linux-musl
|
6
6
|
authors:
|
7
7
|
- なつき
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-10-
|
11
|
+
date: 2023-10-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: google-protobuf
|
@@ -56,10 +56,10 @@ files:
|
|
56
56
|
- lib/sass/embedded/host/function_registry.rb
|
57
57
|
- lib/sass/embedded/host/importer_registry.rb
|
58
58
|
- lib/sass/embedded/host/logger_registry.rb
|
59
|
+
- lib/sass/embedded/host/protofier.rb
|
60
|
+
- lib/sass/embedded/host/structifier.rb
|
59
61
|
- lib/sass/embedded/host/value_protofier.rb
|
60
|
-
- lib/sass/embedded/protofier.rb
|
61
62
|
- lib/sass/embedded/resilient_dispatcher.rb
|
62
|
-
- lib/sass/embedded/structifier.rb
|
63
63
|
- lib/sass/embedded/varint.rb
|
64
64
|
- lib/sass/embedded/version.rb
|
65
65
|
- lib/sass/embedded_protocol.rb
|
@@ -85,8 +85,8 @@ homepage: https://github.com/ntkme/sass-embedded-host-ruby
|
|
85
85
|
licenses:
|
86
86
|
- MIT
|
87
87
|
metadata:
|
88
|
-
documentation_uri: https://rubydoc.info/gems/sass-embedded/1.69.
|
89
|
-
source_code_uri: https://github.com/ntkme/sass-embedded-host-ruby/tree/v1.69.
|
88
|
+
documentation_uri: https://rubydoc.info/gems/sass-embedded/1.69.4
|
89
|
+
source_code_uri: https://github.com/ntkme/sass-embedded-host-ruby/tree/v1.69.4
|
90
90
|
funding_uri: https://github.com/sponsors/ntkme
|
91
91
|
post_install_message:
|
92
92
|
rdoc_options: []
|
@@ -103,7 +103,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
103
103
|
- !ruby/object:Gem::Version
|
104
104
|
version: 3.3.22
|
105
105
|
requirements: []
|
106
|
-
rubygems_version: 3.4.
|
106
|
+
rubygems_version: 3.4.21
|
107
107
|
signing_key:
|
108
108
|
specification_version: 4
|
109
109
|
summary: Use dart-sass with Ruby!
|
@@ -1,86 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Sass
|
4
|
-
class Embedded
|
5
|
-
# The {Protofier} module.
|
6
|
-
#
|
7
|
-
# It converts Pure Ruby types and Protobuf Ruby types.
|
8
|
-
module Protofier
|
9
|
-
module_function
|
10
|
-
|
11
|
-
def from_proto_canonicalize_context(canonicalize_request)
|
12
|
-
CanonicalizeContext.new(
|
13
|
-
canonicalize_request.containing_url == '' ? nil : canonicalize_request.containing_url,
|
14
|
-
canonicalize_request.from_import
|
15
|
-
)
|
16
|
-
end
|
17
|
-
|
18
|
-
def from_proto_compile_response(compile_response)
|
19
|
-
oneof = compile_response.result
|
20
|
-
result = compile_response.public_send(oneof)
|
21
|
-
case oneof
|
22
|
-
when :failure
|
23
|
-
raise CompileError.new(
|
24
|
-
result.message,
|
25
|
-
result.formatted == '' ? nil : result.formatted,
|
26
|
-
result.stack_trace == '' ? nil : result.stack_trace,
|
27
|
-
from_proto_source_span(result.span),
|
28
|
-
compile_response.loaded_urls
|
29
|
-
)
|
30
|
-
when :success
|
31
|
-
CompileResult.new(
|
32
|
-
result.css,
|
33
|
-
result.source_map == '' ? nil : result.source_map,
|
34
|
-
compile_response.loaded_urls
|
35
|
-
)
|
36
|
-
else
|
37
|
-
raise ArgumentError, "Unknown CompileResponse.result #{result}"
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
def from_proto_source_span(source_span)
|
42
|
-
return if source_span.nil?
|
43
|
-
|
44
|
-
Logger::SourceSpan.new(from_proto_source_location(source_span.start),
|
45
|
-
from_proto_source_location(source_span.end),
|
46
|
-
source_span.text,
|
47
|
-
source_span.url == '' ? nil : source_span.url,
|
48
|
-
source_span.context == '' ? nil : source_span.context)
|
49
|
-
end
|
50
|
-
|
51
|
-
def from_proto_source_location(source_location)
|
52
|
-
return if source_location.nil?
|
53
|
-
|
54
|
-
Logger::SourceLocation.new(source_location.offset,
|
55
|
-
source_location.line,
|
56
|
-
source_location.column)
|
57
|
-
end
|
58
|
-
|
59
|
-
def to_proto_syntax(syntax)
|
60
|
-
case syntax&.to_sym
|
61
|
-
when :scss
|
62
|
-
EmbeddedProtocol::Syntax::SCSS
|
63
|
-
when :indented
|
64
|
-
EmbeddedProtocol::Syntax::INDENTED
|
65
|
-
when :css
|
66
|
-
EmbeddedProtocol::Syntax::CSS
|
67
|
-
else
|
68
|
-
raise ArgumentError, 'syntax must be one of :scss, :indented, :css'
|
69
|
-
end
|
70
|
-
end
|
71
|
-
|
72
|
-
def to_proto_output_style(style)
|
73
|
-
case style&.to_sym
|
74
|
-
when :expanded
|
75
|
-
EmbeddedProtocol::OutputStyle::EXPANDED
|
76
|
-
when :compressed
|
77
|
-
EmbeddedProtocol::OutputStyle::COMPRESSED
|
78
|
-
else
|
79
|
-
raise ArgumentError, 'style must be one of :expanded, :compressed'
|
80
|
-
end
|
81
|
-
end
|
82
|
-
end
|
83
|
-
|
84
|
-
private_constant :Protofier
|
85
|
-
end
|
86
|
-
end
|
@@ -1,35 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Sass
|
4
|
-
class Embedded
|
5
|
-
# The {Structifier} module.
|
6
|
-
#
|
7
|
-
# It converts {::Hash} to {Struct}-like objects.
|
8
|
-
module Structifier
|
9
|
-
module_function
|
10
|
-
|
11
|
-
def to_struct(obj, *symbols)
|
12
|
-
return obj unless obj.is_a? Hash
|
13
|
-
|
14
|
-
struct = Object.new
|
15
|
-
symbols.each do |key|
|
16
|
-
next unless obj.key?(key)
|
17
|
-
|
18
|
-
value = obj[key]
|
19
|
-
if value.respond_to? :call
|
20
|
-
struct.define_singleton_method key do |*args, **kwargs|
|
21
|
-
value.call(*args, **kwargs)
|
22
|
-
end
|
23
|
-
else
|
24
|
-
struct.define_singleton_method key do
|
25
|
-
value
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
29
|
-
struct
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
private_constant :Structifier
|
34
|
-
end
|
35
|
-
end
|