compound 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/lib/compound/guard.rb +45 -0
- data/lib/compound/host.rb +35 -0
- data/lib/compound/part.rb +15 -0
- data/lib/compound.rb +4 -0
- metadata +118 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: bde58c968de960b402bea81f6fbbf9b79432dca0
|
4
|
+
data.tar.gz: addbbf2bb047dab73b91fe0d1e4a3467e48bfcaf
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: a5751bb4d778bca22ef25041478f7554970bbb3466fc572ffece3f489a73e02ec01f93582c688a3d12c93c0abcb933acf1422656ce5a6cfb25e5c3db5fc525b6
|
7
|
+
data.tar.gz: 3650a8512ade312a0dedbb3f9d8ca4a75dd2497a064b95ccae5b7083a0e6019b801802eb0a7adc3acac2c40025a96e36d9e6aa075f5fececbccc7fbeda11c8a2
|
@@ -0,0 +1,45 @@
|
|
1
|
+
|
2
|
+
module Compound
|
3
|
+
|
4
|
+
# @api private
|
5
|
+
module BaseGuardMethods
|
6
|
+
def warn_about obj
|
7
|
+
warn "WARNING\n"\
|
8
|
+
"#{obj} is intended only for use in a Compound::Part.\n"\
|
9
|
+
"Please use Compound::Host#compound instead of #extend or #include.\n"\
|
10
|
+
"\n"
|
11
|
+
end
|
12
|
+
|
13
|
+
def included mod
|
14
|
+
guard mod
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
|
19
|
+
module Guard
|
20
|
+
extend BaseGuardMethods
|
21
|
+
|
22
|
+
# @api private
|
23
|
+
def self.guard mod
|
24
|
+
mod.define_singleton_method :extended do |obj|
|
25
|
+
::Compound::Guard.warn_about self unless obj.is_a? ::Compound::Part
|
26
|
+
end
|
27
|
+
mod.define_singleton_method :included do |_|
|
28
|
+
::Compound::Guard.warn_about self
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
|
34
|
+
module GuardAgainst
|
35
|
+
extend BaseGuardMethods
|
36
|
+
|
37
|
+
# @api private
|
38
|
+
def self.guard mod
|
39
|
+
mod.define_singleton_method :compounded do |_|
|
40
|
+
::Compound::GuardAgainst.warn_about self
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
|
2
|
+
module Compound
|
3
|
+
|
4
|
+
module Hosting
|
5
|
+
def compound mod
|
6
|
+
@_compound_parts ||= []
|
7
|
+
@_compound_parts.unshift ::Compound::Part.new self, mod
|
8
|
+
mod.compounded(self) if mod.respond_to? :compounded
|
9
|
+
end
|
10
|
+
|
11
|
+
def method_missing sym, *args, &block
|
12
|
+
component = @_compound_parts &&
|
13
|
+
@_compound_parts.detect { |obj| obj.respond_to? sym }
|
14
|
+
component ? (component.send sym, *args, &block) : super
|
15
|
+
end
|
16
|
+
|
17
|
+
def respond_to? sym
|
18
|
+
super || !!(@_compound_parts &&
|
19
|
+
@_compound_parts.detect { |obj| obj.respond_to? sym })
|
20
|
+
end
|
21
|
+
|
22
|
+
def method sym
|
23
|
+
return super if methods.include? sym
|
24
|
+
component = @_compound_parts &&
|
25
|
+
@_compound_parts.detect { |obj| obj.respond_to? sym }
|
26
|
+
component ? component.method(sym) :
|
27
|
+
raise(NameError, "undefined method `#{sym}' for object `#{self}'")
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
class Host
|
32
|
+
include Hosting
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
|
2
|
+
module Compound
|
3
|
+
|
4
|
+
class Part
|
5
|
+
def method_missing sym, *args, &block
|
6
|
+
@_compound_component_parent.send sym, *args, &block
|
7
|
+
end
|
8
|
+
|
9
|
+
def initialize parent, component_module
|
10
|
+
@_compound_component_parent = parent
|
11
|
+
extend component_module
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
data/lib/compound.rb
ADDED
metadata
ADDED
@@ -0,0 +1,118 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: compound
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Joe McIlvain
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-12-15 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rake
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :development
|
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: pry
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
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: pry-rescue
|
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
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rspec
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: fivemat
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
description: A new paradigm for mixing objects in Ruby.
|
84
|
+
email: joe.eli.mac@gmail.com
|
85
|
+
executables: []
|
86
|
+
extensions: []
|
87
|
+
extra_rdoc_files: []
|
88
|
+
files:
|
89
|
+
- lib/compound/guard.rb
|
90
|
+
- lib/compound/host.rb
|
91
|
+
- lib/compound/part.rb
|
92
|
+
- lib/compound.rb
|
93
|
+
homepage: https://github.com/jemc/compound/
|
94
|
+
licenses:
|
95
|
+
- MIT License
|
96
|
+
metadata: {}
|
97
|
+
post_install_message:
|
98
|
+
rdoc_options: []
|
99
|
+
require_paths:
|
100
|
+
- lib
|
101
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
102
|
+
requirements:
|
103
|
+
- - ">="
|
104
|
+
- !ruby/object:Gem::Version
|
105
|
+
version: '0'
|
106
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
requirements: []
|
112
|
+
rubyforge_project:
|
113
|
+
rubygems_version: 2.1.5
|
114
|
+
signing_key:
|
115
|
+
specification_version: 4
|
116
|
+
summary: compound
|
117
|
+
test_files: []
|
118
|
+
has_rdoc:
|