wtf_methods 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/wtf_methods.rb +38 -11
- 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: 381c8f5f6308da4b67e8c77b1818190d6178332b
|
4
|
+
data.tar.gz: c970c4af5113562c45c6b2daf77508f31acb34d2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a4c0443ed9e3350707b5228de92275f979a7e2a2dbf359b147b4aa0c0ced7bdbfbf260431c3eca0f28e932645363a9733d09fa74022e35dc44c7e40d77ff14d0
|
7
|
+
data.tar.gz: a36496548b5e4fc1dc703e28a3125543f1020e13e5c8c5bd8480f97db9d5cfaa60685622b7408296baca72a0feb84534cba1992ae85b13fedf5a23ca846f3cd2
|
data/lib/wtf_methods.rb
CHANGED
@@ -2,28 +2,55 @@
|
|
2
2
|
class Object
|
3
3
|
def wtf(class_name)
|
4
4
|
|
5
|
-
method_array = []
|
6
|
-
|
7
5
|
if defined?(ActiveRecord::Base)
|
8
|
-
|
6
|
+
excluded_methods = ActiveRecord::Base.methods
|
9
7
|
else
|
10
|
-
|
8
|
+
excluded_methods = Object.methods
|
11
9
|
end
|
12
10
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
11
|
+
class_methods = class_name.methods - excluded_methods
|
12
|
+
instance_methods = class_name.instance_methods - excluded_methods
|
13
|
+
|
14
|
+
puts "===================="
|
15
|
+
puts " CLASS METHODS"
|
16
|
+
puts "--------------------"
|
17
|
+
|
18
|
+
if class_methods.empty?
|
19
|
+
puts " [none]"
|
20
|
+
else
|
21
|
+
puts format_methods(class_methods)
|
18
22
|
end
|
19
23
|
|
20
24
|
puts "===================="
|
21
|
-
|
25
|
+
puts " INSTANCE METHODS"
|
26
|
+
puts "--------------------"
|
27
|
+
|
28
|
+
if instance_methods.empty?
|
22
29
|
puts " [none]"
|
23
30
|
else
|
24
|
-
puts
|
31
|
+
puts format_methods(instance_methods)
|
25
32
|
end
|
33
|
+
|
26
34
|
puts "===================="
|
27
35
|
|
28
36
|
end
|
37
|
+
|
38
|
+
def format_methods(methods)
|
39
|
+
|
40
|
+
method_array = []
|
41
|
+
|
42
|
+
methods.sort.each do |method|
|
43
|
+
if method_array.first && method[0] >= "a" && method[0] != method_array.last[1]
|
44
|
+
method_array << "--------------------"
|
45
|
+
end
|
46
|
+
if method_array.last && method[0..-2] == method_array.last[1..-1] && method[-1] == "!"
|
47
|
+
method_array[-1] = " #{method[0..-2]}(!)"
|
48
|
+
else
|
49
|
+
method_array << " #{method}"
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
return method_array
|
54
|
+
|
55
|
+
end
|
29
56
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: wtf_methods
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Stelios Constantinides
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-12-
|
11
|
+
date: 2013-12-11 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Prints a formatted list of class-specific methods, excluding ActiveRecord::Base
|
14
14
|
(when applicable) and generic Object methods. See the documentation for examples.
|