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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d68b62c2e2a24cd8195e951957aef1e134fba03d149f955fdb6d50818e284b1a
4
- data.tar.gz: f21fd7f0e71d778ce15f82407539595dc427de0efdd3747f3797d95e82c6f8b4
3
+ metadata.gz: ca4c81c2a0441fc352dc9766727920ecd19b5af2111df1a875fb10460e502db8
4
+ data.tar.gz: 9443b8f066c0494b38d2a6ee8885043bee26d8218da487e4ecaf62cec13e09f5
5
5
  SHA512:
6
- metadata.gz: b532773779d7395194b4a2d0cd518291ccc2f9f29e3c58be7fe6857c7055b00da7dcc3f74e2133f44f9d3b10e70a4af8ab51977b7a29e50497f3fb7650bedc03
7
- data.tar.gz: f4d57e9a01119cda50948603270728e8bca299bea8b67da4a8f6b282efd37ff0169f21ddc6754d82cd4b87814c007150f02e940606a4ec82beeb76433212afba
6
+ metadata.gz: 1556831015757b2e488068b0a7a5c69f2ed449ae5a3be15d9da0fc6611c9db0abe4f773c3701e5168fee58daaef84757ff203b2ee20d8df699f861edffb74da4
7
+ data.tar.gz: 759cbe9670bd1f49481a2e8e65f1e3bc6293a0703d540f549daca96f08bed1431a1e7061419b086889bf149007e3911d54565e50959f300a40b9f4a07676ebe4
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- blood (0.1.0)
4
+ blood (0.1.1)
5
5
  tree_html (~> 0.1.10)
6
6
 
7
7
  GEM
data/lib/blood/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Blood
4
- VERSION = "0.1.0"
4
+ VERSION = "0.1.1"
5
5
  end
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
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: blood
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - ken