aspector 0.11.1 → 0.12.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/VERSION CHANGED
@@ -1 +1 @@
1
- 0.11.1
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.11.1"
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-06-27"
12
+ s.date = "2012-07-02"
13
13
  s.description = ""
14
14
  s.email = "gcao99@gmail.com"
15
15
  s.extra_rdoc_files = [
@@ -59,8 +59,8 @@ end
59
59
 
60
60
  ##############################
61
61
 
62
- CacheAspect.apply "A#test", :ttl => 2 # 2 seconds
63
- CacheAspect.apply "A#test2"
62
+ CacheAspect.apply A, :method => "test", :ttl => 2 # 2 seconds
63
+ CacheAspect.apply A, :method => "test2"
64
64
 
65
65
  a = A.new
66
66
 
@@ -28,7 +28,7 @@ end
28
28
 
29
29
  ##############################
30
30
 
31
- ExceptionHandler.apply "A#test"
31
+ ExceptionHandler.apply A, :method => "test"
32
32
 
33
33
  a = A.new
34
34
  a.test 'good'
@@ -19,7 +19,7 @@ class ImplicitMethodOptionTest < Aspector::Base
19
19
  end
20
20
 
21
21
  # ImplicitMethodOptionTest.apply A, :method => 'test'
22
- ImplicitMethodOptionTest.apply "A#test"
22
+ ImplicitMethodOptionTest.apply A, :method => "test"
23
23
 
24
24
  ##############################
25
25
 
@@ -34,7 +34,7 @@ end
34
34
 
35
35
  ##############################
36
36
 
37
- RetryAspect.apply "A#test"
37
+ RetryAspect.apply A, :method => "test"
38
38
 
39
39
  a = A.new
40
40
  a.test
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
@@ -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
 
@@ -78,17 +78,17 @@ describe "Before advices" do
78
78
  end
79
79
 
80
80
  it "implicit method option" do
81
- ImplicitMethodOptionTest = create_test_class do
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 "ImplicitMethodOptionTest#test" do
87
+ aspector klass, :method => [:test] do
88
88
  before :do_this
89
89
  end
90
90
 
91
- o = ImplicitMethodOptionTest.new
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 = ImplicitMethodOptionTest.new
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.11.1
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-06-27 00:00:00.000000000 Z
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: 4044102942176431423
270
+ hash: -1253931844087075152
271
271
  required_rubygems_version: !ruby/object:Gem::Requirement
272
272
  none: false
273
273
  requirements: