aspector 0.12.3 → 0.13.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.
- data/Gemfile +1 -1
- data/Gemfile.lock +21 -21
- data/Rakefile +0 -9
- data/VERSION +1 -1
- data/aspector.gemspec +7 -6
- data/examples/activerecord_hooks.rb +1 -1
- data/examples/cache_aspect.rb +1 -1
- data/examples/design_by_contract.rb +2 -0
- data/lib/aspector/advice.rb +20 -8
- data/lib/aspector/aspect_instances.rb +2 -2
- data/lib/aspector/base.rb +139 -183
- data/lib/aspector/base_class_methods.rb +54 -73
- data/lib/aspector/deferred_option.rb +10 -2
- data/lib/aspector/logger.rb +1 -1
- data/lib/aspector/method_matcher.rb +8 -2
- data/lib/aspector/object_extension.rb +6 -6
- data/run_all_examples.sh +12 -0
- data/spec/unit/around_spec.rb +17 -0
- data/spec/unit/base_class_methods_spec.rb +6 -6
- data/spec/unit/base_spec.rb +1 -1
- data/spec/unit/before_spec.rb +12 -0
- data/spec/unit/method_matcher_spec.rb +2 -2
- metadata +9 -8
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
GEM
|
2
2
|
remote: http://rubygems.org/
|
3
3
|
specs:
|
4
|
-
awesome_print (1.0
|
5
|
-
coderay (1.0.
|
4
|
+
awesome_print (1.1.0)
|
5
|
+
coderay (1.0.8)
|
6
6
|
diff-lcs (1.1.3)
|
7
7
|
git (1.2.5)
|
8
8
|
growl (1.0.3)
|
@@ -19,28 +19,28 @@ GEM
|
|
19
19
|
bundler (~> 1.0)
|
20
20
|
git (>= 1.2.5)
|
21
21
|
rake
|
22
|
-
method_source (0.
|
23
|
-
pry (0.9.
|
22
|
+
method_source (0.8.1)
|
23
|
+
pry (0.9.10)
|
24
24
|
coderay (~> 1.0.5)
|
25
|
-
method_source (~> 0.
|
26
|
-
slop (
|
27
|
-
pry (0.9.
|
25
|
+
method_source (~> 0.8)
|
26
|
+
slop (~> 3.3.1)
|
27
|
+
pry (0.9.10-java)
|
28
28
|
coderay (~> 1.0.5)
|
29
|
-
method_source (~> 0.
|
30
|
-
slop (
|
29
|
+
method_source (~> 0.8)
|
30
|
+
slop (~> 3.3.1)
|
31
31
|
spoon (~> 0.0)
|
32
|
-
rake (0.
|
33
|
-
rb-fsevent (0.
|
34
|
-
rspec (2.
|
35
|
-
rspec-core (~> 2.
|
36
|
-
rspec-expectations (~> 2.
|
37
|
-
rspec-mocks (~> 2.
|
38
|
-
rspec-core (2.
|
39
|
-
rspec-expectations (2.
|
32
|
+
rake (10.0.3)
|
33
|
+
rb-fsevent (0.9.3)
|
34
|
+
rspec (2.12.0)
|
35
|
+
rspec-core (~> 2.12.0)
|
36
|
+
rspec-expectations (~> 2.12.0)
|
37
|
+
rspec-mocks (~> 2.12.0)
|
38
|
+
rspec-core (2.12.2)
|
39
|
+
rspec-expectations (2.12.1)
|
40
40
|
diff-lcs (~> 1.1.3)
|
41
|
-
rspec-mocks (2.
|
42
|
-
ruby-prof (0.11.
|
43
|
-
slop (
|
41
|
+
rspec-mocks (2.12.1)
|
42
|
+
ruby-prof (0.11.3)
|
43
|
+
slop (3.3.3)
|
44
44
|
spoon (0.0.1)
|
45
45
|
thor (0.14.6)
|
46
46
|
|
@@ -57,6 +57,6 @@ DEPENDENCIES
|
|
57
57
|
guard-shell (~> 0.1.1)
|
58
58
|
jeweler (~> 1.6.4)
|
59
59
|
pry
|
60
|
-
rb-fsevent
|
60
|
+
rb-fsevent
|
61
61
|
rspec
|
62
62
|
ruby-prof
|
data/Rakefile
CHANGED
@@ -33,12 +33,3 @@ end
|
|
33
33
|
|
34
34
|
task :default => :spec
|
35
35
|
|
36
|
-
require 'rake/rdoctask'
|
37
|
-
Rake::RDocTask.new do |rdoc|
|
38
|
-
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
39
|
-
|
40
|
-
rdoc.rdoc_dir = 'rdoc'
|
41
|
-
rdoc.title = "aspector #{version}"
|
42
|
-
rdoc.rdoc_files.include('README*')
|
43
|
-
rdoc.rdoc_files.include('lib/**/*.rb')
|
44
|
-
end
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.13.0
|
data/aspector.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "aspector"
|
8
|
-
s.version = "0.
|
8
|
+
s.version = "0.13.0"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Guoliang Cao"]
|
12
|
-
s.date = "
|
12
|
+
s.date = "2013-01-04"
|
13
13
|
s.description = ""
|
14
14
|
s.email = "gcao99@gmail.com"
|
15
15
|
s.extra_rdoc_files = [
|
@@ -61,6 +61,7 @@ Gem::Specification.new do |s|
|
|
61
61
|
"performance-tests/method_invocation_test.rb",
|
62
62
|
"performance-tests/raw_test.rb",
|
63
63
|
"performance-tests/test_helper.rb",
|
64
|
+
"run_all_examples.sh",
|
64
65
|
"spec/functional/advices_on_private_methods_spec.rb",
|
65
66
|
"spec/functional/aspect_on_eigen_class_spec.rb",
|
66
67
|
"spec/functional/aspect_on_object_spec.rb",
|
@@ -82,7 +83,7 @@ Gem::Specification.new do |s|
|
|
82
83
|
s.homepage = "http://github.com/gcao/aspector"
|
83
84
|
s.licenses = ["MIT"]
|
84
85
|
s.require_paths = ["lib"]
|
85
|
-
s.rubygems_version = "1.8.
|
86
|
+
s.rubygems_version = "1.8.24"
|
86
87
|
s.summary = "Aspect Oriented Ruby Programming"
|
87
88
|
|
88
89
|
if s.respond_to? :specification_version then
|
@@ -96,7 +97,7 @@ Gem::Specification.new do |s|
|
|
96
97
|
s.add_development_dependency(%q<guard-bundler>, ["~> 0.1.3"])
|
97
98
|
s.add_development_dependency(%q<guard-rspec>, ["~> 0.5.2"])
|
98
99
|
s.add_development_dependency(%q<guard-shell>, ["~> 0.1.1"])
|
99
|
-
s.add_development_dependency(%q<rb-fsevent>, ["
|
100
|
+
s.add_development_dependency(%q<rb-fsevent>, [">= 0"])
|
100
101
|
s.add_development_dependency(%q<growl>, ["~> 1.0.3"])
|
101
102
|
s.add_development_dependency(%q<awesome_print>, [">= 0"])
|
102
103
|
s.add_development_dependency(%q<pry>, [">= 0"])
|
@@ -108,7 +109,7 @@ Gem::Specification.new do |s|
|
|
108
109
|
s.add_dependency(%q<guard-bundler>, ["~> 0.1.3"])
|
109
110
|
s.add_dependency(%q<guard-rspec>, ["~> 0.5.2"])
|
110
111
|
s.add_dependency(%q<guard-shell>, ["~> 0.1.1"])
|
111
|
-
s.add_dependency(%q<rb-fsevent>, ["
|
112
|
+
s.add_dependency(%q<rb-fsevent>, [">= 0"])
|
112
113
|
s.add_dependency(%q<growl>, ["~> 1.0.3"])
|
113
114
|
s.add_dependency(%q<awesome_print>, [">= 0"])
|
114
115
|
s.add_dependency(%q<pry>, [">= 0"])
|
@@ -121,7 +122,7 @@ Gem::Specification.new do |s|
|
|
121
122
|
s.add_dependency(%q<guard-bundler>, ["~> 0.1.3"])
|
122
123
|
s.add_dependency(%q<guard-rspec>, ["~> 0.5.2"])
|
123
124
|
s.add_dependency(%q<guard-shell>, ["~> 0.1.1"])
|
124
|
-
s.add_dependency(%q<rb-fsevent>, ["
|
125
|
+
s.add_dependency(%q<rb-fsevent>, [">= 0"])
|
125
126
|
s.add_dependency(%q<growl>, ["~> 1.0.3"])
|
126
127
|
s.add_dependency(%q<awesome_print>, [">= 0"])
|
127
128
|
s.add_dependency(%q<pry>, [">= 0"])
|
@@ -13,7 +13,7 @@ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
|
13
13
|
require 'aspector'
|
14
14
|
|
15
15
|
class ActiveRecordHooks < Aspector::Base
|
16
|
-
logger.level = Aspector::
|
16
|
+
logger.level = Aspector::Logging::TRACE
|
17
17
|
|
18
18
|
default :private_methods => true
|
19
19
|
|
data/examples/cache_aspect.rb
CHANGED
@@ -46,7 +46,7 @@ require 'aspector'
|
|
46
46
|
class CacheAspect < Aspector::Base
|
47
47
|
default :ttl => 60
|
48
48
|
|
49
|
-
around :aspect_arg => true, :method_arg => true do |aspect, method, proxy, &block|
|
49
|
+
around :name => 'cache', :aspect_arg => true, :method_arg => true do |aspect, method, proxy, &block|
|
50
50
|
key = method
|
51
51
|
ttl = aspect.options[:ttl]
|
52
52
|
|
data/lib/aspector/advice.rb
CHANGED
@@ -6,20 +6,32 @@ module Aspector
|
|
6
6
|
AROUND = 3
|
7
7
|
RAW = 4
|
8
8
|
|
9
|
-
attr_reader :type, :method_matcher, :options, :advice_block
|
9
|
+
attr_reader :type, :method_matcher, :options, :advice_code, :advice_block
|
10
10
|
attr_accessor :index
|
11
11
|
|
12
12
|
def initialize parent, type, method_matcher, with_method, options = {}, &block
|
13
13
|
@parent = parent
|
14
14
|
@type = type
|
15
15
|
@method_matcher = method_matcher
|
16
|
-
|
16
|
+
|
17
|
+
if with_method.is_a? Symbol
|
18
|
+
@with_method = with_method
|
19
|
+
else
|
20
|
+
@advice_code = with_method
|
21
|
+
end
|
22
|
+
|
17
23
|
@options = options
|
18
24
|
@advice_block = block
|
19
25
|
end
|
20
26
|
|
27
|
+
def name
|
28
|
+
@options[:name] || "advice #{index}"
|
29
|
+
end
|
30
|
+
|
21
31
|
def with_method
|
22
|
-
@
|
32
|
+
unless @advice_code
|
33
|
+
@with_method ||= "aop_#{hash.abs}"
|
34
|
+
end
|
23
35
|
end
|
24
36
|
|
25
37
|
def match? method, context = nil
|
@@ -49,10 +61,6 @@ module Aspector
|
|
49
61
|
type == AROUND
|
50
62
|
end
|
51
63
|
|
52
|
-
def invoke obj, *args, &block
|
53
|
-
obj.send with_method, *args, &block
|
54
|
-
end
|
55
|
-
|
56
64
|
def type_name
|
57
65
|
case @type
|
58
66
|
when BEFORE then @options[:skip_if_false] ? "BEFORE_FILTER" : "BEFORE"
|
@@ -62,9 +70,13 @@ module Aspector
|
|
62
70
|
else "UNKNOWN?!"
|
63
71
|
end
|
64
72
|
end
|
73
|
+
|
74
|
+
def use_deferred_logic? logic
|
75
|
+
method_matcher.use_deferred_logic? logic
|
76
|
+
end
|
65
77
|
|
66
78
|
def to_s
|
67
|
-
s = "
|
79
|
+
s = "#{name}: "
|
68
80
|
s << type_name
|
69
81
|
s << " [" << @method_matcher.to_s << "] DO "
|
70
82
|
if @with_method
|
@@ -3,8 +3,8 @@ module Aspector
|
|
3
3
|
|
4
4
|
def apply_to_method method
|
5
5
|
each do |aspect_instance|
|
6
|
-
next if aspect_instance.
|
7
|
-
aspect_instance.
|
6
|
+
next if aspect_instance.options[:old_methods_only]
|
7
|
+
aspect_instance.apply_to_method method
|
8
8
|
end
|
9
9
|
end
|
10
10
|
|
data/lib/aspector/base.rb
CHANGED
@@ -3,211 +3,156 @@ require 'erb'
|
|
3
3
|
module Aspector
|
4
4
|
class Base
|
5
5
|
|
6
|
-
attr :
|
7
|
-
|
8
|
-
|
9
|
-
attr :aop_target
|
10
|
-
alias target aop_target
|
11
|
-
|
12
|
-
attr :aop_wrapped_methods
|
6
|
+
attr :target
|
7
|
+
attr :options
|
13
8
|
|
14
9
|
def initialize target, options = {}
|
15
|
-
@
|
10
|
+
@target = target
|
16
11
|
|
17
|
-
default_options = self.class.
|
12
|
+
default_options = self.class.default_options
|
18
13
|
if default_options and not default_options.empty?
|
19
|
-
@
|
14
|
+
@options = default_options.merge(options)
|
20
15
|
else
|
21
|
-
@
|
22
|
-
end
|
23
|
-
|
24
|
-
# @aop_context is where advices will be applied (i.e. where methods are modified), can be different from target
|
25
|
-
@aop_context = aop_get_context
|
26
|
-
|
27
|
-
@aop_wrapped_methods = {}
|
28
|
-
|
29
|
-
after_initialize
|
30
|
-
end
|
31
|
-
|
32
|
-
def aop_enable
|
33
|
-
class << self
|
34
|
-
def aop_disabled?; end
|
35
|
-
end
|
36
|
-
|
37
|
-
aop_disabled?
|
38
|
-
end
|
39
|
-
alias enable aop_enable
|
40
|
-
|
41
|
-
def aop_disable
|
42
|
-
class << self
|
43
|
-
def aop_disabled?; true; end
|
16
|
+
@options = options
|
44
17
|
end
|
45
18
|
|
46
|
-
|
47
|
-
end
|
48
|
-
alias disable aop_disable
|
49
|
-
|
50
|
-
def aop_reset_disabled
|
51
|
-
class << self
|
52
|
-
remove_method :aop_disabled?
|
53
|
-
end
|
54
|
-
|
55
|
-
aop_disabled?
|
56
|
-
end
|
57
|
-
alias reset_disabled aop_reset_disabled
|
58
|
-
|
59
|
-
def aop_disabled?
|
19
|
+
@wrapped_methods = {}
|
60
20
|
end
|
61
21
|
|
62
22
|
def disabled?
|
63
|
-
|
23
|
+
# Enabled by default
|
64
24
|
end
|
65
25
|
|
66
|
-
def
|
67
|
-
return @
|
26
|
+
def logger
|
27
|
+
return @logger if @logger
|
68
28
|
|
69
|
-
@
|
70
|
-
@
|
71
|
-
@
|
29
|
+
@logger = Logging.get_logger(self)
|
30
|
+
@logger.level = self.class.logger.level
|
31
|
+
@logger
|
72
32
|
end
|
73
|
-
alias logger aop_logger
|
74
33
|
|
75
|
-
def
|
76
|
-
self.class.
|
34
|
+
def advices
|
35
|
+
self.class.advices
|
77
36
|
end
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
aop_add_method_hooks unless @aop_options[:old_methods_only]
|
87
|
-
after_apply
|
37
|
+
|
38
|
+
def apply
|
39
|
+
invoke_deferred_logics
|
40
|
+
define_methods_for_advice_blocks
|
41
|
+
add_to_instances unless @options[:old_methods_only]
|
42
|
+
apply_to_methods unless @options[:new_methods_only]
|
43
|
+
add_method_hooks unless @options[:old_methods_only]
|
44
|
+
# TODO: clear deferred logic results if they are not used in any advice
|
88
45
|
end
|
89
|
-
alias apply aop_apply
|
90
46
|
|
91
|
-
def
|
92
|
-
|
47
|
+
def apply_to_methods
|
48
|
+
return if advices.empty?
|
93
49
|
|
94
50
|
# If method/methods option is set and all are String or Symbol, apply to those only, instead of
|
95
51
|
# iterating through all methods
|
96
|
-
methods = [@
|
52
|
+
methods = [@options[:method] || @options[:methods]]
|
97
53
|
methods.compact!
|
98
54
|
methods.flatten!
|
99
55
|
|
100
56
|
if not methods.empty? and methods.all?{|method| method.is_a? String or method.is_a? Symbol }
|
101
57
|
methods.each do |method|
|
102
|
-
|
58
|
+
apply_to_method(method.to_s)
|
103
59
|
end
|
104
60
|
|
105
61
|
return
|
106
62
|
end
|
107
63
|
|
108
|
-
|
109
|
-
|
64
|
+
context.public_instance_methods.each do |method|
|
65
|
+
apply_to_method(method.to_s, :public)
|
110
66
|
end
|
111
67
|
|
112
|
-
|
113
|
-
|
68
|
+
context.protected_instance_methods.each do |method|
|
69
|
+
apply_to_method(method.to_s, :protected)
|
114
70
|
end
|
115
71
|
|
116
|
-
if @
|
117
|
-
|
118
|
-
|
72
|
+
if @options[:private_methods]
|
73
|
+
context.private_instance_methods.each do |method|
|
74
|
+
apply_to_method(method.to_s, :private)
|
119
75
|
end
|
120
76
|
end
|
121
77
|
end
|
122
78
|
|
123
|
-
def
|
124
|
-
|
125
|
-
return if
|
79
|
+
def apply_to_method method, scope = nil
|
80
|
+
filtered_advices = filter_advices advices, method
|
81
|
+
return if filtered_advices.empty?
|
126
82
|
|
127
|
-
|
128
|
-
before_apply_to_method method, advices
|
83
|
+
logger.log Logging::DEBUG, 'apply-to-method', method
|
129
84
|
|
130
85
|
scope ||=
|
131
|
-
if
|
86
|
+
if context.private_instance_methods.include?(RUBY_VERSION.index('1.9') ? method.to_sym : method.to_s)
|
132
87
|
:private
|
133
|
-
elsif
|
88
|
+
elsif context.protected_instance_methods.include?(RUBY_VERSION.index('1.9') ? method.to_sym : method.to_s)
|
134
89
|
:protected
|
135
90
|
else
|
136
91
|
:public
|
137
92
|
end
|
138
93
|
|
139
|
-
|
140
|
-
|
141
|
-
after_apply_to_method method, advices
|
94
|
+
recreate_method method, filtered_advices, scope
|
142
95
|
end
|
143
96
|
|
144
|
-
|
145
|
-
|
146
|
-
# Hook method that runs after an aspect is instantiated
|
147
|
-
def after_initialize
|
148
|
-
end
|
149
|
-
|
150
|
-
# Hook method that runs before an aspect is applied
|
151
|
-
def before_apply
|
152
|
-
end
|
153
|
-
|
154
|
-
# Hook method that runs after an aspect is applied
|
155
|
-
def after_apply
|
156
|
-
end
|
157
|
-
|
158
|
-
def before_apply_to_method method, advices
|
159
|
-
end
|
97
|
+
private
|
160
98
|
|
161
|
-
def
|
99
|
+
def deferred_logic_results logic
|
100
|
+
@deferred_logic_results[logic]
|
162
101
|
end
|
163
102
|
|
164
|
-
|
165
|
-
|
166
|
-
def aop_deferred_logic_results logic
|
167
|
-
@aop_deferred_logic_results[logic]
|
103
|
+
def get_wrapped_method_of method
|
104
|
+
@wrapped_methods[method]
|
168
105
|
end
|
169
106
|
|
170
|
-
|
171
|
-
|
107
|
+
# context is where advices will be applied (i.e. where methods are modified), can be different from target
|
108
|
+
def context
|
109
|
+
return @target if @target.is_a?(Module) and not @options[:class_methods]
|
172
110
|
|
173
|
-
class << @
|
111
|
+
class << @target
|
174
112
|
self
|
175
113
|
end
|
176
114
|
end
|
177
115
|
|
178
|
-
def
|
179
|
-
return unless (logics = self.class.send :
|
116
|
+
def invoke_deferred_logics
|
117
|
+
return unless (logics = self.class.send :_deferred_logics_)
|
180
118
|
|
181
|
-
@aop_deferred_logic_results ||= {}
|
182
119
|
logics.each do |logic|
|
183
|
-
|
120
|
+
result = logic.apply context, self
|
121
|
+
if advices.detect {|advice| advice.use_deferred_logic? logic }
|
122
|
+
@deferred_logic_results ||= {}
|
123
|
+
@deferred_logic_results[logic] = result
|
124
|
+
end
|
184
125
|
end
|
185
126
|
end
|
186
127
|
|
187
|
-
def
|
188
|
-
|
128
|
+
def define_methods_for_advice_blocks
|
129
|
+
advices.each do |advice|
|
189
130
|
next if advice.raw?
|
190
131
|
next unless advice.advice_block
|
191
|
-
|
192
|
-
|
132
|
+
context.send :define_method, advice.with_method, advice.advice_block
|
133
|
+
context.send :private, advice.with_method
|
193
134
|
end
|
194
135
|
end
|
195
136
|
|
196
|
-
def
|
197
|
-
|
137
|
+
def add_to_instances
|
138
|
+
return if advices.empty?
|
139
|
+
|
140
|
+
aspect_instances = context.instance_variable_get(:@aop_instances)
|
198
141
|
unless aspect_instances
|
199
142
|
aspect_instances = AspectInstances.new
|
200
|
-
|
143
|
+
context.instance_variable_set(:@aop_instances, aspect_instances)
|
201
144
|
end
|
202
145
|
aspect_instances << self
|
203
146
|
end
|
204
147
|
|
205
|
-
def
|
206
|
-
if
|
207
|
-
|
148
|
+
def add_method_hooks
|
149
|
+
return if advices.empty?
|
150
|
+
|
151
|
+
if @options[:class_methods]
|
152
|
+
return unless @target.is_a?(Module)
|
208
153
|
|
209
|
-
eigen_class = class << @
|
210
|
-
orig_singleton_method_added = @
|
154
|
+
eigen_class = class << @target; self; end
|
155
|
+
orig_singleton_method_added = @target.method(:singleton_method_added)
|
211
156
|
|
212
157
|
eigen_class.send :define_method, :singleton_method_added do |method|
|
213
158
|
aop_singleton_method_added(method) do
|
@@ -215,10 +160,10 @@ module Aspector
|
|
215
160
|
end
|
216
161
|
end
|
217
162
|
else
|
218
|
-
eigen_class = class << @
|
163
|
+
eigen_class = class << @target; self; end
|
219
164
|
|
220
|
-
if @
|
221
|
-
orig_method_added = @
|
165
|
+
if @target.is_a? Module
|
166
|
+
orig_method_added = @target.method(:method_added)
|
222
167
|
else
|
223
168
|
orig_method_added = eigen_class.method(:method_added)
|
224
169
|
end
|
@@ -231,23 +176,23 @@ module Aspector
|
|
231
176
|
end
|
232
177
|
end
|
233
178
|
|
234
|
-
def
|
179
|
+
def filter_advices advices, method
|
235
180
|
advices.select do |advice|
|
236
181
|
advice.match?(method, self)
|
237
182
|
end
|
238
183
|
end
|
239
184
|
|
240
|
-
def
|
241
|
-
|
185
|
+
def recreate_method method, advices, scope
|
186
|
+
context.instance_variable_set(:@aop_creating_method, true)
|
242
187
|
|
243
188
|
raw_advices = advices.select {|advice| advice.raw? }
|
244
189
|
|
245
190
|
if raw_advices.size > 0
|
246
191
|
raw_advices.each do |advice|
|
247
|
-
if @
|
248
|
-
@
|
192
|
+
if @target.is_a? Module and not @options[:class_methods]
|
193
|
+
@target.class_exec method, self, &advice.advice_block
|
249
194
|
else
|
250
|
-
@
|
195
|
+
@target.instance_exec method, self, &advice.advice_block
|
251
196
|
end
|
252
197
|
end
|
253
198
|
|
@@ -255,11 +200,11 @@ module Aspector
|
|
255
200
|
end
|
256
201
|
|
257
202
|
begin
|
258
|
-
@
|
203
|
+
@wrapped_methods[method] = context.instance_method(method)
|
259
204
|
rescue
|
260
205
|
# ignore undefined method error
|
261
|
-
if @
|
262
|
-
|
206
|
+
if @options[:old_methods_only]
|
207
|
+
logger.log Logging::WARN, 'method-not-found', method
|
263
208
|
end
|
264
209
|
|
265
210
|
return
|
@@ -271,81 +216,87 @@ module Aspector
|
|
271
216
|
|
272
217
|
(around_advices.size - 1).downto(1) do |i|
|
273
218
|
advice = around_advices[i]
|
274
|
-
|
219
|
+
recreate_method_with_advices method, [], [], advice
|
275
220
|
end
|
276
221
|
|
277
|
-
|
222
|
+
recreate_method_with_advices method, before_advices, after_advices, around_advices.first, true
|
278
223
|
|
279
|
-
|
224
|
+
context.send scope, method if scope != :public
|
280
225
|
ensure
|
281
|
-
|
226
|
+
context.send :remove_instance_variable, :@aop_creating_method
|
282
227
|
end
|
283
228
|
|
284
|
-
def
|
229
|
+
def recreate_method_with_advices method, before_advices, after_advices, around_advice, is_outermost = false
|
285
230
|
aspect = self
|
286
231
|
|
287
232
|
code = METHOD_TEMPLATE.result(binding)
|
288
|
-
aspect.
|
289
|
-
|
233
|
+
aspect.logger.log Logging::DEBUG, 'generate-code', method, code
|
234
|
+
context.class_eval code, __FILE__, __LINE__ + 4
|
290
235
|
end
|
291
236
|
|
292
237
|
METHOD_TEMPLATE = ERB.new <<-CODE, nil, "%<>"
|
293
238
|
|
294
|
-
orig_method = aspect.
|
239
|
+
orig_method = aspect.send :get_wrapped_method_of, '<%= method %>'
|
295
240
|
% if around_advice
|
296
241
|
wrapped_method = instance_method(:<%= method %>)
|
297
242
|
% end
|
298
243
|
|
299
244
|
define_method :<%= method %> do |*args, &block|
|
300
|
-
% if
|
301
|
-
aspect.
|
245
|
+
% if logger.visible?(Logging::TRACE)
|
246
|
+
aspect.logger.log <%= Logging::TRACE %>, '<%= method %>', 'enter-generated-method'
|
302
247
|
% end
|
303
248
|
|
304
|
-
if aspect.
|
305
|
-
% if
|
306
|
-
aspect.
|
249
|
+
if aspect.disabled?
|
250
|
+
% if logger.visible?(Logging::TRACE)
|
251
|
+
aspect.logger.log <%= Logging::TRACE %>, '<%= method %>', 'exit--generated-method'
|
307
252
|
% end
|
308
253
|
return orig_method.bind(self).call(*args, &block)
|
309
254
|
end
|
310
255
|
|
311
256
|
% if is_outermost
|
312
|
-
result = catch(:
|
257
|
+
result = catch(:returns) do
|
313
258
|
% end
|
314
259
|
|
315
|
-
% unless before_advices.empty?
|
316
|
-
# Before advices
|
317
|
-
% end
|
318
260
|
% before_advices.each do |advice|
|
319
|
-
|
320
|
-
|
261
|
+
# Before advice: <%= advice.name %>
|
262
|
+
% if logger.visible?(Logging::TRACE)
|
263
|
+
aspect.logger.log <%= Logging::TRACE %>, '<%= method %>', 'before-invoke-advice', '<%= advice.name %>'
|
321
264
|
% end
|
265
|
+
% if advice.advice_code
|
266
|
+
result = (<%= advice.advice_code %>)
|
267
|
+
% else
|
322
268
|
result = <%= advice.with_method %> <%
|
323
269
|
if advice.options[:aspect_arg] %>aspect, <% end %><%
|
324
270
|
if advice.options[:method_arg] %>'<%= method %>', <% end
|
325
271
|
%>*args
|
326
|
-
%
|
327
|
-
|
272
|
+
% end
|
273
|
+
% if logger.visible?(Logging::TRACE)
|
274
|
+
aspect.logger.log <%= Logging::TRACE %>, '<%= method %>', 'after--invoke-advice', '<%= advice.name %>'
|
328
275
|
% end
|
329
276
|
% if advice.options[:skip_if_false]
|
330
277
|
unless result
|
331
|
-
% if
|
332
|
-
aspect.
|
278
|
+
% if logger.visible?(Logging::TRACE)
|
279
|
+
aspect.logger.log <%= Logging::TRACE %>, '<%= method %>', 'exit-method-due-to-before-filter', '<%= advice.name %>'
|
333
280
|
% end
|
334
281
|
return
|
335
|
-
|
282
|
+
end
|
336
283
|
% end
|
337
284
|
% end
|
338
285
|
|
339
286
|
% if around_advice
|
340
|
-
# Around advice
|
341
|
-
% if
|
342
|
-
aspect.
|
287
|
+
# Around advice: <%= around_advice.name %>
|
288
|
+
% if logger.visible?(Logging::TRACE)
|
289
|
+
aspect.logger.log <%= Logging::TRACE %>, '<%= method %>', 'before-invoke-advice', '<%= around_advice.name %>'
|
343
290
|
% end
|
344
|
-
%
|
291
|
+
% if around_advice.advice_code
|
292
|
+
result = (<%= around_advice.advice_code.gsub('INVOKE_PROXY', 'wrapped_method.bind(self).call(*args, &block)') %>)
|
293
|
+
|
294
|
+
% else
|
295
|
+
% if logger.visible?(Logging::TRACE)
|
345
296
|
proxy = lambda do |*args, &block|
|
346
|
-
aspect.
|
297
|
+
aspect.logger.log <%= Logging::TRACE %>, '<%= method %>', 'before-invoke-proxy'
|
347
298
|
res = wrapped_method.bind(self).call *args, &block
|
348
|
-
aspect.
|
299
|
+
aspect.logger.log <%= Logging::TRACE %>, '<%= method %>', 'after--invoke-proxy'
|
349
300
|
res
|
350
301
|
end
|
351
302
|
result = <%= around_advice.with_method %> <%
|
@@ -358,29 +309,33 @@ module Aspector
|
|
358
309
|
if around_advice.options[:method_arg] %>'<%= method %>', <% end
|
359
310
|
%>wrapped_method.bind(self), *args, &block
|
360
311
|
% end
|
361
|
-
%
|
362
|
-
|
312
|
+
% end
|
313
|
+
% if logger.visible?(Logging::TRACE)
|
314
|
+
aspect.logger.log <%= Logging::TRACE %>, '<%= method %>', 'after--invoke-advice', '<%= around_advice.name %>'
|
363
315
|
% end
|
364
316
|
|
365
317
|
% else
|
366
318
|
|
367
319
|
# Invoke original method
|
368
|
-
% if
|
369
|
-
aspect.
|
320
|
+
% if logger.visible?(Logging::TRACE)
|
321
|
+
aspect.logger.log <%= Logging::TRACE %>, '<%= method %>', 'before-wrapped-method'
|
370
322
|
% end
|
371
323
|
result = orig_method.bind(self).call *args, &block
|
372
|
-
% if
|
373
|
-
aspect.
|
324
|
+
% if logger.visible?(Logging::TRACE)
|
325
|
+
aspect.logger.log <%= Logging::TRACE %>, '<%= method %>', 'after--wrapped-method'
|
374
326
|
% end
|
375
327
|
|
376
328
|
% end
|
377
329
|
|
378
330
|
% unless after_advices.empty?
|
379
|
-
# After advices
|
380
331
|
% after_advices.each do |advice|
|
381
|
-
|
382
|
-
|
332
|
+
# After advice: <%= advice.name %>
|
333
|
+
% if logger.visible?(Logging::TRACE)
|
334
|
+
aspect.logger.log <%= Logging::TRACE %>, '<%= method %>', 'before-invoke-advice', '<%= advice.name %>'
|
383
335
|
% end
|
336
|
+
% if advice.advice_code
|
337
|
+
result = (<%= advice.advice_code %>)
|
338
|
+
% else
|
384
339
|
% if advice.options[:result_arg]
|
385
340
|
result = <%= advice.with_method %> <%
|
386
341
|
if advice.options[:aspect_arg] %>aspect, <% end %><%
|
@@ -393,8 +348,9 @@ module Aspector
|
|
393
348
|
if advice.options[:method_arg] %>'<%= method %>', <% end
|
394
349
|
%>*args
|
395
350
|
% end
|
396
|
-
%
|
397
|
-
|
351
|
+
% end
|
352
|
+
% if logger.visible?(Logging::TRACE)
|
353
|
+
aspect.logger.log <%= Logging::TRACE %>, '<%= method %>', 'after--invoke-advice', '<%= advice.name %>'
|
398
354
|
% end
|
399
355
|
% end
|
400
356
|
% end
|
@@ -405,8 +361,8 @@ module Aspector
|
|
405
361
|
end # end of catch
|
406
362
|
% end
|
407
363
|
|
408
|
-
% if
|
409
|
-
aspect.
|
364
|
+
% if logger.visible?(Logging::TRACE)
|
365
|
+
aspect.logger.log <%= Logging::TRACE %>, '<%= method %>', 'exit--generated-method'
|
410
366
|
% end
|
411
367
|
result
|
412
368
|
end
|
@@ -3,144 +3,120 @@ module Aspector
|
|
3
3
|
module ClassMethods
|
4
4
|
::Aspector::Base.extend(self)
|
5
5
|
|
6
|
-
def
|
7
|
-
|
8
|
-
send :define_method, :
|
6
|
+
def enable
|
7
|
+
logger.log Logging::INFO, 'enable-aspect'
|
8
|
+
send :define_method, :disabled? do
|
9
9
|
end
|
10
10
|
|
11
11
|
nil
|
12
12
|
end
|
13
|
-
alias enable aop_enable
|
14
13
|
|
15
|
-
def
|
16
|
-
|
17
|
-
send :define_method, :
|
14
|
+
def disable
|
15
|
+
logger.log Logging::INFO, 'disable-aspect'
|
16
|
+
send :define_method, :disabled? do
|
18
17
|
true
|
19
18
|
end
|
20
19
|
|
21
20
|
nil
|
22
21
|
end
|
23
|
-
alias disable aop_disable
|
24
22
|
|
25
23
|
# if ENV["ASPECTOR_LOGGER"] is set, use it
|
26
24
|
# else try to load logem and use Logem::Logger
|
27
25
|
# else use built in logger
|
28
|
-
def
|
29
|
-
@
|
26
|
+
def logger
|
27
|
+
@logger ||= Logging.get_logger(self)
|
30
28
|
end
|
31
|
-
alias logger aop_logger
|
32
29
|
|
33
|
-
def
|
34
|
-
@
|
30
|
+
def advices
|
31
|
+
@advices ||= []
|
35
32
|
end
|
36
|
-
alias logger= aop_logger=
|
37
33
|
|
38
|
-
def
|
39
|
-
@
|
34
|
+
def default_options
|
35
|
+
@default_options ||= {}
|
40
36
|
end
|
41
|
-
alias advices aop_advices
|
42
37
|
|
43
|
-
def
|
44
|
-
@aop_default_options ||= {}
|
45
|
-
end
|
46
|
-
alias default_options aop_default_options
|
47
|
-
|
48
|
-
def aop_apply target, *rest
|
38
|
+
def apply target, *rest
|
49
39
|
options = rest.last.is_a?(Hash) ? rest.pop : {}
|
50
40
|
|
51
41
|
targets = rest.unshift target
|
52
42
|
result = targets.map do |target|
|
53
|
-
|
43
|
+
logger.log Logging::INFO, 'apply', target, options.inspect
|
54
44
|
aspect_instance = new(target, options)
|
55
|
-
aspect_instance.send :
|
45
|
+
aspect_instance.send :apply
|
56
46
|
aspect_instance
|
57
47
|
end
|
58
48
|
|
59
49
|
result.size == 1 ? result.first : result
|
60
50
|
end
|
61
|
-
|
51
|
+
|
52
|
+
private
|
62
53
|
|
63
|
-
def
|
64
|
-
if @
|
65
|
-
@
|
54
|
+
def default options
|
55
|
+
if @default_options
|
56
|
+
@default_options.merge! options
|
66
57
|
else
|
67
|
-
@
|
58
|
+
@default_options = options
|
68
59
|
end
|
69
60
|
end
|
70
|
-
alias default aop_default
|
71
61
|
|
72
|
-
def
|
73
|
-
|
74
|
-
advice.index =
|
75
|
-
|
62
|
+
def before *methods, &block
|
63
|
+
advices << advice = _create_advice_(Aspector::AdviceMetadata::BEFORE, self, methods, &block)
|
64
|
+
advice.index = advices.size
|
65
|
+
logger.log Logging::INFO, 'define-advice', advice
|
76
66
|
advice
|
77
67
|
end
|
78
|
-
alias before aop_before
|
79
68
|
|
80
|
-
def
|
81
|
-
|
82
|
-
advice.index =
|
83
|
-
|
69
|
+
def before_filter *methods, &block
|
70
|
+
advices << advice = _create_advice_(Aspector::AdviceMetadata::BEFORE_FILTER, self, methods, &block)
|
71
|
+
advice.index = advices.size
|
72
|
+
logger.log Logging::INFO, 'define-advice', advice
|
84
73
|
advice
|
85
74
|
end
|
86
|
-
alias before_filter aop_before_filter
|
87
75
|
|
88
|
-
def
|
89
|
-
|
90
|
-
advice.index =
|
91
|
-
|
76
|
+
def after *methods, &block
|
77
|
+
advices << advice = _create_advice_(Aspector::AdviceMetadata::AFTER, self, methods, &block)
|
78
|
+
advice.index = advices.size
|
79
|
+
logger.log Logging::INFO, 'define-advice', advice
|
92
80
|
advice
|
93
81
|
end
|
94
|
-
alias after aop_after
|
95
82
|
|
96
|
-
def
|
97
|
-
|
98
|
-
advice.index =
|
99
|
-
|
83
|
+
def around *methods, &block
|
84
|
+
advices << advice = _create_advice_(Aspector::AdviceMetadata::AROUND, self, methods, &block)
|
85
|
+
advice.index = advices.size
|
86
|
+
logger.log Logging::INFO, 'define-advice', advice
|
100
87
|
advice
|
101
88
|
end
|
102
|
-
alias around aop_around
|
103
89
|
|
104
|
-
def
|
105
|
-
|
106
|
-
advice.index =
|
107
|
-
|
90
|
+
def raw *methods, &block
|
91
|
+
advices << advice = _create_advice_(Aspector::AdviceMetadata::RAW, self, methods, &block)
|
92
|
+
advice.index = advices.size
|
93
|
+
logger.log Logging::INFO, 'define-advice', advice
|
108
94
|
advice
|
109
95
|
end
|
110
|
-
alias raw aop_raw
|
111
96
|
|
112
|
-
def
|
113
|
-
|
97
|
+
def target code = nil, &block
|
98
|
+
raise ArgumentError.new('No code or block is passed.') unless code or block_given?
|
114
99
|
|
115
100
|
logic = DeferredLogic.new(code || block)
|
116
|
-
|
101
|
+
_deferred_logics_ << logic
|
117
102
|
logic
|
118
103
|
end
|
119
|
-
alias target aop_target
|
120
104
|
|
121
|
-
def
|
105
|
+
def options
|
122
106
|
DeferredOption.new
|
123
107
|
end
|
124
|
-
alias options aop_options
|
125
|
-
|
126
|
-
private
|
127
108
|
|
128
|
-
def
|
129
|
-
@
|
109
|
+
def _deferred_logics_
|
110
|
+
@deferred_logics ||= []
|
130
111
|
end
|
131
112
|
|
132
|
-
def
|
113
|
+
def _create_advice_ meta_data, klass_or_module, *methods, &block
|
133
114
|
methods.flatten!
|
134
115
|
|
135
116
|
options = meta_data.default_options.clone
|
136
117
|
options.merge!(methods.pop) if methods.last.is_a? Hash
|
137
118
|
options.merge!(meta_data.mandatory_options)
|
138
119
|
|
139
|
-
# Convert symbols to strings to avoid inconsistencies
|
140
|
-
methods.size.times do |i|
|
141
|
-
methods[i] = methods[i].to_s if methods[i].is_a? Symbol
|
142
|
-
end
|
143
|
-
|
144
120
|
if meta_data.advice_type == Aspector::Advice::RAW
|
145
121
|
raise "Bad raw advice - code block is required" unless block_given?
|
146
122
|
with_method = nil
|
@@ -148,7 +124,12 @@ module Aspector
|
|
148
124
|
with_method = methods.pop unless block_given?
|
149
125
|
end
|
150
126
|
|
151
|
-
|
127
|
+
# Convert symbols to strings to avoid inconsistencies
|
128
|
+
methods.size.times do |i|
|
129
|
+
methods[i] = methods[i].to_s if methods[i].is_a? Symbol
|
130
|
+
end
|
131
|
+
|
132
|
+
methods << DeferredOption.new(:method) << DeferredOption.new(:methods) if methods.empty?
|
152
133
|
|
153
134
|
Aspector::Advice.new(self,
|
154
135
|
meta_data.advice_type,
|
@@ -2,14 +2,22 @@ module Aspector
|
|
2
2
|
class DeferredOption
|
3
3
|
|
4
4
|
attr_reader :key
|
5
|
+
|
6
|
+
def initialize key = nil
|
7
|
+
@key = key
|
8
|
+
end
|
5
9
|
|
6
10
|
def [] key
|
7
11
|
@key = key
|
8
12
|
self
|
9
13
|
end
|
10
14
|
|
11
|
-
def
|
12
|
-
|
15
|
+
def to_s
|
16
|
+
if key
|
17
|
+
"options[#{key.inspect}]"
|
18
|
+
else
|
19
|
+
"options[?]"
|
20
|
+
end
|
13
21
|
end
|
14
22
|
end
|
15
23
|
end
|
data/lib/aspector/logger.rb
CHANGED
@@ -29,7 +29,7 @@ module Aspector
|
|
29
29
|
def log_prefix level
|
30
30
|
s = "#{Time.now} | Aspector | " << level_to_string(level) << " | "
|
31
31
|
if context.is_a? Aspector::Base
|
32
|
-
s << context.class.to_s << " | " << context.
|
32
|
+
s << context.class.to_s << " | " << context.target.to_s << " | "
|
33
33
|
else
|
34
34
|
s << context.to_s << " | "
|
35
35
|
end
|
@@ -15,13 +15,13 @@ module Aspector
|
|
15
15
|
when Symbol
|
16
16
|
item.to_s == method
|
17
17
|
when DeferredLogic
|
18
|
-
value = aspect.
|
18
|
+
value = aspect.deferred_logic_results(item)
|
19
19
|
if value
|
20
20
|
new_matcher = MethodMatcher.new(value)
|
21
21
|
new_matcher.match?(method)
|
22
22
|
end
|
23
23
|
when DeferredOption
|
24
|
-
value = aspect.
|
24
|
+
value = aspect.options[item.key]
|
25
25
|
if value
|
26
26
|
new_matcher = MethodMatcher.new(value)
|
27
27
|
new_matcher.match?(method)
|
@@ -29,6 +29,12 @@ module Aspector
|
|
29
29
|
end
|
30
30
|
end
|
31
31
|
end
|
32
|
+
|
33
|
+
def use_deferred_logic? logic
|
34
|
+
@match_data.detect do |item|
|
35
|
+
logic == item
|
36
|
+
end
|
37
|
+
end
|
32
38
|
|
33
39
|
def to_s
|
34
40
|
@match_data.map {|item| item.inspect }.join ", "
|
@@ -8,23 +8,23 @@ module Aspector
|
|
8
8
|
|
9
9
|
aspect = Aspector(options, &block)
|
10
10
|
|
11
|
-
aspect.
|
12
|
-
args.each {|target| aspect.
|
11
|
+
aspect.apply(self) if self.is_a? Module
|
12
|
+
args.each {|target| aspect.apply(target) }
|
13
13
|
|
14
14
|
aspect
|
15
15
|
end
|
16
16
|
|
17
17
|
def Aspector options = {}, &block
|
18
18
|
klass = Class.new(Aspector::Base)
|
19
|
-
klass.
|
19
|
+
klass.class_eval { default options }
|
20
20
|
klass.class_eval &block if block_given?
|
21
21
|
klass
|
22
22
|
end
|
23
23
|
|
24
|
-
def
|
25
|
-
throw :
|
24
|
+
def returns value = nil
|
25
|
+
throw :returns, value
|
26
26
|
end
|
27
|
-
alias :returns :
|
27
|
+
alias :returns :returns
|
28
28
|
|
29
29
|
end
|
30
30
|
end
|
data/run_all_examples.sh
ADDED
data/spec/unit/around_spec.rb
CHANGED
@@ -20,6 +20,23 @@ describe "Around advices" do
|
|
20
20
|
obj.value.should == %w"before test after"
|
21
21
|
end
|
22
22
|
|
23
|
+
it "logic in String" do
|
24
|
+
klass = create_test_class
|
25
|
+
|
26
|
+
aspector(klass) do
|
27
|
+
around :test, <<-CODE
|
28
|
+
value << "before"
|
29
|
+
result = INVOKE_PROXY
|
30
|
+
value << "after"
|
31
|
+
result
|
32
|
+
CODE
|
33
|
+
end
|
34
|
+
|
35
|
+
obj = klass.new
|
36
|
+
obj.test
|
37
|
+
obj.value.should == %w"before test after"
|
38
|
+
end
|
39
|
+
|
23
40
|
it "logic in block" do
|
24
41
|
klass = create_test_class
|
25
42
|
|
@@ -6,11 +6,11 @@ describe "Aspector::Base class methods" do
|
|
6
6
|
before :test, :do_before
|
7
7
|
end
|
8
8
|
|
9
|
-
klass.send(:
|
10
|
-
advice = klass.send(:
|
9
|
+
klass.send(:advices).size.should == 1
|
10
|
+
advice = klass.send(:advices).first
|
11
11
|
advice.before?.should be_true
|
12
12
|
advice.options[:skip_if_false].should_not be_true
|
13
|
-
advice.with_method.should ==
|
13
|
+
advice.with_method.should == :do_before
|
14
14
|
end
|
15
15
|
|
16
16
|
it "before_filter" do
|
@@ -18,11 +18,11 @@ describe "Aspector::Base class methods" do
|
|
18
18
|
before_filter :test, :do_before
|
19
19
|
end
|
20
20
|
|
21
|
-
klass.send(:
|
22
|
-
advice = klass.send(:
|
21
|
+
klass.send(:advices).size.should == 1
|
22
|
+
advice = klass.send(:advices).first
|
23
23
|
advice.before?.should be_true
|
24
24
|
advice.options[:skip_if_false].should be_true
|
25
|
-
advice.with_method.should ==
|
25
|
+
advice.with_method.should == :do_before
|
26
26
|
end
|
27
27
|
|
28
28
|
end
|
data/spec/unit/base_spec.rb
CHANGED
data/spec/unit/before_spec.rb
CHANGED
@@ -29,6 +29,18 @@ describe "Before advices" do
|
|
29
29
|
obj.value.should == %w"do_block test"
|
30
30
|
end
|
31
31
|
|
32
|
+
it "logic in String" do
|
33
|
+
klass = create_test_class
|
34
|
+
|
35
|
+
aspector(klass) do
|
36
|
+
before :test, "value << 'do_block'"
|
37
|
+
end
|
38
|
+
|
39
|
+
obj = klass.new
|
40
|
+
obj.test
|
41
|
+
obj.value.should == %w"do_block test"
|
42
|
+
end
|
43
|
+
|
32
44
|
it "new methods should work" do
|
33
45
|
klass = Class.new do
|
34
46
|
aspector do
|
@@ -23,7 +23,7 @@ module Aspector
|
|
23
23
|
matcher = MethodMatcher.new(logic)
|
24
24
|
|
25
25
|
aspect = mock(Aspector::Base)
|
26
|
-
aspect.should_receive(:
|
26
|
+
aspect.should_receive(:deferred_logic_results).with(logic).once.and_return(/test/)
|
27
27
|
|
28
28
|
matcher.match?('test', aspect).should_not be_nil
|
29
29
|
end
|
@@ -33,7 +33,7 @@ module Aspector
|
|
33
33
|
matcher = MethodMatcher.new(option)
|
34
34
|
|
35
35
|
aspect = mock(Aspector::Base)
|
36
|
-
aspect.should_receive(:
|
36
|
+
aspect.should_receive(:options).once.and_return({:methods => /test/})
|
37
37
|
|
38
38
|
matcher.match?('test', aspect).should_not be_nil
|
39
39
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: aspector
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.13.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2013-01-04 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|
@@ -128,17 +128,17 @@ dependencies:
|
|
128
128
|
requirement: !ruby/object:Gem::Requirement
|
129
129
|
none: false
|
130
130
|
requirements:
|
131
|
-
- -
|
131
|
+
- - ! '>='
|
132
132
|
- !ruby/object:Gem::Version
|
133
|
-
version: 0
|
133
|
+
version: '0'
|
134
134
|
type: :development
|
135
135
|
prerelease: false
|
136
136
|
version_requirements: !ruby/object:Gem::Requirement
|
137
137
|
none: false
|
138
138
|
requirements:
|
139
|
-
- -
|
139
|
+
- - ! '>='
|
140
140
|
- !ruby/object:Gem::Version
|
141
|
-
version: 0
|
141
|
+
version: '0'
|
142
142
|
- !ruby/object:Gem::Dependency
|
143
143
|
name: growl
|
144
144
|
requirement: !ruby/object:Gem::Requirement
|
@@ -239,6 +239,7 @@ files:
|
|
239
239
|
- performance-tests/method_invocation_test.rb
|
240
240
|
- performance-tests/raw_test.rb
|
241
241
|
- performance-tests/test_helper.rb
|
242
|
+
- run_all_examples.sh
|
242
243
|
- spec/functional/advices_on_private_methods_spec.rb
|
243
244
|
- spec/functional/aspect_on_eigen_class_spec.rb
|
244
245
|
- spec/functional/aspect_on_object_spec.rb
|
@@ -271,7 +272,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
271
272
|
version: '0'
|
272
273
|
segments:
|
273
274
|
- 0
|
274
|
-
hash:
|
275
|
+
hash: -866779375770691873
|
275
276
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
276
277
|
none: false
|
277
278
|
requirements:
|
@@ -280,7 +281,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
280
281
|
version: '0'
|
281
282
|
requirements: []
|
282
283
|
rubyforge_project:
|
283
|
-
rubygems_version: 1.8.
|
284
|
+
rubygems_version: 1.8.24
|
284
285
|
signing_key:
|
285
286
|
specification_version: 3
|
286
287
|
summary: Aspect Oriented Ruby Programming
|