blood 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/blood/version.rb +1 -1
- data/lib/blood.rb +24 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ca4c81c2a0441fc352dc9766727920ecd19b5af2111df1a875fb10460e502db8
|
4
|
+
data.tar.gz: 9443b8f066c0494b38d2a6ee8885043bee26d8218da487e4ecaf62cec13e09f5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1556831015757b2e488068b0a7a5c69f2ed449ae5a3be15d9da0fc6611c9db0abe4f773c3701e5168fee58daaef84757ff203b2ee20d8df699f861edffb74da4
|
7
|
+
data.tar.gz: 759cbe9670bd1f49481a2e8e65f1e3bc6293a0703d540f549daca96f08bed1431a1e7061419b086889bf149007e3911d54565e50959f300a40b9f4a07676ebe4
|
data/Gemfile.lock
CHANGED
data/lib/blood/version.rb
CHANGED
data/lib/blood.rb
CHANGED
@@ -9,7 +9,12 @@ module Blood
|
|
9
9
|
def self.source(mods)
|
10
10
|
hier = Hash.new{ |h, k| h[k] = Set.new }
|
11
11
|
mods.each do |mod|
|
12
|
-
ances = mod.ancestors
|
12
|
+
ances = mod.ancestors.reduce([]) do |arr, a|
|
13
|
+
next arr << a if Class === a
|
14
|
+
arr << Modules.new unless Modules === arr[-1]
|
15
|
+
arr[-1].add(a)
|
16
|
+
arr
|
17
|
+
end
|
13
18
|
ances.each_with_index do |child, i|
|
14
19
|
parent = ances[i + 1]
|
15
20
|
hier[parent] << child
|
@@ -18,6 +23,24 @@ module Blood
|
|
18
23
|
Node.new(BasicObject, hier)
|
19
24
|
end
|
20
25
|
|
26
|
+
class Modules
|
27
|
+
def add(mod)
|
28
|
+
(@mods ||= []) << mod
|
29
|
+
end
|
30
|
+
|
31
|
+
def to_s
|
32
|
+
@to_s ||= (@mods.count == 1 ? @mods[0].to_s : @mods.to_s)
|
33
|
+
end
|
34
|
+
|
35
|
+
def hash
|
36
|
+
to_s.hash
|
37
|
+
end
|
38
|
+
|
39
|
+
def eql?(other)
|
40
|
+
to_s.eql?(other.to_s)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
21
44
|
class Node
|
22
45
|
include TreeHtml
|
23
46
|
|