evt-virtual 2.0.1.2 → 2.1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/virtual/activate.rb +6 -2
- data/lib/virtual/controls/abstract_method.rb +4 -4
- data/lib/virtual/controls/extended.rb +4 -4
- data/lib/virtual/controls/included.rb +4 -4
- data/lib/virtual/controls/protocol_method.rb +40 -0
- data/lib/virtual/controls/pure_virtual_method.rb +18 -5
- data/lib/virtual/controls/virtual_method.rb +18 -5
- data/lib/virtual/controls.rb +1 -0
- data/lib/virtual/macro.rb +12 -3
- data/lib/virtual/protocol_method.rb +3 -7
- data/lib/virtual/pure_method.rb +7 -7
- data/lib/virtual/virtual_method.rb +16 -0
- data/lib/virtual.rb +1 -1
- metadata +4 -3
- data/lib/virtual/method.rb +0 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6b99fa347649061dabcb64bea008a1d50ca99c018bcc26dc1bb95dcb3e7983fe
|
4
|
+
data.tar.gz: 78cfbfb5718dd2b60cff7011521c37bc8dab18a90d433ffd65e367d51be58c47
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 18bb8c29bff1bfeef525735b2369250c3c177219d63aaac860aaa9debfa69c25aa43f8abe53c6dddf3e19a1a8bc8d79dd1b868bf2fc424404a4e011c772e15f5
|
7
|
+
data.tar.gz: e723b840b59c4065fcf05757b3adfcf6626b05c44fd81258a99b7ac64637585fa34f293c0f55946ce044c8527d40011e05e8c6a65f3e6e90771ac98c05172c94
|
data/lib/virtual/activate.rb
CHANGED
@@ -12,9 +12,13 @@ module Virtual
|
|
12
12
|
|
13
13
|
subject = subject_class(target_class)
|
14
14
|
|
15
|
-
|
16
|
-
|
15
|
+
Macro.macro_methods.each do |mthd|
|
16
|
+
if not subject.respond_to?(mthd)
|
17
|
+
return false
|
18
|
+
end
|
17
19
|
end
|
20
|
+
|
21
|
+
true
|
18
22
|
end
|
19
23
|
|
20
24
|
def self.subject_class(subject)
|
@@ -1,15 +1,15 @@
|
|
1
1
|
module Virtual
|
2
2
|
module Controls
|
3
3
|
module AbstractMethod
|
4
|
+
def self.example
|
5
|
+
Example.new
|
6
|
+
end
|
7
|
+
|
4
8
|
class Example
|
5
9
|
include Virtual
|
6
10
|
|
7
11
|
pure_virtual :some_pure_virtual_method
|
8
12
|
end
|
9
|
-
|
10
|
-
def self.example
|
11
|
-
Example.new
|
12
|
-
end
|
13
13
|
end
|
14
14
|
end
|
15
15
|
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
module Virtual
|
2
|
+
module Controls
|
3
|
+
module ProtocolMethod
|
4
|
+
def self.example
|
5
|
+
Example.new
|
6
|
+
end
|
7
|
+
|
8
|
+
class Example
|
9
|
+
include Virtual
|
10
|
+
|
11
|
+
protocol :some_protocol_method
|
12
|
+
end
|
13
|
+
|
14
|
+
module Implemented
|
15
|
+
def self.example
|
16
|
+
Implementer.new
|
17
|
+
end
|
18
|
+
|
19
|
+
class Implementer < Example
|
20
|
+
def some_protocol_method
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
module Override
|
26
|
+
def self.example
|
27
|
+
Class.new do
|
28
|
+
include Virtual
|
29
|
+
|
30
|
+
def some_protocol_method
|
31
|
+
end
|
32
|
+
|
33
|
+
protocol :some_protocol_method
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
@@ -1,24 +1,37 @@
|
|
1
1
|
module Virtual
|
2
2
|
module Controls
|
3
3
|
module PureVirtualMethod
|
4
|
+
def self.example
|
5
|
+
Example.new
|
6
|
+
end
|
7
|
+
|
4
8
|
class Example
|
5
9
|
include Virtual
|
6
10
|
|
7
11
|
pure_virtual :some_pure_virtual_method
|
8
12
|
end
|
9
13
|
|
10
|
-
def self.example
|
11
|
-
Example.new
|
12
|
-
end
|
13
|
-
|
14
14
|
module Implemented
|
15
|
+
def self.example
|
16
|
+
Implementer.new
|
17
|
+
end
|
18
|
+
|
15
19
|
class Implementer < Example
|
16
20
|
def some_pure_virtual_method
|
17
21
|
end
|
18
22
|
end
|
23
|
+
end
|
19
24
|
|
25
|
+
module Override
|
20
26
|
def self.example
|
21
|
-
|
27
|
+
Class.new do
|
28
|
+
include Virtual
|
29
|
+
|
30
|
+
def some_pure_virtual_method
|
31
|
+
end
|
32
|
+
|
33
|
+
pure_virtual :some_pure_virtual_method
|
34
|
+
end
|
22
35
|
end
|
23
36
|
end
|
24
37
|
end
|
@@ -1,17 +1,21 @@
|
|
1
1
|
module Virtual
|
2
2
|
module Controls
|
3
3
|
module VirtualMethod
|
4
|
+
def self.example
|
5
|
+
Example.new
|
6
|
+
end
|
7
|
+
|
4
8
|
class Example
|
5
9
|
include Virtual
|
6
10
|
|
7
11
|
virtual :some_virtual_method
|
8
12
|
end
|
9
13
|
|
10
|
-
def self.example
|
11
|
-
Example.new
|
12
|
-
end
|
13
|
-
|
14
14
|
module Body
|
15
|
+
def self.example
|
16
|
+
Example.new
|
17
|
+
end
|
18
|
+
|
15
19
|
class Example
|
16
20
|
include Virtual
|
17
21
|
|
@@ -19,9 +23,18 @@ module Virtual
|
|
19
23
|
:something
|
20
24
|
end
|
21
25
|
end
|
26
|
+
end
|
22
27
|
|
28
|
+
module Override
|
23
29
|
def self.example
|
24
|
-
|
30
|
+
Class.new do
|
31
|
+
include Virtual
|
32
|
+
|
33
|
+
def some_virtual_method
|
34
|
+
end
|
35
|
+
|
36
|
+
virtual :some_virtual_method
|
37
|
+
end
|
25
38
|
end
|
26
39
|
end
|
27
40
|
end
|
data/lib/virtual/controls.rb
CHANGED
data/lib/virtual/macro.rb
CHANGED
@@ -1,19 +1,28 @@
|
|
1
1
|
module Virtual
|
2
2
|
module Macro
|
3
3
|
def virtual_macro(method_name, &blk)
|
4
|
-
Virtual::
|
4
|
+
Virtual::VirtualMethod.define(self, method_name, &blk)
|
5
5
|
end
|
6
6
|
alias :virtual :virtual_macro
|
7
7
|
|
8
8
|
def pure_macro(method_name)
|
9
|
-
Virtual::PureMethod.define
|
9
|
+
Virtual::PureMethod.define(self, method_name)
|
10
10
|
end
|
11
11
|
alias :pure_virtual :pure_macro
|
12
12
|
alias :abstract :pure_macro
|
13
13
|
|
14
14
|
def protocol_macro(method_name)
|
15
|
-
Virtual::ProtocolMethod.define
|
15
|
+
Virtual::ProtocolMethod.define(self, method_name)
|
16
16
|
end
|
17
17
|
alias :protocol :protocol_macro
|
18
|
+
|
19
|
+
def self.macro_methods
|
20
|
+
[
|
21
|
+
'virtual',
|
22
|
+
'pure_virtual',
|
23
|
+
'abstract',
|
24
|
+
'protocol'
|
25
|
+
]
|
26
|
+
end
|
18
27
|
end
|
19
28
|
end
|
@@ -1,18 +1,14 @@
|
|
1
1
|
module Virtual
|
2
2
|
module ProtocolMethod
|
3
|
-
|
4
|
-
def initialize(message)
|
5
|
-
super("Pure virtual (abstract) protocol method #{message} must be implemented")
|
6
|
-
end
|
7
|
-
end
|
3
|
+
Error = Class.new(RuntimeError)
|
8
4
|
|
9
5
|
def self.define(target_class, method_name)
|
10
6
|
method_defined = target_class.method_defined?(method_name, true) ||
|
11
7
|
target_class.private_method_defined?(method_name, true)
|
12
8
|
|
13
9
|
if not method_defined
|
14
|
-
target_class.send
|
15
|
-
raise Error, "
|
10
|
+
target_class.send(:define_method, method_name) do |*args|
|
11
|
+
raise Error, "Pure virtual (abstract) protocol method #{method_name} of #{self.class.name} must be implemented"
|
16
12
|
end
|
17
13
|
end
|
18
14
|
end
|
data/lib/virtual/pure_method.rb
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
module Virtual
|
2
2
|
module PureMethod
|
3
|
-
|
4
|
-
def initialize(message)
|
5
|
-
super("Pure virtual (abstract) method #{message} must be implemented")
|
6
|
-
end
|
7
|
-
end
|
3
|
+
Error = Class.new(RuntimeError)
|
8
4
|
|
9
5
|
def self.define(target_class, method_name)
|
10
|
-
target_class.
|
11
|
-
raise Error, "
|
6
|
+
if target_class.method_defined?(method_name)
|
7
|
+
raise Error, "#{target_class} already has an implementation of the #{method_name} method"
|
8
|
+
end
|
9
|
+
|
10
|
+
target_class.send(:define_method, method_name) do |*args|
|
11
|
+
raise Error, "Pure virtual (abstract) method #{method_name} of #{self.class.name} must be implemented"
|
12
12
|
end
|
13
13
|
end
|
14
14
|
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module Virtual
|
2
|
+
module VirtualMethod
|
3
|
+
Error = Class.new(RuntimeError)
|
4
|
+
|
5
|
+
def self.define(target_class, method_name, &blk)
|
6
|
+
if target_class.method_defined?(method_name)
|
7
|
+
raise Error, "#{target_class} already has an implementation of the #{method_name} method"
|
8
|
+
end
|
9
|
+
|
10
|
+
blk ||= proc do |*|
|
11
|
+
end
|
12
|
+
|
13
|
+
target_class.send(:define_method, method_name, &blk)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
data/lib/virtual.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: evt-virtual
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- The Eventide Project
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-01-
|
11
|
+
date: 2023-01-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: test_bench
|
@@ -37,13 +37,14 @@ files:
|
|
37
37
|
- lib/virtual/controls/clean.rb
|
38
38
|
- lib/virtual/controls/extended.rb
|
39
39
|
- lib/virtual/controls/included.rb
|
40
|
+
- lib/virtual/controls/protocol_method.rb
|
40
41
|
- lib/virtual/controls/pure_virtual_method.rb
|
41
42
|
- lib/virtual/controls/virtual_method.rb
|
42
43
|
- lib/virtual/macro.rb
|
43
|
-
- lib/virtual/method.rb
|
44
44
|
- lib/virtual/protocol_method.rb
|
45
45
|
- lib/virtual/pure_method.rb
|
46
46
|
- lib/virtual/virtual.rb
|
47
|
+
- lib/virtual/virtual_method.rb
|
47
48
|
homepage: https://github.com/eventide-project/virtual
|
48
49
|
licenses:
|
49
50
|
- MIT
|