aquarium 0.4.0 → 0.4.1

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 (45) hide show
  1. data/CHANGES +26 -5
  2. data/README +8 -8
  3. data/RELEASE-PLAN +20 -2
  4. data/TODO.rb +26 -0
  5. data/UPGRADE +5 -5
  6. data/examples/aspect_design_example.rb +1 -1
  7. data/examples/aspect_design_example_spec.rb +1 -1
  8. data/examples/design_by_contract_example.rb +4 -9
  9. data/examples/design_by_contract_example_spec.rb +7 -9
  10. data/examples/exception_wrapping_example.rb +48 -0
  11. data/examples/exception_wrapping_example_spec.rb +49 -0
  12. data/examples/reusable_aspect_hack_example.rb +56 -0
  13. data/examples/reusable_aspect_hack_example_spec.rb +80 -0
  14. data/lib/aquarium.rb +1 -0
  15. data/lib/aquarium/aspects.rb +1 -1
  16. data/lib/aquarium/aspects/advice.rb +16 -13
  17. data/lib/aquarium/aspects/aspect.rb +81 -56
  18. data/lib/aquarium/aspects/join_point.rb +4 -4
  19. data/lib/aquarium/aspects/pointcut.rb +49 -73
  20. data/lib/aquarium/dsl.rb +2 -0
  21. data/lib/aquarium/dsl/aspect_dsl.rb +77 -0
  22. data/lib/aquarium/{aspects/dsl → dsl}/object_dsl.rb +2 -2
  23. data/lib/aquarium/extras/design_by_contract.rb +1 -1
  24. data/lib/aquarium/finders.rb +1 -1
  25. data/lib/aquarium/finders/method_finder.rb +26 -26
  26. data/lib/aquarium/finders/type_finder.rb +45 -39
  27. data/lib/aquarium/utils/array_utils.rb +6 -5
  28. data/lib/aquarium/utils/default_logger.rb +2 -1
  29. data/lib/aquarium/utils/options_utils.rb +178 -67
  30. data/lib/aquarium/utils/set_utils.rb +8 -3
  31. data/lib/aquarium/version.rb +1 -1
  32. data/spec/aquarium/aspects/aspect_invocation_spec.rb +111 -14
  33. data/spec/aquarium/aspects/aspect_spec.rb +91 -7
  34. data/spec/aquarium/aspects/pointcut_spec.rb +61 -0
  35. data/spec/aquarium/{aspects/dsl → dsl}/aspect_dsl_spec.rb +76 -32
  36. data/spec/aquarium/finders/method_finder_spec.rb +80 -80
  37. data/spec/aquarium/finders/type_finder_spec.rb +57 -52
  38. data/spec/aquarium/finders/type_finder_with_descendents_and_ancestors_spec.rb +12 -12
  39. data/spec/aquarium/spec_example_types.rb +4 -3
  40. data/spec/aquarium/utils/array_utils_spec.rb +9 -7
  41. data/spec/aquarium/utils/options_utils_spec.rb +106 -5
  42. data/spec/aquarium/utils/set_utils_spec.rb +14 -0
  43. metadata +12 -7
  44. data/lib/aquarium/aspects/dsl.rb +0 -2
  45. data/lib/aquarium/aspects/dsl/aspect_dsl.rb +0 -64
@@ -1,2 +0,0 @@
1
- # NEVER require 'aquarium/aspects/dsl/object_dsl' here!
2
- require 'aquarium/aspects/dsl/aspect_dsl'
@@ -1,64 +0,0 @@
1
- require 'aquarium/aspects/aspect'
2
- require 'aquarium/utils/type_utils'
3
-
4
- # Convenience methods added to Object to promote an AOP DSL. If you don't want these methods added to Object,
5
- # then only require aspect.rb and create instances of Aspect.
6
-
7
- module Aquarium
8
- module Aspects
9
- module DSL
10
- module AspectDSL
11
-
12
- def advise *options, &block
13
- o = append_implicit_self options
14
- Aspect.new *o, &block
15
- end
16
-
17
- %w[before after after_returning after_raising around].each do |advice_kind|
18
- module_eval(<<-ADVICE_METHODS, __FILE__, __LINE__)
19
- def #{advice_kind} *options, &block
20
- advise :#{advice_kind}, *options, &block
21
- end
22
- ADVICE_METHODS
23
- end
24
-
25
- %w[after after_returning after_raising].each do |after_kind|
26
- module_eval(<<-AFTER, __FILE__, __LINE__)
27
- def before_and_#{after_kind} *options, &block
28
- advise :before, :#{after_kind}, *options, &block
29
- end
30
- AFTER
31
- end
32
-
33
- alias :after_returning_from :after_returning
34
- alias :after_raising_within :after_raising
35
- alias :after_raising_within_or_returning_from :after
36
-
37
- alias :before_and_after_returning_from :before_and_after_returning
38
- alias :before_and_after_raising_within :before_and_after_raising
39
- alias :before_and_after_raising_within_or_returning_from :before_and_after
40
-
41
- def pointcut *options, &block
42
- o = append_implicit_self options
43
- Pointcut.new *o, &block
44
- end
45
-
46
- # Add the methods as class, not instance, methods.
47
- def self.append_features clazz
48
- super(class << clazz; self; end)
49
- end
50
-
51
- private
52
- def append_implicit_self options
53
- opts = options.dup
54
- if (!opts.empty?) && opts.last.kind_of?(Hash)
55
- opts.last[:default_objects] = self
56
- else
57
- opts << {:default_objects => self}
58
- end
59
- opts
60
- end
61
- end
62
- end
63
- end
64
- end