blood 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/blood/version.rb +1 -1
- data/lib/blood.rb +20 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 761ec35533a1ca239737387f6db021aff647615513d94f3a863d544cff6f829d
|
4
|
+
data.tar.gz: 77c985d7880aa0ec40a88ad5835b666cffbbae181e31c7c2bee9be1696ad8a33
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 913f867664ab4c5ea34c16a07ac93128007cff92f3d9d5f0b817e814cf2e7d6488063d6d227187cbdd4d3e891bcafe829f09d033cb842d7b67c44fbf4bdd0e3c
|
7
|
+
data.tar.gz: e18c7a9b0152137dbef1cbb6efd06fba6bd2f33482866082db6ab228ec3f28c2322d882490ab27017acfcf7c95b8d7daa55da6daf7683d496f924b67594778da
|
data/lib/blood/version.rb
CHANGED
data/lib/blood.rb
CHANGED
@@ -9,6 +9,7 @@ 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
|
+
# maybe [Class, [Module, Module], ...]
|
12
13
|
ances = mod.ancestors.reduce([]) do |arr, a|
|
13
14
|
next arr << a if Class === a
|
14
15
|
arr << Modules.new unless Modules === arr[-1]
|
@@ -32,6 +33,8 @@ module Blood
|
|
32
33
|
@to_s ||= (@mods.count == 1 ? @mods[0].to_s : @mods.to_s)
|
33
34
|
end
|
34
35
|
|
36
|
+
alias_method :name, :to_s
|
37
|
+
|
35
38
|
def hash
|
36
39
|
to_s.hash
|
37
40
|
end
|
@@ -50,16 +53,31 @@ module Blood
|
|
50
53
|
end
|
51
54
|
|
52
55
|
def label_for_tree_html
|
53
|
-
name = ::CGI.escapeHTML(@mod.to_s)
|
56
|
+
name = ::CGI.escapeHTML(@mod.name || @mod.to_s)
|
54
57
|
Class === @mod ? "<span class='hl'>#{name}</span>" : name
|
55
58
|
end
|
56
59
|
|
60
|
+
NORMAL_NAME = /^[A-Z][A-Za-z0-9]*(::[A-Z][A-Za-z0-9]*)*$/
|
61
|
+
|
62
|
+
if Module.method_defined?(:const_source_location)
|
63
|
+
alias_method :raw_label_for_tree_html, :label_for_tree_html
|
64
|
+
|
65
|
+
def label_for_tree_html
|
66
|
+
return raw_label_for_tree_html if Modules === @mod
|
67
|
+
return raw_label_for_tree_html unless @mod.name =~ NORMAL_NAME
|
68
|
+
loc = Module.const_source_location(@mod.name)
|
69
|
+
return raw_label_for_tree_html unless loc
|
70
|
+
loc = ::CGI.escapeHTML(loc.join(':'))
|
71
|
+
"#{raw_label_for_tree_html} <span class='sd'>#{loc}</span>"
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
57
75
|
def children_for_tree_html
|
58
76
|
children.map{ |sub| Node.new(sub, @hier) }
|
59
77
|
end
|
60
78
|
|
61
79
|
def css_for_tree_html
|
62
|
-
'.hl{color: #cc342d;}'
|
80
|
+
'.hl{color: #cc342d;} .sd{color: #9e9e9e;}'
|
63
81
|
end
|
64
82
|
|
65
83
|
private
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: blood
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
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: 2024-
|
11
|
+
date: 2024-05-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: tree_html
|