aquarium 0.4.4 → 0.5.1
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES +31 -6
- data/README +4 -1
- data/RELEASE-PLAN +2 -0
- data/Rakefile +20 -30
- data/UPGRADE +14 -4
- data/lib/aquarium/aspects/advice.rb +25 -10
- data/lib/aquarium/aspects/aspect.rb +8 -7
- data/lib/aquarium/aspects/join_point.rb +15 -5
- data/lib/aquarium/aspects/pointcut.rb +4 -4
- data/lib/aquarium/extensions.rb +0 -1
- data/lib/aquarium/finders/method_finder.rb +3 -10
- data/lib/aquarium/finders/pointcut_finder.rb +15 -5
- data/lib/aquarium/finders/type_finder.rb +0 -1
- data/lib/aquarium/utils/array_utils.rb +0 -1
- data/lib/aquarium/utils/method_utils.rb +13 -2
- data/lib/aquarium/utils/options_utils.rb +1 -0
- data/lib/aquarium/utils/type_utils.rb +21 -5
- data/lib/aquarium/version.rb +2 -2
- data/spec/aquarium/aspects/advice_chain_node_spec.rb +0 -1
- data/spec/aquarium/aspects/advice_spec.rb +80 -45
- data/spec/aquarium/aspects/aspect_invocation_spec.rb +66 -31
- data/spec/aquarium/aspects/aspect_spec.rb +88 -91
- data/spec/aquarium/aspects/concurrent_aspects_spec.rb +1 -1
- data/spec/aquarium/aspects/concurrent_aspects_with_objects_and_types_spec.rb +3 -1
- data/spec/aquarium/aspects/join_point_spec.rb +0 -1
- data/spec/aquarium/aspects/pointcut_spec.rb +21 -18
- data/spec/aquarium/extensions/hash_spec.rb +211 -219
- data/spec/aquarium/extensions/set_spec.rb +1 -1
- data/spec/aquarium/extras/design_by_contract_spec.rb +1 -1
- data/spec/aquarium/finders/finder_result_spec.rb +4 -4
- data/spec/aquarium/finders/method_finder_spec.rb +6 -9
- data/spec/aquarium/finders/type_finder_spec.rb +2 -2
- data/spec/aquarium/finders/type_finder_with_descendents_and_ancestors_spec.rb +12 -10
- data/spec/aquarium/spec_example_types.rb +2 -2
- data/spec/aquarium/spec_helper.rb +1 -1
- data/spec/aquarium/utils/array_utils_spec.rb +32 -5
- data/spec/aquarium/utils/hash_utils_spec.rb +1 -0
- data/spec/aquarium/utils/method_utils_spec.rb +18 -0
- data/spec/aquarium/utils/options_utils_spec.rb +16 -20
- data/spec/aquarium/utils/type_utils_sample_classes.rb +10 -1
- data/spec/aquarium/utils/type_utils_spec.rb +9 -7
- metadata +29 -35
- data/lib/aquarium/extensions/symbol.rb +0 -22
- data/spec/aquarium/extensions/symbol_spec.rb +0 -37
data/CHANGES
CHANGED
@@ -1,14 +1,39 @@
|
|
1
|
-
== Version 0.
|
1
|
+
== Version 0.5.1
|
2
2
|
|
3
|
-
V0.
|
3
|
+
V0.5.1 adds support for Ruby 1.8.7, Ruby 1.9.3, JRuby 1.6.7,
|
4
|
+
RSpec 2.9, and Webgen (0.5.14 - for the build process).
|
5
|
+
|
6
|
+
WARNING: Earlier versions of Ruby 1.8, 1.9 and JRuby 1.X are not
|
7
|
+
supported. JRuby support is limited to "pure" Ruby code; the main
|
8
|
+
RSpec specifications pass under JRuby, but not the JRuby-specific
|
9
|
+
specifications in jruby/spec. Restoring full JRuby support is planned,
|
10
|
+
but the timeframe is TBD.
|
11
|
+
|
12
|
+
It also has some minor API changes summarized below.
|
4
13
|
|
5
14
|
Enhancements:
|
6
|
-
|
7
|
-
|
15
|
+
22558 Support Ruby 1.9.1 (actually 1.9.3)
|
16
|
+
27235 Support RSpec 1.2.8 (actually 2.9) and and JRuby 1.3.1 (actually 1.6.7)
|
17
|
+
27236 Upgrade website generation to webgen 0.5.X (X=14)
|
18
|
+
|
19
|
+
The actual versions of these tools supported are more recent versions
|
20
|
+
shown in parentheses.
|
21
|
+
|
22
|
+
There are no API changes in this release, with two exceptions.
|
23
|
+
|
24
|
+
First, Most of the code changes are minor fixes to RSpec files. The one
|
25
|
+
exception is an apparent change that occurred in JRuby 1.3.X with respect
|
26
|
+
to the access restrictions on Java methods. It now appears that protected
|
27
|
+
methods are public, that is they are in the method list returned by
|
28
|
+
:public_methods, but not :protected_methods. Also, private methods are
|
29
|
+
not returned by any of the :*_methods.
|
30
|
+
|
31
|
+
Second, there was a deprecated option to the MethodFinder class,
|
32
|
+
:options, that has been removed. Use :method_options instead.
|
8
33
|
|
9
|
-
|
34
|
+
I used the upgrade to Webgen 0.5.X as an excuse to refresh the web site's
|
35
|
+
appearance. The content is mostly the same as before.
|
10
36
|
|
11
|
-
I used the upgrade to Webgen 0.5.X as an excuse to refresh the web site's appearance. The content is mostly the same as before.
|
12
37
|
|
13
38
|
== Version 0.4.3
|
14
39
|
|
data/README
CHANGED
@@ -463,7 +463,10 @@ See http://aquarium.rubyforge.org for further documentation.
|
|
463
463
|
=== Acknowledgments
|
464
464
|
|
465
465
|
My colleagues in the AOSD community, in particular those who developed AspectJ, have been a big inspiration.
|
466
|
+
|
466
467
|
The RSpec team, in particular David Chelimsky, have really inspired my thinking about what's possible in Ruby, especially in the realm of DSLs. I also cribbed parts of the RSpec Rake process ;)
|
467
|
-
|
468
|
+
|
469
|
+
Keita Yamaguchi contributed some key patches that enabled Ruby 1.9.3 and JRuby 1.6.7 support, in addition to the prior support for Ruby 1.8.7. These patches allowed me to final release version 0.5.X. Thank you!
|
470
|
+
|
468
471
|
Finally, a number of users have contributed valuable feedback. In particular, thanks to Brendan L., Matthew F., and Mark V.
|
469
472
|
|
data/RELEASE-PLAN
CHANGED
@@ -62,6 +62,8 @@ aspects, for example.
|
|
62
62
|
I'll maintain the current form for backwards compatibility and also because it is convenient for
|
63
63
|
simpler aspects.
|
64
64
|
|
65
|
+
Finally, this release will finally support Ruby 1.9.X and the latest JRuby at the time of the release.
|
66
|
+
|
65
67
|
=== Version 0.6+
|
66
68
|
|
67
69
|
I have been thinking about higher-order abstractions that work above the "Pointcut + Advice
|
data/Rakefile
CHANGED
@@ -4,18 +4,16 @@ require 'rake'
|
|
4
4
|
require 'rake/gempackagetask'
|
5
5
|
require 'rake/contrib/rubyforgepublisher'
|
6
6
|
require 'rake/clean'
|
7
|
-
require '
|
7
|
+
require 'rdoc/task'
|
8
8
|
require 'aquarium/version'
|
9
9
|
|
10
10
|
# Use RSpec's files.
|
11
|
-
require '
|
12
|
-
require 'spec/rake/verify_rcov'
|
13
|
-
|
14
|
-
# TODO: add ../README.markdown to archives.
|
11
|
+
require 'rspec/core/rake_task'
|
15
12
|
|
16
13
|
# Some of the tasks are in separate files since they are also part of the website documentation
|
17
|
-
load File.dirname(__FILE__) + '/rake_tasks/examples.rake'
|
18
|
-
|
14
|
+
#load File.dirname(__FILE__) + '/rake_tasks/examples.rake'
|
15
|
+
# TODO: Replace rcov with simplecov and restore this feature.
|
16
|
+
#load File.dirname(__FILE__) + '/rake_tasks/verify_rcov.rake'
|
19
17
|
|
20
18
|
PKG_NAME = "aquarium"
|
21
19
|
PKG_VERSION = Aquarium::VERSION::STRING
|
@@ -29,34 +27,25 @@ PKG_FILES = FileList[
|
|
29
27
|
]
|
30
28
|
FileUtils.touch(File.dirname(__FILE__) + '/previous_failures.txt')
|
31
29
|
|
32
|
-
|
30
|
+
IS_WINDOWS = (RUBY_VERSION == "1.8.7" ? PLATFORM : RUBY_PLATFORM) =~ /mswin/
|
33
31
|
|
34
|
-
|
35
|
-
Spec::Rake::SpecTask.new do |t|
|
36
|
-
t.spec_files = FileList['spec/**/*_spec.rb', 'examples/**/*_spec.rb']
|
37
|
-
t.spec_opts = ['--options', 'spec.opts']
|
38
|
-
t.rcov = true
|
39
|
-
t.rcov_dir = '../doc/aquarium/out/coverage'
|
40
|
-
t.rcov_opts = ['--exclude', 'examples']
|
41
|
-
end
|
32
|
+
task :default => :spec
|
42
33
|
|
43
|
-
desc "Run all specs
|
44
|
-
|
45
|
-
t.
|
46
|
-
t.spec_opts = ['--format html:../doc/aquarium/out/report.html','--backtrace']
|
34
|
+
desc "Run all specs"
|
35
|
+
RSpec::Core::RakeTask.new do |t|
|
36
|
+
t.rspec_opts = ['--color', '--format progress', '--profile']
|
47
37
|
end
|
48
38
|
|
49
|
-
desc "Run all specs
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
end
|
39
|
+
# desc "Run all specs and store html output in doc/aquarium/out/report.html"
|
40
|
+
# RSpec::Core::RakeTask.new('spec_html') do |t|
|
41
|
+
# t.rspec_opts = ['--format html:../doc/aquarium/out/report.html','--backtrace']
|
42
|
+
# end
|
54
43
|
|
55
44
|
desc 'Generate HTML documentation for website'
|
56
45
|
task :webgen do
|
57
46
|
Dir.chdir '../doc/aquarium' do
|
58
47
|
output = nil
|
59
|
-
IO.popen('webgen 2>&1') do |io|
|
48
|
+
IO.popen('rake webgen 2>&1') do |io|
|
60
49
|
output = io.read
|
61
50
|
end
|
62
51
|
raise "ERROR while running webgen: #{output}" if output =~ /ERROR/n || $? != 0
|
@@ -127,6 +116,7 @@ end
|
|
127
116
|
|
128
117
|
task :clobber do
|
129
118
|
rm_rf '../doc/aquarium/out'
|
119
|
+
rm_rf '../doc/aquarium/webgen.cache'
|
130
120
|
rm_rf 'translated_specs'
|
131
121
|
end
|
132
122
|
|
@@ -166,20 +156,20 @@ end
|
|
166
156
|
# ]
|
167
157
|
|
168
158
|
desc "Build the website, but do not publish it"
|
169
|
-
task :website => [:clobber, :
|
159
|
+
task :website => [:clobber, :rdoc, :webgen] # :spec_html, :verify_jruby, :verify_rcov,
|
170
160
|
|
171
161
|
task :rdoc_rails do
|
172
162
|
Dir.chdir '../aquarium_on_rails' do
|
173
|
-
rake =
|
163
|
+
rake = IS_WINDOWS ? "rake.cmd" : "rake"
|
174
164
|
`#{rake} rdoc`
|
175
165
|
end
|
176
166
|
end
|
177
167
|
|
178
|
-
desc "Verify that the Aquarium specs run under JRuby and that JRuby can advise Java types"
|
168
|
+
desc "Verify that the Aquarium specs run under JRuby and that JRuby can advise Java types. If this task fails, try running 'jruby -S rake' separately."
|
179
169
|
task :verify_jruby do
|
180
170
|
puts "Verifying JRuby Support"
|
181
171
|
Dir.chdir 'jruby' do
|
182
|
-
rake =
|
172
|
+
rake = IS_WINDOWS ? "rake.cmd" : "rake"
|
183
173
|
sh "jruby -S #{rake}"
|
184
174
|
end
|
185
175
|
end
|
data/UPGRADE
CHANGED
@@ -1,8 +1,18 @@
|
|
1
|
-
== Updating to Aquarium-0.
|
1
|
+
== Updating to Aquarium-0.5.X
|
2
2
|
|
3
|
-
This release
|
4
|
-
|
5
|
-
|
3
|
+
This release introduces a few small API changes that are described in
|
4
|
+
CHANGES. The primary goal of the release is to add full support for
|
5
|
+
Ruby 1.9.3 and JRuby 1.6.7.
|
6
|
+
|
7
|
+
It was not tested on early versions of Ruby 1.9 and JRuby 1.X, so users
|
8
|
+
of earlier releases should use caution upgrading. Post any issues to the
|
9
|
+
GitHub project.
|
10
|
+
|
11
|
+
== Updating to Aquarium-0.4.X
|
12
|
+
|
13
|
+
This release is fully backwards-compatible with previous releases. It
|
14
|
+
expands the API slightly and adds internal improvements to better support
|
15
|
+
JRuby. There should be no upgrade issues.
|
6
16
|
|
7
17
|
== Updating to Aquarium-0.3.1
|
8
18
|
|
@@ -1,6 +1,5 @@
|
|
1
1
|
require 'aquarium/utils/array_utils'
|
2
2
|
require 'aquarium/extensions/string'
|
3
|
-
require 'aquarium/extensions/symbol'
|
4
3
|
require 'aquarium/utils/invalid_options'
|
5
4
|
require 'aquarium/utils/nil_object'
|
6
5
|
|
@@ -11,6 +10,11 @@ module Aquarium
|
|
11
10
|
UNKNOWN_ADVICE_KIND = "unknown"
|
12
11
|
|
13
12
|
KINDS_IN_PRIORITY_ORDER = [:around, :before, :after, :after_returning, :after_raising]
|
13
|
+
|
14
|
+
@DEBUG_BACKTRACES = false
|
15
|
+
|
16
|
+
def self.debug_backtraces; @DEBUG_BACKTRACES; end
|
17
|
+
def self.debug_backtraces=( val ); @DEBUG_BACKTRACES = val; end
|
14
18
|
|
15
19
|
def self.kinds; KINDS_IN_PRIORITY_ORDER; end
|
16
20
|
|
@@ -100,9 +104,10 @@ module Aquarium
|
|
100
104
|
next_node.nil?
|
101
105
|
end
|
102
106
|
|
103
|
-
|
104
|
-
|
105
|
-
|
107
|
+
# TODO: remove this method, which causes run-away recursions in R1.9.1
|
108
|
+
# def inspect &block
|
109
|
+
# block ? yield(self) : super
|
110
|
+
# end
|
106
111
|
|
107
112
|
NIL_OBJECT = Aquarium::Utils::NilObject.new
|
108
113
|
|
@@ -126,12 +131,22 @@ module Aquarium
|
|
126
131
|
end
|
127
132
|
|
128
133
|
def handle_call_rescue ex, error_message_prefix, jp
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
134
|
+
if Aquarium::Aspects::Advice.debug_backtraces
|
135
|
+
class_or_instance_method_separater = jp.instance_method? ? "#" : "."
|
136
|
+
context_message = error_message_prefix + "Exception raised while executing \"#{jp.context.advice_kind}\" advice for \"#{jp.type_or_object.inspect}#{class_or_instance_method_separater}#{jp.method_name}\": "
|
137
|
+
|
138
|
+
# Don't prepend the same context message multiple times
|
139
|
+
if ex.message =~ /#{context_message}/
|
140
|
+
context_message = ""
|
141
|
+
end
|
142
|
+
|
143
|
+
backtrace = ex.backtrace
|
144
|
+
e2 = ex.exception(context_message + ex.message + " (join_point = #{jp.inspect})")
|
145
|
+
e2.set_backtrace backtrace
|
146
|
+
raise e2
|
147
|
+
else
|
148
|
+
raise ex
|
149
|
+
end
|
135
150
|
end
|
136
151
|
end
|
137
152
|
|
@@ -37,7 +37,7 @@ module Aquarium
|
|
37
37
|
"pointcuts" => %w[pointcut],
|
38
38
|
"named_pointcuts" => %w[named_pointcut],
|
39
39
|
"exceptions" => %w[exception],
|
40
|
-
"ignore_no_matching_join_points" => %[ignore_no_jps]
|
40
|
+
"ignore_no_matching_join_points" => %w[ignore_no_jps]
|
41
41
|
}
|
42
42
|
["pointcuts", "named_pointcuts"].each do |pc_option|
|
43
43
|
add_prepositional_option_variants_for pc_option, ASPECT_CANONICAL_OPTIONS
|
@@ -341,7 +341,7 @@ module Aquarium
|
|
341
341
|
end
|
342
342
|
|
343
343
|
def join_point_for_aspect_implementation_method? join_point
|
344
|
-
join_point.method_name.to_s.index(
|
344
|
+
join_point.method_name.to_s.index(Aspect.aspect_method_prefix.to_s) == 0
|
345
345
|
end
|
346
346
|
|
347
347
|
def add_advice_to_chain join_point, advice_kind, advice
|
@@ -375,12 +375,12 @@ module Aquarium
|
|
375
375
|
end
|
376
376
|
|
377
377
|
def need_advice_framework? join_point
|
378
|
-
alias_method_name = (Aspect.make_saved_method_name join_point)
|
378
|
+
alias_method_name = (Aspect.make_saved_method_name join_point)
|
379
379
|
private_method_defined?(join_point, alias_method_name) == false
|
380
380
|
end
|
381
381
|
|
382
382
|
def add_advice_framework join_point
|
383
|
-
alias_method_name = (Aspect.make_saved_method_name join_point)
|
383
|
+
alias_method_name = (Aspect.make_saved_method_name join_point)
|
384
384
|
type_to_advise = Aspect.type_to_advise_for join_point
|
385
385
|
# Note: Must set advice chain, a class variable on the type we're advising, FIRST.
|
386
386
|
# Otherwise the class_eval that follows will assume the @@ advice chain belongs to Aspect!
|
@@ -496,7 +496,7 @@ module Aquarium
|
|
496
496
|
end
|
497
497
|
|
498
498
|
def restore_original_method_text join_point
|
499
|
-
alias_method_name = (Aspect.make_saved_method_name join_point)
|
499
|
+
alias_method_name = (Aspect.make_saved_method_name join_point)
|
500
500
|
<<-EOF
|
501
501
|
#{join_point.instance_method? ? "" : "class << self"}
|
502
502
|
#{unalias_original_method_text alias_method_name, join_point}
|
@@ -527,7 +527,8 @@ module Aquarium
|
|
527
527
|
|
528
528
|
def private_method_defined? join_point, alias_method_name
|
529
529
|
type_to_advise = Aspect.type_to_advise_for join_point
|
530
|
-
|
530
|
+
method_name = Aquarium::Utils::MethodUtils.to_name alias_method_name
|
531
|
+
type_to_advise.send(:private_instance_methods).include? method_name
|
531
532
|
end
|
532
533
|
|
533
534
|
def self.make_advice_chain_attr_sym join_point
|
@@ -540,7 +541,7 @@ module Aquarium
|
|
540
541
|
def self.make_saved_method_name join_point
|
541
542
|
type_or_object_key = make_type_or_object_key join_point
|
542
543
|
valid_name = Aquarium::Utils::NameUtils.make_valid_attr_name_from_method_name join_point.method_name
|
543
|
-
"#{Aspect.aspect_method_prefix}saved_#{type_or_object_key}_#{valid_name}"
|
544
|
+
"#{Aspect.aspect_method_prefix}saved_#{type_or_object_key}_#{valid_name}".intern
|
544
545
|
end
|
545
546
|
|
546
547
|
def self.aspect_method_prefix
|
@@ -58,7 +58,12 @@ module Aquarium
|
|
58
58
|
|
59
59
|
alias :to_s :inspect
|
60
60
|
|
61
|
-
|
61
|
+
def inspect
|
62
|
+
"JoinPoint::Context: {advice_kind = #{advice_kind}, advised_object = #{advised_object}, parameters = #{parameters}, " +
|
63
|
+
"proceed_proc = #{proceed_proc}, current_advice_node = #{current_advice_node.inspect}, returned_value = #{returned_value}, " +
|
64
|
+
"raised_exception = #{raised_exception}, block_for_method = #{block_for_method}}"
|
65
|
+
end
|
66
|
+
|
62
67
|
def <=> other
|
63
68
|
return 0 if object_id == other.object_id
|
64
69
|
return 1 if other.nil?
|
@@ -166,7 +171,6 @@ module Aquarium
|
|
166
171
|
@instance_method
|
167
172
|
end
|
168
173
|
|
169
|
-
# We require the same object id, not just equal objects.
|
170
174
|
def <=> other
|
171
175
|
return 0 if object_id == other.object_id
|
172
176
|
return 1 if other.nil?
|
@@ -190,13 +194,13 @@ module Aquarium
|
|
190
194
|
alias :== :eql?
|
191
195
|
alias :=== :eql?
|
192
196
|
|
197
|
+
#todo: restore context output.
|
193
198
|
def inspect
|
194
|
-
"JoinPoint: {target_type = #{target_type.
|
199
|
+
"JoinPoint: {target_type = #{target_type.nil? ? target_type : target_type.name}, target_object = #{target_object.inspect}, method_name = #{method_name}, instance_method? #{instance_method?}, context = #{context.inspect}"
|
195
200
|
end
|
196
201
|
|
197
202
|
alias :to_s :inspect
|
198
203
|
|
199
|
-
|
200
204
|
protected
|
201
205
|
|
202
206
|
def compare_field field_reader, other
|
@@ -207,7 +211,13 @@ module Aquarium
|
|
207
211
|
else
|
208
212
|
return 1 if field2.nil?
|
209
213
|
end
|
210
|
-
block_given?
|
214
|
+
if block_given?
|
215
|
+
yield field1, field2
|
216
|
+
elsif field1.respond_to?(:<=>)
|
217
|
+
field1 <=> field2
|
218
|
+
else
|
219
|
+
field1.to_s <=> field2.to_s
|
220
|
+
end
|
211
221
|
end
|
212
222
|
|
213
223
|
def boolean_compare b1, b2
|
@@ -206,13 +206,13 @@ module Aquarium
|
|
206
206
|
# if you care only about the matched join points, then just compare #join_points_matched
|
207
207
|
def eql? other
|
208
208
|
object_id == other.object_id ||
|
209
|
-
(self.class
|
209
|
+
(self.class == other.class &&
|
210
210
|
specification == other.specification &&
|
211
211
|
candidate_types == other.candidate_types &&
|
212
212
|
candidate_types_excluded == other.candidate_types_excluded &&
|
213
213
|
candidate_objects == other.candidate_objects &&
|
214
|
-
|
215
|
-
|
214
|
+
join_points_matched == other.join_points_matched &&
|
215
|
+
join_points_not_matched == other.join_points_not_matched)
|
216
216
|
end
|
217
217
|
|
218
218
|
alias :== :eql?
|
@@ -250,7 +250,7 @@ module Aquarium
|
|
250
250
|
def self.make_attribute_reading_writing_options options_hash
|
251
251
|
result = {}
|
252
252
|
[:writing, :changing, :reading].each do |attr_key|
|
253
|
-
next if options_hash[attr_key].nil? or options_hash[attr_key].empty?
|
253
|
+
next if options_hash[attr_key].nil? or options_hash[attr_key].to_s.empty?
|
254
254
|
result[:attributes] ||= Set.new([])
|
255
255
|
result[:attribute_options] ||= Set.new([])
|
256
256
|
result[:attributes].merge(Aquarium::Utils::ArrayUtils.make_array(options_hash[attr_key]))
|
data/lib/aquarium/extensions.rb
CHANGED
@@ -62,10 +62,9 @@ module Aquarium
|
|
62
62
|
# By default, the searches are restricted to public instance methods.
|
63
63
|
# * <tt>:method_options => options</tt>
|
64
64
|
# * <tt>:method_option => options</tt>
|
65
|
-
# * <tt>:options => options</tt>
|
66
65
|
# * <tt>:restricting_methods_to => options</tt>
|
67
66
|
#
|
68
|
-
# Note, the <tt>:options</tt> synonym
|
67
|
+
# Note, the older, deprecated <tt>:options</tt> synonym has been removed.
|
69
68
|
#
|
70
69
|
# Here are the allowed "options". Specify one or more of them. Any combination is allowed.
|
71
70
|
# <tt>:public</tt> or <tt>:public_methods</tt>:: Search for public methods (default).
|
@@ -95,7 +94,6 @@ module Aquarium
|
|
95
94
|
init_specification options, CANONICAL_OPTIONS do
|
96
95
|
finish_specification_initialization
|
97
96
|
end
|
98
|
-
warn_if_deprecated_options_used options
|
99
97
|
return Aquarium::Finders::FinderResult.new if nothing_to_find?
|
100
98
|
types_and_objects = input_types + input_objects
|
101
99
|
method_names_or_regexps = input_methods
|
@@ -116,7 +114,7 @@ module Aquarium
|
|
116
114
|
METHOD_FINDER_CANONICAL_OPTIONS = {
|
117
115
|
"objects" => %w[object for_object for_objects on_object on_objects in_object in_objects within_object within_objects],
|
118
116
|
"methods" => %w[method within_method within_methods calling invoking invocations_of calls_to sending_message_to sending_messages_to],
|
119
|
-
"method_options" => %w[
|
117
|
+
"method_options" => %w[method_option restricting_methods_to]
|
120
118
|
}
|
121
119
|
|
122
120
|
%w[objects methods].each do |key|
|
@@ -161,7 +159,7 @@ module Aquarium
|
|
161
159
|
end
|
162
160
|
end
|
163
161
|
options << :instance unless (options.include?(:class) or options.include?(:singleton))
|
164
|
-
Set.new(options.sort.uniq)
|
162
|
+
Set.new(options.sort{|x,y| x.to_s <=> y.to_s}.uniq)
|
165
163
|
end
|
166
164
|
|
167
165
|
def self.all_recognized_method_option_symbols
|
@@ -179,11 +177,6 @@ module Aquarium
|
|
179
177
|
|
180
178
|
private
|
181
179
|
|
182
|
-
def warn_if_deprecated_options_used options
|
183
|
-
return unless options[:options]
|
184
|
-
logger.warn "The :options => ... option is now deprecated. Please use :method_options instead."
|
185
|
-
end
|
186
|
-
|
187
180
|
def do_find_all_by types_and_objects, method_names_or_regexps
|
188
181
|
types_and_objects = make_array types_and_objects
|
189
182
|
names_or_regexps = make_methods_array method_names_or_regexps
|
@@ -107,7 +107,7 @@ module Aquarium
|
|
107
107
|
types.each do |t|
|
108
108
|
candidates = t.constants.select {|c| matches_name(c, names)}
|
109
109
|
candidates.each do |c|
|
110
|
-
if
|
110
|
+
if is_const_defined? t, c
|
111
111
|
con = t.const_get c
|
112
112
|
pointcuts.append_matched({t => con}) if con.kind_of?(Aquarium::Aspects::Pointcut)
|
113
113
|
end
|
@@ -116,6 +116,16 @@ module Aquarium
|
|
116
116
|
pointcuts
|
117
117
|
end
|
118
118
|
|
119
|
+
# Handle Ruby 1.8 vs. 1.9. We don't want to return true
|
120
|
+
# if the const is defined in an ancestor.
|
121
|
+
def is_const_defined? type, name
|
122
|
+
if RUBY_VERSION =~ /^1.8/
|
123
|
+
type.const_defined? name
|
124
|
+
else
|
125
|
+
type.const_defined? name, false
|
126
|
+
end
|
127
|
+
end
|
128
|
+
|
119
129
|
def find_class_variable_pointcuts types, names = :all
|
120
130
|
pointcuts = PoincutFinderResult.new
|
121
131
|
types.each do |t|
|
@@ -131,11 +141,11 @@ module Aquarium
|
|
131
141
|
def matches_name candidate, names
|
132
142
|
return true if names == :all
|
133
143
|
if names.kind_of? Regexp
|
134
|
-
names.match candidate
|
144
|
+
names.match candidate.to_s
|
135
145
|
elsif names.kind_of?(String) or names.kind_of?(Symbol)
|
136
|
-
names.to_s.eql? candidate
|
146
|
+
names.to_s.eql? candidate.to_s
|
137
147
|
else
|
138
|
-
names.
|
148
|
+
names.any? {|name| matches_name(candidate, name)}
|
139
149
|
end
|
140
150
|
end
|
141
151
|
|
@@ -146,7 +156,7 @@ module Aquarium
|
|
146
156
|
elsif names.kind_of?(String) or names.kind_of?(Symbol)
|
147
157
|
names.to_s =~ /^@@/ ? names.to_s : "@@#{names}"
|
148
158
|
else
|
149
|
-
names.inject([]) {|result, name| result << to_class_variable_name(name)
|
159
|
+
names.inject([]) {|result, name| result << to_class_variable_name(name)}
|
150
160
|
end
|
151
161
|
end
|
152
162
|
|