aquarium 0.4.1 → 0.4.2

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.
Files changed (55) hide show
  1. data/Aquarium-IDEA.ipr +252 -0
  2. data/Aquarium-IDEA.iws +493 -0
  3. data/Aquarium.ipr +1 -1
  4. data/Aquarium.iws +133 -138
  5. data/CHANGES +63 -0
  6. data/ParseTreePlay.rb +25 -0
  7. data/README +55 -3
  8. data/RELEASE-PLAN +9 -1
  9. data/TODO.rb +175 -15
  10. data/examples/aspect_design_example.rb +13 -1
  11. data/examples/aspect_design_example_spec.rb +20 -2
  12. data/examples/introductions_example.rb +35 -0
  13. data/examples/introductions_example_spec.rb +37 -0
  14. data/examples/method_missing_example.rb +2 -1
  15. data/lib/aquarium/aspects/advice.rb +127 -74
  16. data/lib/aquarium/aspects/aspect.rb +139 -72
  17. data/lib/aquarium/aspects/default_objects_handler.rb +6 -4
  18. data/lib/aquarium/aspects/exclusion_handler.rb +15 -3
  19. data/lib/aquarium/aspects/join_point.rb +60 -55
  20. data/lib/aquarium/aspects/pointcut.rb +153 -124
  21. data/lib/aquarium/aspects/pointcut_composition.rb +1 -1
  22. data/lib/aquarium/dsl/aspect_dsl.rb +13 -5
  23. data/lib/aquarium/dsl/object_dsl.rb +4 -2
  24. data/lib/aquarium/extras/design_by_contract.rb +9 -5
  25. data/lib/aquarium/finders.rb +1 -0
  26. data/lib/aquarium/finders/finder_result.rb +13 -5
  27. data/lib/aquarium/finders/method_finder.rb +75 -70
  28. data/lib/aquarium/finders/pointcut_finder.rb +166 -0
  29. data/lib/aquarium/finders/type_finder.rb +104 -62
  30. data/lib/aquarium/utils/array_utils.rb +1 -1
  31. data/lib/aquarium/utils/invalid_options.rb +2 -0
  32. data/lib/aquarium/utils/name_utils.rb +3 -2
  33. data/lib/aquarium/utils/nil_object.rb +7 -3
  34. data/lib/aquarium/utils/options_utils.rb +38 -27
  35. data/lib/aquarium/utils/set_utils.rb +2 -2
  36. data/lib/aquarium/utils/type_utils.rb +11 -0
  37. data/lib/aquarium/version.rb +1 -1
  38. data/spec/aquarium/aspects/advice_spec.rb +147 -32
  39. data/spec/aquarium/aspects/aspect_invocation_spec.rb +252 -43
  40. data/spec/aquarium/aspects/aspect_spec.rb +148 -88
  41. data/spec/aquarium/aspects/aspect_with_nested_types_spec.rb +40 -34
  42. data/spec/aquarium/aspects/aspect_with_subtypes_spec.rb +39 -3
  43. data/spec/aquarium/aspects/join_point_spec.rb +190 -227
  44. data/spec/aquarium/aspects/pointcut_spec.rb +24 -1
  45. data/spec/aquarium/dsl/aspect_dsl_spec.rb +17 -17
  46. data/spec/aquarium/finders/method_finder_spec.rb +8 -2
  47. data/spec/aquarium/finders/pointcut_finder_spec.rb +193 -0
  48. data/spec/aquarium/finders/pointcut_finder_spec_test_classes.rb +90 -0
  49. data/spec/aquarium/finders/type_finder_spec.rb +17 -0
  50. data/spec/aquarium/finders/type_finder_with_descendents_and_ancestors_spec.rb +4 -4
  51. data/spec/aquarium/finders/type_finder_with_nested_types.rb +47 -0
  52. data/spec/aquarium/utils/nil_object_spec.rb +21 -0
  53. data/spec/aquarium/utils/type_utils_sample_nested_types.rb +51 -0
  54. data/spec/aquarium/utils/type_utils_spec.rb +18 -1
  55. metadata +13 -3
@@ -0,0 +1,47 @@
1
+ require File.dirname(__FILE__) + '/../spec_helper'
2
+ require File.dirname(__FILE__) + '/../utils/type_utils_sample_classes'
3
+ require File.dirname(__FILE__) + '/../utils/type_utils_sample_nested_types'
4
+ require 'aquarium/finders/type_finder'
5
+
6
+ include Aquarium::Utils
7
+
8
+ def purge_actuals actuals
9
+ # Remove extra stuff inserted by RSpec, Aquarium, and "pretty printer" (rake?), possibly in other specs!
10
+ actuals.matched_keys.reject do |t2|
11
+ t2.name.include?("Spec::") or t2.name =~ /Aquarium::(Utils|Extras|Examples|Aspects|PointcutFinderTestClasses)/ or t2.name =~ /^PP/
12
+ end
13
+ end
14
+
15
+ describe TypeUtils, "#find types and their nested types, using :types_and_nested_types" do
16
+ it "should find the matching types and their nested types." do
17
+ Aquarium::NestedTestTypes.nested_in_NestedTestTypes.keys.each do |t|
18
+ actual = Aquarium::Finders::TypeFinder.new.find :types_and_nested_types => (t.name)
19
+ actual_keys = purge_actuals actual
20
+ actual_keys.sort{|x,y| x.name <=> y.name}.should == Aquarium::NestedTestTypes.nested_in_NestedTestTypes[t].sort{|x,y| x.name <=> y.name}
21
+ actual.not_matched_keys.should == []
22
+ end
23
+ end
24
+
25
+ Aquarium::Finders::TypeFinder::CANONICAL_OPTIONS["types_and_nested_types"].each do |synonym|
26
+ it "should accept :#{synonym} as a synonym for :types_and_nested_types" do
27
+ lambda {Aquarium::Finders::TypeFinder.new.find synonym.intern => TypeUtils.sample_types, :noop => true}.should_not raise_error(InvalidOptions)
28
+ end
29
+ end
30
+ end
31
+
32
+ describe TypeUtils, "#find nested types subtracting out excluded types and descendents, using :exclude_types_and_descendents" do
33
+ it "should find the matching types and their descendent subtypes, minus the excluded type hierarchies." do
34
+ actual = Aquarium::Finders::TypeFinder.new.find :types_and_nested_types => Aquarium::NestedTestTypes,
35
+ :exclude_types_and_nested_types => Aquarium::NestedTestTypes::TopModule
36
+ expected = [Aquarium::NestedTestTypes] + Aquarium::NestedTestTypes.nested_in_NestedTestTypes[Aquarium::NestedTestTypes::TopClass]
37
+ actual_keys = purge_actuals actual
38
+ actual_keys.sort{|x,y| x.name <=> y.name}.should == expected.sort{|x,y| x.name <=> y.name}
39
+ actual.not_matched_keys.should == []
40
+ end
41
+
42
+ Aquarium::Finders::TypeFinder::CANONICAL_OPTIONS["exclude_types_and_nested_types"].each do |synonym|
43
+ it "should accept :#{synonym} as a synonym for :exclude_types_and_nested_types" do
44
+ lambda {Aquarium::Finders::TypeFinder.new.find :exclude_types_and_nested_types => ModuleForDescendents, synonym.intern => D1ForDescendents, :noop => true}.should_not raise_error(InvalidOptions)
45
+ end
46
+ end
47
+ end
@@ -2,6 +2,27 @@ require File.dirname(__FILE__) + '/../spec_helper'
2
2
  require File.dirname(__FILE__) + '/../spec_example_types'
3
3
  require 'aquarium/utils/nil_object'
4
4
 
5
+ describe Aquarium::Utils::NilObject, "#eql?" do
6
+ it "should return true when called with any other NilObject" do
7
+ nil_object1 = Aquarium::Utils::NilObject.new
8
+ nil_object2 = Aquarium::Utils::NilObject.new
9
+ nil_object1.should eql(nil_object1)
10
+ nil_object1.should eql(nil_object2)
11
+ nil_object2.should eql(nil_object1)
12
+ nil_object1.eql?(nil_object1).should be_true
13
+ nil_object1.eql?(nil_object2).should be_true
14
+ nil_object2.eql?(nil_object1).should be_true
15
+ end
16
+
17
+ it "should return false when called with any other object" do
18
+ nil_object = Aquarium::Utils::NilObject.new
19
+ nil_object.should_not eql(nil)
20
+ nil_object.should_not eql("nil_object")
21
+ nil_object.eql?(nil).should be_false
22
+ nil_object.eql?("nil_object").should be_false
23
+ end
24
+ end
25
+
5
26
  describe Aquarium::Utils::NilObject, " (when a message is sent to it)" do
6
27
  it "should return itself, by default, for methods not defined for Object" do
7
28
  nil_object = Aquarium::Utils::NilObject.new
@@ -0,0 +1,51 @@
1
+ module Aquarium
2
+ module NestedTestTypes
3
+ def ntt; end
4
+ module TopModule
5
+ def tm; end
6
+ module MiddleModule
7
+ def mm; end
8
+ module BottomModule
9
+ def bm; end
10
+ end
11
+ class BottomModuleClass
12
+ def bmc; end
13
+ end
14
+ end
15
+ end
16
+ class TopClass
17
+ def tc; end
18
+ class MiddleClass
19
+ def mc; end
20
+ class BottomClass
21
+ def bc; end
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
27
+
28
+
29
+ module Aquarium
30
+ module NestedTestTypes
31
+ @@bottom_modules = [Aquarium::NestedTestTypes::TopModule::MiddleModule::BottomModule]
32
+ @@bottom_modules_classes = [Aquarium::NestedTestTypes::TopModule::MiddleModule::BottomModuleClass]
33
+ @@middle_modules = [Aquarium::NestedTestTypes::TopModule::MiddleModule] + @@bottom_modules + @@bottom_modules_classes
34
+ @@top_modules = [Aquarium::NestedTestTypes::TopModule] + @@middle_modules
35
+ @@bottom_classes = [Aquarium::NestedTestTypes::TopClass::MiddleClass::BottomClass]
36
+ @@middle_classes = [Aquarium::NestedTestTypes::TopClass::MiddleClass] + @@bottom_classes
37
+ @@top_classes = [Aquarium::NestedTestTypes::TopClass] + @@middle_classes
38
+ @@all_types = [Aquarium::NestedTestTypes] + @@top_modules + @@top_classes
39
+ def self.nested_in_NestedTestTypes
40
+ {Aquarium::NestedTestTypes => @@all_types,
41
+ Aquarium::NestedTestTypes::TopModule => @@top_modules,
42
+ Aquarium::NestedTestTypes::TopModule::MiddleModule => @@middle_modules,
43
+ Aquarium::NestedTestTypes::TopModule::MiddleModule::BottomModule => @@bottom_modules,
44
+ Aquarium::NestedTestTypes::TopModule::MiddleModule::BottomModuleClass => @@bottom_modules_classes,
45
+ Aquarium::NestedTestTypes::TopClass => @@top_classes,
46
+ Aquarium::NestedTestTypes::TopClass::MiddleClass => @@middle_classes,
47
+ Aquarium::NestedTestTypes::TopClass::MiddleClass::BottomClass => @@bottom_classes}
48
+ end
49
+ end
50
+ end
51
+
@@ -1,6 +1,7 @@
1
1
  require File.dirname(__FILE__) + '/../spec_helper'
2
2
  require 'aquarium/utils/type_utils'
3
3
  require File.dirname(__FILE__) + '/../utils/type_utils_sample_classes'
4
+ require File.dirname(__FILE__) + '/../utils/type_utils_sample_nested_types'
4
5
 
5
6
  include Aquarium::Utils
6
7
 
@@ -82,4 +83,20 @@ describe TypeUtils, ".descendents applied to JRuby-wrapped Java classes" do
82
83
  it "should properly determine descendents" do
83
84
  TypeUtils.descendents(FakeJRubyWrapperModule).should include(FakeJRubyWrapperClass)
84
85
  end
85
- end
86
+ end
87
+
88
+ describe TypeUtils, ".nested called with a type" do
89
+ it "should return the type itself in the result" do
90
+ Aquarium::NestedTestTypes.nested_in_NestedTestTypes.keys.each do |t|
91
+ TypeUtils.nested(t).should include(t)
92
+ end
93
+ end
94
+
95
+ it "should return all the modules and classes nested under the type, inclusive" do
96
+ Aquarium::NestedTestTypes.nested_in_NestedTestTypes.keys.each do |t|
97
+ actual_types = TypeUtils.nested(t)
98
+ actual_types.sort{|x,y| x.name <=> y.name}.should == Aquarium::NestedTestTypes.nested_in_NestedTestTypes[t].sort{|x,y| x.name <=> y.name}
99
+ end
100
+ end
101
+ end
102
+
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: aquarium
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ version: 0.4.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aquarium Development Team
@@ -9,7 +9,7 @@ autorequire: aquarium
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-04-15 00:00:00 -05:00
12
+ date: 2008-05-25 00:00:00 -05:00
13
13
  default_executable: ""
14
14
  dependencies: []
15
15
 
@@ -25,11 +25,14 @@ extra_rdoc_files:
25
25
  - MIT-LICENSE
26
26
  - UPGRADE
27
27
  files:
28
+ - Aquarium-IDEA.ipr
29
+ - Aquarium-IDEA.iws
28
30
  - Aquarium.ipr
29
31
  - Aquarium.iws
30
32
  - CHANGES
31
33
  - EXAMPLES.rd
32
34
  - MIT-LICENSE
35
+ - ParseTreePlay.rb
33
36
  - Rakefile
34
37
  - README
35
38
  - RELEASE-PLAN
@@ -56,6 +59,7 @@ files:
56
59
  - lib/aquarium/extras.rb
57
60
  - lib/aquarium/finders/finder_result.rb
58
61
  - lib/aquarium/finders/method_finder.rb
62
+ - lib/aquarium/finders/pointcut_finder.rb
59
63
  - lib/aquarium/finders/type_finder.rb
60
64
  - lib/aquarium/finders.rb
61
65
  - lib/aquarium/utils/array_utils.rb
@@ -96,8 +100,11 @@ files:
96
100
  - spec/aquarium/extras/design_by_contract_spec.rb
97
101
  - spec/aquarium/finders/finder_result_spec.rb
98
102
  - spec/aquarium/finders/method_finder_spec.rb
103
+ - spec/aquarium/finders/pointcut_finder_spec.rb
104
+ - spec/aquarium/finders/pointcut_finder_spec_test_classes.rb
99
105
  - spec/aquarium/finders/type_finder_spec.rb
100
106
  - spec/aquarium/finders/type_finder_with_descendents_and_ancestors_spec.rb
107
+ - spec/aquarium/finders/type_finder_with_nested_types.rb
101
108
  - spec/aquarium/spec_example_types.rb
102
109
  - spec/aquarium/spec_helper.rb
103
110
  - spec/aquarium/utils/array_utils_spec.rb
@@ -111,6 +118,7 @@ files:
111
118
  - spec/aquarium/utils/options_utils_spec.rb
112
119
  - spec/aquarium/utils/set_utils_spec.rb
113
120
  - spec/aquarium/utils/type_utils_sample_classes.rb
121
+ - spec/aquarium/utils/type_utils_sample_nested_types.rb
114
122
  - spec/aquarium/utils/type_utils_spec.rb
115
123
  - examples/aspect_design_example.rb
116
124
  - examples/aspect_design_example_spec.rb
@@ -118,6 +126,8 @@ files:
118
126
  - examples/design_by_contract_example_spec.rb
119
127
  - examples/exception_wrapping_example.rb
120
128
  - examples/exception_wrapping_example_spec.rb
129
+ - examples/introductions_example.rb
130
+ - examples/introductions_example_spec.rb
121
131
  - examples/method_missing_example.rb
122
132
  - examples/method_missing_example_spec.rb
123
133
  - examples/method_tracing_example.rb
@@ -158,6 +168,6 @@ rubyforge_project: aquarium
158
168
  rubygems_version: 1.0.1
159
169
  signing_key:
160
170
  specification_version: 2
161
- summary: Aquarium-0.4.1 (r7) - Aspect-Oriented Programming toolkit for Ruby http://aquarium.rubyforge.org
171
+ summary: Aquarium-0.4.2 (r7) - Aspect-Oriented Programming toolkit for Ruby http://aquarium.rubyforge.org
162
172
  test_files: []
163
173