did_you_mean 0.9.10-java → 0.10.0-java

Sign up to get free protection for your applications and to get access to all the features.
Files changed (58) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +4 -0
  3. data/.travis.yml +13 -19
  4. data/CHANGELOG.md +229 -0
  5. data/Gemfile +4 -7
  6. data/README.md +5 -16
  7. data/Rakefile +35 -33
  8. data/benchmark/jaro_winkler/memory_usage.rb +12 -0
  9. data/benchmark/jaro_winkler/speed.rb +14 -0
  10. data/benchmark/levenshtein/memory_usage.rb +12 -0
  11. data/benchmark/levenshtein/speed.rb +17 -0
  12. data/benchmark/memory_usage.rb +31 -0
  13. data/did_you_mean.gemspec +9 -2
  14. data/evaluation/calculator.rb +122 -0
  15. data/evaluation/dictionary_generator.rb +36 -0
  16. data/evaluation/incorrect_words.yaml +1159 -0
  17. data/ext/did_you_mean/extconf.rb +1 -1
  18. data/ext/did_you_mean/{method_missing.c → method_receiver.c} +1 -1
  19. data/lib/did_you_mean.rb +22 -3
  20. data/lib/did_you_mean/core_ext/name_error.rb +30 -22
  21. data/lib/did_you_mean/core_ext/no_method_error.rb +13 -2
  22. data/lib/did_you_mean/core_ext/rubinius.rb +16 -0
  23. data/lib/did_you_mean/finders.rb +48 -17
  24. data/lib/did_you_mean/finders/method_finder.rb +62 -0
  25. data/lib/did_you_mean/finders/name_error_finders.rb +8 -11
  26. data/lib/did_you_mean/finders/name_error_finders/class_finder.rb +77 -0
  27. data/lib/did_you_mean/finders/name_error_finders/name_finder.rb +18 -0
  28. data/lib/did_you_mean/formatter.rb +20 -0
  29. data/lib/did_you_mean/jaro_winkler.rb +87 -0
  30. data/lib/did_you_mean/test_helper.rb +1 -1
  31. data/lib/did_you_mean/version.rb +1 -1
  32. data/test/core_ext/name_error_extension_test.rb +74 -0
  33. data/test/{no_method_error_extension_test.rb → core_ext/no_method_error_extension_test.rb} +1 -1
  34. data/test/correctable/class_name_test.rb +65 -0
  35. data/test/correctable/method_name_test.rb +84 -0
  36. data/test/{null_finder_test.rb → correctable/uncorrectable_name_test.rb} +3 -7
  37. data/test/correctable/variable_name_test.rb +79 -0
  38. data/test/edit_distance/jaro_winkler_test.rb +30 -0
  39. data/test/test_helper.rb +2 -20
  40. data/test/word_collection_test.rb +76 -12
  41. metadata +58 -56
  42. data/Appraisals +0 -23
  43. data/gemfiles/activerecord_32.gemfile +0 -21
  44. data/gemfiles/activerecord_40.gemfile +0 -21
  45. data/gemfiles/activerecord_41.gemfile +0 -21
  46. data/gemfiles/activerecord_42.gemfile +0 -21
  47. data/gemfiles/activerecord_edge.gemfile +0 -25
  48. data/lib/did_you_mean/finders/name_error_finders/similar_class_finder.rb +0 -50
  49. data/lib/did_you_mean/finders/name_error_finders/similar_name_finder.rb +0 -61
  50. data/lib/did_you_mean/finders/similar_attribute_finder.rb +0 -26
  51. data/lib/did_you_mean/finders/similar_method_finder.rb +0 -34
  52. data/lib/did_you_mean/word_collection.rb +0 -30
  53. data/test/all_test.rb +0 -18
  54. data/test/name_error_extension_test.rb +0 -73
  55. data/test/similar_attribute_finder_test.rb +0 -17
  56. data/test/similar_class_finder_test.rb +0 -85
  57. data/test/similar_method_finder_test.rb +0 -60
  58. data/test/similar_name_finder_test.rb +0 -62
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b651d4bc1e770fc156d06ed110e6d562c19df3a4
4
- data.tar.gz: cff148bb8f3c3c81165072be6b903e2f94183283
3
+ metadata.gz: d906ea272934313116cb6d8e2998b319a853e5e9
4
+ data.tar.gz: 3a5b104adea621420f2984e310ca7cde002dce05
5
5
  SHA512:
6
- metadata.gz: b24627fdab616c582a527929127d3d58219d9f68b4f0a9c44b58492a5f62f9a829573470f1a9adca02d7d85a5cd36026cf620e207e541598d2936eab6a4233db
7
- data.tar.gz: dc63d5a7e148597d3f5f65ac741d0fc31db1497de80ecf06595c0f92c2d10d1cc424a907cb28868c438038fab342f6245856b8a6a178880fe9636d0fc6376b9d
6
+ metadata.gz: d5f543c037613afc29083d55883c792cb3c78989fa1f4a3532455c39f6c7bc21d262bc1ffeb0a329d68910b479598d8adc38c2c6054955f7c1e2c84ba837b5fb
7
+ data.tar.gz: 224dcc94dbc8cea6c5e65d74f1296cae5d588ce3d5f025919eb285c66ff040cc0126568df1a15675fd02f15da0a00ed466c1c319005c0bbee093cb050ed8b450
data/.gitignore CHANGED
@@ -17,6 +17,10 @@ spec/reports
17
17
  test/tmp
18
18
  test/version_tmp
19
19
  tmp
20
+ log
21
+
22
+ evaluation/dictionary.yml
23
+ benchmark/results
20
24
 
21
25
  ext/**/*.o
22
26
  ext/**/*.so
data/.travis.yml CHANGED
@@ -3,33 +3,27 @@ script: bundle exec rake test
3
3
  cache: bundler
4
4
  sudo: false
5
5
 
6
+ before_install:
7
+ - 'if [[ "$TRAVIS_RUBY_VERSION" =~ "jruby" ]]; then rvm get head && rvm use --install $TRAVIS_RUBY_VERSION; fi'
8
+
9
+ after_success:
10
+ - bundle exec rake test:accuracy
11
+ - bundle exec rake benchmark:memory
12
+
6
13
  rvm:
7
14
  - 1.9.3
8
15
  - 2.0.0
9
- - 2.1.5
10
- - 2.2.0
16
+ - 2.1
17
+ - 2.2
11
18
  - ruby-head
12
- - jruby-1.7.17
19
+ - jruby-1.7.21
20
+ - jruby-9.0.0.0
13
21
  - jruby-head
14
22
  - rbx-2.4.1
15
-
16
- gemfile:
17
- - gemfiles/activerecord_32.gemfile
18
- - gemfiles/activerecord_40.gemfile
19
- - gemfiles/activerecord_41.gemfile
20
- - gemfiles/activerecord_42.gemfile
21
- - gemfiles/activerecord_edge.gemfile
23
+ - rbx-2.5.8
22
24
 
23
25
  matrix:
24
- exclude:
25
- - rvm: 1.9.3
26
- gemfile: gemfiles/activerecord_edge.gemfile
27
- - rvm: 2.0.0
28
- gemfile: gemfiles/activerecord_edge.gemfile
29
- - rvm: 2.1.5
30
- gemfile: gemfiles/activerecord_edge.gemfile
31
26
  allow_failures:
27
+ - rvm: ruby-head
32
28
  - rvm: jruby-head
33
- - rvm: rbx-2.4.1
34
- - gemfile: gemfiles/activerecord_edge.gemfile
35
29
  fast_finish: true
data/CHANGELOG.md ADDED
@@ -0,0 +1,229 @@
1
+ ## [v0.9.10](https://github.com/yuki24/did_you_mean/tree/v0.9.10)
2
+
3
+ _<sup>released on 2015-05-14 03:04:47 UTC</sup>_
4
+
5
+ #### Bug Fixes
6
+
7
+ - Fixed a bug where a duplicate "did you mean?" message was appended each time `#to_s` is called ( [@danfinnie](https://github.com/danfinnie), [#51](https://github.com/yuki24/did_you_mean/issues/51 "Duplicate output for constants in separate gem"))
8
+
9
+ ## [v0.9.9](https://github.com/yuki24/did_you_mean/tree/v0.9.9)
10
+
11
+ _<sup>released on 2015-05-13 03:48:19 UTC</sup>_
12
+
13
+ #### Small/Internal Changes
14
+
15
+ - Order word suggestions based on Levenshtein distance ( [@tleish](https://github.com/tleish), [#31](https://github.com/yuki24/did_you_mean/pull/31 "Order word suggestions based on Levenshtein.distance."))
16
+ - Reduce memory allocation by about 40%
17
+ - Speed up Levenshtein distance calculation by about 40%
18
+ - The Java extension has been replaced with a pure JRuby implementation
19
+
20
+ ## [v0.9.8](https://github.com/yuki24/did_you_mean/tree/v0.9.8)
21
+
22
+ _<sup>released on 2015-04-12 01:55:27 UTC</sup>_
23
+
24
+ #### Internal Changes
25
+
26
+ - Speed up Levenshtein by 50% and reduce 97% of memory usage
27
+
28
+ ## [v0.9.7](https://github.com/yuki24/did_you_mean/tree/v0.9.7)
29
+
30
+ _<sup>released on 2015-04-02 04:20:26 UTC</sup>_
31
+
32
+ #### Bug Fixes
33
+
34
+ - Fixed an issue where _did\_you\_mean_ doesn't install on JRuby properly.
35
+
36
+ ## [v0.9.6](https://github.com/yuki24/did_you_mean/tree/v0.9.6)
37
+
38
+ _<sup>released on 2015-01-24 23:19:27 UTC</sup>_
39
+
40
+ #### Bug Fixes
41
+
42
+ - Fixed a bug where did\_you\_mean incorrectly suggests protected methods when it just isn't callable ( [@glittershark](https://github.com/glittershark), [#34](https://github.com/yuki24/did_you_mean/issues/34 "Did\_you\_mean incorrectly called when attempting to call protected/private method"))
43
+
44
+ ## [v0.9.5](https://github.com/yuki24/did_you_mean/tree/v0.9.5)
45
+
46
+ _<sup>released on 2015-01-07 12:41:23 UTC</sup>_
47
+
48
+ #### Bug Fixes
49
+
50
+ - Whitelist `#safe_constantize` method from `ActiveSupport::Inflector` to avoid significant performance slowdown ( [@tleish](https://github.com/tleish), [#19](https://github.com/yuki24/did_you_mean/issues/19 "Significant Slowdown when Using Debugger"), [#20](https://github.com/yuki24/did_you_mean/pull/20 "Whitelisting safe\_constantize (ActiveSupport::Inflector) method"))
51
+
52
+ ## [v0.9.4](https://github.com/yuki24/did_you_mean/tree/v0.9.4)
53
+
54
+ _<sup>released on 2014-11-19 20:00:00 UTC</sup>_
55
+
56
+ #### Bug Fixes
57
+
58
+ - Fixed a bug where no suggestions will be made on JRuby
59
+
60
+ ## [v0.9.3](https://github.com/yuki24/did_you_mean/tree/v0.9.3)
61
+
62
+ _<sup>released on 2014-11-18 03:50:11 UTC</sup>_
63
+
64
+ **This version has been yanked from rubygems.org as it doesn't work with jRuby at all. Please upgrade to 0.9.4 or higher as soon as possible.**
65
+
66
+ #### Internal Changes
67
+
68
+ - Replaced the crazy C extension with a so much better one (thanks to [@nobu](https://github.com/nobu)!)
69
+
70
+ ## [v0.9.2](https://github.com/yuki24/did_you_mean/tree/v0.9.2)
71
+
72
+ _<sup>released on 2014-11-17 15:32:33 UTC</sup>_
73
+
74
+ #### Bug Fixes
75
+
76
+ - Fixed a bug where did\_you\_mean doesn't compile on Ruby 2.1.2/2.1.5 ( [#16](https://github.com/yuki24/did_you_mean/issues/16 "Gem building failed on Debian 6.0.10 x86\_64"))
77
+
78
+ ## [v0.9.1](https://github.com/yuki24/did_you_mean/tree/v0.9.1)
79
+
80
+ _<sup>released on 2014-11-16 18:54:24 UTC</sup>_
81
+
82
+ **This version has been yanked from rubygems.org as it doesn't compile on Ruby 2.1.2 and 2.1.5. Please upgrade to 0.9.4 or higher as soon as possible.**
83
+
84
+ #### Internal Changes
85
+
86
+ - Shrink the gem size by removing unneeded ruby header files.
87
+ - Now it forces everyone to upgrade the gem when they upgrade Ruby to a new version. This avoids introducing a bug like [#14](https://github.com/yuki24/did_you_mean/issues/14 "Compatibility with `letter\_opener` gem").
88
+
89
+ ## [v0.9.0](https://github.com/yuki24/did_you_mean/tree/v0.9.0)
90
+
91
+ _<sup>released on 2014-11-09 01:26:31 UTC</sup>_
92
+
93
+ #### New Features
94
+
95
+ - did\_you\_mean now suggests instance variable names if `@` is missing ( [#12](https://github.com/yuki24/did_you_mean/issues/12 "Suggest instance- and class-vars"), [<tt>39d1e2b</tt>](https://github.com/yuki24/did_you_mean/commit/39d1e2bd66d6ff8acbc4dd5da922fc7e5fcefb20))
96
+
97
+ ```ruby
98
+ @full_name = "Yuki Nishijima"
99
+ first_name, last_name = full_name.split(" ")
100
+ # => NameError: undefined local variable or method `full_name' for main:Object
101
+ #
102
+ # Did you mean? @full_name
103
+ #
104
+ ```
105
+
106
+ #### Bug Fixes
107
+
108
+ - Fixed a bug where did\_you\_mean changes some behaviours of Ruby 2.1.3/2.1.4 installed on Max OS X ( [#14](https://github.com/yuki24/did_you_mean/issues/14 "Compatibility with `letter\_opener` gem"), [<tt>44c451f</tt>](https://github.com/yuki24/did_you_mean/commit/44c451f8c38b11763ba28ddf1ceb9696707ccea0), [<tt>9ebde21</tt>](https://github.com/yuki24/did_you_mean/commit/9ebde211e92eac8494e704f627c62fea7fdbee16))
109
+ - Fixed a bug where sometimes `NoMethodError` suggests duplicate method names ( [<tt>9865cc5</tt>](https://github.com/yuki24/did_you_mean/commit/9865cc5a9ce926dd9ad4c20d575b710e5f257a4b))
110
+
111
+ ## [v0.8.0](https://github.com/yuki24/did_you_mean/tree/v0.8.0)
112
+
113
+ _<sup>released on 2014-10-27 02:03:13 UTC</sup>_
114
+
115
+ **This version has been yanked from rubygems.org as it has a serious bug with Ruby 2.1.3 and 2.1.4 installed on Max OS X. Please upgrade to 0.9.4 or higher as soon as possible.**
116
+
117
+ #### New Features
118
+
119
+ - JRuby support!
120
+
121
+ #### Bug Fixes
122
+
123
+ - Fixed a bug where did\_you\_mean unexpectedly disables [better\_errors](https://github.com/charliesome/better_errors)'s REPL
124
+ - Replaced [binding\_of\_caller](https://github.com/banister/binding_of_caller) dependency with [interception](https://github.com/ConradIrwin/interception)
125
+ - Fixed the wrong implementation of Levenshtein algorithm ( [#2](https://github.com/yuki24/did_you_mean/pull/2 "Fix bug of DidYouMean::Levenshtein#min3."), [@fortissimo1997](https://github.com/fortissimo1997))
126
+
127
+ ## [v0.7.0](https://github.com/yuki24/did_you_mean/tree/v0.7.0)
128
+
129
+ _<sup>released on 2014-09-26 03:37:18 UTC</sup>_
130
+
131
+ **This version has been yanked from rubygems.org as it has a serious bug with Ruby 2.1.3 and 2.1.4 installed on Max OS X. Please upgrade to 0.9.4 or higher as soon as possible.**
132
+
133
+ #### New Features
134
+
135
+ - Added support for Ruby 2.1.3, 2.2.0-preview1 and ruby-head
136
+ - Added support for ActiveRecord 4.2.0.beta1
137
+ - Word searching is now about 40% faster than v0.6.0
138
+ - Removed `text` gem dependency
139
+ - Better output on pry and Rspec
140
+
141
+ #### Small/Internal Changes
142
+
143
+ - A lot of internal refactoring
144
+
145
+ ## [v0.6.0](https://github.com/yuki24/did_you_mean/tree/v0.6.0)
146
+
147
+ _<sup>released on 2014-05-18 00:23:24 UTC</sup>_
148
+
149
+ **This version has been yanked from rubygems.org as it has a serious bug with Ruby 2.1.3 and 2.1.4 installed on Max OS X. Please upgrade to 0.9.0 as soon as possible.**
150
+
151
+ #### New Features
152
+
153
+ - Added basic support for constants. Now you'll see class name suggestions when you misspelled a class names/module names:
154
+
155
+ ```ruby
156
+ > Ocject
157
+ # => NameError: uninitialized constant Ocject
158
+ #
159
+ # Did you mean? Object
160
+ #
161
+ ```
162
+
163
+ #### Bug Fixes
164
+
165
+ - Fixed a bug where did\_you\_mean segfaults on Ruby head(2.2.0dev)
166
+
167
+ ## [v0.5.0](https://github.com/yuki24/did_you_mean/tree/v0.5.0)
168
+
169
+ _<sup>released on 2014-05-10 17:59:54 UTC</sup>_
170
+
171
+ #### New Features
172
+
173
+ - Added support for Ruby 2.1.2
174
+
175
+ ## [v0.4.0](https://github.com/yuki24/did_you_mean/tree/v0.4.0)
176
+
177
+ _<sup>released on 2014-04-20 02:10:31 UTC</sup>_
178
+
179
+ #### New Features
180
+
181
+ - did\_you\_mean now suggests a similar attribute name when you misspelled it.
182
+
183
+ ```ruby
184
+ User.new(flrst_name: "wrong flrst name")
185
+ # => ActiveRecord::UnknownAttributeError: unknown attribute: flrst_name
186
+ #
187
+ # Did you mean? first_name: string
188
+ #
189
+ ```
190
+
191
+ #### Bug Fixes
192
+
193
+ - Fixed a bug where did\_you\_mean doesn't work with `ActiveRecord::UnknownAttributeError`
194
+
195
+ ## [v0.3.1](https://github.com/yuki24/did_you_mean/tree/v0.3.1)
196
+
197
+ _<sup>released on 2014-03-20 23:16:20 UTC</sup>_
198
+
199
+ #### Small/Internal Changes
200
+
201
+ - Changed output for readability.
202
+ - Better algorithm to find the correct method.
203
+
204
+ ## [v0.3.0](https://github.com/yuki24/did_you_mean/tree/v0.3.0)
205
+
206
+ _<sup>released on 2014-03-20 23:13:13 UTC</sup>_
207
+
208
+ #### New Features
209
+
210
+ - Added support for Ruby 2.1.1 and 2.2.0(head).
211
+
212
+ ## [v0.2.0](https://github.com/yuki24/did_you_mean/tree/v0.2.0)
213
+
214
+ _<sup>released on 2014-03-20 23:12:13 UTC</sup>_
215
+
216
+ #### Incompatible Changes
217
+
218
+ - dropped support for JRuby and Rubbinious.
219
+
220
+ #### New Features
221
+
222
+ - did\_you\_mean no longer makes Ruby slow.
223
+
224
+ ## [v0.1.0: First Release](https://github.com/yuki24/did_you_mean/tree/v0.1.0)
225
+
226
+ _<sup>released on 2014-03-20 23:11:14 UTC</sup>_
227
+
228
+ - Now you will have "did you mean?" experience in Ruby!
229
+ - but still very experimental since this gem makes Ruby a lot slower.
data/Gemfile CHANGED
@@ -3,16 +3,13 @@ source 'https://rubygems.org'
3
3
  # Specify your gem's dependencies in did_you_mean.gemspec
4
4
  gemspec
5
5
 
6
- platforms :ruby do
7
- gem 'sqlite3'
8
- end
9
-
10
- platforms :jruby do
11
- gem 'activerecord-jdbcsqlite3-adapter'
12
- end
6
+ gem 'benchmark-ips'
7
+ gem 'memory_profiler'
8
+ gem 'jaro_winkler', '~> 1.3.6'
13
9
 
14
10
  platforms :rbx do
15
11
  gem 'rubysl', '~> 2.0'
12
+ gem 'rubysl-openssl', '2.2.1'
16
13
  gem 'racc'
17
14
  gem 'rubinius-developer_tools'
18
15
  end
data/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  'Did you mean?' experience in Ruby. No, Really.
4
4
 
5
- **For those who are still using 0.6.0, 0.7.0 and 0.8.0, please upgrade to 0.9.0 as they have a serious bug with Ruby 2.1.3 and 2.1.4 installed on Max OS X.**
5
+ **For those who are still using 0.6.0, 0.7.0 and 0.8.0, please upgrade to the latest version (0.9.6) as they have a serious bug with Ruby 2.1.3 and 2.1.4 installed on Mac OS X.**
6
6
 
7
7
  ## Installation
8
8
 
@@ -72,16 +72,6 @@ params.with_inddiferent_access
72
72
  #
73
73
  ```
74
74
 
75
- ### ActiveRecord::UnknownAttributeError
76
-
77
- ```ruby
78
- User.new(nmee: "wrong flrst name")
79
- # => ActiveRecord::UnknownAttributeError: unknown attribute: nmee
80
- #
81
- # Did you mean? name: string
82
- #
83
- ```
84
-
85
75
  ## 'Did You Mean' Experience is Everywhere
86
76
 
87
77
  _did\_you\_mean_ gem automagically puts method suggestions into the error message. This means you'll have the "Did you mean?" experience almost everywhere:
@@ -92,10 +82,9 @@ _did\_you\_mean_ gem automagically puts method suggestions into the error messag
92
82
 
93
83
  _did\_you\_mean_ gem supports the following implementations:
94
84
 
95
- * MRI 1.9.3, 2.0.0, 2.1.x, 2.2.0-preview1 and ruby-head
96
- * JRuby (tested against 1.7.16)
97
-
98
- Any other implementations are **NOT** supported (Rubinius support is work in progress).
85
+ * MRI 1.9.3, 2.0.0, 2.1.x, 2.2.x and ruby-head
86
+ * JRuby 1.7.21, 9.0.0.0 and jruby-head
87
+ * Rubinius 2.4.1 and 2.5.8
99
88
 
100
89
  ## Contributing
101
90
 
@@ -107,4 +96,4 @@ Any other implementations are **NOT** supported (Rubinius support is work in pro
107
96
 
108
97
  ## License
109
98
 
110
- Copyright (c) 2014 Yuki Nishijima. See MIT-LICENSE for further details.
99
+ Copyright (c) 2015 Yuki Nishijima. See MIT-LICENSE for further details.
data/Rakefile CHANGED
@@ -1,48 +1,50 @@
1
1
  require 'bundler/gem_tasks'
2
2
 
3
- def mri?
4
- defined?(RUBY_ENGINE) && RUBY_ENGINE == "ruby"
5
- end
6
-
7
- desc "run tests"
8
- task default: [:test]
9
-
10
- if mri?
3
+ if RUBY_ENGINE == "ruby"
11
4
  require 'rake/extensiontask'
12
5
 
13
- Rake::ExtensionTask.new('did_you_mean') do |ext|
14
- ext.name = "method_missing"
6
+ Rake::ExtensionTask.new 'did_you_mean' do |ext|
7
+ ext.name = "method_receiver"
15
8
  ext.lib_dir = "lib/did_you_mean"
16
9
  end
10
+ end
17
11
 
18
- desc "Run tests"
19
- task :test do
20
- Rake::Task['compile'].reenable
21
- Rake::Task['compile'].invoke
12
+ require 'rake/testtask'
22
13
 
23
- begin
24
- $stdout.puts("\033[33m")
25
- sh "bundle exec ruby test/all_test.rb"
26
- ensure
27
- $stdout.puts("\033[0m")
28
- end
14
+ Rake::TestTask.new do |task|
15
+ task.libs << "test"
16
+ task.pattern = 'test/**/*_test.rb'
17
+ task.verbose = true
18
+ # task.warning = true
19
+ end
29
20
 
30
- Rake::Task['clobber'].execute
21
+ desc "Run tests"
22
+ task test: [:clobber, :compile] if RUBY_ENGINE == 'ruby'
23
+ task default: :test
24
+
25
+ namespace :test do
26
+ namespace :accuracy do
27
+ desc "Download Wiktionary's Simple English data and save it as a dictionary"
28
+ task :prepare do
29
+ sh 'ruby evaluation/dictionary_generator.rb'
30
+ end
31
31
  end
32
32
 
33
- namespace :test do
34
- desc "Run tests without re-compiling extensions"
35
- task :without_compile do
36
- $stdout.puts("\033[33m")
37
- sh "bundle exec ruby test/all_test.rb"
38
- $stdout.puts("\033[0m")
33
+ desc "Calculate accuracy of the gems' spell checker"
34
+ task :accuracy do
35
+ if !File.exist?("evaluation/dictionary.yml")
36
+ puts 'Generating dictionary for evaluation:'
37
+ Rake::Task["test:accuracy:prepare"].execute
38
+ puts "\n"
39
39
  end
40
+
41
+ sh 'bundle exec ruby evaluation/calculator.rb'
40
42
  end
41
- else # for Rubinius
42
- desc "Run tests"
43
- task :test do
44
- $stdout.puts("\033[33m")
45
- sh "bundle exec ruby test/all_test.rb"
46
- $stdout.puts("\033[0m")
43
+ end
44
+
45
+ namespace :benchmark do
46
+ desc "Measure memory usage by the did_you_mean gem"
47
+ task :memory do
48
+ sh 'bundle exec ruby benchmark/memory_usage.rb'
47
49
  end
48
50
  end