aspector 0.11.0 → 0.11.1

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.11.0
1
+ 0.11.1
data/aspector.gemspec CHANGED
@@ -4,14 +4,14 @@
4
4
  # -*- encoding: utf-8 -*-
5
5
 
6
6
  Gem::Specification.new do |s|
7
- s.name = %q{aspector}
8
- s.version = "0.11.0"
7
+ s.name = "aspector"
8
+ s.version = "0.11.1"
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 = %q{2012-04-15}
13
- s.description = %q{}
14
- s.email = %q{gcao99@gmail.com}
12
+ s.date = "2012-06-27"
13
+ s.description = ""
14
+ s.email = "gcao99@gmail.com"
15
15
  s.extra_rdoc_files = [
16
16
  "LICENSE.txt",
17
17
  "README.rdoc"
@@ -75,11 +75,11 @@ Gem::Specification.new do |s|
75
75
  "spec/unit/method_matcher_spec.rb",
76
76
  "spec/unit/raw_spec.rb"
77
77
  ]
78
- s.homepage = %q{http://github.com/gcao/aspector}
78
+ s.homepage = "http://github.com/gcao/aspector"
79
79
  s.licenses = ["MIT"]
80
80
  s.require_paths = ["lib"]
81
- s.rubygems_version = %q{1.6.2}
82
- s.summary = %q{Aspect Oriented Ruby Programming}
81
+ s.rubygems_version = "1.8.18"
82
+ s.summary = "Aspect Oriented Ruby Programming"
83
83
 
84
84
  if s.respond_to? :specification_version then
85
85
  s.specification_version = 3
data/lib/aspector/base.rb CHANGED
@@ -250,7 +250,12 @@ module Aspector
250
250
  return if raw_advices.size == advices.size
251
251
  end
252
252
 
253
- @aop_wrapped_methods[method] = @aop_context.instance_method(method)
253
+ begin
254
+ @aop_wrapped_methods[method] = @aop_context.instance_method(method)
255
+ rescue
256
+ # ignore undefined method error
257
+ return
258
+ end
254
259
 
255
260
  before_advices = advices.select {|advice| advice.before? }
256
261
  after_advices = advices.select {|advice| advice.after? }
@@ -10,23 +10,22 @@ module Aspector
10
10
  DEFAULT_VISIBLE_LEVEL = INFO
11
11
 
12
12
  # Actions
13
- DEFINE_ADVICE = %W"define-advice"
14
- APPLY = %W"apply"
15
- APPLY_TO_METHOD = %W"apply-to-method #{DEBUG}"
16
- ENABLE_ASPECT = %W"enable-aspect"
17
- DISABLE_ASPECT = %W"disable-aspect"
18
-
19
- GENERATE_CODE = %W"generate-code #{DEBUG}"
20
-
21
- ENTER_GENERATED_METHOD = %W"enter-generated-method #{TRACE}"
22
- EXIT_GENERATED_METHOD = %W"exit--generated-method #{TRACE}"
23
- EXIT_BECAUSE_DISABLED = %W"exit--because-disabled #{TRACE}"
24
- BEFORE_INVOKE_ADVICE = %W"before-invoke-advice #{TRACE}"
25
- AFTER_INVOKE_ADVICE = %W"after--invoke-advice #{TRACE}"
26
- BEFORE_WRAPPED_METHOD = %W"before-wrapped-method #{TRACE}"
27
- AFTER_WRAPPED_METHOD = %W"after--wrapped-method #{TRACE}"
28
- BEFORE_INVOKE_PROXY = %W"before-invoke-proxy #{TRACE}"
29
- AFTER_INVOKE_PROXY = %W"after--invoke-proxy #{TRACE}"
13
+ DEFINE_ADVICE = ["define-advice" , INFO]
14
+ APPLY = ["apply" , INFO]
15
+ APPLY_TO_METHOD = ["apply-to-method", DEBUG]
16
+ ENABLE_ASPECT = ["enable-aspect" , INFO]
17
+ DISABLE_ASPECT = ["disable-aspect" , INFO]
18
+ GENERATE_CODE = ["generate-code" , DEBUG]
19
+
20
+ ENTER_GENERATED_METHOD = ["enter-generated-method", TRACE]
21
+ EXIT_GENERATED_METHOD = ["exit--generated-method", TRACE]
22
+ EXIT_BECAUSE_DISABLED = ["exit--because-disabled", TRACE]
23
+ BEFORE_INVOKE_ADVICE = ["before-invoke-advice" , TRACE]
24
+ AFTER_INVOKE_ADVICE = ["after--invoke-advice" , TRACE]
25
+ BEFORE_WRAPPED_METHOD = ["before-wrapped-method" , TRACE]
26
+ AFTER_WRAPPED_METHOD = ["after--wrapped-method" , TRACE]
27
+ BEFORE_INVOKE_PROXY = ["before-invoke-proxy" , TRACE]
28
+ AFTER_INVOKE_PROXY = ["after--invoke-proxy" , TRACE]
30
29
 
31
30
  attr_reader :context
32
31
  attr_writer :level
@@ -47,7 +46,7 @@ module Aspector
47
46
  end
48
47
 
49
48
  def log action_level, *args
50
- action, level = parse_action_level(action_level)
49
+ action, level = *action_level
51
50
 
52
51
  return if self.level > level
53
52
 
@@ -55,7 +54,7 @@ module Aspector
55
54
  end
56
55
 
57
56
  def log_method_call method, action_level, *args
58
- action, level = parse_action_level(action_level)
57
+ action, level = *action_level
59
58
 
60
59
  return if self.level > level
61
60
 
@@ -68,12 +67,6 @@ module Aspector
68
67
 
69
68
  private
70
69
 
71
- def parse_action_level action_level
72
- action = action_level[0]
73
- level = (action_level[1] || INFO).to_i
74
- return action, level
75
- end
76
-
77
70
  def log_prefix level
78
71
  s = "Aspector | " << level_to_string(level) << " | "
79
72
  if context.is_a? Aspector::Base
@@ -95,7 +88,7 @@ module Aspector
95
88
  end
96
89
 
97
90
  def string_to_level level_string
98
- return if level_string.nil? or level_string.strip == ''
91
+ return DEFAULT_VISIBLE_LEVEL if level_string.nil? or level_string.strip == ''
99
92
 
100
93
  case level_string.downcase
101
94
  when 'error' then ERROR
data/spec/spec_helper.rb CHANGED
@@ -1,3 +1,5 @@
1
+ ENV["ASPECTOR_LOG_LEVEL"] ||= "warn"
2
+
1
3
  $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
2
4
  $LOAD_PATH.unshift(File.dirname(__FILE__))
3
5
  require 'rspec'
@@ -77,5 +77,17 @@ describe "Aspector::Base" do
77
77
  obj.value.should == %w"do_this(TargetArgumentTestAspect) test"
78
78
  end
79
79
 
80
+ it "should not fail if method does not exist" do
81
+ klass = Class.new
82
+
83
+ aspect = Aspector do
84
+ before options[:methods] do
85
+ # dummy advice
86
+ end
87
+ end
88
+
89
+ aspect.apply(klass, :methods => 'not_exist')
90
+ end
91
+
80
92
  end
81
93
 
metadata CHANGED
@@ -1,202 +1,200 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: aspector
3
- version: !ruby/object:Gem::Version
4
- hash: 51
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.11.1
5
5
  prerelease:
6
- segments:
7
- - 0
8
- - 11
9
- - 0
10
- version: 0.11.0
11
6
  platform: ruby
12
- authors:
7
+ authors:
13
8
  - Guoliang Cao
14
9
  autorequire:
15
10
  bindir: bin
16
11
  cert_chain: []
17
-
18
- date: 2012-04-15 00:00:00 -04:00
19
- default_executable:
20
- dependencies:
21
- - !ruby/object:Gem::Dependency
22
- prerelease: false
23
- type: :development
24
- requirement: &id001 !ruby/object:Gem::Requirement
25
- none: false
26
- requirements:
27
- - - ">="
28
- - !ruby/object:Gem::Version
29
- hash: 3
30
- segments:
31
- - 0
32
- version: "0"
12
+ date: 2012-06-27 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
33
15
  name: rspec
34
- version_requirements: *id001
35
- - !ruby/object:Gem::Dependency
36
- prerelease: false
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
37
22
  type: :development
38
- requirement: &id002 !ruby/object:Gem::Requirement
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
30
+ - !ruby/object:Gem::Dependency
31
+ name: jeweler
32
+ requirement: !ruby/object:Gem::Requirement
39
33
  none: false
40
- requirements:
34
+ requirements:
41
35
  - - ~>
42
- - !ruby/object:Gem::Version
43
- hash: 7
44
- segments:
45
- - 1
46
- - 6
47
- - 4
36
+ - !ruby/object:Gem::Version
48
37
  version: 1.6.4
49
- name: jeweler
50
- version_requirements: *id002
51
- - !ruby/object:Gem::Dependency
52
- prerelease: false
53
38
  type: :development
54
- requirement: &id003 !ruby/object:Gem::Requirement
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
55
41
  none: false
56
- requirements:
57
- - - ">="
58
- - !ruby/object:Gem::Version
59
- hash: 3
60
- segments:
61
- - 0
62
- version: "0"
42
+ requirements:
43
+ - - ~>
44
+ - !ruby/object:Gem::Version
45
+ version: 1.6.4
46
+ - !ruby/object:Gem::Dependency
63
47
  name: ruby-prof
64
- version_requirements: *id003
65
- - !ruby/object:Gem::Dependency
66
- prerelease: false
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
67
54
  type: :development
68
- requirement: &id004 !ruby/object:Gem::Requirement
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
69
57
  none: false
70
- requirements:
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ - !ruby/object:Gem::Dependency
63
+ name: guard
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
71
67
  - - ~>
72
- - !ruby/object:Gem::Version
73
- hash: 55
74
- segments:
75
- - 0
76
- - 8
77
- - 4
68
+ - !ruby/object:Gem::Version
78
69
  version: 0.8.4
79
- name: guard
80
- version_requirements: *id004
81
- - !ruby/object:Gem::Dependency
82
- prerelease: false
83
70
  type: :development
84
- requirement: &id005 !ruby/object:Gem::Requirement
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
85
73
  none: false
86
- requirements:
74
+ requirements:
87
75
  - - ~>
88
- - !ruby/object:Gem::Version
89
- hash: 29
90
- segments:
91
- - 0
92
- - 1
93
- - 3
94
- version: 0.1.3
76
+ - !ruby/object:Gem::Version
77
+ version: 0.8.4
78
+ - !ruby/object:Gem::Dependency
95
79
  name: guard-bundler
96
- version_requirements: *id005
97
- - !ruby/object:Gem::Dependency
98
- prerelease: false
80
+ requirement: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - ~>
84
+ - !ruby/object:Gem::Version
85
+ version: 0.1.3
99
86
  type: :development
100
- requirement: &id006 !ruby/object:Gem::Requirement
87
+ prerelease: false
88
+ version_requirements: !ruby/object:Gem::Requirement
101
89
  none: false
102
- requirements:
90
+ requirements:
103
91
  - - ~>
104
- - !ruby/object:Gem::Version
105
- hash: 15
106
- segments:
107
- - 0
108
- - 5
109
- - 2
110
- version: 0.5.2
92
+ - !ruby/object:Gem::Version
93
+ version: 0.1.3
94
+ - !ruby/object:Gem::Dependency
111
95
  name: guard-rspec
112
- version_requirements: *id006
113
- - !ruby/object:Gem::Dependency
114
- prerelease: false
96
+ requirement: !ruby/object:Gem::Requirement
97
+ none: false
98
+ requirements:
99
+ - - ~>
100
+ - !ruby/object:Gem::Version
101
+ version: 0.5.2
115
102
  type: :development
116
- requirement: &id007 !ruby/object:Gem::Requirement
103
+ prerelease: false
104
+ version_requirements: !ruby/object:Gem::Requirement
117
105
  none: false
118
- requirements:
106
+ requirements:
119
107
  - - ~>
120
- - !ruby/object:Gem::Version
121
- hash: 25
122
- segments:
123
- - 0
124
- - 1
125
- - 1
126
- version: 0.1.1
108
+ - !ruby/object:Gem::Version
109
+ version: 0.5.2
110
+ - !ruby/object:Gem::Dependency
127
111
  name: guard-shell
128
- version_requirements: *id007
129
- - !ruby/object:Gem::Dependency
130
- prerelease: false
112
+ requirement: !ruby/object:Gem::Requirement
113
+ none: false
114
+ requirements:
115
+ - - ~>
116
+ - !ruby/object:Gem::Version
117
+ version: 0.1.1
131
118
  type: :development
132
- requirement: &id008 !ruby/object:Gem::Requirement
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
133
121
  none: false
134
- requirements:
122
+ requirements:
135
123
  - - ~>
136
- - !ruby/object:Gem::Version
137
- hash: 97
138
- segments:
139
- - 0
140
- - 4
141
- - 3
142
- - 1
143
- version: 0.4.3.1
124
+ - !ruby/object:Gem::Version
125
+ version: 0.1.1
126
+ - !ruby/object:Gem::Dependency
144
127
  name: rb-fsevent
145
- version_requirements: *id008
146
- - !ruby/object:Gem::Dependency
147
- prerelease: false
128
+ requirement: !ruby/object:Gem::Requirement
129
+ none: false
130
+ requirements:
131
+ - - ~>
132
+ - !ruby/object:Gem::Version
133
+ version: 0.4.3.1
148
134
  type: :development
149
- requirement: &id009 !ruby/object:Gem::Requirement
135
+ prerelease: false
136
+ version_requirements: !ruby/object:Gem::Requirement
150
137
  none: false
151
- requirements:
138
+ requirements:
152
139
  - - ~>
153
- - !ruby/object:Gem::Version
154
- hash: 17
155
- segments:
156
- - 1
157
- - 0
158
- - 3
159
- version: 1.0.3
140
+ - !ruby/object:Gem::Version
141
+ version: 0.4.3.1
142
+ - !ruby/object:Gem::Dependency
160
143
  name: growl
161
- version_requirements: *id009
162
- - !ruby/object:Gem::Dependency
163
- prerelease: false
144
+ requirement: !ruby/object:Gem::Requirement
145
+ none: false
146
+ requirements:
147
+ - - ~>
148
+ - !ruby/object:Gem::Version
149
+ version: 1.0.3
164
150
  type: :development
165
- requirement: &id010 !ruby/object:Gem::Requirement
151
+ prerelease: false
152
+ version_requirements: !ruby/object:Gem::Requirement
166
153
  none: false
167
- requirements:
168
- - - ">="
169
- - !ruby/object:Gem::Version
170
- hash: 3
171
- segments:
172
- - 0
173
- version: "0"
154
+ requirements:
155
+ - - ~>
156
+ - !ruby/object:Gem::Version
157
+ version: 1.0.3
158
+ - !ruby/object:Gem::Dependency
174
159
  name: awesome_print
175
- version_requirements: *id010
176
- - !ruby/object:Gem::Dependency
177
- prerelease: false
160
+ requirement: !ruby/object:Gem::Requirement
161
+ none: false
162
+ requirements:
163
+ - - ! '>='
164
+ - !ruby/object:Gem::Version
165
+ version: '0'
178
166
  type: :development
179
- requirement: &id011 !ruby/object:Gem::Requirement
167
+ prerelease: false
168
+ version_requirements: !ruby/object:Gem::Requirement
180
169
  none: false
181
- requirements:
182
- - - ">="
183
- - !ruby/object:Gem::Version
184
- hash: 3
185
- segments:
186
- - 0
187
- version: "0"
170
+ requirements:
171
+ - - ! '>='
172
+ - !ruby/object:Gem::Version
173
+ version: '0'
174
+ - !ruby/object:Gem::Dependency
188
175
  name: pry
189
- version_requirements: *id011
190
- description: ""
176
+ requirement: !ruby/object:Gem::Requirement
177
+ none: false
178
+ requirements:
179
+ - - ! '>='
180
+ - !ruby/object:Gem::Version
181
+ version: '0'
182
+ type: :development
183
+ prerelease: false
184
+ version_requirements: !ruby/object:Gem::Requirement
185
+ none: false
186
+ requirements:
187
+ - - ! '>='
188
+ - !ruby/object:Gem::Version
189
+ version: '0'
190
+ description: ''
191
191
  email: gcao99@gmail.com
192
192
  executables: []
193
-
194
193
  extensions: []
195
-
196
- extra_rdoc_files:
194
+ extra_rdoc_files:
197
195
  - LICENSE.txt
198
196
  - README.rdoc
199
- files:
197
+ files:
200
198
  - .document
201
199
  - .irbrc
202
200
  - .rspec
@@ -254,39 +252,32 @@ files:
254
252
  - spec/unit/deferred_logic_spec.rb
255
253
  - spec/unit/method_matcher_spec.rb
256
254
  - spec/unit/raw_spec.rb
257
- has_rdoc: true
258
255
  homepage: http://github.com/gcao/aspector
259
- licenses:
256
+ licenses:
260
257
  - MIT
261
258
  post_install_message:
262
259
  rdoc_options: []
263
-
264
- require_paths:
260
+ require_paths:
265
261
  - lib
266
- required_ruby_version: !ruby/object:Gem::Requirement
262
+ required_ruby_version: !ruby/object:Gem::Requirement
267
263
  none: false
268
- requirements:
269
- - - ">="
270
- - !ruby/object:Gem::Version
271
- hash: 3
272
- segments:
264
+ requirements:
265
+ - - ! '>='
266
+ - !ruby/object:Gem::Version
267
+ version: '0'
268
+ segments:
273
269
  - 0
274
- version: "0"
275
- required_rubygems_version: !ruby/object:Gem::Requirement
270
+ hash: 4044102942176431423
271
+ required_rubygems_version: !ruby/object:Gem::Requirement
276
272
  none: false
277
- requirements:
278
- - - ">="
279
- - !ruby/object:Gem::Version
280
- hash: 3
281
- segments:
282
- - 0
283
- version: "0"
273
+ requirements:
274
+ - - ! '>='
275
+ - !ruby/object:Gem::Version
276
+ version: '0'
284
277
  requirements: []
285
-
286
278
  rubyforge_project:
287
- rubygems_version: 1.6.2
279
+ rubygems_version: 1.8.18
288
280
  signing_key:
289
281
  specification_version: 3
290
282
  summary: Aspect Oriented Ruby Programming
291
283
  test_files: []
292
-