constree 0.1.1 → 0.1.5

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
- SHA1:
3
- metadata.gz: 1b101ec84610a6f7d3e988fb320773c4c3d15a3b
4
- data.tar.gz: 3a4e13a59be613d33799afdb8548cc3bd008fde8
2
+ SHA256:
3
+ metadata.gz: d6c196c688b12a0c6b2c8c68ad8eed30f84a7bbf8f0a2fcdd80e0d4f558f1af4
4
+ data.tar.gz: 7756e2e7b876586067c207a63e26f0a902c4a794469b1a1e58fb79940c389d7c
5
5
  SHA512:
6
- metadata.gz: 951f0e0c1fd79a543a4f70a9c55e737650d2fc6709329ae94e0c1550568538f3cbfb9bc37c738e03b37f6254adf88bfbe25f3271c454b5ca745604ababda1661
7
- data.tar.gz: 2439cff5df3410d9f6f3594a3bb48c0c70089d3b269b0e44837664032e4f66123d7a748aa766503cc0a5073af8c2c2175f4f285d51cd1b42e53523b90f6bd5a5
6
+ metadata.gz: 7028fa86fe6b790f631501357712517742e6228506aed26fc255c193f8933fd8457961b2609ff9d224634c7212aa9db2d6ece2b89b15cf9286c829c720192051
7
+ data.tar.gz: 9619da2f82b609b5c16cb1b7f36896b2daf5f9ac20afb49f6a30bab32d3e59648be5f41ad2be005d2264939075305b42f881160344c5bde44b73457f1cb88656
data/README.md CHANGED
@@ -21,22 +21,20 @@ Or install it yourself as:
21
21
  ## Example: constants in Minitest::Spec
22
22
 
23
23
  ```ruby
24
- 2.2.2 :001 > require 'constree/module'
25
- => true
26
- 2.2.2 :002 > require 'minitest/spec'
27
- => true
28
- 2.2.2 :003 > Minitest::Spec.constreep
29
- Minitest::Spec (Class)
24
+ irb(main):001:0> require 'minitest/spec'
25
+ => true
26
+ irb(main):002:0> Constree.p Minitest::Spec
27
+ Minitest::Spec < Minitest::Spec::DSL::InstanceMethods < Minitest::Test < Minitest::Guard < Minitest::Test::LifecycleHooks < Minitest::Reportable < Minitest::Assertions < Minitest::Runnable < Object < Minitest::Expectations < Kernel < BasicObject
30
28
  ├─DSL (Module)
31
- │ ├─TYPES (Array)
32
- │ └─InstanceMethods (Module)
29
+ │ ├─InstanceMethods (Module)
30
+ │ └─TYPES (Array)
33
31
  ├─TYPES → Minitest::Spec::DSL::TYPES
34
32
  ├─PASSTHROUGH_EXCEPTIONS (Array)
35
33
  ├─TEARDOWN_METHODS (Array)
36
34
  ├─LifecycleHooks (Module)
37
- ├─UNDEFINED (Object)
38
35
  ├─E (String)
36
+ ├─UNDEFINED (Object)
39
37
  └─SIGNALS (Hash)
40
- => nil
38
+ => nil
41
39
  ```
42
40
 
data/constree.gemspec CHANGED
@@ -20,9 +20,9 @@ Gem::Specification.new do |spec|
20
20
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
21
21
  spec.require_paths = ["lib"]
22
22
 
23
- spec.add_development_dependency "bundler", "~> 1.13"
23
+ spec.add_development_dependency "bundler", "> 1.13"
24
24
  spec.add_development_dependency "rake", "~> 10.0"
25
25
  spec.add_development_dependency "minitest", "~> 5.0"
26
26
 
27
- spec.add_development_dependency "tree_graph", "0.1.0"
27
+ spec.add_dependency "tree_graph", "~> 0.2.0"
28
28
  end
data/lib/constree/node.rb CHANGED
@@ -1,29 +1,24 @@
1
1
  require 'tree_graph'
2
2
 
3
3
  module Constree
4
- Node = Struct.new :constant, :name, :parent, :is_last do
4
+ Node = Struct.new :constant, :name, :parent do
5
5
 
6
6
  include TreeGraph
7
7
 
8
- def parent_for_tree_graph
9
- parent
10
- end
11
-
12
8
  def label_for_tree_graph
13
9
  display_name + ' ' + type
14
10
  end
15
11
 
16
- def is_last_for_tree_graph
17
- is_last ? true : false
12
+ def children_for_tree_graph
13
+ @sub_consts ||= []
18
14
  end
19
15
 
20
16
  attr_accessor :ref
21
17
 
22
18
  def sub_nodes
23
19
  return [] unless constant.is_a? Module
24
- names = constant.constants
25
- names.reduce([]) do |nodes, name|
26
- nodes << Node.new(constant.const_get(name), name, self, nodes.count == names.count - 1)
20
+ constant.constants.map do |name|
21
+ Node.new(constant.const_get(name), name, self)
27
22
  end
28
23
  end
29
24
 
@@ -45,7 +40,9 @@ module Constree
45
40
  end
46
41
 
47
42
  def type
48
- ref ? "→ #{ref.full_name}" : "(#{constant.class.to_s})"
43
+ return "→ #{ref.full_name}" if ref
44
+ return "(#{constant.class.to_s})" unless Class === constant
45
+ "< " + constant.ancestors[1..].map(&:to_s).join(" < ")
49
46
  end
50
47
 
51
48
  def not_yet? seen
@@ -1,3 +1,3 @@
1
1
  module Constree
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.5"
3
3
  end
data/lib/constree.rb CHANGED
@@ -11,6 +11,7 @@ module Constree
11
11
 
12
12
  node.sub_nodes.each do |sub_n|
13
13
  seen << sub_n
14
+ node.children_for_tree_graph << sub_n
14
15
  list(sub_n, seen) if sub_n.not_yet? seen
15
16
  end
16
17
 
@@ -18,9 +19,7 @@ module Constree
18
19
  end
19
20
 
20
21
  def of mod
21
- list(mod).
22
- map(&:tree_graph_level).
23
- join("\n")
22
+ list(mod).first.tree_graph
24
23
  end
25
24
 
26
25
  def p mod
metadata CHANGED
@@ -1,27 +1,27 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: constree
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - ken
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-02-03 00:00:00.000000000 Z
11
+ date: 2021-10-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ">"
18
18
  - !ruby/object:Gem::Version
19
19
  version: '1.13'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - "~>"
24
+ - - ">"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '1.13'
27
27
  - !ruby/object:Gem::Dependency
@@ -56,16 +56,16 @@ dependencies:
56
56
  name: tree_graph
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - '='
59
+ - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: 0.1.0
62
- type: :development
61
+ version: 0.2.0
62
+ type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - '='
66
+ - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: 0.1.0
68
+ version: 0.2.0
69
69
  description:
70
70
  email:
71
71
  - block24block@gmail.com
@@ -106,8 +106,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
106
106
  - !ruby/object:Gem::Version
107
107
  version: '0'
108
108
  requirements: []
109
- rubyforge_project:
110
- rubygems_version: 2.5.2
109
+ rubygems_version: 3.2.3
111
110
  signing_key:
112
111
  specification_version: 4
113
112
  summary: recursively show the structure of constants in a module