aspectual 0.0.2 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +2 -2
- data/aspectual-0.0.2.gem +0 -0
- data/aspectual.gemspec +3 -3
- data/lib/aspectual/version.rb +1 -1
- data/lib/aspectual.rb +6 -3
- data/spec/lib/aspectual_spec.rb +54 -6
- metadata +14 -13
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3229da9400effd5026b954ea45865ea5e57e514c
|
4
|
+
data.tar.gz: 68bc5c8b63eee406ac02127f9c3c0cc9d6f2c0a9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d259200db5b129a02b80b26cd8622ea969a67f5ed2b47451e77d6026e7aabf657a5be86ecd8e21bed7b6e1ba938cc14df0c4a20d2064503f229dc67959b987d6
|
7
|
+
data.tar.gz: e2e37da471291d851655249b0a3eda4f063a754f3569e1cf6cddd8fdbe7a094f13f2a8e9225f9ee95e7ef5c00b606c54036666ac8a14df28a2938dde612229dc
|
data/Gemfile.lock
CHANGED
data/aspectual-0.0.2.gem
ADDED
Binary file
|
data/aspectual.gemspec
CHANGED
@@ -20,7 +20,7 @@ Gem::Specification.new do |spec|
|
|
20
20
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
21
21
|
spec.require_paths = ["lib"]
|
22
22
|
|
23
|
-
spec.add_development_dependency "bundler", "~>
|
24
|
-
spec.add_development_dependency "rake"
|
25
|
-
spec.add_development_dependency "rspec"
|
23
|
+
spec.add_development_dependency "bundler", "~> 0"
|
24
|
+
spec.add_development_dependency "rake", "~> 0"
|
25
|
+
spec.add_development_dependency "rspec", "~> 0"
|
26
26
|
end
|
data/lib/aspectual/version.rb
CHANGED
data/lib/aspectual.rb
CHANGED
@@ -6,6 +6,7 @@ module Aspectual
|
|
6
6
|
# aspects are added to one method, the first declared method will be
|
7
7
|
# added last.
|
8
8
|
@_before_aspects = Array(aspects[:before]).reverse
|
9
|
+
@_around_aspects = Array(aspects[:around]).reverse
|
9
10
|
@_after_aspects = Array(aspects[:after])
|
10
11
|
end
|
11
12
|
|
@@ -14,7 +15,7 @@ module Aspectual
|
|
14
15
|
return if @_defining_method
|
15
16
|
if method_defined?(method_symbol)
|
16
17
|
|
17
|
-
%w{before after}.each do |position|
|
18
|
+
%w{before around after}.each do |position|
|
18
19
|
current_aspects = instance_variable_get("@_#{position}_aspects")
|
19
20
|
if current_aspects
|
20
21
|
current_aspects.each do |aspect|
|
@@ -39,10 +40,12 @@ module Aspectual
|
|
39
40
|
without_aspect_method_name = method_symbol.to_s + "_without_#{position}_" + aspect.to_s
|
40
41
|
|
41
42
|
case position
|
42
|
-
when "after"
|
43
|
-
aspect_proc = lambda {|*args| send(without_aspect_method_name, *args); send(aspect, *args)}
|
44
43
|
when "before"
|
45
44
|
aspect_proc = lambda {|*args| send(aspect, *args); send(without_aspect_method_name, *args)}
|
45
|
+
when "around"
|
46
|
+
aspect_proc = lambda {|*args| send(aspect, *args, &Proc.new{send(without_aspect_method_name, *args)})}
|
47
|
+
when "after"
|
48
|
+
aspect_proc = lambda {|*args| send(without_aspect_method_name, *args); send(aspect, *args)}
|
46
49
|
end
|
47
50
|
|
48
51
|
define_method(with_aspect_method_name, aspect_proc)
|
data/spec/lib/aspectual_spec.rb
CHANGED
@@ -49,12 +49,32 @@ describe Aspectual do
|
|
49
49
|
self
|
50
50
|
end
|
51
51
|
|
52
|
+
def block_test_method_0
|
53
|
+
methods_called << "before_block_test_method_0_block"
|
54
|
+
yield
|
55
|
+
methods_called << "after_block_test_method_0_block"
|
56
|
+
self
|
57
|
+
end
|
58
|
+
|
59
|
+
def block_test_method_1
|
60
|
+
methods_called << "before_block_test_method_1_block"
|
61
|
+
yield
|
62
|
+
methods_called << "after_block_test_method_1_block"
|
63
|
+
self
|
64
|
+
end
|
65
|
+
|
52
66
|
aspects before: :single_test_method
|
53
67
|
def single_before_test_method
|
54
68
|
methods_called << "single_before_test_method"
|
55
69
|
self
|
56
70
|
end
|
57
71
|
|
72
|
+
aspects around: :block_test_method_0
|
73
|
+
def single_around_test_method
|
74
|
+
methods_called << "single_around_test_method"
|
75
|
+
self
|
76
|
+
end
|
77
|
+
|
58
78
|
aspects after: :single_test_method
|
59
79
|
def single_after_test_method
|
60
80
|
methods_called << "single_after_test_method"
|
@@ -67,6 +87,12 @@ describe Aspectual do
|
|
67
87
|
self
|
68
88
|
end
|
69
89
|
|
90
|
+
aspects around: [:block_test_method_0, :block_test_method_1]
|
91
|
+
def array_around_test_method
|
92
|
+
methods_called << "array_around_test_method"
|
93
|
+
self
|
94
|
+
end
|
95
|
+
|
70
96
|
aspects after: [:array_test_method_0, :array_test_method_1]
|
71
97
|
def array_after_test_method
|
72
98
|
methods_called << "array_after_test_method"
|
@@ -102,7 +128,7 @@ describe Aspectual do
|
|
102
128
|
describe "before aspects" do
|
103
129
|
it "calls before aspect methods before the called method" do
|
104
130
|
test_instance = TestClass.new.single_before_test_method
|
105
|
-
expect(test_instance.methods_called).to
|
131
|
+
expect(test_instance.methods_called).to eq(%w{
|
106
132
|
single_test_method
|
107
133
|
single_before_test_method
|
108
134
|
})
|
@@ -110,7 +136,7 @@ describe Aspectual do
|
|
110
136
|
|
111
137
|
it "allows multiple aspects to be declared" do
|
112
138
|
test_instance = TestClass.new.array_before_test_method
|
113
|
-
expect(test_instance.methods_called).to
|
139
|
+
expect(test_instance.methods_called).to eq(%w{
|
114
140
|
array_test_method_0
|
115
141
|
array_test_method_1
|
116
142
|
array_before_test_method
|
@@ -121,15 +147,15 @@ describe Aspectual do
|
|
121
147
|
describe "after aspects" do
|
122
148
|
it "calls before aspect methods before the called method" do
|
123
149
|
test_instance = TestClass.new.single_after_test_method
|
124
|
-
expect(test_instance.methods_called).to
|
125
|
-
single_test_method
|
150
|
+
expect(test_instance.methods_called).to eq(%w{
|
126
151
|
single_after_test_method
|
152
|
+
single_test_method
|
127
153
|
})
|
128
154
|
end
|
129
155
|
|
130
156
|
it "allows multiple aspects to be declared" do
|
131
157
|
test_instance = TestClass.new.array_after_test_method
|
132
|
-
expect(test_instance.methods_called).to
|
158
|
+
expect(test_instance.methods_called).to eq(%w{
|
133
159
|
array_after_test_method
|
134
160
|
array_test_method_0
|
135
161
|
array_test_method_1
|
@@ -137,10 +163,32 @@ describe Aspectual do
|
|
137
163
|
end
|
138
164
|
end
|
139
165
|
|
166
|
+
describe "around aspects" do
|
167
|
+
it "calls around aspect methods around the called method" do
|
168
|
+
test_instance = TestClass.new.single_around_test_method
|
169
|
+
expect(test_instance.methods_called).to eq(%w{
|
170
|
+
before_block_test_method_0_block
|
171
|
+
single_around_test_method
|
172
|
+
after_block_test_method_0_block
|
173
|
+
})
|
174
|
+
end
|
175
|
+
|
176
|
+
it "allows multiple aspects to be declared" do
|
177
|
+
test_instance = TestClass.new.array_around_test_method
|
178
|
+
expect(test_instance.methods_called).to eq(%w{
|
179
|
+
before_block_test_method_0_block
|
180
|
+
before_block_test_method_1_block
|
181
|
+
array_around_test_method
|
182
|
+
after_block_test_method_1_block
|
183
|
+
after_block_test_method_0_block
|
184
|
+
})
|
185
|
+
end
|
186
|
+
end
|
187
|
+
|
140
188
|
describe "mixed aspects" do
|
141
189
|
it "calls all the aspect declarations in the correct order" do
|
142
190
|
test_instance = TestClass.new.before_and_after_aspects_test_method
|
143
|
-
expect(test_instance.methods_called).to
|
191
|
+
expect(test_instance.methods_called).to eq(%w{
|
144
192
|
before_test_method_0
|
145
193
|
before_test_method_1
|
146
194
|
before_and_after_aspects_test_method
|
metadata
CHANGED
@@ -1,55 +1,55 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: aspectual
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alex Sunderland
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-12-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - ~>
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '0'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - ~>
|
24
|
+
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
26
|
+
version: '0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '0'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- -
|
38
|
+
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rspec
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- -
|
45
|
+
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: '0'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- -
|
52
|
+
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
55
|
description: "\n A simple gem to support minimal Aspect Oriented Programming in
|
@@ -64,6 +64,7 @@ files:
|
|
64
64
|
- Gemfile.lock
|
65
65
|
- README.md
|
66
66
|
- aspectual-0.0.1.gem
|
67
|
+
- aspectual-0.0.2.gem
|
67
68
|
- aspectual.gemspec
|
68
69
|
- lib/aspectual.rb
|
69
70
|
- lib/aspectual/version.rb
|
@@ -78,17 +79,17 @@ require_paths:
|
|
78
79
|
- lib
|
79
80
|
required_ruby_version: !ruby/object:Gem::Requirement
|
80
81
|
requirements:
|
81
|
-
- -
|
82
|
+
- - ">="
|
82
83
|
- !ruby/object:Gem::Version
|
83
84
|
version: '0'
|
84
85
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
85
86
|
requirements:
|
86
|
-
- -
|
87
|
+
- - ">="
|
87
88
|
- !ruby/object:Gem::Version
|
88
89
|
version: '0'
|
89
90
|
requirements: []
|
90
91
|
rubyforge_project:
|
91
|
-
rubygems_version: 2.
|
92
|
+
rubygems_version: 2.4.3
|
92
93
|
signing_key:
|
93
94
|
specification_version: 4
|
94
95
|
summary: A gem to help with AOP.
|