rambling-trie 0.3.3 → 0.3.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/README.markdown CHANGED
@@ -61,7 +61,7 @@ trie.has_branch_for? 'partial_word'
61
61
  ### Compression
62
62
 
63
63
  By default, the Rambling Trie works as a Standard Trie.
64
- You can obtain a Compressed Trie from the Standard one, by using the compression feature.
64
+ Starting from version 0.1.0, you can obtain a Compressed Trie from the Standard one, by using the compression feature.
65
65
  Just call the `compress!` method on the `Rambling::Trie` instance:
66
66
 
67
67
  ``` ruby
@@ -69,10 +69,11 @@ trie.compress!
69
69
  ```
70
70
 
71
71
  This will reduce the amount of Trie nodes by eliminating the redundant ones, which are the only-child non-terminal nodes.
72
- This will also make the Trie faster to traverse.
72
+
73
+ Starting from version 0.3.2, the `has_branch_for?` and `is_word?` methods work as expected on a compressed trie.
73
74
 
74
75
  __Note that the `compress!` method acts over the `Rambling::Trie` instance it belongs to.__
75
- __Also, words added after compression will create new nodes and re-compression is not supported.__
76
+ __Also, adding words after compression is not supported.__
76
77
 
77
78
  You can find out if a `Rambling::Trie` instance is compressed by calling the `compressed?` method:
78
79
 
@@ -82,7 +83,7 @@ trie.compressed?
82
83
 
83
84
  ## Further Documentation
84
85
 
85
- You can find further API documentation on the autogenerated [RubyDoc.info](http://rubydoc.info/gems/rambling-trie/0.3.3/Rambling)
86
+ You can find further API documentation on the autogenerated [RubyDoc.info](http://rubydoc.info/gems/rambling-trie)
86
87
 
87
88
  ## Compatible Ruby and Rails versions
88
89
 
data/lib/rambling-trie.rb CHANGED
@@ -1,8 +1,12 @@
1
- require File.join(File.dirname(__FILE__), 'rambling.rb')
2
- require File.join(File.dirname(__FILE__), 'invalid_trie_operation.rb')
3
- require File.join(File.dirname(__FILE__), 'children_hash_deferer.rb')
4
- require File.join(File.dirname(__FILE__), 'trie_compressor.rb')
5
- require File.join(File.dirname(__FILE__), 'trie_branches.rb')
6
- require File.join(File.dirname(__FILE__), 'trie_node.rb')
7
- require File.join(File.dirname(__FILE__), 'trie.rb')
8
- require File.join(File.dirname(__FILE__), 'rambling-trie', 'version.rb')
1
+ [
2
+ 'rambling',
3
+ 'invalid_trie_operation',
4
+ 'children_hash_deferer',
5
+ 'trie_compressor',
6
+ 'trie_branches',
7
+ 'trie_node',
8
+ 'trie',
9
+ 'rambling-trie/version'
10
+ ].each do |file|
11
+ require File.join File.dirname(__FILE__), file
12
+ end
@@ -1,16 +1,16 @@
1
1
  namespace :gem do
2
+ desc 'Build the rambling-trie gem'
2
3
  task :build do
3
- desc 'Build the rambling-trie gem'
4
4
  system 'gem build rambling-trie.gemspec'
5
5
  end
6
6
 
7
+ desc 'Push the latest version of the rambling-trie gem'
7
8
  task release: :build do
8
- desc 'Push the latest version of the rambling-trie gem'
9
9
  system "gem push rambling-trie-#{Rambling::Trie::VERSION}.gem"
10
10
  end
11
11
 
12
+ desc 'Output the current rambling-trie version'
12
13
  task :version do
13
- desc 'Output the current rambling-trie version'
14
14
  puts "rambling-trie #{Rambling::Trie::VERSION}"
15
15
  end
16
16
  end
@@ -36,12 +36,14 @@ namespace :performance do
36
36
  File.join(File.dirname(__FILE__), '..', '..', '..', *filename)
37
37
  end
38
38
 
39
+ desc 'Generate performance report'
39
40
  task :report do
40
41
  puts 'Generating performance report...'
41
42
  generate_report
42
43
  end
43
44
 
44
45
  namespace :report do
46
+ desc 'Generate performance report and append result to reports/performance'
45
47
  task :save do
46
48
  puts 'Generating performance report...'
47
49
  generate_report(get_path('reports', 'performance'))
@@ -49,13 +51,14 @@ namespace :performance do
49
51
  end
50
52
  end
51
53
 
54
+ desc 'Generate application profiling reports'
52
55
  task :profile do
53
56
  puts 'Generating profiling reports...'
54
57
 
55
58
  rambling_trie = Rambling::Trie.new(get_path('assets', 'dictionaries', 'words_with_friends.txt'))
56
59
  words = ['hi', 'help', 'beautiful', 'impressionism', 'anthropological']
57
- methods = [:has_branch_for?]#, :is_word?]
58
- tries = [lambda {rambling_trie.compress!}]#lambda {rambling_trie}, lambda {rambling_trie.compress!}]
60
+ methods = [:has_branch_for?, :is_word?]
61
+ tries = [lambda {rambling_trie.clone}, lambda {rambling_trie.clone.compress!}]
59
62
 
60
63
  methods.each do |method|
61
64
  tries.each do |trie_generator|
@@ -75,5 +78,6 @@ namespace :performance do
75
78
  puts 'Done'
76
79
  end
77
80
 
81
+ desc 'Generate profiling and performance reports'
78
82
  task all: [:profile, :report]
79
83
  end
@@ -1,8 +1,6 @@
1
1
  module Rambling
2
- class Trie
3
- unless defined?(Rambling::Trie::VERSION)
4
- # Current version of the rambling-trie.
5
- VERSION = '0.3.3'
6
- end
2
+ unless defined?(Rambling::Trie::VERSION)
3
+ # Current version of the rambling-trie.
4
+ Rambling::Trie.const_set(:VERSION, '0.3.4')
7
5
  end
8
6
  end
data/lib/trie_branches.rb CHANGED
@@ -49,9 +49,11 @@ module Rambling
49
49
  return @children[sym_key].has_compressed_branch_for?(chars) if key.length == first_letter.length
50
50
 
51
51
  while not chars.empty?
52
- first_letter += chars.slice!(0)
52
+ char = chars.slice!(0)
53
53
 
54
- break unless key.start_with?(first_letter)
54
+ break unless key[first_letter.length] == char
55
+
56
+ first_letter += char
55
57
  return true if chars.empty?
56
58
  return @children[sym_key].has_compressed_branch_for?(chars) if key.length == first_letter.length
57
59
  end
data/lib/trie_node.rb CHANGED
@@ -56,9 +56,5 @@ module Rambling
56
56
  def parent=(parent)
57
57
  @parent = parent
58
58
  end
59
-
60
- def terminal=(terminal)
61
- @is_terminal = terminal
62
- end
63
59
  end
64
60
  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: 0.3.3
4
+ version: 0.3.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-02-13 00:00:00.000000000 Z
12
+ date: 2012-04-27 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec
16
- requirement: &17006080 !ruby/object:Gem::Requirement
16
+ requirement: &18848840 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: 2.0.0
22
22
  type: :development
23
23
  prerelease: false
24
- version_requirements: *17006080
24
+ version_requirements: *18848840
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: rake
27
- requirement: &17018000 !ruby/object:Gem::Requirement
27
+ requirement: &18866100 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: 0.9.2
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *17018000
35
+ version_requirements: *18866100
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: ruby-prof
38
- requirement: &17031020 !ruby/object:Gem::Requirement
38
+ requirement: &18865120 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: 0.10.8
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *17031020
46
+ version_requirements: *18865120
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: yard
49
- requirement: &16618180 !ruby/object:Gem::Requirement
49
+ requirement: &18864100 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: 0.7.5
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *16618180
57
+ version_requirements: *18864100
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: redcarpet
60
- requirement: &16616900 !ruby/object:Gem::Requirement
60
+ requirement: &18862620 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ! '>='
@@ -65,7 +65,7 @@ dependencies:
65
65
  version: 2.1.0
66
66
  type: :development
67
67
  prerelease: false
68
- version_requirements: *16616900
68
+ version_requirements: *18862620
69
69
  description: The Rambling Trie is a custom implementation of the Trie data structure
70
70
  with Ruby, which includes compression abilities and is designed to be very fast
71
71
  to traverse.
@@ -74,17 +74,28 @@ executables: []
74
74
  extensions: []
75
75
  extra_rdoc_files: []
76
76
  files:
77
- - ./lib/children_hash_deferer.rb
78
- - ./lib/invalid_trie_operation.rb
79
- - ./lib/rambling-trie/tasks/gem.rb
80
- - ./lib/rambling-trie/tasks/performance.rb
81
- - ./lib/rambling-trie/version.rb
82
- - ./lib/rambling-trie.rb
83
- - ./lib/rambling.rb
84
- - ./lib/trie.rb
85
- - ./lib/trie_branches.rb
86
- - ./lib/trie_compressor.rb
87
- - ./lib/trie_node.rb
77
+ - !binary |-
78
+ Li9saWIvY2hpbGRyZW5faGFzaF9kZWZlcmVyLnJi
79
+ - !binary |-
80
+ Li9saWIvaW52YWxpZF90cmllX29wZXJhdGlvbi5yYg==
81
+ - !binary |-
82
+ Li9saWIvcmFtYmxpbmctdHJpZS90YXNrcy9nZW0ucmI=
83
+ - !binary |-
84
+ Li9saWIvcmFtYmxpbmctdHJpZS90YXNrcy9wZXJmb3JtYW5jZS5yYg==
85
+ - !binary |-
86
+ Li9saWIvcmFtYmxpbmctdHJpZS92ZXJzaW9uLnJi
87
+ - !binary |-
88
+ Li9saWIvcmFtYmxpbmctdHJpZS5yYg==
89
+ - !binary |-
90
+ Li9saWIvcmFtYmxpbmcucmI=
91
+ - !binary |-
92
+ Li9saWIvdHJpZS5yYg==
93
+ - !binary |-
94
+ Li9saWIvdHJpZV9icmFuY2hlcy5yYg==
95
+ - !binary |-
96
+ Li9saWIvdHJpZV9jb21wcmVzc29yLnJi
97
+ - !binary |-
98
+ Li9saWIvdHJpZV9ub2RlLnJi
88
99
  - LICENSE
89
100
  - README.markdown
90
101
  homepage: http://github.com/ramblinglabs/rambling-trie
@@ -107,7 +118,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
107
118
  version: '0'
108
119
  requirements: []
109
120
  rubyforge_project:
110
- rubygems_version: 1.8.15
121
+ rubygems_version: 1.8.17
111
122
  signing_key:
112
123
  specification_version: 3
113
124
  summary: A custom implementation of the trie data structure.