rambling-trie 2.5.0 → 2.5.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (54) hide show
  1. checksums.yaml +4 -4
  2. data/Dockerfile +28 -0
  3. data/Gemfile +18 -9
  4. data/Guardfile +16 -5
  5. data/README.md +23 -23
  6. data/Rakefile +6 -0
  7. data/Steepfile +35 -0
  8. data/lib/rambling/trie/comparable.rb +2 -2
  9. data/lib/rambling/trie/compressible.rb +1 -1
  10. data/lib/rambling/trie/compressor.rb +22 -21
  11. data/lib/rambling/trie/configuration/properties.rb +5 -4
  12. data/lib/rambling/trie/configuration/provider_collection.rb +12 -7
  13. data/lib/rambling/trie/configuration.rb +2 -3
  14. data/lib/rambling/trie/container.rb +20 -23
  15. data/lib/rambling/trie/enumerable.rb +4 -5
  16. data/lib/rambling/trie/nodes/compressed.rb +26 -16
  17. data/lib/rambling/trie/nodes/node.rb +31 -8
  18. data/lib/rambling/trie/nodes/raw.rb +16 -19
  19. data/lib/rambling/trie/nodes.rb +2 -3
  20. data/lib/rambling/trie/readers/plain_text.rb +2 -2
  21. data/lib/rambling/trie/readers.rb +2 -3
  22. data/lib/rambling/trie/serializers/marshal.rb +1 -1
  23. data/lib/rambling/trie/serializers/yaml.rb +1 -1
  24. data/lib/rambling/trie/serializers/zip.rb +12 -6
  25. data/lib/rambling/trie/serializers.rb +2 -3
  26. data/lib/rambling/trie/stringifyable.rb +1 -1
  27. data/lib/rambling/trie/version.rb +1 -1
  28. data/lib/rambling/trie.rb +11 -14
  29. data/rambling-trie.gemspec +1 -1
  30. data/sig/lib/rambling/trie/comparable.rbs +17 -0
  31. data/sig/lib/rambling/trie/compressible.rbs +17 -0
  32. data/sig/lib/rambling/trie/compressor.rbs +17 -0
  33. data/sig/lib/rambling/trie/configuration/properties.rbs +28 -0
  34. data/sig/lib/rambling/trie/configuration/provider_collection.rbs +47 -0
  35. data/sig/lib/rambling/trie/container.rbs +69 -0
  36. data/sig/lib/rambling/trie/enumerable.rbs +23 -0
  37. data/sig/lib/rambling/trie/inspectable.rbs +27 -0
  38. data/sig/lib/rambling/trie/invalid_operation.rbs +7 -0
  39. data/sig/lib/rambling/trie/nodes/compressed.rbs +25 -0
  40. data/sig/lib/rambling/trie/nodes/missing.rbs +9 -0
  41. data/sig/lib/rambling/trie/nodes/node.rbs +69 -0
  42. data/sig/lib/rambling/trie/nodes/raw.rbs +27 -0
  43. data/sig/lib/rambling/trie/readers/plain_text.rbs +9 -0
  44. data/sig/lib/rambling/trie/readers/reader.rbs +9 -0
  45. data/sig/lib/rambling/trie/serializers/file.rbs +8 -0
  46. data/sig/lib/rambling/trie/serializers/marshal.rbs +13 -0
  47. data/sig/lib/rambling/trie/serializers/serializer.rbs +10 -0
  48. data/sig/lib/rambling/trie/serializers/yaml.rbs +13 -0
  49. data/sig/lib/rambling/trie/serializers/zip.rbs +21 -0
  50. data/sig/lib/rambling/trie/stringifyable.rbs +21 -0
  51. data/sig/lib/rambling/trie.rbs +27 -0
  52. data/sig/lib/zip/entry.rbs +11 -0
  53. data/sig/lib/zip/file.rbs +11 -0
  54. metadata +29 -3
@@ -0,0 +1,47 @@
1
+ module Rambling
2
+ module Trie
3
+ module Configuration
4
+ class ProviderCollection[TProvider < _Nilable]
5
+ interface _Nilable
6
+ def nil?: -> bool
7
+ end
8
+
9
+ @providers: Hash[Symbol, TProvider]
10
+
11
+ attr_reader name: Symbol
12
+ attr_reader default: TProvider?
13
+
14
+ def initialize: (Symbol, Hash[Symbol, TProvider], ?TProvider?) -> void
15
+
16
+ def []: (Symbol) -> TProvider
17
+
18
+ def add: (Symbol, TProvider) -> TProvider
19
+
20
+ def default=: (TProvider?) -> TProvider?
21
+
22
+ def formats: -> Array[Symbol]
23
+
24
+ def providers: -> Hash[Symbol, TProvider]
25
+
26
+ def reset: -> void
27
+
28
+ def resolve: (String) -> TProvider?
29
+
30
+ private
31
+
32
+ attr_reader configured_default: TProvider?
33
+ attr_reader configured_providers: Hash[Symbol, TProvider]
34
+
35
+ def []=: (Symbol, TProvider) -> TProvider
36
+
37
+ def values: -> Array[TProvider]
38
+
39
+ def file_format: (String) -> Symbol
40
+
41
+ def contains?: (TProvider?) -> bool
42
+
43
+ alias provider_instances values
44
+ end
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,69 @@
1
+ module Rambling
2
+ module Trie
3
+ class Container
4
+ include ::Enumerable[String]
5
+
6
+ @compressor: Compressor
7
+
8
+ attr_reader root: Nodes::Node
9
+
10
+ def initialize: (Nodes::Node, Compressor) ?{ (Container) -> void } -> void
11
+
12
+ def add: (String) -> Nodes::Node
13
+
14
+ def concat: (Array[String]) -> Array[Nodes::Node]
15
+
16
+ def compress!: -> Container
17
+
18
+ def compress: -> Container
19
+
20
+ def each: { (String) -> void } -> (Enumerator[String, void] | Enumerable)
21
+
22
+ def partial_word?: (String) -> bool
23
+
24
+ def push: (*String) -> Array[Nodes::Node]
25
+
26
+ def word?: (String) -> bool
27
+
28
+ def scan: (String) -> Array[String]
29
+
30
+ def words_within: (String) -> Array[String]
31
+
32
+ def words_within?: (String) -> bool
33
+
34
+ def ==: (Container) -> bool
35
+
36
+ def []: (Symbol) -> Nodes::Node
37
+
38
+ def children: -> Array[Nodes::Node]
39
+
40
+ def children_tree: -> Hash[Symbol, Nodes::Node]
41
+
42
+ def compressed?: -> bool
43
+
44
+ def to_a: -> Array[String]
45
+
46
+ def key?: (Symbol) -> bool
47
+
48
+ def size: -> Numeric
49
+
50
+ alias include? word?
51
+ alias match? partial_word?
52
+ alias words? scan
53
+ alias << add
54
+ alias has_key? key?
55
+ alias has_letter? key?
56
+
57
+ private
58
+
59
+ attr_reader compressor: Compressor
60
+ attr_writer root: Nodes::Node
61
+
62
+ def words_within_root: (String) ?{ (String) -> void } -> Enumerator[String, void]
63
+
64
+ def compress_root: -> Nodes::Compressed
65
+
66
+ def reversed_char_symbols: (String) -> Array[Symbol]
67
+ end
68
+ end
69
+ end
@@ -0,0 +1,23 @@
1
+ module Rambling
2
+ module Trie
3
+ module Enumerable
4
+ include ::Enumerable[String]
5
+
6
+ EMPTY_ENUMERATOR: Enumerator[String, void]
7
+
8
+ alias size count
9
+
10
+ def each: { (String) -> void } -> (Enumerator[String, void] | Enumerable)
11
+
12
+ private
13
+
14
+ # abstract methods
15
+
16
+ def as_word: -> String
17
+
18
+ def terminal?: -> bool
19
+
20
+ def children_tree: -> Hash[Symbol, Nodes::Node]
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,27 @@
1
+ module Rambling
2
+ module Trie
3
+ module Inspectable
4
+ def inspect: -> String
5
+
6
+ private
7
+
8
+ def class_name: -> String?
9
+
10
+ def attributes: -> String
11
+
12
+ def letter_inspect: -> String
13
+
14
+ def terminal_inspect: -> String
15
+
16
+ def children_inspect: -> String
17
+
18
+ # abstract methods
19
+
20
+ def letter: -> Symbol
21
+
22
+ def terminal: -> bool?
23
+
24
+ def children_tree: -> Hash[Symbol, Nodes::Node]
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,7 @@
1
+ module Rambling
2
+ module Trie
3
+ class InvalidOperation < RuntimeError
4
+ def initialize: (String? message) -> void
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,25 @@
1
+ module Rambling
2
+ module Trie
3
+ module Nodes
4
+ class Compressed < Node
5
+ def initialize: (?Symbol?, ?Node?, ?Hash[Symbol, Node]) -> void
6
+
7
+ def add: (Array[Symbol]) -> Node
8
+
9
+ def compressed?: -> bool
10
+
11
+ private
12
+
13
+ # overrides
14
+
15
+ def children_match_prefix: (Array[String]) { (String) -> void } -> Enumerator[String, void]
16
+
17
+ def partial_word_chars?: (Array[String]) -> bool
18
+
19
+ def word_chars?: (Array[String]) -> bool
20
+
21
+ def closest_node: (Array[String]) -> Node
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,9 @@
1
+ module Rambling
2
+ module Trie
3
+ module Nodes
4
+ class Missing < Node
5
+ def initialize: -> void
6
+ end
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,69 @@
1
+ module Rambling
2
+ module Trie
3
+ module Nodes
4
+ class Node
5
+ include Compressible
6
+ include Enumerable
7
+ include Comparable
8
+ include Stringifyable
9
+ include Inspectable
10
+
11
+ attr_reader letter: Symbol?
12
+ attr_accessor children_tree: Hash[Symbol, Node]
13
+ attr_accessor parent: Node?
14
+
15
+ def initialize: (?Symbol?, ?Node?, ?Hash[Symbol, Node]) -> void
16
+
17
+ def add: (Array[Symbol]) -> Node
18
+
19
+ def children: -> Array[Node]
20
+
21
+ def first_child: -> Node?
22
+
23
+ def match_prefix: (Array[String]) { (String) -> void } -> Enumerator[String, void]
24
+
25
+ def root?: -> bool
26
+
27
+ def scan: (Array[String]) -> Node
28
+
29
+ def terminal?: -> bool
30
+
31
+ def terminal!: -> Node
32
+
33
+ def letter=: (String | Symbol?) -> Symbol?
34
+
35
+ def compressed?: -> bool
36
+
37
+ def partial_word?: (Array[String]) -> bool
38
+
39
+ def word?: (Array[String]) -> bool
40
+
41
+ def []: (Symbol) -> Node
42
+
43
+ def []=: (Symbol, Node) -> Node
44
+
45
+ def key?: (Symbol) -> bool
46
+
47
+ def delete: (Symbol) -> Node?
48
+
49
+ alias has_key? key?
50
+
51
+ private
52
+
53
+ attr_accessor terminal: bool?
54
+
55
+ def missing: -> Node
56
+
57
+ # abstract methods
58
+
59
+ def children_match_prefix: (Array[String]) { (String) -> void } -> Enumerator[String, void]
60
+
61
+ def partial_word_chars?: (Array[String]) -> bool
62
+
63
+ def word_chars?: (Array[String]) -> bool
64
+
65
+ def closest_node: (Array[String]) -> Node
66
+ end
67
+ end
68
+ end
69
+ end
@@ -0,0 +1,27 @@
1
+ module Rambling
2
+ module Trie
3
+ module Nodes
4
+ class Raw < Node
5
+ def add: (Array[Symbol]) -> Node
6
+
7
+ def compressed?: -> bool
8
+
9
+ private
10
+
11
+ def add_to_children_tree: (Array[Symbol]) -> Node
12
+
13
+ def new_node: (Symbol) -> Node
14
+
15
+ # overrides
16
+
17
+ def children_match_prefix: (Array[String]) { (String) -> void } -> Enumerator[String, void]
18
+
19
+ def partial_word_chars?: (Array[String]) -> bool
20
+
21
+ def word_chars?: (Array[String]) -> bool
22
+
23
+ def closest_node: (Array[String]) -> Node
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,9 @@
1
+ module Rambling
2
+ module Trie
3
+ module Readers
4
+ class PlainText < Reader
5
+ def each_word: (String) { (String?) -> void } -> (Enumerator[String?, void] | PlainText)
6
+ end
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,9 @@
1
+ module Rambling
2
+ module Trie
3
+ module Readers
4
+ class Reader
5
+ def each_word: (String) { (String) -> void } -> (Enumerator[String, void] | Reader)
6
+ end
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,8 @@
1
+ module Rambling
2
+ module Trie
3
+ module Serializers
4
+ class File < Serializer[String]
5
+ end
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,13 @@
1
+ module Rambling
2
+ module Trie
3
+ module Serializers
4
+ class Marshal < Serializer[Nodes::Node]
5
+ @serializer: Serializer[String]
6
+
7
+ private
8
+
9
+ attr_reader serializer: Serializer[String]
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,10 @@
1
+ module Rambling
2
+ module Trie
3
+ module Serializers
4
+ class Serializer[TContents]
5
+ def load: (String) -> TContents
6
+ def dump: (TContents, String) -> Numeric
7
+ end
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,13 @@
1
+ module Rambling
2
+ module Trie
3
+ module Serializers
4
+ class Yaml < Serializer[Nodes::Node]
5
+ @serializer: Serializer[String]
6
+
7
+ private
8
+
9
+ attr_reader serializer: Serializer[String]
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,21 @@
1
+ module Rambling
2
+ module Trie
3
+ module Serializers
4
+ class Zip < Serializer[Nodes::Node]
5
+ @properties: Configuration::Properties
6
+
7
+ def initialize: (Configuration::Properties) -> void
8
+
9
+ private
10
+
11
+ attr_reader properties: Configuration::Properties
12
+
13
+ def serializers: -> Configuration::ProviderCollection[Serializer[Nodes::Node]]
14
+
15
+ def tmp_path: -> String
16
+
17
+ def path: (String) -> String
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,21 @@
1
+ module Rambling
2
+ module Trie
3
+ module Stringifyable
4
+ def as_word: -> String
5
+
6
+ def to_s: -> String
7
+
8
+ private
9
+
10
+ # abstract methods
11
+
12
+ def letter: -> Symbol
13
+
14
+ def terminal?: -> bool
15
+
16
+ def parent: -> Nodes::Node?
17
+
18
+ def children_tree: -> Hash[Symbol, Nodes::Node]
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,27 @@
1
+ module Rambling
2
+ module Trie
3
+ VERSION: String
4
+
5
+ @properties: Configuration::Properties
6
+
7
+ def self.create: (?String?, ?Readers::Reader?) ?{ (Container) -> void } -> Container
8
+
9
+ def self.load: (String, ?Serializers::Serializer[Nodes::Node]?) ?{ (Container) -> void } -> Container
10
+
11
+ def self.dump: (Container, String, ?Serializers::Serializer[Nodes::Node]?) -> void
12
+
13
+ def self.config: ?{ (Configuration::Properties) -> void } -> Configuration::Properties
14
+
15
+ private
16
+
17
+ def self.properties: -> Configuration::Properties
18
+
19
+ def self.readers: -> Configuration::ProviderCollection[Readers::Reader]
20
+
21
+ def self.serializers: -> Configuration::ProviderCollection[Serializers::Serializer[Nodes::Node]]
22
+
23
+ def self.compressor: -> Compressor
24
+
25
+ def self.root_builder: -> ^() -> Nodes::Node
26
+ end
27
+ end
@@ -0,0 +1,11 @@
1
+ module Zip
2
+ class Entry
3
+ include Enumerable[Entry]
4
+
5
+ def name: -> String
6
+
7
+ def extract: (String) -> void
8
+
9
+ def each: ?{ (Entry) -> void } -> (Enumerator[Entry, void])
10
+ end
11
+ end
@@ -0,0 +1,11 @@
1
+ module Zip
2
+ class File
3
+ CREATE: bool
4
+
5
+ def self.open: [TContent] (String, ?bool?) { (File) -> TContent } -> TContent
6
+
7
+ def entries: -> Array[Entry]
8
+
9
+ def add: (String, String) -> void
10
+ end
11
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rambling-trie
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.5.0
4
+ version: 2.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Edgar Gonzalez
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2024-11-30 00:00:00.000000000 Z
12
+ date: 2024-12-05 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: 'The Rambling Trie is a Ruby implementation of the trie data structure,
15
15
  which includes compression abilities and is designed to be very fast to traverse. '
@@ -20,11 +20,13 @@ executables: []
20
20
  extensions: []
21
21
  extra_rdoc_files: []
22
22
  files:
23
+ - Dockerfile
23
24
  - Gemfile
24
25
  - Guardfile
25
26
  - LICENSE
26
27
  - README.md
27
28
  - Rakefile
29
+ - Steepfile
28
30
  - lib/rambling-trie.rb
29
31
  - lib/rambling/trie.rb
30
32
  - lib/rambling/trie/comparable.rb
@@ -54,6 +56,30 @@ files:
54
56
  - lib/rambling/trie/stringifyable.rb
55
57
  - lib/rambling/trie/version.rb
56
58
  - rambling-trie.gemspec
59
+ - sig/lib/rambling/trie.rbs
60
+ - sig/lib/rambling/trie/comparable.rbs
61
+ - sig/lib/rambling/trie/compressible.rbs
62
+ - sig/lib/rambling/trie/compressor.rbs
63
+ - sig/lib/rambling/trie/configuration/properties.rbs
64
+ - sig/lib/rambling/trie/configuration/provider_collection.rbs
65
+ - sig/lib/rambling/trie/container.rbs
66
+ - sig/lib/rambling/trie/enumerable.rbs
67
+ - sig/lib/rambling/trie/inspectable.rbs
68
+ - sig/lib/rambling/trie/invalid_operation.rbs
69
+ - sig/lib/rambling/trie/nodes/compressed.rbs
70
+ - sig/lib/rambling/trie/nodes/missing.rbs
71
+ - sig/lib/rambling/trie/nodes/node.rbs
72
+ - sig/lib/rambling/trie/nodes/raw.rbs
73
+ - sig/lib/rambling/trie/readers/plain_text.rbs
74
+ - sig/lib/rambling/trie/readers/reader.rbs
75
+ - sig/lib/rambling/trie/serializers/file.rbs
76
+ - sig/lib/rambling/trie/serializers/marshal.rbs
77
+ - sig/lib/rambling/trie/serializers/serializer.rbs
78
+ - sig/lib/rambling/trie/serializers/yaml.rbs
79
+ - sig/lib/rambling/trie/serializers/zip.rbs
80
+ - sig/lib/rambling/trie/stringifyable.rbs
81
+ - sig/lib/zip/entry.rbs
82
+ - sig/lib/zip/file.rbs
57
83
  homepage: https://github.com/gonzedge/rambling-trie
58
84
  licenses:
59
85
  - MIT
@@ -79,7 +105,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
79
105
  - !ruby/object:Gem::Version
80
106
  version: '0'
81
107
  requirements: []
82
- rubygems_version: 3.5.3
108
+ rubygems_version: 3.5.22
83
109
  signing_key:
84
110
  specification_version: 4
85
111
  summary: A Ruby implementation of the trie data structure.