geilitool 0.0.1 → 0.1.0
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 +4 -4
- data/lib/geilitool/version.rb +1 -1
- data/lib/geilitool.rb +51 -0
- data/spec/kernel_spec.rb +44 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 92317c01927ed6875216843c822d3a895af0364e
|
4
|
+
data.tar.gz: 27b12f6cb77a8c2fb3665ceac736984d505e6068
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f5cf1784125ac5e748e002efd1c9a97fc9279c6e82db8cb66b7c0661d73c57c316e89dd684e90b5ac3e0c4d11470ff4c8d87aaa7b0ac76803b1d36e2eadeae48
|
7
|
+
data.tar.gz: 419542642ba7687aa97b23897fed86e5fd5daec5b0530ae88112546525b538cacf19eab13b21e14db09b97a6b8f115e10acfad7c787e0dab3c3326d771b26c29
|
data/lib/geilitool/version.rb
CHANGED
data/lib/geilitool.rb
CHANGED
@@ -1,5 +1,56 @@
|
|
1
1
|
require "geilitool/version"
|
2
2
|
|
3
|
+
# This is a Kernel extention
|
4
|
+
module Kernel
|
5
|
+
|
6
|
+
#list ancestors displaying eigeinclass
|
7
|
+
def geili_ancestors
|
8
|
+
eigeinclass = class << self;self;end
|
9
|
+
full_ancestors = [eigeinclass]
|
10
|
+
modules = eigeinclass.included_modules
|
11
|
+
x = eigeinclass
|
12
|
+
while x.superclass do
|
13
|
+
x = x.superclass
|
14
|
+
full_ancestors << x
|
15
|
+
deleted = []
|
16
|
+
modules.each do |m|
|
17
|
+
if x.include? m
|
18
|
+
unless x.superclass and x.superclass.include? m
|
19
|
+
full_ancestors << m
|
20
|
+
deleted << m
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
deleted.each do |m|
|
25
|
+
modules.delete m
|
26
|
+
end
|
27
|
+
end
|
28
|
+
full_ancestors
|
29
|
+
end
|
30
|
+
|
31
|
+
#find class displaying eigeinclass
|
32
|
+
def geili_class
|
33
|
+
eigeinclass = class << self;self;end
|
34
|
+
class_stack = [eigeinclass]
|
35
|
+
x = eigeinclass
|
36
|
+
while x.superclass and x.to_s.include?('#') do
|
37
|
+
x = x.superclass
|
38
|
+
class_stack << x
|
39
|
+
end
|
40
|
+
class_stack
|
41
|
+
end
|
42
|
+
|
43
|
+
#find the class or module where defined given method
|
44
|
+
def geili_defined? name
|
45
|
+
result = []
|
46
|
+
geili_ancestors.each do |m|
|
47
|
+
result << m if m.instance_methods(false).include? name.to_sym
|
48
|
+
end
|
49
|
+
result
|
50
|
+
end
|
51
|
+
|
52
|
+
end
|
53
|
+
|
3
54
|
module Geilitool
|
4
55
|
# Your code goes here...
|
5
56
|
end
|
data/spec/kernel_spec.rb
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
lib = File.expand_path('../../lib', __FILE__)
|
2
|
+
require "#{lib}/geilitool"
|
3
|
+
|
4
|
+
|
5
|
+
module X1
|
6
|
+
end
|
7
|
+
module X2
|
8
|
+
def self.included base
|
9
|
+
base.extend X2_1
|
10
|
+
end
|
11
|
+
module X2_1
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
class A1
|
16
|
+
def self.singleton_aaa
|
17
|
+
puts 'singleton_aaa in A1'
|
18
|
+
end
|
19
|
+
class << self
|
20
|
+
include X1
|
21
|
+
self
|
22
|
+
end
|
23
|
+
include X2
|
24
|
+
def to_s
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
describe Kernel do
|
29
|
+
context "the extention in module kenerl" do
|
30
|
+
it "#full_ancestors " do
|
31
|
+
class A2 < A1;end
|
32
|
+
class A3 < A2;end
|
33
|
+
a3 = A3.new
|
34
|
+
puts "a3 ancestors: " << a3.geili_ancestors.join(',')
|
35
|
+
puts "A3 ancestors: " << A3.geili_ancestors.join(',')
|
36
|
+
puts ""
|
37
|
+
puts "a3 class: " << a3.geili_class.join(',')
|
38
|
+
puts "A3 class: " << A3.geili_class.join(',')
|
39
|
+
puts ""
|
40
|
+
puts "a3#to_s: " << a3.geili_defined?('to_s').join(',')
|
41
|
+
puts ""
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: geilitool
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- homeway
|
@@ -53,6 +53,7 @@ files:
|
|
53
53
|
- geilitool.gemspec
|
54
54
|
- lib/geilitool.rb
|
55
55
|
- lib/geilitool/version.rb
|
56
|
+
- spec/kernel_spec.rb
|
56
57
|
homepage: ''
|
57
58
|
licenses:
|
58
59
|
- MIT
|
@@ -77,4 +78,5 @@ rubygems_version: 2.0.3
|
|
77
78
|
signing_key:
|
78
79
|
specification_version: 4
|
79
80
|
summary: There is some new features, such as full ancestors included eigeinclass
|
80
|
-
test_files:
|
81
|
+
test_files:
|
82
|
+
- spec/kernel_spec.rb
|