constree 0.1.7 → 0.1.8

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: bdccf3b020fb9b2b3a5c599bab8e5acedf62f08b8ed77b7f6afcdb9dbee7e074
4
- data.tar.gz: 85c983124f2990e636e60ddddbe05fc19519a11bf3d9a69d63a3b416b35be6b9
3
+ metadata.gz: fda87378a074ec894ad39ea09eff44fe458f6ea5ad208b9a53ff097a07c2d8b8
4
+ data.tar.gz: e2b0d100fdfac4da1ab1eedec5eb1efc98383de15a55a67aa642a34601505d7c
5
5
  SHA512:
6
- metadata.gz: f4162527720c2ba191a1b8cd7668100c43767e10935d3ec7eba79a77f4b90991d60d0e59390546fd0aa4745cb58cd623d6cd3b05c8ffc1bc7b8b7a22da424b5c
7
- data.tar.gz: 1159cfc11945b68a73533552e6f019873da48a42930f1d37b6a42147e031542a366f6c51e2d7bdd5f869661263f6ffa7c1546ee2292f00d59236bf0317d0ae26
6
+ metadata.gz: 833f161b42abd52f8193281c0236b19b5b72edfe8738a28e73861611ab15cdab1733846b4d70fc625dc14b32100ca17085021a4c7298f9a6904881e34ee39622
7
+ data.tar.gz: b6558cc98fc60be4e1e6c0701abc56cfdabe8c549b89f7f96938aa238caa0849618945061a7fce1270e2799d5b0b278f717592d7c72eaff8e5b99f8cfa8ae58e
data/README.md CHANGED
@@ -18,12 +18,20 @@ Or install it yourself as:
18
18
 
19
19
  $ gem install constree
20
20
 
21
- ## Example: constants in Minitest::Spec
21
+ ## Example: output tree to html
22
+
23
+ ```ruby
24
+ File.open('somewhere', 'w') do |f|
25
+ f.puts Constree.html_of SomeConstant
26
+ end
27
+ ```
28
+
29
+ ## Example: check constants in concurrent-ruby, in irb console
22
30
 
23
31
  ```ruby
24
32
  irb(main):001:0> require "concurrent-ruby"
25
33
  => true
26
- irb(main):002:0> Constree.p Minitest::Spec
34
+ irb(main):002:0> Constree.p Concurrent
27
35
  Concurrent {:kla=>Module}
28
36
  ├─AbstractExchanger {:kla=>Class, :aft=>[Concurrent::Synchronization::Object, Concurrent::Synchronization::MriObject, Concurrent::Synchronization::MriAttrVolatile, Concurrent::Synchronization::AbstractObject, Object, Kernel, BasicObject]}
29
37
  │ └─ClassMethods {:kla=>Module}
data/constree.gemspec CHANGED
@@ -25,4 +25,5 @@ Gem::Specification.new do |spec|
25
25
  spec.add_development_dependency "minitest", "~> 5.0"
26
26
 
27
27
  spec.add_dependency "tree_graph", "~> 0.2.0"
28
+ spec.add_dependency "tree_html", "~> 0.1.10"
28
29
  end
data/lib/constree/node.rb CHANGED
@@ -1,4 +1,5 @@
1
1
  require 'tree_graph'
2
+ require 'tree_html'
2
3
 
3
4
  module Constree
4
5
  Node = Struct.new :constant, :name, :parent do
@@ -13,6 +14,18 @@ module Constree
13
14
  @sub_consts ||= []
14
15
  end
15
16
 
17
+ include TreeHtml
18
+
19
+ def label_for_tree_html
20
+ "<span class='hl'>#{display_name}</span> #{verbose}"
21
+ end
22
+
23
+ alias_method :children_for_tree_html, :children_for_tree_graph
24
+
25
+ def css_for_tree_html
26
+ '.hl{color: coral;}'
27
+ end
28
+
16
29
  attr_accessor :ref
17
30
 
18
31
  def sub_nodes
@@ -36,6 +49,7 @@ module Constree
36
49
  end
37
50
 
38
51
  def == other
52
+ return false unless constant.is_a? Module
39
53
  return false unless other.is_a? Node
40
54
  constant == other.constant
41
55
  end
@@ -1,3 +1,3 @@
1
1
  module Constree
2
- VERSION = "0.1.7"
2
+ VERSION = "0.1.8"
3
3
  end
data/lib/constree.rb CHANGED
@@ -22,6 +22,10 @@ module Constree
22
22
  list(mod).first.tree_graph
23
23
  end
24
24
 
25
+ def html_of mod
26
+ list(mod).first.tree_html_full
27
+ end
28
+
25
29
  def p mod
26
30
  puts of mod
27
31
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: constree
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.7
4
+ version: 0.1.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - ken
@@ -66,6 +66,20 @@ dependencies:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
68
  version: 0.2.0
69
+ - !ruby/object:Gem::Dependency
70
+ name: tree_html
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: 0.1.10
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: 0.1.10
69
83
  description:
70
84
  email:
71
85
  - block24block@gmail.com