evt-subst_attr 0.1.0.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 +7 -0
- data/lib/subst_attr.rb +8 -0
- data/lib/subst_attr/activate.rb +9 -0
- data/lib/subst_attr/attribute.rb +9 -0
- data/lib/subst_attr/macro.rb +8 -0
- data/lib/subst_attr/substitute.rb +70 -0
- metadata +91 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: d0c8b42d93f06c2c8c30c537c870edd0fb39be2c
|
4
|
+
data.tar.gz: 84093d6e68bd4100c1dd0d53e99fab1152316464
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: c20162dc91e81c04f259a672c82f4200b42a829178ff5f10c8cecdc639c2ec3cbdf44ef7243489cd965c4e67f6839a2c2d027a177fdea0a49c8b251f7e367eae
|
7
|
+
data.tar.gz: d8b4d7db2e8f3c930c97a4ecd468b43df1f4d1ceb9aa7439b62254c9fa16983ea2d3725350815fe1bbe755e3e87be2cf158405df8050f2834c3ad416058ce1ab
|
data/lib/subst_attr.rb
ADDED
@@ -0,0 +1,70 @@
|
|
1
|
+
module SubstAttr
|
2
|
+
module Substitute
|
3
|
+
extend self
|
4
|
+
|
5
|
+
def build(interface=nil)
|
6
|
+
if interface
|
7
|
+
specialization = specialization(interface, :Substitute)
|
8
|
+
return specialization if specialization
|
9
|
+
end
|
10
|
+
|
11
|
+
return NullObject.build interface
|
12
|
+
end
|
13
|
+
|
14
|
+
def call(attr_name, receiver)
|
15
|
+
interface = receiver.send(attr_name).class
|
16
|
+
substitute = build(interface)
|
17
|
+
receiver.send :"#{attr_name}=", substitute
|
18
|
+
end
|
19
|
+
|
20
|
+
def specialization(interface, const_name)
|
21
|
+
unless interface.const_defined?(const_name)
|
22
|
+
return nil
|
23
|
+
end
|
24
|
+
|
25
|
+
mod = interface.const_get(const_name)
|
26
|
+
|
27
|
+
unless mod.respond_to?(:build)
|
28
|
+
return nil
|
29
|
+
end
|
30
|
+
|
31
|
+
mod.send :build
|
32
|
+
end
|
33
|
+
|
34
|
+
module NullObject
|
35
|
+
extend self
|
36
|
+
|
37
|
+
Weak = Naught.build do |config|
|
38
|
+
config.define_explicit_conversions
|
39
|
+
config.define_implicit_conversions
|
40
|
+
config.predicates_return false
|
41
|
+
config.singleton
|
42
|
+
end
|
43
|
+
|
44
|
+
def build(interface=nil)
|
45
|
+
if interface
|
46
|
+
specialization = Substitute.specialization(interface, :NullObject)
|
47
|
+
|
48
|
+
if specialization
|
49
|
+
return specialization
|
50
|
+
else
|
51
|
+
return strict interface
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
weak
|
56
|
+
end
|
57
|
+
|
58
|
+
def weak
|
59
|
+
Weak.get
|
60
|
+
end
|
61
|
+
|
62
|
+
def strict(interface)
|
63
|
+
Naught.build do |config|
|
64
|
+
config.singleton
|
65
|
+
config.impersonate interface
|
66
|
+
end.get
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
metadata
ADDED
@@ -0,0 +1,91 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: evt-subst_attr
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- The Eventide Project
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-12-20 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: evt-attribute
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: naught
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: ntl-test_bench
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
description: " "
|
56
|
+
email: opensource@eventide-project.org
|
57
|
+
executables: []
|
58
|
+
extensions: []
|
59
|
+
extra_rdoc_files: []
|
60
|
+
files:
|
61
|
+
- lib/subst_attr.rb
|
62
|
+
- lib/subst_attr/activate.rb
|
63
|
+
- lib/subst_attr/attribute.rb
|
64
|
+
- lib/subst_attr/macro.rb
|
65
|
+
- lib/subst_attr/substitute.rb
|
66
|
+
homepage: https://github.com/eventide-project/subst-attr
|
67
|
+
licenses:
|
68
|
+
- MIT
|
69
|
+
metadata: {}
|
70
|
+
post_install_message:
|
71
|
+
rdoc_options: []
|
72
|
+
require_paths:
|
73
|
+
- lib
|
74
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
75
|
+
requirements:
|
76
|
+
- - ">="
|
77
|
+
- !ruby/object:Gem::Version
|
78
|
+
version: 2.3.3
|
79
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
80
|
+
requirements:
|
81
|
+
- - ">="
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
version: '0'
|
84
|
+
requirements: []
|
85
|
+
rubyforge_project:
|
86
|
+
rubygems_version: 2.5.2
|
87
|
+
signing_key:
|
88
|
+
specification_version: 4
|
89
|
+
summary: Declare attributes that have default implementations that are substitutes
|
90
|
+
or null objects
|
91
|
+
test_files: []
|