Permalink
Browse files

+ more helpful tokenizer error message

  • Loading branch information...
1 parent 32db768 commit 5fe7671a573db15bb0d62de9b60236112f7290e8 @floere committed Sep 23, 2012
Showing with 36 additions and 4 deletions.
  1. +6 −0 CHANGELOG.md
  2. +15 −1 server/lib/picky/tokenizer.rb
  3. +14 −2 server/spec/lib/tokenizer_spec.rb
  4. +1 −1 version.rb
View
@@ -1,5 +1,11 @@
## Upcoming Version
+## 4.6.5 "Help is on the way"
+
+###### [Server](https://github.com/floere/picky/tree/master/server)
+
+- More helpful tokenizer error message.
+
## 4.6.4 "Swish swish clang clang"
###### [Server](https://github.com/floere/picky/tree/master/server)
@@ -184,7 +184,21 @@ def initialize options = {}
send method_name, value unless value.nil?
end
rescue NoMethodError => e
- raise %Q{The option "#{e.name}" is not a valid option for a Picky tokenizer.\nPlease see https://github.com/floere/picky/wiki/Indexing-configuration for valid options.}
+ # TODO Print out valid options.
+ #
+ raise <<-ERROR
+The option "#{e.name}" is not a valid option for a Picky tokenizer.
+Please see https://github.com/floere/picky/wiki/Indexing-configuration for valid options.
+A short overview:
+ removes_characters /regexp/
+ stopwords /regexp/
+ splits_text_on /regexp/ or "String", default /\s/
+ normalizes_words [[/replace (this)/, 'with this \\1'], ...]
+ rejects_token_if Proc/lambda, default :blank?.to_proc
+ substitutes_characters_with Picky::CharacterSubstituter or responds to #substitute(String)
+ case_sensitive true/false
+
+ERROR
end
def default_options
{
@@ -8,7 +8,19 @@
it 'informs the user nicely' do
expect {
described_class.new rejetcs_token_if: :blank?.to_proc
- }.to raise_error(%Q{The option "rejetcs_token_if" is not a valid option for a Picky tokenizer.\nPlease see https://github.com/floere/picky/wiki/Indexing-configuration for valid options.})
+ }.to raise_error(<<-MESSAGE)
+The option "rejetcs_token_if" is not a valid option for a Picky tokenizer.
+Please see https://github.com/floere/picky/wiki/Indexing-configuration for valid options.
+A short overview:
+ removes_characters /regexp/
+ stopwords /regexp/
+ splits_text_on /regexp/ or "String", default /\s/
+ normalizes_words [[/replace (this)/, 'with this \\1'], ...]
+ rejects_token_if Proc/lambda, default :blank?.to_proc
+ substitutes_characters_with Picky::CharacterSubstituter or responds to #substitute(String)
+ case_sensitive true/false
+
+MESSAGE
end
end
@@ -27,7 +39,7 @@
Stopwords: -
Splits text on: /\\s/
Normalizes words: -
-Rejects tokens? Yes, see line 16 in app/application.rb
+Rejects tokens? Yes, see line 28 in app/application.rb
Substitutes chars? -
Case sensitive? Yes.
EXPECTED
View
@@ -1,3 +1,3 @@
module Picky
- VERSION = '4.6.4'
+ VERSION = '4.6.5'
end

0 comments on commit 5fe7671

Please sign in to comment.