aspectual 0.1.1 → 0.9.0

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.
@@ -1,221 +1,284 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require_relative '../../lib/aspectual'
2
4
 
3
- describe Aspectual do
4
- class TestClass
5
- extend Aspectual
5
+ class TestClass
6
+ extend Aspectual
6
7
 
7
- attr_reader :methods_called
8
+ attr_reader :methods_called
8
9
 
9
- def initialize
10
- # This is to ensure that all methods are properly called within the
11
- # context of the current instance of this object.
12
- @methods_called = []
13
- end
10
+ def initialize
11
+ # This is to ensure that all methods are properly called within the
12
+ # context of the current instance of this object.
13
+ @methods_called = []
14
+ end
14
15
 
15
- # These definitions could be looped over to make this class shorter, but the
16
- # decision has been made to go for clarity over brevity.
17
- def single_test_method
18
- methods_called << "single_test_method"
19
- self
20
- end
16
+ # These definitions could be looped over to make this class shorter, but the
17
+ # decision has been made to go for clarity over brevity.
18
+ def single_test_method
19
+ methods_called << 'single_test_method'
20
+ self
21
+ end
21
22
 
22
- def array_test_method_0
23
- methods_called << "array_test_method_0"
24
- self
25
- end
23
+ def array_test_method_0
24
+ methods_called << 'array_test_method_0'
25
+ self
26
+ end
26
27
 
27
- def array_test_method_1
28
- methods_called << "array_test_method_1"
29
- self
30
- end
28
+ def array_test_method_1
29
+ methods_called << 'array_test_method_1'
30
+ self
31
+ end
31
32
 
32
- def before_test_method_0
33
- methods_called << "before_test_method_0"
34
- self
35
- end
33
+ def before_test_method_0
34
+ methods_called << 'before_test_method_0'
35
+ self
36
+ end
36
37
 
37
- def before_test_method_1
38
- methods_called << "before_test_method_1"
39
- self
40
- end
38
+ def before_test_method_1
39
+ methods_called << 'before_test_method_1'
40
+ self
41
+ end
41
42
 
42
- def after_test_method_0
43
- methods_called << "after_test_method_0"
44
- self
45
- end
43
+ def after_test_method_0
44
+ methods_called << 'after_test_method_0'
45
+ self
46
+ end
46
47
 
47
- def after_test_method_1
48
- methods_called << "after_test_method_1"
49
- self
50
- end
48
+ def after_test_method_1
49
+ methods_called << 'after_test_method_1'
50
+ self
51
+ end
51
52
 
52
- def block_test_method_0
53
- methods_called << "before_block_test_method_0_block"
54
- yield
55
- methods_called << "after_block_test_method_0_block"
56
- self
57
- end
53
+ def block_test_method_0
54
+ methods_called << 'before_block_test_method_0_block'
55
+ yield
56
+ methods_called << 'after_block_test_method_0_block'
57
+ self
58
+ end
58
59
 
59
- def block_test_method_1
60
- methods_called << "before_block_test_method_1_block"
61
- yield
62
- methods_called << "after_block_test_method_1_block"
63
- self
64
- end
60
+ def block_test_method_1
61
+ methods_called << 'before_block_test_method_1_block'
62
+ yield
63
+ methods_called << 'after_block_test_method_1_block'
64
+ self
65
+ end
65
66
 
66
- aspects before: :single_test_method
67
- def single_before_test_method
68
- methods_called << "single_before_test_method"
69
- self
70
- end
67
+ aspects before: :single_test_method
68
+ def single_before_test_method
69
+ methods_called << 'single_before_test_method'
70
+ self
71
+ end
71
72
 
72
- aspects around: :block_test_method_0
73
- def single_around_test_method
74
- methods_called << "single_around_test_method"
75
- self
76
- end
73
+ aspects around: :block_test_method_0
74
+ def single_around_test_method
75
+ methods_called << 'single_around_test_method'
76
+ self
77
+ end
77
78
 
78
- aspects after: :single_test_method
79
- def single_after_test_method
80
- methods_called << "single_after_test_method"
81
- self
82
- end
79
+ aspects after: :single_test_method
80
+ def single_after_test_method
81
+ methods_called << 'single_after_test_method'
82
+ self
83
+ end
83
84
 
84
- aspects before: [:array_test_method_0, :array_test_method_1]
85
- def array_before_test_method
86
- methods_called << "array_before_test_method"
87
- self
88
- end
85
+ aspects before: %i[array_test_method_0 array_test_method_1]
86
+ def array_before_test_method
87
+ methods_called << 'array_before_test_method'
88
+ self
89
+ end
89
90
 
90
- aspects around: [:block_test_method_0, :block_test_method_1]
91
- def array_around_test_method
92
- methods_called << "array_around_test_method"
93
- self
94
- end
91
+ aspects before: :array_test_method_0
92
+ aspects before: :array_test_method_1
93
+ def multiple_before_test_method
94
+ methods_called << 'multiple_before_test_method'
95
+ self
96
+ end
95
97
 
96
- aspects after: [:array_test_method_0, :array_test_method_1]
97
- def array_after_test_method
98
- methods_called << "array_after_test_method"
99
- self
100
- end
98
+ def specific_before_test_method
99
+ methods_called << 'specific_before_test_method'
100
+ self
101
+ end
102
+ aspects :specific_before_test_method, before: :single_test_method
101
103
 
102
- aspects before: [:before_test_method_0, :before_test_method_1], after: [:after_test_method_0, :after_test_method_1]
103
- def before_and_after_aspects_test_method
104
- methods_called << "before_and_after_aspects_test_method"
105
- self
106
- end
104
+ aspects around: %i[block_test_method_0 block_test_method_1]
105
+ def array_around_test_method
106
+ methods_called << 'array_around_test_method'
107
+ self
108
+ end
107
109
 
108
- def public_aspect_method
109
- methods_called << "public_aspect_method"
110
- self
111
- end
110
+ aspects around: :block_test_method_0
111
+ aspects around: :block_test_method_1
112
+ def multiple_around_test_method
113
+ methods_called << 'multiple_around_test_method'
114
+ self
115
+ end
112
116
 
113
- protected
114
- aspects before: :public_aspect_method
115
- def protected_method
116
- methods_called << "protected_method"
117
- self
118
- end
117
+ def specific_around_test_method
118
+ methods_called << 'specific_around_test_method'
119
+ self
120
+ end
121
+ aspects :specific_around_test_method, around: :block_test_method_0
119
122
 
120
- private
121
- aspects before: :public_aspect_method
122
- def private_method
123
- methods_called << "private_method"
124
- self
125
- end
123
+ aspects after: %i[array_test_method_0 array_test_method_1]
124
+ def array_after_test_method
125
+ methods_called << 'array_after_test_method'
126
+ self
127
+ end
128
+
129
+ aspects after: :array_test_method_0
130
+ aspects after: :array_test_method_1
131
+ def multiple_after_test_method
132
+ methods_called << 'multiple_after_test_method'
133
+ self
134
+ end
135
+
136
+ def specific_after_test_method
137
+ methods_called << 'specific_after_test_method'
138
+ self
139
+ end
140
+ aspects :specific_after_test_method, after: :single_test_method
141
+
142
+ aspects(
143
+ before: %i[before_test_method_0 before_test_method_1],
144
+ around: %i[block_test_method_0 block_test_method_1],
145
+ after: %i[after_test_method_0 after_test_method_1],
146
+ )
147
+ def before_around_and_after_aspects_test_method
148
+ methods_called << 'before_around_and_after_aspects_test_method'
149
+ self
126
150
  end
151
+ end
127
152
 
128
- describe "before aspects" do
129
- it "calls before aspect methods before the called method" do
153
+ describe Aspectual do
154
+ describe 'before aspects' do
155
+ it 'calls before aspect methods before the called method' do
130
156
  test_instance = TestClass.new.single_before_test_method
131
- expect(test_instance.methods_called).to eq(%w{
132
- single_test_method
133
- single_before_test_method
134
- })
157
+ expect(test_instance.methods_called).to eq(%w[
158
+ single_test_method
159
+ single_before_test_method
160
+ ])
135
161
  end
136
162
 
137
- it "allows multiple aspects to be declared" do
163
+ it 'can be defined for a specific method' do
164
+ test_instance = TestClass.new.specific_before_test_method
165
+ expect(test_instance.methods_called).to eq(%w[
166
+ single_test_method
167
+ specific_before_test_method
168
+ ])
169
+ end
170
+
171
+ it 'allows multiple aspects to be declared' do
138
172
  test_instance = TestClass.new.array_before_test_method
139
- expect(test_instance.methods_called).to eq(%w{
140
- array_test_method_0
141
- array_test_method_1
142
- array_before_test_method
143
- })
173
+ expect(test_instance.methods_called).to eq(%w[
174
+ array_test_method_0
175
+ array_test_method_1
176
+ array_before_test_method
177
+ ])
178
+ end
179
+
180
+ it 'allows multiple aspects to be declared in separate calls' do
181
+ test_instance = TestClass.new.multiple_before_test_method
182
+ expect(test_instance.methods_called).to eq(%w[
183
+ array_test_method_0
184
+ array_test_method_1
185
+ multiple_before_test_method
186
+ ])
144
187
  end
145
188
  end
146
189
 
147
- describe "after aspects" do
148
- it "calls before aspect methods before the called method" do
190
+ describe 'after aspects' do
191
+ it 'calls before aspect methods before the called method' do
149
192
  test_instance = TestClass.new.single_after_test_method
150
- expect(test_instance.methods_called).to eq(%w{
151
- single_after_test_method
152
- single_test_method
153
- })
193
+ expect(test_instance.methods_called).to eq(%w[
194
+ single_after_test_method
195
+ single_test_method
196
+ ])
154
197
  end
155
198
 
156
- it "allows multiple aspects to be declared" do
157
- test_instance = TestClass.new.array_after_test_method
158
- expect(test_instance.methods_called).to eq(%w{
159
- array_after_test_method
160
- array_test_method_0
161
- array_test_method_1
162
- })
199
+ it 'can be defined for a specific method' do
200
+ test_instance = TestClass.new.specific_after_test_method
201
+ expect(test_instance.methods_called).to eq(%w[
202
+ specific_after_test_method
203
+ single_test_method
204
+ ])
163
205
  end
164
- end
165
206
 
166
- describe "around aspects" do
167
- it "calls around aspect methods around the called method" do
168
- test_instance = TestClass.new.single_around_test_method
169
- expect(test_instance.methods_called).to eq(%w{
170
- before_block_test_method_0_block
171
- single_around_test_method
172
- after_block_test_method_0_block
173
- })
207
+ it 'allows multiple aspects to be declared' do
208
+ test_instance = TestClass.new.array_after_test_method
209
+ expect(test_instance.methods_called).to eq(%w[
210
+ array_after_test_method
211
+ array_test_method_0
212
+ array_test_method_1
213
+ ])
174
214
  end
175
215
 
176
- it "allows multiple aspects to be declared" do
177
- test_instance = TestClass.new.array_around_test_method
178
- expect(test_instance.methods_called).to eq(%w{
179
- before_block_test_method_0_block
180
- before_block_test_method_1_block
181
- array_around_test_method
182
- after_block_test_method_1_block
183
- after_block_test_method_0_block
184
- })
216
+ it 'allows multiple aspects to be declared in separate calls' do
217
+ test_instance = TestClass.new.multiple_after_test_method
218
+ expect(test_instance.methods_called).to eq(%w[
219
+ multiple_after_test_method
220
+ array_test_method_0
221
+ array_test_method_1
222
+ ])
185
223
  end
186
224
  end
187
225
 
188
- describe "mixed aspects" do
189
- it "calls all the aspect declarations in the correct order" do
190
- test_instance = TestClass.new.before_and_after_aspects_test_method
191
- expect(test_instance.methods_called).to eq(%w{
192
- before_test_method_0
193
- before_test_method_1
194
- before_and_after_aspects_test_method
195
- after_test_method_0
196
- after_test_method_1
197
- })
226
+ describe 'around aspects' do
227
+ it 'calls around aspect methods around the called method' do
228
+ test_instance = TestClass.new.single_around_test_method
229
+ expect(test_instance.methods_called).to eq(%w[
230
+ before_block_test_method_0_block
231
+ single_around_test_method
232
+ after_block_test_method_0_block
233
+ ])
198
234
  end
199
- end
200
235
 
201
- describe "public methods" do
202
- it "stay public" do
203
- test_instance = TestClass.new.single_before_test_method
204
- expect(test_instance.public_methods).to include(:single_before_test_method)
236
+ it 'can be defined for a specific method' do
237
+ test_instance = TestClass.new.specific_around_test_method
238
+ expect(test_instance.methods_called).to eq(%w[
239
+ before_block_test_method_0_block
240
+ specific_around_test_method
241
+ after_block_test_method_0_block
242
+ ])
243
+ end
244
+
245
+ it 'allows multiple aspects to be declared' do
246
+ test_instance = TestClass.new.array_around_test_method
247
+ expect(test_instance.methods_called).to eq(%w[
248
+ before_block_test_method_0_block
249
+ before_block_test_method_1_block
250
+ array_around_test_method
251
+ after_block_test_method_1_block
252
+ after_block_test_method_0_block
253
+ ])
205
254
  end
206
- end
207
255
 
208
- describe "protected methods" do
209
- it "stay protected" do
210
- test_instance = TestClass.new
211
- expect(test_instance.protected_methods).to include(:protected_method)
256
+ it 'allows multiple aspects to be declared in separate calls' do
257
+ test_instance = TestClass.new.multiple_around_test_method
258
+ expect(test_instance.methods_called).to eq(%w[
259
+ before_block_test_method_0_block
260
+ before_block_test_method_1_block
261
+ multiple_around_test_method
262
+ after_block_test_method_1_block
263
+ after_block_test_method_0_block
264
+ ])
212
265
  end
213
266
  end
214
267
 
215
- describe "private methods" do
216
- it "stay private" do
217
- test_instance = TestClass.new
218
- expect(test_instance.private_methods).to include(:private_method)
268
+ describe 'mixed aspects' do
269
+ it 'calls all the aspect declarations in the correct order' do
270
+ test_instance = TestClass.new.before_around_and_after_aspects_test_method
271
+ expect(test_instance.methods_called).to eq(%w[
272
+ before_test_method_0
273
+ before_test_method_1
274
+ before_block_test_method_0_block
275
+ before_block_test_method_1_block
276
+ before_around_and_after_aspects_test_method
277
+ after_block_test_method_1_block
278
+ after_block_test_method_0_block
279
+ after_test_method_0
280
+ after_test_method_1
281
+ ])
219
282
  end
220
283
  end
221
284
  end
metadata CHANGED
@@ -1,57 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: aspectual
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.9.0
5
5
  platform: ruby
6
6
  authors:
7
- - Alex Sunderland
8
- autorequire:
7
+ - Fell Sunderland
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2014-12-27 00:00:00.000000000 Z
12
- dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: bundler
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - ">="
18
- - !ruby/object:Gem::Version
19
- version: '0'
20
- type: :development
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - ">="
25
- - !ruby/object:Gem::Version
26
- version: '0'
27
- - !ruby/object:Gem::Dependency
28
- name: rake
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - ">="
32
- - !ruby/object:Gem::Version
33
- version: '0'
34
- type: :development
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - ">="
39
- - !ruby/object:Gem::Version
40
- version: '0'
41
- - !ruby/object:Gem::Dependency
42
- name: rspec
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - ">="
46
- - !ruby/object:Gem::Version
47
- version: '0'
48
- type: :development
49
- prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - ">="
53
- - !ruby/object:Gem::Version
54
- version: '0'
10
+ date: 1980-01-02 00:00:00.000000000 Z
11
+ dependencies: []
55
12
  description: "\n A simple gem to support minimal Aspect Oriented Programming in
56
13
  ruby.\n "
57
14
  email:
@@ -60,18 +17,30 @@ executables: []
60
17
  extensions: []
61
18
  extra_rdoc_files: []
62
19
  files:
20
+ - ".github/workflows/rubocop.yml"
21
+ - ".github/workflows/ruby.yml"
63
22
  - ".gitignore"
23
+ - ".rubocop.yml"
64
24
  - Gemfile
65
25
  - README.md
66
26
  - aspectual.gemspec
67
27
  - lib/aspectual.rb
28
+ - lib/aspectual/method_construction.rb
68
29
  - lib/aspectual/version.rb
30
+ - spec/lib/aspectual_block_args_spec.rb
31
+ - spec/lib/aspectual_complex_args_spec.rb
32
+ - spec/lib/aspectual_inheritance_spec.rb
33
+ - spec/lib/aspectual_kwargs_spec.rb
34
+ - spec/lib/aspectual_non_word_ending_character_spec.rb
35
+ - spec/lib/aspectual_positional_args_spec.rb
36
+ - spec/lib/aspectual_return_value_spec.rb
37
+ - spec/lib/aspectual_scoping_spec.rb
69
38
  - spec/lib/aspectual_spec.rb
70
39
  homepage: https://github.com/AgentAntelope/aspectual
71
40
  licenses:
72
41
  - MIT
73
- metadata: {}
74
- post_install_message:
42
+ metadata:
43
+ rubygems_mfa_required: 'true'
75
44
  rdoc_options: []
76
45
  require_paths:
77
46
  - lib
@@ -79,17 +48,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
79
48
  requirements:
80
49
  - - ">="
81
50
  - !ruby/object:Gem::Version
82
- version: '0'
51
+ version: '3.1'
83
52
  required_rubygems_version: !ruby/object:Gem::Requirement
84
53
  requirements:
85
54
  - - ">="
86
55
  - !ruby/object:Gem::Version
87
56
  version: '0'
88
57
  requirements: []
89
- rubyforge_project:
90
- rubygems_version: 2.4.5
91
- signing_key:
58
+ rubygems_version: 4.0.15
92
59
  specification_version: 4
93
60
  summary: A gem to help with AOP.
94
- test_files:
95
- - spec/lib/aspectual_spec.rb
61
+ test_files: []