mmmm 0.1.3 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/mmmm/helper.rb +1 -2
- data/lib/mmmm/object_method.rb +3 -3
- data/lib/mmmm/object_methods.rb +31 -20
- data/lib/mmmm/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a9f1cf1b165a5b5c70a800ee3d5fc641552b3ab4
|
4
|
+
data.tar.gz: 39e1d73d93248f5bf5cb41fbc7d00d81990eec6a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b33542499bb7e20bc5f4cd1d40a04c475f0a03561dd55f02b382fb2075a5c5e32f16497e9e27516668b479bbe3fdebd70b111885c20158a31459a8ac07c48fc1
|
7
|
+
data.tar.gz: e9970ad0598a27573b78fed9cb464134ec8a091fcbcd1be0638c4194734f96101e60ea18929305d917d640f1caf8d4818a0f983a171e0cdbb24a52ec11910dc5
|
data/lib/mmmm/helper.rb
CHANGED
@@ -11,8 +11,7 @@ module Mmmm
|
|
11
11
|
def helper name
|
12
12
|
if Mmmm::Top.respond_to? name or
|
13
13
|
Mmmm::Top.private_methods.include? name
|
14
|
-
|
15
|
-
return
|
14
|
+
raise NameError, "#{name} is already defined. Please use Mmmm.helper(:another_name)"
|
16
15
|
end
|
17
16
|
define_helper_method name
|
18
17
|
end
|
data/lib/mmmm/object_method.rb
CHANGED
@@ -7,8 +7,8 @@ module Mmmm
|
|
7
7
|
|
8
8
|
def inspect
|
9
9
|
@locs_in_all_ancs.
|
10
|
-
|
11
|
-
|
10
|
+
map{ |file, line| [file.cyan, line].join(' ') }.
|
11
|
+
join("\n")
|
12
12
|
end
|
13
13
|
|
14
14
|
private
|
@@ -24,7 +24,7 @@ module Mmmm
|
|
24
24
|
loc = instance_method_location method_name, class_or_module
|
25
25
|
locs << loc unless loc.nil?
|
26
26
|
end.
|
27
|
-
|
27
|
+
uniq
|
28
28
|
end
|
29
29
|
|
30
30
|
def instance_method_location method_name, mod
|
data/lib/mmmm/object_methods.rb
CHANGED
@@ -3,49 +3,60 @@ module Mmmm
|
|
3
3
|
|
4
4
|
class FileLineMethod
|
5
5
|
attr_reader :file, :line, :method
|
6
|
-
def initialize src_loc, m
|
6
|
+
def initialize src_loc, m, inherited
|
7
7
|
@file = src_loc[0]
|
8
8
|
@line = src_loc[1]
|
9
9
|
@method = m
|
10
|
+
@inherited = inherited
|
11
|
+
end
|
12
|
+
|
13
|
+
def inherited?
|
14
|
+
@inherited
|
10
15
|
end
|
11
16
|
end
|
12
17
|
|
13
18
|
def initialize obj
|
14
|
-
|
15
|
-
flm_arr = file_line_method_arr(obj)
|
16
|
-
@group_by_file = group_by_file(flm_arr)
|
19
|
+
@obj = obj
|
17
20
|
end
|
18
21
|
|
19
22
|
def inspect
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
+
group_by_inherited_and_file.
|
24
|
+
map { |inh_file, flms| "#{inh_file[1].cyan} #{inh_file[0]}\n#{lm_in_string(flms)}" }.
|
25
|
+
join("\n")
|
23
26
|
end
|
24
27
|
|
25
28
|
private
|
26
29
|
|
27
|
-
def file_line_method_arr
|
28
|
-
obj.methods.
|
29
|
-
file_line = obj.method(m).source_location
|
30
|
-
if file_line
|
31
|
-
rs << FileLineMethod.new(file_line, m)
|
32
|
-
end
|
33
|
-
rs
|
30
|
+
def file_line_method_arr
|
31
|
+
@obj.methods.each_with_object([]) do |m, rs|
|
32
|
+
file_line = @obj.method(m).source_location
|
33
|
+
rs << FileLineMethod.new(file_line, m, inherited?(m)) if file_line
|
34
34
|
end
|
35
35
|
end
|
36
36
|
|
37
|
-
def
|
38
|
-
|
39
|
-
|
40
|
-
|
37
|
+
def inherited? method
|
38
|
+
not open_class_defined_methods.include? method
|
39
|
+
end
|
40
|
+
|
41
|
+
def open_class_defined_methods
|
42
|
+
@ocdm ||= [:singleton_class, :class].
|
43
|
+
map{ |klass| @obj.send(klass).instance_methods(false) }.
|
44
|
+
flatten.
|
45
|
+
uniq
|
46
|
+
end
|
47
|
+
|
48
|
+
def group_by_inherited_and_file
|
49
|
+
grouped = file_line_method_arr.
|
50
|
+
group_by{ |flm| [flm.inherited?.to_s, flm.file] }.
|
51
|
+
sort_by{ |inh_f, _| inh_f }
|
41
52
|
|
42
53
|
Hash[grouped]
|
43
54
|
end
|
44
55
|
|
45
56
|
def lm_in_string flms
|
46
57
|
flms.
|
47
|
-
|
48
|
-
|
58
|
+
map {|flm| "#{format('%5d', flm.line)} #{flm.method}" }.
|
59
|
+
join("\n")
|
49
60
|
end
|
50
61
|
end
|
51
62
|
end
|
data/lib/mmmm/version.rb
CHANGED
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.
|
4
|
+
version: 0.1.4
|
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-
|
11
|
+
date: 2016-10-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -96,7 +96,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
96
96
|
version: '0'
|
97
97
|
requirements: []
|
98
98
|
rubyforge_project:
|
99
|
-
rubygems_version: 2.
|
99
|
+
rubygems_version: 2.6.7
|
100
100
|
signing_key:
|
101
101
|
specification_version: 4
|
102
102
|
summary: find (all) method source location
|