aquarium 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES +35 -0
- data/MIT-LICENSE +1 -1
- data/README +66 -20
- data/Rakefile +1 -1
- data/UPGRADE +5 -0
- data/examples/aspect_design_example.rb +5 -4
- data/examples/aspect_design_example_spec.rb +6 -5
- data/examples/design_by_contract_example.rb +3 -3
- data/examples/design_by_contract_example_spec.rb +4 -4
- data/examples/method_missing_example.rb +1 -1
- data/examples/method_missing_example_spec.rb +2 -2
- data/examples/method_tracing_example.rb +3 -3
- data/examples/method_tracing_example_spec.rb +6 -6
- data/lib/aquarium/aspects/advice.rb +2 -3
- data/lib/aquarium/aspects/aspect.rb +100 -246
- data/lib/aquarium/aspects/{default_object_handler.rb → default_objects_handler.rb} +7 -6
- data/lib/aquarium/aspects/dsl/aspect_dsl.rb +2 -2
- data/lib/aquarium/aspects/pointcut.rb +190 -107
- data/lib/aquarium/finders/method_finder.rb +120 -34
- data/lib/aquarium/finders/type_finder.rb +2 -5
- data/lib/aquarium/utils.rb +1 -0
- data/lib/aquarium/utils/array_utils.rb +11 -3
- data/lib/aquarium/utils/options_utils.rb +74 -0
- data/lib/aquarium/utils/type_utils.rb +25 -11
- data/lib/aquarium/version.rb +1 -1
- data/spec/aquarium/aspects/advice_chain_node_spec.rb +1 -1
- data/spec/aquarium/aspects/advice_spec.rb +1 -1
- data/spec/aquarium/aspects/aspect_invocation_spec.rb +179 -145
- data/spec/aquarium/aspects/aspect_spec.rb +1 -1
- data/spec/aquarium/aspects/aspect_with_nested_types_spec.rb +1 -1
- data/spec/aquarium/aspects/aspect_with_subtypes_spec.rb +1 -1
- data/spec/aquarium/aspects/concurrent_aspects_spec.rb +1 -1
- data/spec/aquarium/aspects/concurrent_aspects_with_objects_and_types_spec.rb +1 -1
- data/spec/aquarium/aspects/default_objects_handler_spec.rb +147 -0
- data/spec/aquarium/aspects/dsl/aspect_dsl_spec.rb +72 -121
- data/spec/aquarium/aspects/join_point_spec.rb +1 -1
- data/spec/aquarium/aspects/pointcut_and_composition_spec.rb +1 -1
- data/spec/aquarium/aspects/pointcut_or_composition_spec.rb +48 -47
- data/spec/aquarium/aspects/pointcut_spec.rb +727 -410
- data/spec/aquarium/extensions/hash_spec.rb +1 -1
- data/spec/aquarium/extensions/regex_spec.rb +1 -1
- data/spec/aquarium/extensions/set_spec.rb +1 -1
- data/spec/aquarium/extensions/string_spec.rb +1 -1
- data/spec/aquarium/extensions/symbol_spec.rb +1 -1
- data/spec/aquarium/extras/design_by_contract_spec.rb +1 -1
- data/spec/aquarium/finders/finder_result_spec.rb +1 -1
- data/spec/aquarium/finders/method_finder_spec.rb +49 -16
- data/spec/aquarium/finders/type_finder_spec.rb +1 -1
- data/spec/aquarium/finders/type_finder_with_descendents_and_ancestors_spec.rb +16 -1
- data/spec/aquarium/utils/array_utils_spec.rb +31 -6
- data/spec/aquarium/utils/hash_utils_spec.rb +1 -1
- data/spec/aquarium/utils/html_escaper_spec.rb +1 -1
- data/spec/aquarium/utils/logic_error_spec.rb +1 -1
- data/spec/aquarium/utils/method_utils_spec.rb +1 -1
- data/spec/aquarium/utils/name_utils_spec.rb +1 -1
- data/spec/aquarium/utils/nil_object_spec.rb +1 -1
- data/spec/aquarium/utils/set_utils_spec.rb +1 -1
- data/spec/aquarium/utils/type_utils_spec.rb +1 -1
- metadata +9 -7
@@ -1,4 +1,4 @@
|
|
1
|
-
require File.dirname(__FILE__) + '/../spec_helper
|
1
|
+
require File.dirname(__FILE__) + '/../spec_helper'
|
2
2
|
require File.dirname(__FILE__) + '/../spec_example_classes'
|
3
3
|
require 'aquarium/finders/method_finder'
|
4
4
|
|
@@ -82,24 +82,39 @@ describe Aquarium::Finders::MethodFinder, "#find (synonymous input parameters)"
|
|
82
82
|
before_method_finder_spec
|
83
83
|
end
|
84
84
|
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
85
|
+
Aquarium::Finders::MethodFinder::CANONICAL_OPTIONS["types"].each do |key|
|
86
|
+
it "should accept :#{key} as a synonym for :types." do
|
87
|
+
expected = Aquarium::Finders::MethodFinder.new.find :types => Derived, :methods => [/^mbase/, /^mmodule/]
|
88
|
+
actual = Aquarium::Finders::MethodFinder.new.find key.intern => Derived, :methods => [/^mbase/, /^mmodule/]
|
89
|
+
actual.should == expected
|
90
|
+
end
|
89
91
|
end
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
92
|
+
|
93
|
+
Aquarium::Finders::MethodFinder::CANONICAL_OPTIONS["objects"].each do |key|
|
94
|
+
it "should accept :#{key} as a synonym for :objects." do
|
95
|
+
child = Derived.new
|
96
|
+
expected = Aquarium::Finders::MethodFinder.new.find :objects => child, :methods => [/^mbase/, /^mmodule/]
|
97
|
+
actual = Aquarium::Finders::MethodFinder.new.find key.intern => child, :methods => [/^mbase/, /^mmodule/]
|
98
|
+
actual.should == expected
|
99
|
+
end
|
96
100
|
end
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
101
|
+
|
102
|
+
Aquarium::Finders::MethodFinder::CANONICAL_OPTIONS["methods"].each do |key|
|
103
|
+
it "should accept :#{key} as a synonym for :methods." do
|
104
|
+
expected = Aquarium::Finders::MethodFinder.new.find :types => Derived, :methods => [/^mbase/, /^mmodule/]
|
105
|
+
actual = Aquarium::Finders::MethodFinder.new.find :types => Derived, key.intern => [/^mbase/, /^mmodule/]
|
106
|
+
actual.should == expected
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
Aquarium::Finders::MethodFinder::CANONICAL_OPTIONS["options"].each do |key|
|
111
|
+
it "should accept :#{key} as a synonym for :options." do
|
112
|
+
expected = Aquarium::Finders::MethodFinder.new.find :types => Derived, :methods => [/^mder/, /^mmod/], :options => [:exclude_ancestor_methods]
|
113
|
+
actual = Aquarium::Finders::MethodFinder.new.find :types => Derived, :methods => [/^mder/, /^mmod/], key.intern => [:exclude_ancestor_methods]
|
114
|
+
actual.should == expected
|
115
|
+
end
|
102
116
|
end
|
117
|
+
|
103
118
|
end
|
104
119
|
|
105
120
|
describe Aquarium::Finders::MethodFinder, "#find (invalid input parameters)" do
|
@@ -330,6 +345,14 @@ describe Aquarium::Finders::MethodFinder, "#find (searching for class methods)"
|
|
330
345
|
actual.matched[ClassWithPrivateClassMethod].should == Set.new(ClassWithPrivateClassMethod.public_methods.sort.map{|m| m.intern})
|
331
346
|
end
|
332
347
|
|
348
|
+
it "should accept :all_methods as a synonym for :all." do
|
349
|
+
actual = Aquarium::Finders::MethodFinder.new.find :types => [ClassWithPublicClassMethod, ClassWithPrivateClassMethod], :methods => :all_methods, :options => :class
|
350
|
+
actual.matched.size.should == 2
|
351
|
+
actual.not_matched.size.should == 0
|
352
|
+
actual.matched[ClassWithPublicClassMethod].should == Set.new(ClassWithPublicClassMethod.public_methods.sort.map{|m| m.intern})
|
353
|
+
actual.matched[ClassWithPrivateClassMethod].should == Set.new(ClassWithPrivateClassMethod.public_methods.sort.map{|m| m.intern})
|
354
|
+
end
|
355
|
+
|
333
356
|
it "should find all public class methods in types, but not ancestors, when searching with the :all method specification and the :class and :exclude_ancestor_methods options." do
|
334
357
|
actual = Aquarium::Finders::MethodFinder.new.find :types => [ClassWithPublicClassMethod, ClassWithPrivateClassMethod], :methods => :all, :options => [:class, :exclude_ancestor_methods]
|
335
358
|
actual.matched.size.should == 1
|
@@ -569,6 +592,16 @@ describe Aquarium::Finders::MethodFinder, "#find (using :methods => :all)" do
|
|
569
592
|
actual.matched[pub].should == Set.new([:public_instance_test_method])
|
570
593
|
end
|
571
594
|
|
595
|
+
it "should ignore other method arguments if :all_methods is present." do
|
596
|
+
actual = Aquarium::Finders::MethodFinder.new.find :type => ClassWithPublicInstanceMethod, :method => [:all_methods, :none, /.*foo.*/], :methods =>[/.*bar.*/, /^baz/], :options => :exclude_ancestor_methods
|
597
|
+
actual.matched.size.should == 1
|
598
|
+
actual.matched[ClassWithPublicInstanceMethod].should == Set.new([:public_instance_test_method])
|
599
|
+
pub = ClassWithPublicInstanceMethod.new
|
600
|
+
actual = Aquarium::Finders::MethodFinder.new.find :object => pub, :method => [:all, :none, /.*foo.*/], :methods =>[/.*bar.*/, /^baz/], :options => :exclude_ancestor_methods
|
601
|
+
actual.matched.size.should == 1
|
602
|
+
actual.matched[pub].should == Set.new([:public_instance_test_method])
|
603
|
+
end
|
604
|
+
|
572
605
|
it "should report [:all] as the not_matched value when :all is the method argument and no methods match, e.g., for :exclude_ancestor_methods." do
|
573
606
|
actual = Aquarium::Finders::MethodFinder.new.find :type => ClassWithPrivateInstanceMethod, :method => :all, :options => :exclude_ancestor_methods
|
574
607
|
actual.matched.size.should == 0
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require File.dirname(__FILE__) + '/../spec_helper
|
1
|
+
require File.dirname(__FILE__) + '/../spec_helper'
|
2
2
|
require File.dirname(__FILE__) + '/../utils/type_utils_sample_classes'
|
3
3
|
require 'aquarium/finders/type_finder'
|
4
4
|
|
@@ -151,6 +151,21 @@ end
|
|
151
151
|
EOF
|
152
152
|
end
|
153
153
|
|
154
|
+
describe "#find with regular expressions, including descendents and ancestors" do
|
155
|
+
it "should find the matching types, including their descendents and ancestors, even in different nested modules." do
|
156
|
+
doption = "types_and_descendents".intern
|
157
|
+
aoption = "types_and_ancestors".intern
|
158
|
+
regexs = [/ForDescendents$/, /Aquarium::ForDescendents::.*ForDescendents/]
|
159
|
+
actual = Aquarium::Finders::TypeFinder.new.find aoption => regexs, doption => regexs
|
160
|
+
actual_keys = purge_actuals actual
|
161
|
+
expected = Aquarium::Utils::TypeUtils.sample_types_descendents_and_ancestors.keys + [Kernel, Object]
|
162
|
+
actual_keys.size.should == expected.size
|
163
|
+
expected.each do |t|
|
164
|
+
actual_keys.should include(t)
|
165
|
+
end
|
166
|
+
actual.not_matched_keys.should == []
|
167
|
+
end
|
168
|
+
end
|
154
169
|
|
155
170
|
describe "#find with regular expressions, including descendents and ancestors", :shared => true do
|
156
171
|
it "should find the matching types, including their descendents and ancestors, even in different nested modules." do
|
@@ -1,13 +1,17 @@
|
|
1
|
-
require File.dirname(__FILE__) + '/../spec_helper
|
1
|
+
require File.dirname(__FILE__) + '/../spec_helper'
|
2
2
|
require 'aquarium/utils/array_utils'
|
3
3
|
require 'set'
|
4
4
|
|
5
|
-
describe Aquarium::Utils::ArrayUtils, "make_array" do
|
6
|
-
|
5
|
+
describe Aquarium::Utils::ArrayUtils, "#make_array" do
|
7
6
|
it "should return an empty array if the input is nil." do
|
8
7
|
make_array(nil).should == []
|
9
8
|
end
|
10
9
|
|
10
|
+
it "should accept a list of arguments instead of an array or Set." do
|
11
|
+
make_array(nil, nil).should == []
|
12
|
+
make_array(nil, 1, 2, nil, 3, 4).should == [1, 2, 3, 4]
|
13
|
+
end
|
14
|
+
|
11
15
|
it "should return an empty array if an input array contains all nils." do
|
12
16
|
make_array([nil, nil]).should == []
|
13
17
|
end
|
@@ -40,8 +44,29 @@ describe Aquarium::Utils::ArrayUtils, "make_array" do
|
|
40
44
|
make_array(Set.new([1,2,"123"])).should == [1,2,"123"]
|
41
45
|
end
|
42
46
|
|
43
|
-
it "should
|
44
|
-
make_array(
|
45
|
-
|
47
|
+
it "should be available as a class method." do
|
48
|
+
Aquarium::Utils::ArrayUtils.make_array(Set.new([1,2,"123"])).should == [1,2,"123"]
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
describe Aquarium::Utils::ArrayUtils, "#strip_nils" do
|
53
|
+
it "should return an empty array if an input array contains all nils." do
|
54
|
+
strip_nils([nil, nil]).should == []
|
55
|
+
end
|
56
|
+
|
57
|
+
it "should return an empty array if an input Set contains all nils." do
|
58
|
+
strip_nils(Set.new([nil, nil])).should == []
|
59
|
+
end
|
60
|
+
|
61
|
+
it "should return an array with all nils removed from the input array." do
|
62
|
+
strip_nils([nil, 1, 2, nil, 3, 4]).should == [1, 2, 3, 4]
|
63
|
+
end
|
64
|
+
|
65
|
+
it "should return an array with all nils removed from the input Set." do
|
66
|
+
strip_nils(Set.new([nil, 1, 2, nil, 3, 4])).should == [1, 2, 3, 4]
|
67
|
+
end
|
68
|
+
|
69
|
+
it "should be accessible as a class method." do
|
70
|
+
Aquarium::Utils::ArrayUtils.strip_nils(Set.new([nil, 1, 2, nil, 3, 4])).should == [1, 2, 3, 4]
|
46
71
|
end
|
47
72
|
end
|
metadata
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: aquarium
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
5
|
-
platform:
|
4
|
+
version: 0.3.0
|
5
|
+
platform: ruby
|
6
6
|
authors:
|
7
|
-
-
|
7
|
+
- Aquarium Development Team
|
8
8
|
autorequire: aquarium
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date:
|
12
|
+
date: 2008-01-21 00:00:00 -06:00
|
13
13
|
default_executable: ""
|
14
14
|
dependencies: []
|
15
15
|
|
@@ -34,7 +34,7 @@ files:
|
|
34
34
|
- UPGRADE
|
35
35
|
- lib/aquarium/aspects/advice.rb
|
36
36
|
- lib/aquarium/aspects/aspect.rb
|
37
|
-
- lib/aquarium/aspects/
|
37
|
+
- lib/aquarium/aspects/default_objects_handler.rb
|
38
38
|
- lib/aquarium/aspects/dsl/aspect_dsl.rb
|
39
39
|
- lib/aquarium/aspects/dsl/object_dsl.rb
|
40
40
|
- lib/aquarium/aspects/dsl.rb
|
@@ -63,6 +63,7 @@ files:
|
|
63
63
|
- lib/aquarium/utils/method_utils.rb
|
64
64
|
- lib/aquarium/utils/name_utils.rb
|
65
65
|
- lib/aquarium/utils/nil_object.rb
|
66
|
+
- lib/aquarium/utils/options_utils.rb
|
66
67
|
- lib/aquarium/utils/set_utils.rb
|
67
68
|
- lib/aquarium/utils/type_utils.rb
|
68
69
|
- lib/aquarium/utils.rb
|
@@ -77,6 +78,7 @@ files:
|
|
77
78
|
- spec/aquarium/aspects/concurrent_aspects_spec.rb
|
78
79
|
- spec/aquarium/aspects/concurrent_aspects_with_objects_and_types_spec.rb
|
79
80
|
- spec/aquarium/aspects/concurrently_accessed.rb
|
81
|
+
- spec/aquarium/aspects/default_objects_handler_spec.rb
|
80
82
|
- spec/aquarium/aspects/dsl/aspect_dsl_spec.rb
|
81
83
|
- spec/aquarium/aspects/join_point_spec.rb
|
82
84
|
- spec/aquarium/aspects/pointcut_and_composition_spec.rb
|
@@ -143,9 +145,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
143
145
|
requirements: []
|
144
146
|
|
145
147
|
rubyforge_project: aquarium
|
146
|
-
rubygems_version: 0.
|
148
|
+
rubygems_version: 1.0.1
|
147
149
|
signing_key:
|
148
150
|
specification_version: 2
|
149
|
-
summary: Aquarium-0.
|
151
|
+
summary: Aquarium-0.3.0 (r7) - Aspect-Oriented Programming toolkit for Ruby http://aquarium.rubyforge.org
|
150
152
|
test_files: []
|
151
153
|
|