rambling-trie 2.4.0 → 2.5.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (92) hide show
  1. checksums.yaml +4 -4
  2. data/Dockerfile +28 -0
  3. data/Gemfile +20 -8
  4. data/Guardfile +16 -5
  5. data/README.md +38 -32
  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 -19
  11. data/lib/rambling/trie/configuration/properties.rb +10 -6
  12. data/lib/rambling/trie/configuration/provider_collection.rb +14 -9
  13. data/lib/rambling/trie/configuration.rb +2 -3
  14. data/lib/rambling/trie/container.rb +32 -24
  15. data/lib/rambling/trie/enumerable.rb +5 -6
  16. data/lib/rambling/trie/nodes/compressed.rb +26 -16
  17. data/lib/rambling/trie/nodes/node.rb +35 -12
  18. data/lib/rambling/trie/nodes/raw.rb +18 -20
  19. data/lib/rambling/trie/nodes.rb +2 -3
  20. data/lib/rambling/trie/readers/plain_text.rb +3 -3
  21. data/lib/rambling/trie/readers.rb +2 -3
  22. data/lib/rambling/trie/serializers/file.rb +1 -3
  23. data/lib/rambling/trie/serializers/marshal.rb +4 -4
  24. data/lib/rambling/trie/serializers/yaml.rb +3 -3
  25. data/lib/rambling/trie/serializers/zip.rb +13 -5
  26. data/lib/rambling/trie/serializers.rb +2 -3
  27. data/lib/rambling/trie/stringifyable.rb +1 -1
  28. data/lib/rambling/trie/version.rb +1 -1
  29. data/lib/rambling/trie.rb +12 -15
  30. data/rambling-trie.gemspec +4 -10
  31. data/sig/lib/rambling/trie/comparable.rbs +17 -0
  32. data/sig/lib/rambling/trie/compressible.rbs +17 -0
  33. data/sig/lib/rambling/trie/compressor.rbs +17 -0
  34. data/sig/lib/rambling/trie/configuration/properties.rbs +28 -0
  35. data/sig/lib/rambling/trie/configuration/provider_collection.rbs +47 -0
  36. data/sig/lib/rambling/trie/container.rbs +69 -0
  37. data/sig/lib/rambling/trie/enumerable.rbs +23 -0
  38. data/sig/lib/rambling/trie/inspectable.rbs +27 -0
  39. data/sig/lib/rambling/trie/invalid_operation.rbs +7 -0
  40. data/sig/lib/rambling/trie/nodes/compressed.rbs +25 -0
  41. data/sig/lib/rambling/trie/nodes/missing.rbs +9 -0
  42. data/sig/lib/rambling/trie/nodes/node.rbs +69 -0
  43. data/sig/lib/rambling/trie/nodes/raw.rbs +27 -0
  44. data/sig/lib/rambling/trie/readers/plain_text.rbs +9 -0
  45. data/sig/lib/rambling/trie/readers/reader.rbs +9 -0
  46. data/sig/lib/rambling/trie/serializers/file.rbs +8 -0
  47. data/sig/lib/rambling/trie/serializers/marshal.rbs +13 -0
  48. data/sig/lib/rambling/trie/serializers/serializer.rbs +10 -0
  49. data/sig/lib/rambling/trie/serializers/yaml.rbs +13 -0
  50. data/sig/lib/rambling/trie/serializers/zip.rbs +21 -0
  51. data/sig/lib/rambling/trie/stringifyable.rbs +21 -0
  52. data/sig/lib/rambling/trie.rbs +27 -0
  53. data/sig/lib/zip/entry.rbs +11 -0
  54. data/sig/lib/zip/file.rbs +11 -0
  55. metadata +34 -123
  56. data/spec/assets/test_words.en_US.txt +0 -23
  57. data/spec/assets/test_words.es_DO.txt +0 -24
  58. data/spec/integration/rambling/trie_spec.rb +0 -116
  59. data/spec/lib/rambling/trie/comparable_spec.rb +0 -87
  60. data/spec/lib/rambling/trie/compressor_spec.rb +0 -111
  61. data/spec/lib/rambling/trie/configuration/properties_spec.rb +0 -75
  62. data/spec/lib/rambling/trie/configuration/provider_collection_spec.rb +0 -177
  63. data/spec/lib/rambling/trie/container_spec.rb +0 -466
  64. data/spec/lib/rambling/trie/enumerable_spec.rb +0 -50
  65. data/spec/lib/rambling/trie/inspectable_spec.rb +0 -62
  66. data/spec/lib/rambling/trie/nodes/compressed_spec.rb +0 -43
  67. data/spec/lib/rambling/trie/nodes/node_spec.rb +0 -9
  68. data/spec/lib/rambling/trie/nodes/raw_spec.rb +0 -184
  69. data/spec/lib/rambling/trie/readers/plain_text_spec.rb +0 -26
  70. data/spec/lib/rambling/trie/readers/reader_spec.rb +0 -14
  71. data/spec/lib/rambling/trie/serializers/file_spec.rb +0 -11
  72. data/spec/lib/rambling/trie/serializers/marshal_spec.rb +0 -10
  73. data/spec/lib/rambling/trie/serializers/serializer_spec.rb +0 -21
  74. data/spec/lib/rambling/trie/serializers/yaml_spec.rb +0 -10
  75. data/spec/lib/rambling/trie/serializers/zip_spec.rb +0 -36
  76. data/spec/lib/rambling/trie/stringifyable_spec.rb +0 -89
  77. data/spec/lib/rambling/trie_spec.rb +0 -244
  78. data/spec/spec_helper.rb +0 -42
  79. data/spec/support/config.rb +0 -15
  80. data/spec/support/helpers/add_word.rb +0 -20
  81. data/spec/support/helpers/one_line_heredoc.rb +0 -11
  82. data/spec/support/shared_examples/a_compressible_trie.rb +0 -46
  83. data/spec/support/shared_examples/a_container_partial_word.rb +0 -17
  84. data/spec/support/shared_examples/a_container_scan.rb +0 -14
  85. data/spec/support/shared_examples/a_container_word.rb +0 -43
  86. data/spec/support/shared_examples/a_container_words_within.rb +0 -44
  87. data/spec/support/shared_examples/a_serializable_trie.rb +0 -26
  88. data/spec/support/shared_examples/a_serializer.rb +0 -60
  89. data/spec/support/shared_examples/a_trie_data_structure.rb +0 -45
  90. data/spec/support/shared_examples/a_trie_node.rb +0 -135
  91. data/spec/support/shared_examples/a_trie_node_implementation.rb +0 -149
  92. data/spec/tmp/.gitkeep +0 -0
@@ -3,6 +3,6 @@
3
3
  module Rambling
4
4
  module Trie
5
5
  # Current version of the rambling-trie.
6
- VERSION = '2.4.0'
6
+ VERSION = '2.5.1'
7
7
  end
8
8
  end
data/lib/rambling/trie.rb CHANGED
@@ -1,18 +1,17 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ path = File.join 'rambling', 'trie'
3
4
  %w(
4
5
  comparable compressible compressor configuration container enumerable inspectable invalid_operation
5
6
  readers serializers stringifyable nodes version
6
- ).each do |file|
7
- require File.join('rambling', 'trie', file)
8
- end
7
+ ).each { |file| require File.join(path, file) }
9
8
 
10
9
  # General namespace for all Rambling gems.
11
10
  module Rambling
12
- # Entry point for +rambling-trie+ API.
11
+ # Entry point for `rambling-trie` API.
13
12
  module Trie
14
13
  class << self
15
- # Creates a new +Rambling::Trie+. Entry point for the +rambling-trie+ API.
14
+ # Creates a new `Rambling::Trie`. Entry point for the `rambling-trie` API.
16
15
  # @param [String, nil] filepath the file to load the words from.
17
16
  # @param [Readers::Reader, nil] reader the file parser to get each word.
18
17
  # @return [Container] the trie just created.
@@ -26,9 +25,7 @@ module Rambling
26
25
  if filepath
27
26
  reader ||= readers.resolve filepath
28
27
  # noinspection RubyMismatchedArgumentType,RubyNilAnalysis
29
- reader.each_word filepath do |word|
30
- container << word
31
- end
28
+ (reader || raise).each_word(filepath) { |word| container << word }
32
29
  end
33
30
 
34
31
  yield container if block_given?
@@ -37,18 +34,18 @@ module Rambling
37
34
 
38
35
  # Loads an existing trie from disk into memory. By default, it will
39
36
  # deduce the correct way to deserialize based on the file extension.
40
- # Available formats are +yml+, +marshal+, and +zip+ versions of all the
37
+ # Available formats are `yml`, `marshal`, and `zip` versions of all the
41
38
  # previous formats. You can also define your own.
42
39
  # @param [String] filepath the file to load the words from.
43
40
  # @param [Serializer, nil] serializer the object responsible of loading the trie from disk.
44
41
  # @return [Container] the trie just loaded.
45
42
  # @yield [Container] the trie just loaded.
46
43
  # @see Rambling::Trie::Serializers Serializers.
47
- # @note Use of # {https://ruby-doc.org/core-2.7.0/Marshal.html#method-c-load Marshal.load} is generally
48
- # discouraged. Only use the +.marshal+ format with trusted input.
44
+ # @note Use of # {https://ruby-doc.org/3.3.0/Marshal.html#method-c-load Marshal.load} is generally
45
+ # discouraged. Only use the `.marshal` format with trusted input.
49
46
  def load filepath, serializer = nil
50
47
  serializer ||= serializers.resolve filepath
51
- root = serializer.load filepath
48
+ root = (serializer || raise).load filepath
52
49
  Rambling::Trie::Container.new root, compressor do |container|
53
50
  yield container if block_given?
54
51
  end
@@ -56,7 +53,7 @@ module Rambling
56
53
 
57
54
  # Dumps an existing trie from memory into disk. By default, it will
58
55
  # deduce the correct way to serialize based on the file extension.
59
- # Available formats are +yml+, +marshal+, and +zip+ versions of all the
56
+ # Available formats are `yml`, `marshal`, and `zip` versions of all the
60
57
  # previous formats. You can also define your own.
61
58
  # @param [Container] trie the trie to dump into disk.
62
59
  # @param [String] filepath the file to dump to serialized trie into.
@@ -66,10 +63,10 @@ module Rambling
66
63
  def dump trie, filepath, serializer = nil
67
64
  serializer ||= serializers.resolve filepath
68
65
  # noinspection RubyNilAnalysis
69
- serializer.dump trie.root, filepath
66
+ (serializer || raise).dump trie.root, filepath
70
67
  end
71
68
 
72
- # Provides configuration properties for the +Rambling::Trie+ gem.
69
+ # Provides configuration properties for the `Rambling::Trie` gem.
73
70
  # @return [Configuration::Properties] the configured properties of the gem.
74
71
  # @yield [Configuration::Properties] the configured properties of the gem.
75
72
  def config
@@ -14,28 +14,22 @@ Gem::Specification.new do |gem|
14
14
 
15
15
  gem.summary = 'A Ruby implementation of the trie data structure.'
16
16
  gem.homepage = 'https://github.com/gonzedge/rambling-trie'
17
- gem.date = Time.now.strftime '%Y-%m-%d'
18
17
  gem.metadata = {
19
- 'changelog_uri' => 'https://github.com/gonzedge/rambling-trie/blob/master/CHANGELOG.md',
18
+ 'changelog_uri' => 'https://github.com/gonzedge/rambling-trie/blob/main/CHANGELOG.md',
20
19
  'documentation_uri' => 'https://www.rubydoc.info/gems/rambling-trie',
20
+ 'rubygems_mfa_required' => 'true',
21
21
  }
22
22
 
23
23
  executables = `git ls-files -- bin/*`.split "\n"
24
- files = `git ls-files -- {lib,*file,*.gemspec,LICENSE*,README*}`.split "\n"
25
- test_files = `git ls-files -- {test,spec,features}/*`.split "\n"
24
+ files = `git ls-files -- {lib,sig,*file,*.gemspec,LICENSE*,README*}`.split "\n"
26
25
 
27
26
  gem.executables = executables.map { |f| File.basename f }
28
27
  gem.files = files
29
- gem.test_files = test_files
30
28
  gem.require_paths = %w(lib)
31
29
 
32
30
  gem.name = 'rambling-trie'
33
31
  gem.license = 'MIT'
34
32
  gem.version = Rambling::Trie::VERSION
35
33
  gem.platform = Gem::Platform::RUBY
36
- gem.required_ruby_version = '>= 2.7', '< 4'
37
-
38
- gem.add_development_dependency 'rake', '~> 13.1'
39
- gem.add_development_dependency 'rspec', '~> 3.12'
40
- gem.add_development_dependency 'yard', '~> 0.9.34'
34
+ gem.required_ruby_version = '>= 3.1', '< 4'
41
35
  end
@@ -0,0 +1,17 @@
1
+ module Rambling
2
+ module Trie
3
+ module Comparable
4
+ def ==: (Nodes::Node) -> bool
5
+
6
+ private
7
+
8
+ # abstract methods
9
+
10
+ def letter: -> Symbol
11
+
12
+ def terminal?: -> bool
13
+
14
+ def children_tree: -> Hash[Symbol, Nodes::Node]
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,17 @@
1
+ module Rambling
2
+ module Trie
3
+ module Compressible
4
+ def compressible?: -> bool
5
+
6
+ private
7
+
8
+ # abstract methods
9
+
10
+ def root?: -> bool
11
+
12
+ def terminal?: -> bool
13
+
14
+ def children_tree: -> Hash[Symbol, Nodes::Node]
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,17 @@
1
+ module Rambling
2
+ module Trie
3
+ class Compressor
4
+ def compress: (Nodes::Node?) -> Nodes::Compressed?
5
+
6
+ private
7
+
8
+ def compress_only_child_and_merge: (Nodes::Node) -> Nodes::Compressed
9
+
10
+ def merge: (Nodes::Node, Nodes::Node) -> Nodes::Compressed
11
+
12
+ def compress_children_and_copy: (Nodes::Node) -> Nodes::Compressed
13
+
14
+ def compress_children: (Hash[Symbol, Nodes::Node]) -> Hash[Symbol, Nodes::Node]
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,28 @@
1
+ module Rambling
2
+ module Trie
3
+ module Configuration
4
+ class Properties
5
+ attr_reader readers: ProviderCollection[Readers::Reader]
6
+ attr_reader serializers: ProviderCollection[Serializers::Serializer[Nodes::Node]]
7
+ attr_accessor compressor: Compressor
8
+ attr_accessor root_builder: ^() -> Nodes::Node
9
+ attr_accessor tmp_path: String
10
+
11
+ def initialize: -> void
12
+
13
+ def reset: -> void
14
+
15
+ private
16
+
17
+ attr_writer readers: ProviderCollection[Readers::Reader]
18
+ attr_writer serializers: ProviderCollection[Serializers::Serializer[Nodes::Node]]
19
+
20
+ def reset_readers: -> void
21
+
22
+ def default_reader_providers: -> Hash[Symbol, Readers::Reader]
23
+
24
+ def reset_serializers: -> void
25
+ end
26
+ end
27
+ end
28
+ end
@@ -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