rambling-trie 0.5.2 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.travis.yml +1 -0
- data/Gemfile +1 -5
- data/LICENSE +3 -1
- data/README.markdown +19 -8
- data/lib/rambling/trie.rb +4 -3
- data/lib/rambling/trie/branches.rb +24 -29
- data/lib/rambling/trie/compressor.rb +9 -5
- data/lib/rambling/trie/enumerable.rb +1 -1
- data/lib/rambling/trie/inspector.rb +1 -1
- data/lib/rambling/trie/node.rb +26 -11
- data/lib/rambling/trie/root.rb +28 -14
- data/lib/rambling/trie/tasks/performance.rb +4 -29
- data/lib/rambling/trie/version.rb +1 -1
- data/spec/lib/rambling/trie/node_spec.rb +82 -47
- data/spec/lib/rambling/trie/root_spec.rb +121 -97
- data/spec/spec_helper.rb +2 -0
- metadata +17 -38
- data/lib/rambling/trie/children_hash_deferer.rb +0 -35
- data/spec/lib/rambling/trie/children_hash_deferer_spec.rb +0 -59
data/spec/spec_helper.rb
CHANGED
@@ -10,6 +10,8 @@ require 'rambling-trie'
|
|
10
10
|
RSpec.configure do |config|
|
11
11
|
config.order = :random
|
12
12
|
config.treat_symbols_as_metadata_keys_with_true_values = true
|
13
|
+
config.run_all_when_everything_filtered = true
|
14
|
+
config.filter_run :focus
|
13
15
|
|
14
16
|
config.expect_with :rspec do |c|
|
15
17
|
c.syntax = :expect
|
metadata
CHANGED
@@ -1,8 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rambling-trie
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
5
|
-
prerelease:
|
4
|
+
version: 0.6.0
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Edgar Gonzalez
|
@@ -10,86 +9,76 @@ authors:
|
|
10
9
|
autorequire:
|
11
10
|
bindir: bin
|
12
11
|
cert_chain: []
|
13
|
-
date: 2013-
|
12
|
+
date: 2013-03-10 00:00:00.000000000 Z
|
14
13
|
dependencies:
|
15
14
|
- !ruby/object:Gem::Dependency
|
16
15
|
name: rspec
|
17
16
|
requirement: !ruby/object:Gem::Requirement
|
18
|
-
none: false
|
19
17
|
requirements:
|
20
|
-
- -
|
18
|
+
- - '>='
|
21
19
|
- !ruby/object:Gem::Version
|
22
20
|
version: 2.12.0
|
23
21
|
type: :development
|
24
22
|
prerelease: false
|
25
23
|
version_requirements: !ruby/object:Gem::Requirement
|
26
|
-
none: false
|
27
24
|
requirements:
|
28
|
-
- -
|
25
|
+
- - '>='
|
29
26
|
- !ruby/object:Gem::Version
|
30
27
|
version: 2.12.0
|
31
28
|
- !ruby/object:Gem::Dependency
|
32
29
|
name: rake
|
33
30
|
requirement: !ruby/object:Gem::Requirement
|
34
|
-
none: false
|
35
31
|
requirements:
|
36
|
-
- -
|
32
|
+
- - '>='
|
37
33
|
- !ruby/object:Gem::Version
|
38
34
|
version: 10.0.0.1
|
39
35
|
type: :development
|
40
36
|
prerelease: false
|
41
37
|
version_requirements: !ruby/object:Gem::Requirement
|
42
|
-
none: false
|
43
38
|
requirements:
|
44
|
-
- -
|
39
|
+
- - '>='
|
45
40
|
- !ruby/object:Gem::Version
|
46
41
|
version: 10.0.0.1
|
47
42
|
- !ruby/object:Gem::Dependency
|
48
43
|
name: ruby-prof
|
49
44
|
requirement: !ruby/object:Gem::Requirement
|
50
|
-
none: false
|
51
45
|
requirements:
|
52
|
-
- -
|
46
|
+
- - '>='
|
53
47
|
- !ruby/object:Gem::Version
|
54
48
|
version: 0.11.2
|
55
49
|
type: :development
|
56
50
|
prerelease: false
|
57
51
|
version_requirements: !ruby/object:Gem::Requirement
|
58
|
-
none: false
|
59
52
|
requirements:
|
60
|
-
- -
|
53
|
+
- - '>='
|
61
54
|
- !ruby/object:Gem::Version
|
62
55
|
version: 0.11.2
|
63
56
|
- !ruby/object:Gem::Dependency
|
64
57
|
name: yard
|
65
58
|
requirement: !ruby/object:Gem::Requirement
|
66
|
-
none: false
|
67
59
|
requirements:
|
68
|
-
- -
|
60
|
+
- - '>='
|
69
61
|
- !ruby/object:Gem::Version
|
70
62
|
version: 0.8.3
|
71
63
|
type: :development
|
72
64
|
prerelease: false
|
73
65
|
version_requirements: !ruby/object:Gem::Requirement
|
74
|
-
none: false
|
75
66
|
requirements:
|
76
|
-
- -
|
67
|
+
- - '>='
|
77
68
|
- !ruby/object:Gem::Version
|
78
69
|
version: 0.8.3
|
79
70
|
- !ruby/object:Gem::Dependency
|
80
71
|
name: redcarpet
|
81
72
|
requirement: !ruby/object:Gem::Requirement
|
82
|
-
none: false
|
83
73
|
requirements:
|
84
|
-
- -
|
74
|
+
- - '>='
|
85
75
|
- !ruby/object:Gem::Version
|
86
76
|
version: 2.2.2
|
87
77
|
type: :development
|
88
78
|
prerelease: false
|
89
79
|
version_requirements: !ruby/object:Gem::Requirement
|
90
|
-
none: false
|
91
80
|
requirements:
|
92
|
-
- -
|
81
|
+
- - '>='
|
93
82
|
- !ruby/object:Gem::Version
|
94
83
|
version: 2.2.2
|
95
84
|
description: The Rambling Trie is a custom implementation of the Trie data structure
|
@@ -114,7 +103,6 @@ files:
|
|
114
103
|
- lib/rambling-trie.rb
|
115
104
|
- lib/rambling/trie.rb
|
116
105
|
- lib/rambling/trie/branches.rb
|
117
|
-
- lib/rambling/trie/children_hash_deferer.rb
|
118
106
|
- lib/rambling/trie/compressor.rb
|
119
107
|
- lib/rambling/trie/enumerable.rb
|
120
108
|
- lib/rambling/trie/inspector.rb
|
@@ -130,7 +118,6 @@ files:
|
|
130
118
|
- spec/assets/test_words.txt
|
131
119
|
- spec/integration/rambling/trie_spec.rb
|
132
120
|
- spec/lib/rambling/trie/branches_spec.rb
|
133
|
-
- spec/lib/rambling/trie/children_hash_deferer_spec.rb
|
134
121
|
- spec/lib/rambling/trie/enumerable_spec.rb
|
135
122
|
- spec/lib/rambling/trie/inspector_spec.rb
|
136
123
|
- spec/lib/rambling/trie/node_spec.rb
|
@@ -140,39 +127,31 @@ files:
|
|
140
127
|
- spec/spec_helper.rb
|
141
128
|
homepage: http://github.com/gonzedge/rambling-trie
|
142
129
|
licenses: []
|
130
|
+
metadata: {}
|
143
131
|
post_install_message:
|
144
132
|
rdoc_options: []
|
145
133
|
require_paths:
|
146
134
|
- lib
|
147
135
|
required_ruby_version: !ruby/object:Gem::Requirement
|
148
|
-
none: false
|
149
136
|
requirements:
|
150
|
-
- -
|
137
|
+
- - '>='
|
151
138
|
- !ruby/object:Gem::Version
|
152
139
|
version: '0'
|
153
|
-
segments:
|
154
|
-
- 0
|
155
|
-
hash: 4017458515202388954
|
156
140
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
157
|
-
none: false
|
158
141
|
requirements:
|
159
|
-
- -
|
142
|
+
- - '>='
|
160
143
|
- !ruby/object:Gem::Version
|
161
144
|
version: '0'
|
162
|
-
segments:
|
163
|
-
- 0
|
164
|
-
hash: 4017458515202388954
|
165
145
|
requirements: []
|
166
146
|
rubyforge_project:
|
167
|
-
rubygems_version:
|
147
|
+
rubygems_version: 2.0.2
|
168
148
|
signing_key:
|
169
|
-
specification_version:
|
149
|
+
specification_version: 4
|
170
150
|
summary: A custom implementation of the trie data structure.
|
171
151
|
test_files:
|
172
152
|
- spec/assets/test_words.txt
|
173
153
|
- spec/integration/rambling/trie_spec.rb
|
174
154
|
- spec/lib/rambling/trie/branches_spec.rb
|
175
|
-
- spec/lib/rambling/trie/children_hash_deferer_spec.rb
|
176
155
|
- spec/lib/rambling/trie/enumerable_spec.rb
|
177
156
|
- spec/lib/rambling/trie/inspector_spec.rb
|
178
157
|
- spec/lib/rambling/trie/node_spec.rb
|
@@ -1,35 +0,0 @@
|
|
1
|
-
module Rambling
|
2
|
-
module Trie
|
3
|
-
# Provides some proxy methods to the children's hash for readability.
|
4
|
-
module ChildrenHashDeferer
|
5
|
-
# Proxies to @children[key]
|
6
|
-
# @param [Symbol] key the key to look for in the children's hash.
|
7
|
-
# @return [Node, nil] the child node with that key or nil.
|
8
|
-
def [](key)
|
9
|
-
children[key]
|
10
|
-
end
|
11
|
-
|
12
|
-
# Proxies to @children[key] = value.
|
13
|
-
# @param [Symbol] key the to add or change the value for.
|
14
|
-
# @param [Node] value the node to add to the children's hash.
|
15
|
-
# @return [Node, nil] the child node with that key or nil.
|
16
|
-
def []=(key, value)
|
17
|
-
children[key] = value
|
18
|
-
end
|
19
|
-
|
20
|
-
# Proxies to @children.delete(key)
|
21
|
-
# @param [Symbol] key the key to delete in the children's hash.
|
22
|
-
# @return [Node, nil] the child node corresponding to the key just deleted or nil.
|
23
|
-
def delete(key)
|
24
|
-
children.delete(key)
|
25
|
-
end
|
26
|
-
|
27
|
-
# Proxies to @children.has_key?(key)
|
28
|
-
# @param [Symbol] key the key to look for in the children's hash.
|
29
|
-
# @return [Boolean] `true` for the keys that exist in the children's hash, false otherwise.
|
30
|
-
def has_key?(key)
|
31
|
-
children.has_key?(key)
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
@@ -1,59 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
module Rambling
|
4
|
-
module Trie
|
5
|
-
describe ChildrenHashDeferer do
|
6
|
-
class ClassWithChildren
|
7
|
-
include ChildrenHashDeferer
|
8
|
-
attr_accessor :children
|
9
|
-
|
10
|
-
def initialize()
|
11
|
-
@children = {}
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
let(:deferer) { ClassWithChildren.new }
|
16
|
-
|
17
|
-
describe '#[]' do
|
18
|
-
let(:key) { :key }
|
19
|
-
let(:value) { 'value' }
|
20
|
-
|
21
|
-
it 'defers to the children hash' do
|
22
|
-
deferer.children.should_receive(:[]).with(key).and_return value
|
23
|
-
expect(deferer[key]).to eq value
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
describe '#[]=' do
|
28
|
-
let(:key) { :key }
|
29
|
-
let(:value) { 'value' }
|
30
|
-
|
31
|
-
it 'defers to the children hash' do
|
32
|
-
deferer.children.should_receive(:[]=).with(key, value)
|
33
|
-
deferer[key] = value
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
describe '#delete' do
|
38
|
-
let(:key) { :key }
|
39
|
-
let(:value) { 'value' }
|
40
|
-
|
41
|
-
it 'defers to the children hash' do
|
42
|
-
deferer.children.should_receive(:delete).with(key).and_return value
|
43
|
-
expect(deferer.delete key).to eq value
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
|
-
describe '#has_key' do
|
48
|
-
let(:key) { :key }
|
49
|
-
|
50
|
-
it 'defers to the children hash' do
|
51
|
-
[true, false].each do |value|
|
52
|
-
deferer.children.should_receive(:has_key?).with(key).and_return value
|
53
|
-
expect(deferer.has_key? key).to eq value
|
54
|
-
end
|
55
|
-
end
|
56
|
-
end
|
57
|
-
end
|
58
|
-
end
|
59
|
-
end
|