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.
- data/CHANGES +26 -5
- data/README +8 -8
- data/RELEASE-PLAN +20 -2
- data/TODO.rb +26 -0
- data/UPGRADE +5 -5
- data/examples/aspect_design_example.rb +1 -1
- data/examples/aspect_design_example_spec.rb +1 -1
- data/examples/design_by_contract_example.rb +4 -9
- data/examples/design_by_contract_example_spec.rb +7 -9
- data/examples/exception_wrapping_example.rb +48 -0
- data/examples/exception_wrapping_example_spec.rb +49 -0
- data/examples/reusable_aspect_hack_example.rb +56 -0
- data/examples/reusable_aspect_hack_example_spec.rb +80 -0
- data/lib/aquarium.rb +1 -0
- data/lib/aquarium/aspects.rb +1 -1
- data/lib/aquarium/aspects/advice.rb +16 -13
- data/lib/aquarium/aspects/aspect.rb +81 -56
- data/lib/aquarium/aspects/join_point.rb +4 -4
- data/lib/aquarium/aspects/pointcut.rb +49 -73
- data/lib/aquarium/dsl.rb +2 -0
- data/lib/aquarium/dsl/aspect_dsl.rb +77 -0
- data/lib/aquarium/{aspects/dsl → dsl}/object_dsl.rb +2 -2
- data/lib/aquarium/extras/design_by_contract.rb +1 -1
- data/lib/aquarium/finders.rb +1 -1
- data/lib/aquarium/finders/method_finder.rb +26 -26
- data/lib/aquarium/finders/type_finder.rb +45 -39
- data/lib/aquarium/utils/array_utils.rb +6 -5
- data/lib/aquarium/utils/default_logger.rb +2 -1
- data/lib/aquarium/utils/options_utils.rb +178 -67
- data/lib/aquarium/utils/set_utils.rb +8 -3
- data/lib/aquarium/version.rb +1 -1
- data/spec/aquarium/aspects/aspect_invocation_spec.rb +111 -14
- data/spec/aquarium/aspects/aspect_spec.rb +91 -7
- data/spec/aquarium/aspects/pointcut_spec.rb +61 -0
- data/spec/aquarium/{aspects/dsl → dsl}/aspect_dsl_spec.rb +76 -32
- data/spec/aquarium/finders/method_finder_spec.rb +80 -80
- data/spec/aquarium/finders/type_finder_spec.rb +57 -52
- data/spec/aquarium/finders/type_finder_with_descendents_and_ancestors_spec.rb +12 -12
- data/spec/aquarium/spec_example_types.rb +4 -3
- data/spec/aquarium/utils/array_utils_spec.rb +9 -7
- data/spec/aquarium/utils/options_utils_spec.rb +106 -5
- data/spec/aquarium/utils/set_utils_spec.rb +14 -0
- metadata +12 -7
- data/lib/aquarium/aspects/dsl.rb +0 -2
- data/lib/aquarium/aspects/dsl/aspect_dsl.rb +0 -64
data/lib/aquarium/aspects/dsl.rb
DELETED
@@ -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
|