evt-virtual 0.1.0.2 → 0.1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- data/lib/virtual.rb +1 -0
- data/lib/virtual/activate.rb +20 -2
- data/lib/virtual/controls.rb +6 -0
- data/lib/virtual/controls/abstract_method.rb +16 -0
- data/lib/virtual/controls/clean.rb +13 -0
- data/lib/virtual/controls/extended.rb +14 -0
- data/lib/virtual/controls/included.rb +14 -0
- data/lib/virtual/controls/pure_virtual_method.rb +27 -0
- data/lib/virtual/controls/virtual_method.rb +30 -0
- data/lib/virtual/pure_method.rb +6 -6
- data/lib/virtual/virtual.rb +9 -0
- metadata +11 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 1044d9a76ab3791cd6a9453e3f1c11b62134e873080b827f1ce2173edad7eb91
|
4
|
+
data.tar.gz: 5a133a6740bb3166a8a107e9d948f749e7e015eb497345a45afd6fcd584d0d6d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 53c9359bbae22d1d3d9b44f5ad48529fb73004a615227c36bb5cc1850dead0b83421b447c8e41068f8bd861f1a05825b185fe384eba9f2d2370f84c1baaa7f5e
|
7
|
+
data.tar.gz: 9467cceabc33a7063cb2be68715b9edc91194d26cd8c8c228cc0fad8a3e41fc894410f9470527332a26767714e92d7c9b1fa437ddc1d0fa31299eb433eb27342
|
data/lib/virtual.rb
CHANGED
data/lib/virtual/activate.rb
CHANGED
@@ -2,8 +2,26 @@ module Virtual
|
|
2
2
|
def self.activate(target_class=nil)
|
3
3
|
target_class ||= Object
|
4
4
|
|
5
|
-
return if target_class.ancestors.include?
|
5
|
+
return if target_class.ancestors.include?(Virtual::Macro)
|
6
6
|
|
7
|
-
target_class.extend
|
7
|
+
target_class.extend(Virtual::Macro)
|
8
|
+
end
|
9
|
+
|
10
|
+
module Assertions
|
11
|
+
def activated?
|
12
|
+
subject = Assertions.subject_class(self)
|
13
|
+
|
14
|
+
['virtual', 'pure_virtual', 'abstract'].each do |mthd|
|
15
|
+
fail mthd unless subject.respond_to?(mthd)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.subject_class(subject)
|
20
|
+
if [Module, Class].include?(subject)
|
21
|
+
return subject
|
22
|
+
else
|
23
|
+
return subject.class
|
24
|
+
end
|
25
|
+
end
|
8
26
|
end
|
9
27
|
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module Virtual
|
2
|
+
module Controls
|
3
|
+
module PureVirtualMethod
|
4
|
+
class Example
|
5
|
+
include Virtual
|
6
|
+
|
7
|
+
pure_virtual :some_pure_virtual_method
|
8
|
+
end
|
9
|
+
|
10
|
+
def self.example
|
11
|
+
Example.new
|
12
|
+
end
|
13
|
+
|
14
|
+
module Implemented
|
15
|
+
class Implementer < Example
|
16
|
+
def some_pure_virtual_method
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.example
|
21
|
+
Implementer.new
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
@@ -0,0 +1,30 @@
|
|
1
|
+
module Virtual
|
2
|
+
module Controls
|
3
|
+
module VirtualMethod
|
4
|
+
class Example
|
5
|
+
include Virtual
|
6
|
+
|
7
|
+
virtual :some_virtual_method
|
8
|
+
end
|
9
|
+
|
10
|
+
def self.example
|
11
|
+
Example.new
|
12
|
+
end
|
13
|
+
|
14
|
+
module Body
|
15
|
+
class Example
|
16
|
+
include Virtual
|
17
|
+
|
18
|
+
virtual :some_virtual_method do |*|
|
19
|
+
:something
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def self.example
|
24
|
+
Example.new
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
data/lib/virtual/pure_method.rb
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
module Virtual
|
2
|
-
|
3
|
-
|
4
|
-
|
2
|
+
module PureMethod
|
3
|
+
class Error < RuntimeError
|
4
|
+
def initialize(message)
|
5
|
+
super("Pure virtual (abstract) method #{message} must be implemented")
|
6
|
+
end
|
5
7
|
end
|
6
|
-
end
|
7
8
|
|
8
|
-
module PureMethod
|
9
9
|
def self.define(target_class, method_name)
|
10
10
|
target_class.send :define_method, method_name do |*args|
|
11
|
-
raise
|
11
|
+
raise Error, "\"#{method_name}\" of #{target_class.name}"
|
12
12
|
end
|
13
13
|
end
|
14
14
|
end
|
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: 0.1.0
|
4
|
+
version: 0.1.1.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:
|
11
|
+
date: 2018-04-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: test_bench
|
@@ -32,9 +32,17 @@ extra_rdoc_files: []
|
|
32
32
|
files:
|
33
33
|
- lib/virtual.rb
|
34
34
|
- lib/virtual/activate.rb
|
35
|
+
- lib/virtual/controls.rb
|
36
|
+
- lib/virtual/controls/abstract_method.rb
|
37
|
+
- lib/virtual/controls/clean.rb
|
38
|
+
- lib/virtual/controls/extended.rb
|
39
|
+
- lib/virtual/controls/included.rb
|
40
|
+
- lib/virtual/controls/pure_virtual_method.rb
|
41
|
+
- lib/virtual/controls/virtual_method.rb
|
35
42
|
- lib/virtual/macro.rb
|
36
43
|
- lib/virtual/method.rb
|
37
44
|
- lib/virtual/pure_method.rb
|
45
|
+
- lib/virtual/virtual.rb
|
38
46
|
homepage: https://github.com/eventide-project/virtual
|
39
47
|
licenses:
|
40
48
|
- MIT
|
@@ -55,7 +63,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
55
63
|
version: '0'
|
56
64
|
requirements: []
|
57
65
|
rubyforge_project:
|
58
|
-
rubygems_version: 2.
|
66
|
+
rubygems_version: 2.7.3
|
59
67
|
signing_key:
|
60
68
|
specification_version: 4
|
61
69
|
summary: Virtual method declaration
|