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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fda87378a074ec894ad39ea09eff44fe458f6ea5ad208b9a53ff097a07c2d8b8
4
- data.tar.gz: e2b0d100fdfac4da1ab1eedec5eb1efc98383de15a55a67aa642a34601505d7c
3
+ metadata.gz: 1bcfc7a688043ae320be5ab2ded3d28f2631c7c2eb8e72175d5813f410c9ce11
4
+ data.tar.gz: 36fdeedbd8924a5407d5ce519937db857a19233c48fa4bceadb8393f3d9ff8ff
5
5
  SHA512:
6
- metadata.gz: 833f161b42abd52f8193281c0236b19b5b72edfe8738a28e73861611ab15cdab1733846b4d70fc625dc14b32100ca17085021a4c7298f9a6904881e34ee39622
7
- data.tar.gz: b6558cc98fc60be4e1e6c0701abc56cfdabe8c549b89f7f96938aa238caa0849618945061a7fce1270e2799d5b0b278f717592d7c72eaff8e5b99f8cfa8ae58e
6
+ metadata.gz: 3e0a14a48ee6e30df121beef8f0a6c66319f1b0b1a2ce49285e3489fb1b2d57b2daef463b1f79c6e2a2f8f76795f784b473bd1f48b5c10edc3aed129d4a56358
7
+ data.tar.gz: 1b14c36e7d3ecb7a8169bd1838fe04225a607ad8ee5a1bab37a0fe094798439495441bc76ad826cd616127d78054ea93a76ba24d9a8d827715a9792e62282efc
data/.gitignore CHANGED
@@ -9,3 +9,4 @@
9
9
  /tmp/
10
10
  *.swp
11
11
  *.gem
12
+ .ruby-version
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
@@ -1,3 +1,3 @@
1
1
  module Constree
2
- VERSION = "0.1.8"
2
+ VERSION = "0.1.9"
3
3
  end
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.8
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: 2022-12-10 00:00:00.000000000 Z
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.6
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: []