gaddag 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (49) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +5 -0
  3. data/.rspec +2 -0
  4. data/.ruby-version +1 -0
  5. data/Gemfile +3 -0
  6. data/LICENSE.txt +22 -0
  7. data/README.md +38 -0
  8. data/Rakefile +1 -0
  9. data/gaddag.gemspec +31 -0
  10. data/lib/gaddag.rb +47 -0
  11. data/lib/gaddag/arc.rb +41 -0
  12. data/lib/gaddag/node.rb +115 -0
  13. data/lib/gaddag/path.rb +72 -0
  14. data/lib/gaddag/word.rb +39 -0
  15. data/spec/shared/unit/gaddag/arc_context.rb +6 -0
  16. data/spec/shared/unit/gaddag/node/create_arc_behaviour.rb +41 -0
  17. data/spec/shared/unit/gaddag/node/create_final_path_behaviour.rb +33 -0
  18. data/spec/shared/unit/gaddag/node/create_path_behaviour.rb +15 -0
  19. data/spec/shared/unit/gaddag/node/create_path_context.rb +6 -0
  20. data/spec/unit/gaddag/add_spec.rb +46 -0
  21. data/spec/unit/gaddag/arc/add_final_letter_spec.rb +24 -0
  22. data/spec/unit/gaddag/arc/final_paths_spec.rb +49 -0
  23. data/spec/unit/gaddag/arc/initialize_spec.rb +16 -0
  24. data/spec/unit/gaddag/find_spec.rb +66 -0
  25. data/spec/unit/gaddag/initialize_spec.rb +11 -0
  26. data/spec/unit/gaddag/node/arc_spec.rb +23 -0
  27. data/spec/unit/gaddag/node/create_arc_spec.rb +8 -0
  28. data/spec/unit/gaddag/node/create_final_arc_spec.rb +18 -0
  29. data/spec/unit/gaddag/node/create_final_path_spec.rb +43 -0
  30. data/spec/unit/gaddag/node/create_path_spec.rb +44 -0
  31. data/spec/unit/gaddag/node/final_path_spec.rb +30 -0
  32. data/spec/unit/gaddag/node/final_paths_spec.rb +48 -0
  33. data/spec/unit/gaddag/node/follow_arc_spec.rb +24 -0
  34. data/spec/unit/gaddag/node/follow_path_spec.rb +41 -0
  35. data/spec/unit/gaddag/node/path_spec.rb +30 -0
  36. data/spec/unit/gaddag/path/equal_value_spec.rb +17 -0
  37. data/spec/unit/gaddag/path/include_delimiter_spec.rb +15 -0
  38. data/spec/unit/gaddag/path/initialize_spec.rb +12 -0
  39. data/spec/unit/gaddag/path/reversed_prefix_letters_spec.rb +34 -0
  40. data/spec/unit/gaddag/path/start_with_spec.rb +39 -0
  41. data/spec/unit/gaddag/path/suffix_letters_spec.rb +34 -0
  42. data/spec/unit/gaddag/path/to_ary_spec.rb +15 -0
  43. data/spec/unit/gaddag/path/to_s_spec.rb +18 -0
  44. data/spec/unit/gaddag/path/to_word_spec.rb +37 -0
  45. data/spec/unit/gaddag/word/equal_value_spec.rb +17 -0
  46. data/spec/unit/gaddag/word/initialize_spec.rb +12 -0
  47. data/spec/unit/gaddag/word/to_delimited_paths_spec.rb +29 -0
  48. data/spec/unit/gaddag/word/to_s_spec.rb +18 -0
  49. metadata +252 -0
@@ -0,0 +1,29 @@
1
+ # encoding: utf-8
2
+
3
+ require 'gaddag'
4
+
5
+ describe GADDAG::Word, '#to_delimited_paths' do
6
+ context 'when the word is empty' do
7
+ subject { GADDAG::Word.new([]) }
8
+ specify { expect(subject.to_delimited_paths).to be_empty }
9
+ end
10
+
11
+ context 'when the word consists of a single letter' do
12
+ subject { GADDAG::Word.new(%w[A]) }
13
+ specify { expect(subject.to_delimited_paths).to be_empty }
14
+ end
15
+
16
+ context 'when the word consists of multiple letters' do
17
+ subject { GADDAG::Word.new(%w[B R E A K]) }
18
+ let(:delimited_paths) { subject.to_delimited_paths }
19
+
20
+ it 'returns a list of delimited paths' do
21
+ expect(delimited_paths).to match_array([
22
+ GADDAG::Path.new(%w[B] + [GADDAG::Path::DELIMITER] + %w[R E A K]),
23
+ GADDAG::Path.new(%w[R B] + [GADDAG::Path::DELIMITER] + %w[E A K]),
24
+ GADDAG::Path.new(%w[E R B] + [GADDAG::Path::DELIMITER] + %w[A K]),
25
+ GADDAG::Path.new(%w[A E R B] + [GADDAG::Path::DELIMITER] + %w[K])
26
+ ])
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,18 @@
1
+ # encoding: utf-8
2
+
3
+ require 'gaddag'
4
+
5
+ describe GADDAG::Word, '#to_s' do
6
+ context 'when the word is empty' do
7
+ let(:word) { GADDAG::Word.new([]) }
8
+ specify { expect(word.to_s).to be_empty }
9
+ end
10
+
11
+ context 'when the word is not empty' do
12
+ let(:word) { GADDAG::Word.new(%w[B R E A K]) }
13
+
14
+ it 'concatenates the letters in this word' do
15
+ expect(word.to_s).to eq('BREAK')
16
+ end
17
+ end
18
+ end
metadata ADDED
@@ -0,0 +1,252 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: gaddag
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.1
5
+ platform: ruby
6
+ authors:
7
+ - Thomas Brus
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-05-14 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: equalizer
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: 0.0.9
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: 0.0.9
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: 1.5.1
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ version: 1.5.1
41
+ - !ruby/object:Gem::Dependency
42
+ name: yard
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ~>
46
+ - !ruby/object:Gem::Version
47
+ version: 0.8.7
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: 0.8.7
55
+ - !ruby/object:Gem::Dependency
56
+ name: inch
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: 0.4.5
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ~>
67
+ - !ruby/object:Gem::Version
68
+ version: 0.4.5
69
+ - !ruby/object:Gem::Dependency
70
+ name: rspec
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ~>
74
+ - !ruby/object:Gem::Version
75
+ version: 2.14.1
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ~>
81
+ - !ruby/object:Gem::Version
82
+ version: 2.14.1
83
+ - !ruby/object:Gem::Dependency
84
+ name: mutant
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ~>
88
+ - !ruby/object:Gem::Version
89
+ version: 0.5.11
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ~>
95
+ - !ruby/object:Gem::Version
96
+ version: 0.5.11
97
+ - !ruby/object:Gem::Dependency
98
+ name: mutant-rspec
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ~>
102
+ - !ruby/object:Gem::Version
103
+ version: 0.5.10
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ~>
109
+ - !ruby/object:Gem::Version
110
+ version: 0.5.10
111
+ - !ruby/object:Gem::Dependency
112
+ name: rake
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - '>='
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - '>='
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ - !ruby/object:Gem::Dependency
126
+ name: pry
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - '>='
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - '>='
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
139
+ description:
140
+ email:
141
+ - thomas.brus@me.com
142
+ executables: []
143
+ extensions: []
144
+ extra_rdoc_files: []
145
+ files:
146
+ - .gitignore
147
+ - .rspec
148
+ - .ruby-version
149
+ - Gemfile
150
+ - LICENSE.txt
151
+ - README.md
152
+ - Rakefile
153
+ - gaddag.gemspec
154
+ - lib/gaddag.rb
155
+ - lib/gaddag/arc.rb
156
+ - lib/gaddag/node.rb
157
+ - lib/gaddag/path.rb
158
+ - lib/gaddag/word.rb
159
+ - spec/shared/unit/gaddag/arc_context.rb
160
+ - spec/shared/unit/gaddag/node/create_arc_behaviour.rb
161
+ - spec/shared/unit/gaddag/node/create_final_path_behaviour.rb
162
+ - spec/shared/unit/gaddag/node/create_path_behaviour.rb
163
+ - spec/shared/unit/gaddag/node/create_path_context.rb
164
+ - spec/unit/gaddag/add_spec.rb
165
+ - spec/unit/gaddag/arc/add_final_letter_spec.rb
166
+ - spec/unit/gaddag/arc/final_paths_spec.rb
167
+ - spec/unit/gaddag/arc/initialize_spec.rb
168
+ - spec/unit/gaddag/find_spec.rb
169
+ - spec/unit/gaddag/initialize_spec.rb
170
+ - spec/unit/gaddag/node/arc_spec.rb
171
+ - spec/unit/gaddag/node/create_arc_spec.rb
172
+ - spec/unit/gaddag/node/create_final_arc_spec.rb
173
+ - spec/unit/gaddag/node/create_final_path_spec.rb
174
+ - spec/unit/gaddag/node/create_path_spec.rb
175
+ - spec/unit/gaddag/node/final_path_spec.rb
176
+ - spec/unit/gaddag/node/final_paths_spec.rb
177
+ - spec/unit/gaddag/node/follow_arc_spec.rb
178
+ - spec/unit/gaddag/node/follow_path_spec.rb
179
+ - spec/unit/gaddag/node/path_spec.rb
180
+ - spec/unit/gaddag/path/equal_value_spec.rb
181
+ - spec/unit/gaddag/path/include_delimiter_spec.rb
182
+ - spec/unit/gaddag/path/initialize_spec.rb
183
+ - spec/unit/gaddag/path/reversed_prefix_letters_spec.rb
184
+ - spec/unit/gaddag/path/start_with_spec.rb
185
+ - spec/unit/gaddag/path/suffix_letters_spec.rb
186
+ - spec/unit/gaddag/path/to_ary_spec.rb
187
+ - spec/unit/gaddag/path/to_s_spec.rb
188
+ - spec/unit/gaddag/path/to_word_spec.rb
189
+ - spec/unit/gaddag/word/equal_value_spec.rb
190
+ - spec/unit/gaddag/word/initialize_spec.rb
191
+ - spec/unit/gaddag/word/to_delimited_paths_spec.rb
192
+ - spec/unit/gaddag/word/to_s_spec.rb
193
+ homepage: https://github.com/thomasbrus/gaddag
194
+ licenses:
195
+ - MIT
196
+ metadata: {}
197
+ post_install_message:
198
+ rdoc_options: []
199
+ require_paths:
200
+ - lib
201
+ required_ruby_version: !ruby/object:Gem::Requirement
202
+ requirements:
203
+ - - '>='
204
+ - !ruby/object:Gem::Version
205
+ version: '0'
206
+ required_rubygems_version: !ruby/object:Gem::Requirement
207
+ requirements:
208
+ - - '>='
209
+ - !ruby/object:Gem::Version
210
+ version: '0'
211
+ requirements: []
212
+ rubyforge_project:
213
+ rubygems_version: 2.0.14
214
+ signing_key:
215
+ specification_version: 4
216
+ summary: Implementation of the GADDAG data structure
217
+ test_files:
218
+ - spec/shared/unit/gaddag/arc_context.rb
219
+ - spec/shared/unit/gaddag/node/create_arc_behaviour.rb
220
+ - spec/shared/unit/gaddag/node/create_final_path_behaviour.rb
221
+ - spec/shared/unit/gaddag/node/create_path_behaviour.rb
222
+ - spec/shared/unit/gaddag/node/create_path_context.rb
223
+ - spec/unit/gaddag/add_spec.rb
224
+ - spec/unit/gaddag/arc/add_final_letter_spec.rb
225
+ - spec/unit/gaddag/arc/final_paths_spec.rb
226
+ - spec/unit/gaddag/arc/initialize_spec.rb
227
+ - spec/unit/gaddag/find_spec.rb
228
+ - spec/unit/gaddag/initialize_spec.rb
229
+ - spec/unit/gaddag/node/arc_spec.rb
230
+ - spec/unit/gaddag/node/create_arc_spec.rb
231
+ - spec/unit/gaddag/node/create_final_arc_spec.rb
232
+ - spec/unit/gaddag/node/create_final_path_spec.rb
233
+ - spec/unit/gaddag/node/create_path_spec.rb
234
+ - spec/unit/gaddag/node/final_path_spec.rb
235
+ - spec/unit/gaddag/node/final_paths_spec.rb
236
+ - spec/unit/gaddag/node/follow_arc_spec.rb
237
+ - spec/unit/gaddag/node/follow_path_spec.rb
238
+ - spec/unit/gaddag/node/path_spec.rb
239
+ - spec/unit/gaddag/path/equal_value_spec.rb
240
+ - spec/unit/gaddag/path/include_delimiter_spec.rb
241
+ - spec/unit/gaddag/path/initialize_spec.rb
242
+ - spec/unit/gaddag/path/reversed_prefix_letters_spec.rb
243
+ - spec/unit/gaddag/path/start_with_spec.rb
244
+ - spec/unit/gaddag/path/suffix_letters_spec.rb
245
+ - spec/unit/gaddag/path/to_ary_spec.rb
246
+ - spec/unit/gaddag/path/to_s_spec.rb
247
+ - spec/unit/gaddag/path/to_word_spec.rb
248
+ - spec/unit/gaddag/word/equal_value_spec.rb
249
+ - spec/unit/gaddag/word/initialize_spec.rb
250
+ - spec/unit/gaddag/word/to_delimited_paths_spec.rb
251
+ - spec/unit/gaddag/word/to_s_spec.rb
252
+ has_rdoc: