constree 0.1.8 → 0.1.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/README.md +27 -0
- data/lib/constree/version.rb +1 -1
- data/lib/constree.rb +9 -3
- metadata +7 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1bcfc7a688043ae320be5ab2ded3d28f2631c7c2eb8e72175d5813f410c9ce11
|
4
|
+
data.tar.gz: 36fdeedbd8924a5407d5ce519937db857a19233c48fa4bceadb8393f3d9ff8ff
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3e0a14a48ee6e30df121beef8f0a6c66319f1b0b1a2ce49285e3489fb1b2d57b2daef463b1f79c6e2a2f8f76795f784b473bd1f48b5c10edc3aed129d4a56358
|
7
|
+
data.tar.gz: 1b14c36e7d3ecb7a8169bd1838fe04225a607ad8ee5a1bab37a0fe094798439495441bc76ad826cd616127d78054ea93a76ba24d9a8d827715a9792e62282efc
|
data/.gitignore
CHANGED
data/README.md
CHANGED
@@ -18,6 +18,33 @@ Or install it yourself as:
|
|
18
18
|
|
19
19
|
$ gem install constree
|
20
20
|
|
21
|
+
## Example: find distinct module/class under a module
|
22
|
+
|
23
|
+
```ruby
|
24
|
+
[1] pry(main)> require "concurrent-ruby"
|
25
|
+
=> true
|
26
|
+
[2] pry(main)> require "constree"
|
27
|
+
=> true
|
28
|
+
[3] pry(main)> Constree.uniq(Concurrent)
|
29
|
+
=> #<Set:
|
30
|
+
{Concurrent,
|
31
|
+
Concurrent::AtomicDirectUpdate,
|
32
|
+
Concurrent::AtomicNumericCompareAndSetWrapper,
|
33
|
+
Concurrent::CyclicBarrier,
|
34
|
+
Concurrent::Synchronization::Volatile::ClassMethods,
|
35
|
+
Concurrent::Promises,
|
36
|
+
Concurrent::Promises::FactoryMethods,
|
37
|
+
Concurrent::Promises::FactoryMethods::Configuration,
|
38
|
+
Concurrent::Promises::Resolvable,
|
39
|
+
Concurrent::Promises::InternalStates::State,
|
40
|
+
Concurrent::Promises::InternalStates::Pending,
|
41
|
+
Concurrent::Promises::InternalStates::Reserved,
|
42
|
+
Concurrent::Promises::InternalStates::ResolvedWithResult,
|
43
|
+
Concurrent::Promises::InternalStates::Fulfilled,
|
44
|
+
Concurrent::Promises::InternalStates::FulfilledArray,
|
45
|
+
...
|
46
|
+
```
|
47
|
+
|
21
48
|
## Example: output tree to html
|
22
49
|
|
23
50
|
```ruby
|
data/lib/constree/version.rb
CHANGED
data/lib/constree.rb
CHANGED
@@ -1,9 +1,17 @@
|
|
1
1
|
require 'constree/version'
|
2
2
|
require 'constree/node'
|
3
|
+
require 'set'
|
3
4
|
|
4
5
|
module Constree
|
5
|
-
|
6
6
|
class << self
|
7
|
+
def uniq(mod, set = Set.new)
|
8
|
+
set << mod
|
9
|
+
mod.constants.each do |name|
|
10
|
+
sub_mod = mod.const_get(name)
|
11
|
+
uniq(sub_mod, set) if ::Module === sub_mod && !set.include?(sub_mod)
|
12
|
+
end
|
13
|
+
set
|
14
|
+
end
|
7
15
|
|
8
16
|
def list node, seen=[]
|
9
17
|
node = Node.new node unless node.is_a? Node
|
@@ -29,7 +37,5 @@ module Constree
|
|
29
37
|
def p mod
|
30
38
|
puts of mod
|
31
39
|
end
|
32
|
-
|
33
40
|
end
|
34
|
-
|
35
41
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: constree
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ken
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-02-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -80,7 +80,7 @@ dependencies:
|
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: 0.1.10
|
83
|
-
description:
|
83
|
+
description:
|
84
84
|
email:
|
85
85
|
- block24block@gmail.com
|
86
86
|
executables: []
|
@@ -105,7 +105,7 @@ homepage: https://github.com/turnon/constree
|
|
105
105
|
licenses:
|
106
106
|
- MIT
|
107
107
|
metadata: {}
|
108
|
-
post_install_message:
|
108
|
+
post_install_message:
|
109
109
|
rdoc_options: []
|
110
110
|
require_paths:
|
111
111
|
- lib
|
@@ -120,8 +120,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
120
120
|
- !ruby/object:Gem::Version
|
121
121
|
version: '0'
|
122
122
|
requirements: []
|
123
|
-
rubygems_version: 3.1
|
124
|
-
signing_key:
|
123
|
+
rubygems_version: 3.4.1
|
124
|
+
signing_key:
|
125
125
|
specification_version: 4
|
126
126
|
summary: recursively show the structure of constants in a module
|
127
127
|
test_files: []
|