mtrack 2.0.2 → 2.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +1 -1
- data/lib/mtrack/mixin.rb +3 -4
- data/lib/mtrack/version.rb +3 -4
- data/spec/lib/mtrack/mixin_spec.rb +25 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8d17138603c8953364240a742a8a995903bb9d8e
|
4
|
+
data.tar.gz: d77448219c49d86d8d40ac266f2159ddd865400d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c3f1ec9ace1fad251c1462538217e25bc70eccd75c278191acdaa3629b68bae855c31e0bb6b15fa4a866efd70384716fb6ed4487b38906696d67bde2a28108f1
|
7
|
+
data.tar.gz: d94116ca86eba9945937b0a72ef764a746253d38594ad7ba4e1235d009ef2ec22a6ebf7e2ce811eacca1a8a5aae0feaae3057c99e3da27d0606795029faff392
|
data/Gemfile
CHANGED
data/lib/mtrack/mixin.rb
CHANGED
@@ -31,12 +31,11 @@ module MTrack
|
|
31
31
|
# call-seq:
|
32
32
|
# newly_defined_methods(mod, old_methods) => set
|
33
33
|
#
|
34
|
-
# Calculates the difference between +mod+'s currently defined
|
35
|
-
# methods and +old_methods+.
|
34
|
+
# Calculates the difference between +mod+'s currently defined methods and +old_methods+.
|
36
35
|
#
|
37
36
|
# Returns a set with the result.
|
38
37
|
def newly_defined_methods(mod, old_methods)
|
39
|
-
(mod.
|
38
|
+
(mod.instance_methods(false) + mod.private_instance_methods(false) - old_methods).to_set
|
40
39
|
end
|
41
40
|
|
42
41
|
##
|
@@ -63,7 +62,7 @@ module MTrack
|
|
63
62
|
#
|
64
63
|
# Returns a set containing the methods that were defined within the block.
|
65
64
|
def track_methods_for(mod, group_name, &b)
|
66
|
-
old_methods = mod.
|
65
|
+
old_methods = mod.instance_methods(false) + mod.private_instance_methods(false)
|
67
66
|
|
68
67
|
begin
|
69
68
|
mod.module_eval(&b) if block_given?
|
data/lib/mtrack/version.rb
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
##
|
2
|
-
# MTrack extends the functionality of Modules and Classes and enables them to
|
3
|
-
#
|
4
|
-
# even through a hierarchy of inclusion and/or inheritance.
|
2
|
+
# MTrack extends the functionality of Modules and Classes and enables them to define methods within groups. These
|
3
|
+
# methods can then be queried back even through a hierarchy of inclusion and/or inheritance.
|
5
4
|
#
|
6
5
|
# module M
|
7
6
|
# extend MTrack::Mixin
|
@@ -20,5 +19,5 @@
|
|
20
19
|
# D.tracked_methods #=> #<Set: {:method_1, :method_2, :method_3}>
|
21
20
|
module MTrack
|
22
21
|
# Current version of MTrack.
|
23
|
-
VERSION = "2.0
|
22
|
+
VERSION = "2.1.0"
|
24
23
|
end
|
@@ -64,6 +64,12 @@ describe MTrack::Mixin do
|
|
64
64
|
track_methods(:even) { define_method :two, METHOD_DEFINITION }
|
65
65
|
end
|
66
66
|
define_method :unt_2, METHOD_DEFINITION
|
67
|
+
|
68
|
+
track_methods :visibility do
|
69
|
+
public # rubocop:disable Style/EmptyLinesAroundAccessModifier
|
70
|
+
|
71
|
+
define_method :my_public, METHOD_DEFINITION
|
72
|
+
end
|
67
73
|
end
|
68
74
|
end
|
69
75
|
end
|
@@ -80,6 +86,12 @@ describe MTrack::Mixin do
|
|
80
86
|
track_methods(:odd) { define_method :three, METHOD_DEFINITION }
|
81
87
|
end
|
82
88
|
define_method :unt_3, METHOD_DEFINITION
|
89
|
+
|
90
|
+
track_methods :visibility do
|
91
|
+
protected # rubocop:disable Style/EmptyLinesAroundAccessModifier
|
92
|
+
|
93
|
+
define_method :my_protected, METHOD_DEFINITION
|
94
|
+
end
|
83
95
|
end
|
84
96
|
end
|
85
97
|
end
|
@@ -95,6 +107,12 @@ describe MTrack::Mixin do
|
|
95
107
|
track_methods(:even) { define_method :four, METHOD_DEFINITION }
|
96
108
|
end
|
97
109
|
define_method :unt_4, METHOD_DEFINITION
|
110
|
+
|
111
|
+
track_methods :visibility do
|
112
|
+
private # rubocop:disable Style/EmptyLinesAroundAccessModifier
|
113
|
+
|
114
|
+
define_method :my_private, METHOD_DEFINITION
|
115
|
+
end
|
98
116
|
end
|
99
117
|
end
|
100
118
|
end
|
@@ -175,6 +193,7 @@ describe MTrack::Mixin do
|
|
175
193
|
expect(subject.tracked_methods(:numbers)).to match_array([:one, :two])
|
176
194
|
expect(subject.tracked_methods(:odd)).to match_array([:one])
|
177
195
|
expect(subject.tracked_methods(:even)).to match_array([:two])
|
196
|
+
expect(subject.tracked_methods(:visibility)).to match_array([:my_public])
|
178
197
|
end
|
179
198
|
|
180
199
|
it "untracks removed methods" do
|
@@ -203,6 +222,7 @@ describe MTrack::Mixin do
|
|
203
222
|
expect(subject.tracked_methods(:numbers)).to match_array([:two, :three])
|
204
223
|
expect(subject.tracked_methods(:even)).to match_array([:two])
|
205
224
|
expect(subject.tracked_methods(:odd)).to match_array([:three])
|
225
|
+
expect(subject.tracked_methods(:visibility)).to match_array([:my_protected])
|
206
226
|
end
|
207
227
|
|
208
228
|
it "untracks removed methods" do
|
@@ -231,6 +251,7 @@ describe MTrack::Mixin do
|
|
231
251
|
expect(subject.tracked_methods(:numbers)).to match_array([:three, :four])
|
232
252
|
expect(subject.tracked_methods(:odd)).to match_array([:three])
|
233
253
|
expect(subject.tracked_methods(:even)).to match_array([:four])
|
254
|
+
expect(subject.tracked_methods(:visibility)).to match_array([:my_private])
|
234
255
|
end
|
235
256
|
|
236
257
|
it "untracks removed methods" do
|
@@ -255,6 +276,7 @@ describe MTrack::Mixin do
|
|
255
276
|
expect(subject.tracked_methods(:numbers)).to match_array([:one, :two, :three, :four, :five])
|
256
277
|
expect(subject.tracked_methods(:odd)).to match_array([:one, :three, :five])
|
257
278
|
expect(subject.tracked_methods(:even)).to match_array([:two, :four])
|
279
|
+
expect(subject.tracked_methods(:visibility)).to match_array([:my_public, :my_protected])
|
258
280
|
end
|
259
281
|
|
260
282
|
it "untracks removed methods" do
|
@@ -285,6 +307,7 @@ describe MTrack::Mixin do
|
|
285
307
|
expect(subject.tracked_methods(:numbers)).to match_array([:three, :four, :five, :six])
|
286
308
|
expect(subject.tracked_methods(:odd)).to match_array([:three, :five])
|
287
309
|
expect(subject.tracked_methods(:even)).to match_array([:four, :six])
|
310
|
+
expect(subject.tracked_methods(:visibility)).to match_array([:my_private])
|
288
311
|
end
|
289
312
|
|
290
313
|
it "untracks removed methods" do
|
@@ -312,6 +335,7 @@ describe MTrack::Mixin do
|
|
312
335
|
expect(subject.tracked_methods(:numbers)).to match_array([:one, :two, :three, :four, :five, :six, :seven])
|
313
336
|
expect(subject.tracked_methods(:odd)).to match_array([:one, :three, :five, :seven])
|
314
337
|
expect(subject.tracked_methods(:even)).to match_array([:two, :four, :six])
|
338
|
+
expect(subject.tracked_methods(:visibility)).to match_array([:my_public, :my_protected])
|
315
339
|
end
|
316
340
|
|
317
341
|
it "untracks removed methods" do
|
@@ -345,6 +369,7 @@ describe MTrack::Mixin do
|
|
345
369
|
expect(subject.tracked_methods(:numbers)).to match_array([:one, :two, :three, :four, :five, :six, :seven, :eight])
|
346
370
|
expect(subject.tracked_methods(:odd)).to match_array([:one, :three, :five, :seven])
|
347
371
|
expect(subject.tracked_methods(:even)).to match_array([:two, :four, :six, :eight])
|
372
|
+
expect(subject.tracked_methods(:visibility)).to match_array([:my_public, :my_protected, :my_private])
|
348
373
|
end
|
349
374
|
|
350
375
|
it "untracks removed methods" do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mtrack
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0
|
4
|
+
version: 2.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gabriel de Oliveira
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-01-
|
11
|
+
date: 2015-01-21 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: |
|
14
14
|
MTrack extends the functionality of modules and classes and enables them to define public methods within groups. These
|