mtrack 1.0.1 → 1.0.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 47372a8862653c8eb0f9e0d0d1bfa23b4444c2ad
4
- data.tar.gz: 3685e9ba264b976121b5a03cb9f7d5a8634a73f5
3
+ metadata.gz: 9f9c9bb07bed7e3b987ad36fc5a7652a0d16c251
4
+ data.tar.gz: b979016ffe198365cc5a8cac84cb55a13833598f
5
5
  SHA512:
6
- metadata.gz: 256525258b5c0734ac001c3523c2e784a2837a935300d0954c78f66a324525fdea8668c52786a118d0703cc6b2475cd5c5997c8b1044df2a08861b73d2b8a980
7
- data.tar.gz: 61e344ae82889273640dcf6beb3e2e3a4f08d2103435daf829ce63245f8af8ce216aa5320af81bb63fa9e485ded32d8938e2788555f453b884b80ee10e38df8c
6
+ metadata.gz: 0652e5ba511e35770f6235913a33d6d3dff5c73e741c6be565380f7ddc31154f27de449ad77b437f7196493cb44a686f2543d4864adb97223a6eed7c7279a5a0
7
+ data.tar.gz: 6ae8c5a491700c4936d3c5579731cf0521b85d2d3e7c768d8a71cd57feacd51ed559f4dbf3c12e77fb805d8df77c9ea9df428bc3acbc02897049a217a50f3817
data/.rubocop.yml ADDED
@@ -0,0 +1,8 @@
1
+ Metrics/LineLength:
2
+ Max: 120
3
+ Style/HashSyntax:
4
+ EnforcedStyle: hash_rockets
5
+ Style/SpaceInsideBlockBraces:
6
+ SpaceBeforeBlockParameters: false
7
+ Style/StringLiterals:
8
+ EnforcedStyle: double_quotes
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 2.1.3
1
+ 2.1.4
data/.travis.yml CHANGED
@@ -1,15 +1,16 @@
1
1
  language: ruby
2
2
  rvm:
3
- - ruby-head
4
- - 2.1
5
- - 2.0
6
- - 1.9.3
7
- - 1.9.2
8
- - 1.8.7
9
- - jruby-head
10
- - jruby-1.7
11
- - jruby-1.6
12
- bundler_args: --without development
3
+ - ruby-head
4
+ - 2.1
5
+ - 2.0
6
+ - 1.9.3
7
+ - 1.9.2
8
+ - 1.8.7
9
+ - jruby-head
10
+ - jruby-1.7
11
+ - jruby-1.6
12
+ bundler_args: "--without development"
13
13
  addons:
14
14
  code_climate:
15
- repo_token: cc41eb6449075390a8bdb804fa3ff5865a7fbf22384fcd1757730b702eefdb0a
15
+ repo_token:
16
+ secure: HdKw+GBs77+DnKb9oRTaARf8GuTAaKedEGvxh2W6z8NsxhbSVY5hJAYWdqg/8r2Aywqui7+8OH1bJ90PixipgJjIlDu8uamaiYfjScPMk5VPl0UOtOo/cAo4F79d1lHsbymtuoZI8Mat7FE0//d1QorruZ1lsXsKPrWWPi9byV0=
data/Gemfile CHANGED
@@ -4,8 +4,10 @@ gemspec
4
4
  group :development do
5
5
  gem "byebug", "~> 3.5.1"
6
6
  gem "guard-rspec", "~> 4.3.1"
7
+ gem "guard-rubocop", "~> 1.2.0"
7
8
  gem "libnotify", "~> 0.8.4"
8
9
  gem "pry", "~> 0.10.1"
10
+ gem "rubocop", "~> 0.27.0"
9
11
  end
10
12
 
11
13
  group :development, :test do
data/Guardfile CHANGED
@@ -1,5 +1,10 @@
1
- guard :rspec, cmd: "rspec -fd" do
2
- watch(%r{^spec/.+_spec\.rb$})
3
- watch(%r{^lib/(.+)\.rb$}) {|m| "spec/lib/#{m[1]}_spec.rb" }
1
+ guard :rspec, :cmd => "rspec -fd" do
2
+ watch(/^spec\/.+_spec\.rb$/)
3
+ watch(/^lib\/(.+)\.rb$/) {|m| "spec/lib/#{m[1]}_spec.rb" }
4
4
  watch("spec/spec_helper.rb") { "spec" }
5
5
  end
6
+
7
+ guard :rubocop do
8
+ watch(/.+\.rb$/)
9
+ watch(/(?:.+\/)?\.rubocop\.yml$/) {|m| File.dirname(m[0]) }
10
+ end
data/lib/mtrack/mixin.rb CHANGED
@@ -60,7 +60,7 @@ module MTrack
60
60
  old_methods = mod.public_instance_methods false
61
61
 
62
62
  begin
63
- mod.module_eval &b if block_given?
63
+ mod.module_eval(&b) if block_given?
64
64
  ensure
65
65
  tracked = newly_defined_methods(mod, old_methods)
66
66
  save_tracked_methods(mod, group_name, tracked)
data/lib/mtrack/state.rb CHANGED
@@ -3,17 +3,15 @@ require "set"
3
3
  require "mtrack/state/group"
4
4
 
5
5
  module MTrack
6
-
7
6
  ##
8
7
  # Holds the internal state of tracked methods on Modules and Classes.
9
8
  class State
10
-
11
9
  ##
12
10
  # call-seq:
13
11
  # new() => new_state
14
12
  #
15
13
  # Creates a new State instance.
16
- def initialize()
14
+ def initialize
17
15
  self.groups = {}
18
16
  self.super_states = Set.new
19
17
  self.undefined = Set.new
@@ -62,7 +60,7 @@ module MTrack
62
60
  #
63
61
  # Returns passed +name+.
64
62
  def delete_tracked(name)
65
- groups.each {|k, v| v.delete_tracked name }
63
+ groups.values.each {|v| v.delete_tracked name }
66
64
  name
67
65
  end
68
66
 
@@ -2,11 +2,9 @@ require "set"
2
2
 
3
3
  module MTrack
4
4
  class State
5
-
6
5
  ##
7
6
  # Handles method information for each group in MTrack::State#groups.
8
7
  class Group
9
-
10
8
  ##
11
9
  # call-seq:
12
10
  # new() => new_group
@@ -19,7 +19,6 @@
19
19
  #
20
20
  # D.tracked_methods #=> #<Set: {:method_1, :method_2, :method_3}>
21
21
  module MTrack
22
-
23
22
  # Current version of MTrack.
24
- VERSION = "1.0.1"
23
+ VERSION = "1.0.2"
25
24
  end
data/mtrack.gemspec CHANGED
@@ -8,7 +8,7 @@ Gem::Specification.new do |spec|
8
8
  spec.version = MTrack::VERSION
9
9
  spec.authors = ["Gabriel de Oliveira"]
10
10
  spec.email = ["deoliveira.gab@gmail.com"]
11
- spec.summary = %q{Group and track methods on classes and modules.}
11
+ spec.summary = "Group and track methods on classes and modules."
12
12
  spec.description = <<-EOS.strip.gsub(/\n/, "").gsub(/\s{2,}/, " ")
13
13
  MTrack extends the functionality of modules and
14
14
  classes and enables them to define public methods
@@ -20,6 +20,6 @@ Gem::Specification.new do |spec|
20
20
  spec.license = "MIT"
21
21
 
22
22
  spec.files = `git ls-files -z`.split("\x0")
23
- spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
23
+ spec.test_files = spec.files.grep(/^(test|spec|features)\//)
24
24
  spec.require_paths = ["lib"]
25
25
  end
@@ -0,0 +1,4 @@
1
+ inherit_from:
2
+ - ../../.rubocop.yml
3
+ Metrics/LineLength:
4
+ Max: 140
@@ -38,7 +38,7 @@ describe MTrack::Mixin do
38
38
  end
39
39
  end
40
40
  end
41
-
41
+
42
42
  let(:base_module_2) do
43
43
  Module.new.tap do |m|
44
44
  m.module_eval do
@@ -53,7 +53,7 @@ describe MTrack::Mixin do
53
53
  end
54
54
  end
55
55
  end
56
-
56
+
57
57
  let(:base_module_3) do
58
58
  Module.new.tap do |m|
59
59
  m.module_eval do
@@ -68,7 +68,7 @@ describe MTrack::Mixin do
68
68
  end
69
69
  end
70
70
  end
71
-
71
+
72
72
  let(:sub_module_1) do
73
73
  bm_1 = base_module_1
74
74
  bm_2 = base_module_2
@@ -86,7 +86,7 @@ describe MTrack::Mixin do
86
86
  end
87
87
  end
88
88
  end
89
-
89
+
90
90
  let(:sub_module_2) do
91
91
  bm_3 = base_module_3
92
92
  Module.new.tap do |m|
@@ -103,7 +103,7 @@ describe MTrack::Mixin do
103
103
  end
104
104
  end
105
105
  end
106
-
106
+
107
107
  let(:super_class) do
108
108
  sm_1 = sub_module_1
109
109
  Class.new.tap do |c|
@@ -119,7 +119,7 @@ describe MTrack::Mixin do
119
119
  end
120
120
  end
121
121
  end
122
-
122
+
123
123
  let(:sub_class) do
124
124
  sm_2 = sub_module_2
125
125
  sc = super_class
@@ -139,254 +139,250 @@ describe MTrack::Mixin do
139
139
 
140
140
  context "base module 1" do
141
141
  subject { base_module_1 }
142
-
142
+
143
143
  it "tracks methods" do
144
144
  expect(subject.tracked_methods).to match_array([:meth])
145
145
  expect(subject.tracked_methods(:numbers)).to match_array([:one, :two])
146
146
  expect(subject.tracked_methods(:odd)).to match_array([:one])
147
147
  expect(subject.tracked_methods(:even)).to match_array([:two])
148
148
  end
149
-
149
+
150
150
  it "untracks removed methods" do
151
151
  subject.module_eval { remove_method :meth }
152
152
  expect(subject.tracked_methods).to be_empty
153
153
  end
154
-
154
+
155
155
  it "untracks undefined methods" do
156
156
  subject.module_eval { undef_method :meth }
157
157
  expect(subject.tracked_methods).to be_empty
158
-
158
+
159
159
  subject.module_eval { define_method :meth, METHOD_DEFINITION }
160
160
  expect(subject.tracked_methods).to be_empty
161
161
  end
162
162
  end
163
-
163
+
164
164
  context "base module 2" do
165
165
  subject { base_module_2 }
166
-
166
+
167
167
  it "tracks methods" do
168
168
  expect(subject.tracked_methods).to match_array([:meth])
169
169
  expect(subject.tracked_methods(:numbers)).to match_array([:two, :three])
170
170
  expect(subject.tracked_methods(:even)).to match_array([:two])
171
171
  expect(subject.tracked_methods(:odd)).to match_array([:three])
172
172
  end
173
-
173
+
174
174
  it "untracks removed methods" do
175
175
  subject.module_eval { remove_method :meth }
176
176
  expect(subject.tracked_methods).to be_empty
177
177
  end
178
-
178
+
179
179
  it "untracks undefined methods" do
180
180
  subject.module_eval { undef_method :meth }
181
181
  expect(subject.tracked_methods).to be_empty
182
-
182
+
183
183
  subject.module_eval { define_method :meth, METHOD_DEFINITION }
184
184
  expect(subject.tracked_methods).to be_empty
185
185
  end
186
186
  end
187
-
187
+
188
188
  context "base module 3" do
189
189
  subject { base_module_3 }
190
-
190
+
191
191
  it "tracks methods" do
192
192
  expect(subject.tracked_methods).to match_array([:meth])
193
193
  expect(subject.tracked_methods(:numbers)).to match_array([:three, :four])
194
194
  expect(subject.tracked_methods(:odd)).to match_array([:three])
195
195
  expect(subject.tracked_methods(:even)).to match_array([:four])
196
196
  end
197
-
197
+
198
198
  it "untracks removed methods" do
199
199
  subject.module_eval { remove_method :meth }
200
200
  expect(subject.tracked_methods).to be_empty
201
201
  end
202
-
202
+
203
203
  it "untracks undefined methods" do
204
204
  subject.module_eval { undef_method :meth }
205
205
  expect(subject.tracked_methods).to be_empty
206
-
206
+
207
207
  subject.module_eval { define_method :meth, METHOD_DEFINITION }
208
208
  expect(subject.tracked_methods).to be_empty
209
209
  end
210
210
  end
211
-
211
+
212
212
  context "sub module 1" do
213
213
  subject { sub_module_1 }
214
-
214
+
215
215
  it "tracks methods" do
216
216
  expect(subject.tracked_methods).to match_array([:meth])
217
217
  expect(subject.tracked_methods(:numbers)).to match_array([:one, :two, :three, :four, :five])
218
218
  expect(subject.tracked_methods(:odd)).to match_array([:one, :three, :five])
219
219
  expect(subject.tracked_methods(:even)).to match_array([:two, :four])
220
220
  end
221
-
221
+
222
222
  it "untracks removed methods" do
223
223
  subject.module_eval { remove_method :meth }
224
224
  expect(subject.tracked_methods).to match_array([:meth])
225
-
225
+
226
226
  base_module_1.module_eval { remove_method :meth }
227
227
  expect(subject.tracked_methods).to match_array([:meth])
228
-
228
+
229
229
  base_module_2.module_eval { remove_method :meth }
230
230
  expect(subject.tracked_methods).to be_empty
231
231
  end
232
-
232
+
233
233
  it "untracks undefined methods" do
234
234
  subject.module_eval { undef_method :meth }
235
235
  expect(subject.tracked_methods).to be_empty
236
-
236
+
237
237
  subject.module_eval { define_method :meth, METHOD_DEFINITION }
238
238
  expect(subject.tracked_methods).to match_array([:meth])
239
239
  end
240
240
  end
241
-
241
+
242
242
  context "sub module 2" do
243
243
  subject { sub_module_2 }
244
-
244
+
245
245
  it "tracks methods" do
246
246
  expect(subject.tracked_methods).to match_array([:meth])
247
247
  expect(subject.tracked_methods(:numbers)).to match_array([:three, :four, :five, :six])
248
248
  expect(subject.tracked_methods(:odd)).to match_array([:three, :five])
249
249
  expect(subject.tracked_methods(:even)).to match_array([:four, :six])
250
250
  end
251
-
251
+
252
252
  it "untracks removed methods" do
253
253
  base_module_3.module_eval { remove_method :meth }
254
254
  expect(subject.tracked_methods).to match_array([:meth])
255
-
255
+
256
256
  subject.module_eval { remove_method :meth }
257
257
  expect(subject.tracked_methods).to be_empty
258
258
  end
259
-
259
+
260
260
  it "untracks undefined methods" do
261
261
  subject.module_eval { undef_method :meth }
262
262
  expect(subject.tracked_methods).to be_empty
263
-
263
+
264
264
  subject.module_eval { define_method :meth, METHOD_DEFINITION }
265
265
  expect(subject.tracked_methods).to match_array([:meth])
266
266
  end
267
267
  end
268
-
268
+
269
269
  context "super class" do
270
270
  subject { super_class }
271
-
271
+
272
272
  it "tracks methods" do
273
273
  expect(subject.tracked_methods).to match_array([:meth])
274
274
  expect(subject.tracked_methods(:numbers)).to match_array([:one, :two, :three, :four, :five, :six, :seven])
275
275
  expect(subject.tracked_methods(:odd)).to match_array([:one, :three, :five, :seven])
276
276
  expect(subject.tracked_methods(:even)).to match_array([:two, :four, :six])
277
277
  end
278
-
278
+
279
279
  it "untracks removed methods" do
280
280
  subject.class_eval { remove_method :meth }
281
281
  expect(subject.tracked_methods).to match_array([:meth])
282
-
282
+
283
283
  sub_module_1.module_eval { remove_method :meth }
284
284
  expect(subject.tracked_methods).to match_array([:meth])
285
-
285
+
286
286
  base_module_2.module_eval { remove_method :meth }
287
287
  expect(subject.tracked_methods).to match_array([:meth])
288
-
288
+
289
289
  base_module_1.module_eval { remove_method :meth }
290
290
  expect(subject.tracked_methods).to be_empty
291
291
  end
292
-
292
+
293
293
  it "untracks undefined methods" do
294
294
  subject.module_eval { undef_method :meth }
295
295
  expect(subject.tracked_methods).to be_empty
296
-
296
+
297
297
  subject.module_eval { define_method :meth, METHOD_DEFINITION }
298
298
  expect(subject.tracked_methods).to match_array([:meth])
299
299
  end
300
300
  end
301
-
301
+
302
302
  context "sub class" do
303
303
  subject { sub_class }
304
-
304
+
305
305
  it "tracks methods" do
306
306
  expect(subject.tracked_methods).to match_array([:meth])
307
307
  expect(subject.tracked_methods(:numbers)).to match_array([:one, :two, :three, :four, :five, :six, :seven, :eight])
308
308
  expect(subject.tracked_methods(:odd)).to match_array([:one, :three, :five, :seven])
309
309
  expect(subject.tracked_methods(:even)).to match_array([:two, :four, :six, :eight])
310
310
  end
311
-
311
+
312
312
  it "untracks removed methods" do
313
313
  base_module_1.module_eval { remove_method :meth }
314
314
  expect(subject.tracked_methods).to match_array([:meth])
315
-
315
+
316
316
  base_module_2.module_eval { remove_method :meth }
317
317
  expect(subject.tracked_methods).to match_array([:meth])
318
-
318
+
319
319
  base_module_3.module_eval { remove_method :meth }
320
320
  expect(subject.tracked_methods).to match_array([:meth])
321
-
321
+
322
322
  sub_module_1.module_eval { remove_method :meth }
323
323
  expect(subject.tracked_methods).to match_array([:meth])
324
-
324
+
325
325
  sub_module_2.module_eval { remove_method :meth }
326
326
  expect(subject.tracked_methods).to match_array([:meth])
327
-
327
+
328
328
  super_class.class_eval { remove_method :meth }
329
329
  expect(subject.tracked_methods).to match_array([:meth])
330
-
330
+
331
331
  subject.class_eval { remove_method :meth }
332
332
  expect(subject.tracked_methods).to be_empty
333
333
  end
334
-
334
+
335
335
  it "untracks undefined methods" do
336
336
  subject.module_eval { undef_method :meth }
337
337
  expect(subject.tracked_methods).to be_empty
338
-
338
+
339
339
  subject.module_eval { define_method :meth, METHOD_DEFINITION }
340
340
  expect(subject.tracked_methods).to match_array([:meth])
341
341
  end
342
342
  end
343
-
343
+
344
344
  context "partially defined" do
345
345
  context "module" do
346
346
  it "tracks methods" do
347
347
  m = ::Module.new
348
-
348
+
349
349
  expect do
350
350
  m.module_eval do
351
351
  extend MTrack::Mixin
352
352
  track_methods do
353
353
  define_method :meth_1, METHOD_DEFINITION
354
354
  define_method :meth_2, METHOD_DEFINITION
355
- raise "Unexpected error"
356
- define_method :meth_3, METHOD_DEFINITION
357
- define_method :meth_4, METHOD_DEFINITION
355
+ fail "Unexpected error"
358
356
  end
359
357
  end
360
358
  end.to raise_error(RuntimeError, "Unexpected error")
361
-
359
+
362
360
  expect(m.public_instance_methods(false).map(&:to_sym)).to match_array([:meth_1, :meth_2])
363
361
  expect(m.tracked_methods).to match_array([:meth_1, :meth_2])
364
362
  end
365
363
  end
366
-
364
+
367
365
  context "class" do
368
366
  it "tracks methods" do
369
367
  c = ::Class.new
370
-
368
+
371
369
  expect do
372
370
  c.class_eval do
373
371
  extend MTrack::Mixin
374
372
  track_methods do
375
373
  define_method :meth_1, METHOD_DEFINITION
376
374
  define_method :meth_2, METHOD_DEFINITION
377
- raise "Unexpected error"
378
- define_method :meth_3, METHOD_DEFINITION
379
- define_method :meth_4, METHOD_DEFINITION
375
+ fail "Unexpected error"
380
376
  end
381
377
  end
382
378
  end.to raise_error(RuntimeError, "Unexpected error")
383
-
379
+
384
380
  expect(c.public_instance_methods(false).map(&:to_sym)).to match_array([:meth_1, :meth_2])
385
381
  expect(c.tracked_methods).to match_array([:meth_1, :meth_2])
386
382
  end
387
383
  end
388
384
  end
389
-
385
+
390
386
  context "inclusion" do
391
387
  it "adds #{described_class} to submodule" do
392
388
  bm_1 = base_module_1
@@ -394,7 +390,7 @@ describe MTrack::Mixin do
394
390
  expect(m.tracked_methods).to match_array([:meth])
395
391
  end
396
392
  end
397
-
393
+
398
394
  context "inheritance" do
399
395
  it "adds #{described_class} to subclass" do
400
396
  c = ::Class.new(super_class)
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: 1.0.1
4
+ version: 1.0.2
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: 2014-10-11 00:00:00.000000000 Z
11
+ date: 2014-11-07 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: MTrack extends the functionality of modules and classes and enables them
14
14
  to define public methods within groups. These methods can then be queried back even
@@ -20,6 +20,7 @@ extensions: []
20
20
  extra_rdoc_files: []
21
21
  files:
22
22
  - ".gitignore"
23
+ - ".rubocop.yml"
23
24
  - ".ruby-version"
24
25
  - ".travis.yml"
25
26
  - Gemfile
@@ -33,6 +34,7 @@ files:
33
34
  - lib/mtrack/state/group.rb
34
35
  - lib/mtrack/version.rb
35
36
  - mtrack.gemspec
37
+ - spec/lib/.rubocop.yml
36
38
  - spec/lib/mtrack/mixin_spec.rb
37
39
  - spec/lib/mtrack/state/group_spec.rb
38
40
  - spec/lib/mtrack/state_spec.rb
@@ -65,6 +67,7 @@ signing_key:
65
67
  specification_version: 4
66
68
  summary: Group and track methods on classes and modules.
67
69
  test_files:
70
+ - spec/lib/.rubocop.yml
68
71
  - spec/lib/mtrack/mixin_spec.rb
69
72
  - spec/lib/mtrack/state/group_spec.rb
70
73
  - spec/lib/mtrack/state_spec.rb