evt-virtual 2.0.1.2 → 2.1.0.1
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 +8 -7
- data/lib/virtual/virtual_method.rb +17 -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: c36a981db81c8a89d7512dc367dce98d2602e7fbf66a247ebee9ace0878ff560
|
4
|
+
data.tar.gz: 28388f60c3efbcdced0986c36f4cea9da4369a3cd0deb103f42d9cdcb5a60653
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 03636bbd14d687e7ffd7909128366ee0d4ee550ece6bdbdc185a6b8b3b94d00c879cd63edd2b282328cca920562ced102bd6ebcb829656fe297f5e4770ffdafa
|
7
|
+
data.tar.gz: b320530f626e41d760c028ce572f9a2a85ea2ca773fb5ff945ea336ed7037b4bddf0959abd7ff9d55e34dafc373ac9b0c123bd5d0d71e62b9f10b50a6a2e051d
|
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,15 @@
|
|
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
|
-
|
11
|
-
|
6
|
+
## Re-enable when possible. Caused regressions in core libraries - Scott, Tue Jan 10 2022
|
7
|
+
# if target_class.method_defined?(method_name)
|
8
|
+
# raise Error, "#{target_class} already has an implementation of the #{method_name} method"
|
9
|
+
# end
|
10
|
+
|
11
|
+
target_class.send(:define_method, method_name) do |*args|
|
12
|
+
raise Error, "Pure virtual (abstract) method #{method_name} of #{self.class.name} must be implemented"
|
12
13
|
end
|
13
14
|
end
|
14
15
|
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module Virtual
|
2
|
+
module VirtualMethod
|
3
|
+
Error = Class.new(RuntimeError)
|
4
|
+
|
5
|
+
def self.define(target_class, method_name, &blk)
|
6
|
+
## Re-enable when possible. Caused regressions in core libraries - Scott, Tue Jan 10 2022
|
7
|
+
# if target_class.method_defined?(method_name)
|
8
|
+
# raise Error, "#{target_class} already has an implementation of the #{method_name} method"
|
9
|
+
# end
|
10
|
+
|
11
|
+
blk ||= proc do |*|
|
12
|
+
end
|
13
|
+
|
14
|
+
target_class.send(:define_method, method_name, &blk)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
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.1
|
4
|
+
version: 2.1.0.1
|
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
|