mmmm 0.1.0 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: eaf5565dcbd9ccbc37a3cd0516c71218d4372250
4
- data.tar.gz: 0ddb3c91ee8b55c054a247feb12fdd2f905df5f2
3
+ metadata.gz: 355b6e4fe1af02875a46c394cf82339e21fc3058
4
+ data.tar.gz: 33f3f2e282de829772fcac530056a92d16db942d
5
5
  SHA512:
6
- metadata.gz: 2e063410c32e3bcec3aa12d7dc2523cc2be623b45db711f329f12f3ab1fbb3fed91f0da83dee5b8a99a247a2f9b9dc471a9973938ac031516b697b2be8c8b5e3
7
- data.tar.gz: c56d8bf449116e0ec4161c82031f7990deb7572750a9c955c17d9a6ea0e014f769e128ae0752b1a7b12b769274ed76943f475e58451759f2e7b772d070affbfe
6
+ metadata.gz: e9322e14ef3a4ee3d95294a24413d9d593a9dcdd9e9ed217f095a93e70fdf2c2e8af8073f27cd41a2e6e7af31d7c66b7e7ad9bc901a4141480426b1797ec62e3
7
+ data.tar.gz: aa794b129795b4c98a204e743adad8a734a3a26d3ea0b92ec3c29f2da5080423603ae93c850e1710115692849fc3039ab9ca99d7636db48797d0cef21f574875
data/lib/mmmm/src_loc.rb CHANGED
@@ -19,9 +19,32 @@ module Mmmm
19
19
 
20
20
  private
21
21
 
22
- def src_loc obj, method
23
- file, line = obj.method(method).source_location
24
- puts [cyan(file), line].join ' '
22
+ def src_loc obj, method_name
23
+ ancs = all_ancestors(obj)
24
+ instance_method_locations(method_name, ancs).
25
+ each do |file, line|
26
+ puts [cyan(file), line].join ' '
27
+ end
28
+ end
29
+
30
+ def all_ancestors obj
31
+ obj.
32
+ singleton_class.
33
+ ancestors
34
+ end
35
+
36
+ def instance_method_locations method_name, mods
37
+ mods.each_with_object([]) do |class_or_module, locs|
38
+ loc = instance_method_location method_name, class_or_module
39
+ locs << loc unless loc.nil?
40
+ end.
41
+ uniq
42
+ end
43
+
44
+ def instance_method_location method_name, mod
45
+ mod.instance_method(method_name).source_location
46
+ rescue NameError => e
47
+ nil
25
48
  end
26
49
 
27
50
  def all_src_loc obj
data/lib/mmmm/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Mmmm
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.2"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mmmm
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - ken
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-10-22 00:00:00.000000000 Z
11
+ date: 2016-10-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -93,7 +93,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
93
93
  version: '0'
94
94
  requirements: []
95
95
  rubyforge_project:
96
- rubygems_version: 2.4.8
96
+ rubygems_version: 2.6.7
97
97
  signing_key:
98
98
  specification_version: 4
99
99
  summary: find (all) method source location