aspector 0.11.1 → 0.12.0
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/aspector.gemspec +2 -2
- data/examples/cache_aspect.rb +2 -2
- data/examples/exception_handler.rb +1 -1
- data/examples/implicit_method_option_test.rb +1 -1
- data/examples/retry_aspect.rb +1 -1
- data/lib/aspector/base.rb +4 -0
- data/lib/aspector/base_class_methods.rb +0 -12
- data/lib/aspector/logger.rb +3 -0
- data/spec/unit/before_spec.rb +4 -24
- metadata +3 -3
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.12.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.12.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 = "2012-
|
12
|
+
s.date = "2012-07-02"
|
13
13
|
s.description = ""
|
14
14
|
s.email = "gcao99@gmail.com"
|
15
15
|
s.extra_rdoc_files = [
|
data/examples/cache_aspect.rb
CHANGED
data/examples/retry_aspect.rb
CHANGED
data/lib/aspector/base.rb
CHANGED
@@ -254,6 +254,10 @@ module Aspector
|
|
254
254
|
@aop_wrapped_methods[method] = @aop_context.instance_method(method)
|
255
255
|
rescue
|
256
256
|
# ignore undefined method error
|
257
|
+
if @aop_options[:old_methods_only]
|
258
|
+
aop_logger.log Logger::METHOD_NOT_FOUND, method
|
259
|
+
end
|
260
|
+
|
257
261
|
return
|
258
262
|
end
|
259
263
|
|
@@ -39,18 +39,6 @@ module Aspector
|
|
39
39
|
|
40
40
|
def aop_apply target, options = {}
|
41
41
|
aop_logger.log Logger::APPLY, target, options.inspect
|
42
|
-
# Handle 'Klass#method' and 'Klass.method' shortcut
|
43
|
-
if target.is_a? String
|
44
|
-
if target.index('.')
|
45
|
-
target, method = target.split('.')
|
46
|
-
target = Object.const_get target
|
47
|
-
options.merge! :method => method, :class_methods => true
|
48
|
-
else
|
49
|
-
target, method = target.split('#')
|
50
|
-
target = Object.const_get target
|
51
|
-
options.merge! :method => method
|
52
|
-
end
|
53
|
-
end
|
54
42
|
|
55
43
|
aspect_instance = new(target, options)
|
56
44
|
aspect_instance.send :aop_apply
|
data/lib/aspector/logger.rb
CHANGED
@@ -27,6 +27,9 @@ module Aspector
|
|
27
27
|
BEFORE_INVOKE_PROXY = ["before-invoke-proxy" , TRACE]
|
28
28
|
AFTER_INVOKE_PROXY = ["after--invoke-proxy" , TRACE]
|
29
29
|
|
30
|
+
# Unexpected behaviors
|
31
|
+
METHOD_NOT_FOUND = ["method-not-found" , WARN]
|
32
|
+
|
30
33
|
attr_reader :context
|
31
34
|
attr_writer :level
|
32
35
|
|
data/spec/unit/before_spec.rb
CHANGED
@@ -78,17 +78,17 @@ describe "Before advices" do
|
|
78
78
|
end
|
79
79
|
|
80
80
|
it "implicit method option" do
|
81
|
-
|
81
|
+
klass = create_test_class do
|
82
82
|
def do_this
|
83
83
|
value << "do_this"
|
84
84
|
end
|
85
85
|
end
|
86
86
|
|
87
|
-
aspector
|
87
|
+
aspector klass, :method => [:test] do
|
88
88
|
before :do_this
|
89
89
|
end
|
90
90
|
|
91
|
-
o =
|
91
|
+
o = klass.new
|
92
92
|
o.test
|
93
93
|
o.value.should == %w"do_this test"
|
94
94
|
end
|
@@ -104,30 +104,10 @@ describe "Before advices" do
|
|
104
104
|
before :do_this
|
105
105
|
end
|
106
106
|
|
107
|
-
o =
|
107
|
+
o = klass.new
|
108
108
|
o.test
|
109
109
|
o.value.should == %w"do_this test"
|
110
110
|
end
|
111
111
|
|
112
|
-
it "klass.method shortcut" do
|
113
|
-
module KlassMethodTest
|
114
|
-
def self.value
|
115
|
-
@value ||= []
|
116
|
-
end
|
117
|
-
|
118
|
-
def self.test
|
119
|
-
value << "test"
|
120
|
-
end
|
121
|
-
end
|
122
|
-
|
123
|
-
aspector "KlassMethodTest.test" do
|
124
|
-
before do
|
125
|
-
value << "before"
|
126
|
-
end
|
127
|
-
end
|
128
|
-
|
129
|
-
KlassMethodTest.test.should == %w"before test"
|
130
|
-
end
|
131
|
-
|
132
112
|
end
|
133
113
|
|
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.12.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: 2012-
|
12
|
+
date: 2012-07-02 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|
@@ -267,7 +267,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
267
267
|
version: '0'
|
268
268
|
segments:
|
269
269
|
- 0
|
270
|
-
hash:
|
270
|
+
hash: -1253931844087075152
|
271
271
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
272
272
|
none: false
|
273
273
|
requirements:
|