picky 3.0.0.pre1 → 3.0.0.pre2

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.
Files changed (36) hide show
  1. data/lib/picky/adapters/rack/search.rb +3 -3
  2. data/lib/picky/adapters/rack.rb +3 -3
  3. data/lib/picky/application.rb +5 -3
  4. data/lib/picky/backend/file/json.rb +7 -0
  5. data/lib/picky/backend/file/text.rb +2 -2
  6. data/lib/picky/character_substituters/west_european.rb +3 -0
  7. data/lib/picky/extensions/symbol.rb +4 -4
  8. data/lib/picky/indexes/index.rb +11 -85
  9. data/lib/picky/indexes/index_indexed.rb +13 -2
  10. data/lib/picky/indexes/index_indexing.rb +38 -11
  11. data/lib/picky/loader.rb +0 -4
  12. data/lib/picky/search.rb +71 -78
  13. data/lib/picky/tokenizers/base.rb +4 -2
  14. data/lib/picky.rb +6 -0
  15. data/spec/lib/application_spec.rb +31 -11
  16. data/spec/lib/backend/files_spec.rb +1 -1
  17. data/spec/lib/categories_indexed_spec.rb +2 -2
  18. data/spec/lib/category_indexed_spec.rb +7 -2
  19. data/spec/lib/category_indexing_spec.rb +1 -1
  20. data/spec/lib/category_spec.rb +1 -1
  21. data/spec/lib/frontend_adapters/rack_spec.rb +4 -4
  22. data/spec/lib/indexed/bundle/memory_spec.rb +2 -2
  23. data/spec/lib/indexed/bundle/redis_spec.rb +1 -1
  24. data/spec/lib/indexed/wrappers/exact_first_spec.rb +2 -2
  25. data/spec/lib/indexes/index_indexed_spec.rb +25 -3
  26. data/spec/lib/indexes/index_indexing_spec.rb +58 -10
  27. data/spec/lib/indexes/index_spec.rb +13 -7
  28. data/spec/lib/indexes/redis_spec.rb +1 -1
  29. data/spec/lib/indexing/bundle/memory_partial_generation_speed_spec.rb +1 -1
  30. data/spec/lib/indexing/bundle/memory_spec.rb +1 -1
  31. data/spec/lib/indexing/bundle/redis_spec.rb +1 -1
  32. data/spec/lib/search_spec.rb +18 -18
  33. data/spec/lib/tokenizers/base_spec.rb +3 -3
  34. metadata +3 -6
  35. data/lib/picky/loggers/search.rb +0 -26
  36. data/spec/lib/loggers/search_spec.rb +0 -19
@@ -8,11 +8,12 @@ describe Picky::Application do
8
8
  it "should run ok" do
9
9
  lambda {
10
10
  class MinimalTestApplication < described_class
11
- books = Picky::Indexes::Memory.new :books,
12
- source: Picky::Sources::DB.new(
13
- 'SELECT id, title FROM books',
14
- :file => 'app/db.yml'
15
- )
11
+ books = Picky::Indexes::Memory.new :books do
12
+ source Picky::Sources::DB.new(
13
+ 'SELECT id, title FROM books',
14
+ :file => 'app/db.yml'
15
+ )
16
+ end
16
17
  books.define_category :title
17
18
 
18
19
  rack_adapter.stub! :exclaim # Stopping it from exclaiming.
@@ -43,11 +44,13 @@ describe Picky::Application do
43
44
  substitutes_characters_with: Picky::CharacterSubstituters::WestEuropean.new,
44
45
  maximum_tokens: 5
45
46
 
46
- books_index = Picky::Indexes::Memory.new :books,
47
- source: Picky::Sources::DB.new(
48
- 'SELECT id, title, author, isbn13 as isbn FROM books',
49
- :file => 'app/db.yml'
50
- )
47
+ books_index = Picky::Indexes::Memory.new :books do
48
+ source Picky::Sources::DB.new(
49
+ 'SELECT id, title, author, isbn13 as isbn FROM books',
50
+ :file => 'app/db.yml'
51
+ )
52
+ end
53
+
51
54
  books_index.define_category :title,
52
55
  similarity: Picky::Similarity::DoubleMetaphone.new(3) # Up to three similar title word indexed.
53
56
  books_index.define_category :author,
@@ -67,9 +70,11 @@ describe Picky::Application do
67
70
  rack_adapter.stub! :exclaim # Stopping it from exclaiming.
68
71
 
69
72
  route %r{^/books} => Picky::Search.new(books_index)
70
- route %r{^/buks} => Picky::Search.new(books_index) do
73
+
74
+ buks_search = Picky::Search.new(books_index) do
71
75
  searching removes_characters: /[buks]/
72
76
  end
77
+ route %r{^/buks} => buks_search
73
78
  end
74
79
  }.should_not raise_error
75
80
  end
@@ -119,6 +124,21 @@ describe Picky::Application do
119
124
  end
120
125
  end
121
126
 
127
+ describe 'route' do
128
+ it 'is delegated' do
129
+ described_class.rack_adapter.should_receive(:route).once.with :some_options
130
+
131
+ described_class.route(:some_options)
132
+ end
133
+ it 'raises on block' do
134
+ expect {
135
+ described_class.route :quack => Hash.new do # Anything with a block.
136
+ # do something
137
+ end
138
+ }.to raise_error("Warning: block passed into #route method, not into Search.new!")
139
+ end
140
+ end
141
+
122
142
  describe 'call' do
123
143
  before(:each) do
124
144
  @routes = stub :routes
@@ -3,7 +3,7 @@ require 'spec_helper'
3
3
  describe Picky::Backend::Files do
4
4
 
5
5
  before(:each) do
6
- index = Picky::Indexes::Memory.new :some_index, source: []
6
+ index = Picky::Indexes::Memory.new :some_index
7
7
  category = Picky::Category.new :some_category, index
8
8
  bundle = Picky::Indexing::Bundle::Base.new :some_bundle, category, nil, nil, nil
9
9
 
@@ -22,7 +22,7 @@ describe Picky::Categories do
22
22
 
23
23
  context "with real categories" do
24
24
  before(:each) do
25
- @index1 = Picky::Indexes::Memory.new :name, source: []
25
+ @index1 = Picky::Indexes::Memory.new :name
26
26
 
27
27
  @categories = described_class.new
28
28
  @categories << Picky::Category.new(:category1, @index1)
@@ -65,7 +65,7 @@ describe Picky::Categories do
65
65
 
66
66
  context 'without options' do
67
67
  before(:each) do
68
- @index1 = Picky::Indexes::Memory.new :some_index, source: []
68
+ @index1 = Picky::Indexes::Memory.new :some_index
69
69
 
70
70
  @category1 = Picky::Category.new :category1, @index1
71
71
  @category2 = Picky::Category.new :category2, @index1
@@ -3,7 +3,9 @@ require 'spec_helper'
3
3
  describe Picky::Category do
4
4
 
5
5
  before(:each) do
6
- @index = Picky::Indexes::Index.new :some_index, source: []
6
+ @index = Picky::Indexes::Index.new :some_index do
7
+ source []
8
+ end
7
9
  @partial_strategy = stub :partial, :use_exact_for_partial? => false
8
10
  @weights_strategy = stub :weights
9
11
  @similarity_strategy = stub :similarity
@@ -40,7 +42,10 @@ describe Picky::Category do
40
42
  end
41
43
  context 'indexed_bundle_class defined differently' do
42
44
  before(:each) do
43
- @category = described_class.new :some_name, Picky::Indexes::Redis.new(:some_index_name, source: [])
45
+ index = Picky::Indexes::Redis.new(:some_index_name) do
46
+ source []
47
+ end
48
+ @category = described_class.new :some_name, index
44
49
  end
45
50
  context 'with a partial strategy that uses the exact index' do
46
51
  before(:each) do
@@ -3,7 +3,7 @@ require 'spec_helper'
3
3
  describe Picky::Category do
4
4
 
5
5
  before(:each) do
6
- @index = Picky::Indexes::Memory.new :some_index, source: []
6
+ @index = Picky::Indexes::Memory.new :some_index
7
7
  @source = stub :some_given_source, :key_format => nil
8
8
  end
9
9
  let(:category) { described_class.new(:some_category, @index, :source => @source).tap { |c| c.stub! :timed_exclaim } }
@@ -2,7 +2,7 @@ require 'spec_helper'
2
2
 
3
3
  describe Picky::Category do
4
4
 
5
- let(:index) { Picky::Indexes::Memory.new :some_index, source: [] }
5
+ let(:index) { Picky::Indexes::Memory.new :some_index }
6
6
  let(:category) { described_class.new :some_category, index }
7
7
 
8
8
  it 'should set defaults correctly' do
@@ -63,7 +63,7 @@ describe Picky::FrontendAdapters::Rack do
63
63
  context 'real routes' do
64
64
  before(:each) do
65
65
  @rack_adapter.reset_routes
66
- PickyLog.stub! :log
66
+ Picky.logger.stub! :log
67
67
  end
68
68
  it 'should route correctly' do
69
69
  env = {}
@@ -107,7 +107,7 @@ describe Picky::FrontendAdapters::Rack do
107
107
  env = rack_defaults_for '/searches/some_route?query=some_query'
108
108
 
109
109
  search = stub :search
110
- search.should_receive(:search_with_text).once.with(anything, 20, 0).and_return(Picky::Results.new)
110
+ search.should_receive(:search).once.with(anything, 20, 0).and_return(Picky::Results.new)
111
111
  Picky::Search.stub! :new => search
112
112
 
113
113
  @rack_adapter.route '/searches/some_route' => Picky::Search.new(:some_index, :some_other_index)
@@ -119,7 +119,7 @@ describe Picky::FrontendAdapters::Rack do
119
119
  env = rack_defaults_for '/searches/some_route?query=some_query&type=some_type'
120
120
 
121
121
  search = stub :search
122
- search.should_receive(:search_with_text).once.with(anything, 20, 0).and_return(Picky::Results.new)
122
+ search.should_receive(:search).once.with(anything, 20, 0).and_return(Picky::Results.new)
123
123
  Picky::Search.stub! :new => search
124
124
 
125
125
  @rack_adapter.route '/searches/some_route' => Picky::Search.new(:some_index, :some_other_index), :query => { :type => :some_type }
@@ -131,7 +131,7 @@ describe Picky::FrontendAdapters::Rack do
131
131
  env = rack_defaults_for '/searches/some_wrong_route?query=some_query'
132
132
 
133
133
  search = stub :search
134
- search.should_receive(:search_with_text).never
134
+ search.should_receive(:search).never
135
135
  Picky::Search.stub! :new => search
136
136
 
137
137
  @rack_adapter.route '/searches/some_route' => Picky::Search.new(:some_index, :some_other_index)
@@ -3,7 +3,7 @@ require 'spec_helper'
3
3
  describe Picky::Indexed::Bundle::Memory do
4
4
 
5
5
  before(:each) do
6
- @index = Picky::Indexes::Memory.new :some_index, source: []
6
+ @index = Picky::Indexes::Memory.new :some_index
7
7
  @category = Picky::Category.new :some_category, @index
8
8
 
9
9
  @similarity = stub :similarity
@@ -153,7 +153,7 @@ describe Picky::Indexed::Bundle::Memory do
153
153
 
154
154
  describe 'initialization' do
155
155
  before(:each) do
156
- @index = Picky::Indexes::Memory.new :some_index, source: []
156
+ @index = Picky::Indexes::Memory.new :some_index
157
157
  @category = Picky::Category.new :some_category, @index
158
158
 
159
159
  @bundle = described_class.new :some_name, @category, :similarity
@@ -7,7 +7,7 @@ describe Picky::Indexed::Bundle::Redis do
7
7
 
8
8
  Picky::Backend::Redis.stub! :new => @backend
9
9
 
10
- @index = Picky::Indexes::Memory.new :some_index, source: []
10
+ @index = Picky::Indexes::Memory.new :some_index
11
11
  @category = Picky::Category.new :some_category, @index
12
12
 
13
13
  @similarity = stub :similarity
@@ -13,7 +13,7 @@ describe Picky::Indexed::Wrappers::ExactFirst do
13
13
  describe "self.wrap" do
14
14
  context "index" do
15
15
  it "wraps each category" do
16
- index = Picky::Indexes::Memory.new :some_index, source: []
16
+ index = Picky::Indexes::Memory.new :some_index
17
17
  index.define_category :some_category
18
18
 
19
19
  Picky::Indexed::Wrappers::ExactFirst.wrap index
@@ -23,7 +23,7 @@ describe Picky::Indexed::Wrappers::ExactFirst do
23
23
  end
24
24
  end
25
25
  it "returns the index" do
26
- index = Picky::Indexes::Memory.new :some_index, source: []
26
+ index = Picky::Indexes::Memory.new :some_index
27
27
  index.define_category :some_category
28
28
 
29
29
  described_class.wrap(index).should == index
@@ -4,7 +4,7 @@ describe Picky::Indexes::Index do
4
4
 
5
5
  context 'without stubbed categories' do
6
6
  before(:each) do
7
- @index = described_class.new :some_index_name, source: []
7
+ @index = described_class.new :some_index_name
8
8
  end
9
9
 
10
10
  describe 'define_category' do
@@ -23,7 +23,7 @@ describe Picky::Indexes::Index do
23
23
  before(:each) do
24
24
  @categories = stub :categories
25
25
 
26
- @index = described_class.new :some_name, source: []
26
+ @index = described_class.new :some_name
27
27
  @index.define_category :some_category_name1
28
28
  @index.define_category :some_category_name2
29
29
 
@@ -46,9 +46,31 @@ describe Picky::Indexes::Index do
46
46
  end
47
47
  end
48
48
 
49
+ context 'result_identifier' do
50
+ context 'with it set' do
51
+ let(:index) do
52
+ described_class.new :some_name do
53
+ result_identifier :some_identifier
54
+ end
55
+ end
56
+ it 'has an after_indexing set' do
57
+ index.result_identifier.should == :some_identifier
58
+ end
59
+ end
60
+ context 'with it not set' do
61
+ let(:index) do
62
+ described_class.new :some_name do
63
+ end
64
+ end
65
+ it 'returns the name' do
66
+ index.result_identifier.should == :some_name
67
+ end
68
+ end
69
+ end
70
+
49
71
  context "no categories" do
50
72
  it "works" do
51
- described_class.new :some_name, source: []
73
+ described_class.new :some_name
52
74
  end
53
75
  end
54
76
 
@@ -4,14 +4,25 @@ describe Picky::Indexes::Index do
4
4
 
5
5
  describe 'tokenizer' do
6
6
  context 'with tokenizer' do
7
- let(:index) { described_class.new :some_name, source: [], tokenizer: 'some tokenizer' }
7
+ let(:tokenizer) { stub :tokenizer, :tokenize => '' }
8
+ let(:index) do
9
+ the_tokenizer = tokenizer
10
+ described_class.new :some_name do
11
+ source []
12
+ indexing the_tokenizer
13
+ end
14
+ end
8
15
 
9
16
  it 'does things in order' do
10
- index.tokenizer.should == 'some tokenizer'
17
+ index.tokenizer.should == tokenizer
11
18
  end
12
19
  end
13
20
  context 'without tokenizer' do
14
- let(:index) { described_class.new :some_name, source: [] }
21
+ let(:index) do
22
+ described_class.new :some_name do
23
+ source []
24
+ end
25
+ end
15
26
 
16
27
  it 'does things in order' do
17
28
  index.tokenizer.should == Picky::Indexes.tokenizer
@@ -19,9 +30,35 @@ describe Picky::Indexes::Index do
19
30
  end
20
31
  end
21
32
 
33
+ context 'after_indexing' do
34
+ context 'with it set' do
35
+ let(:index) do
36
+ described_class.new :some_name do
37
+ after_indexing "some after indexing going on"
38
+ end
39
+ end
40
+ it 'has an after_indexing set' do
41
+ index.after_indexing.should == "some after indexing going on"
42
+ end
43
+ end
44
+ context 'with it not set' do
45
+ let(:index) do
46
+ described_class.new :some_name do
47
+ end
48
+ end
49
+ it 'does not have an after_indexing set' do
50
+ index.after_indexing.should == nil
51
+ end
52
+ end
53
+ end
54
+
22
55
  context 'in general' do
23
56
  context 'with #each source' do
24
- let(:index) { described_class.new :some_name, source: [] }
57
+ let(:index) do
58
+ described_class.new :some_name do
59
+ source []
60
+ end
61
+ end
25
62
 
26
63
  it 'does things in order' do
27
64
  index.should_receive(:check_source_empty).once.with.ordered
@@ -32,7 +69,12 @@ describe Picky::Indexes::Index do
32
69
  end
33
70
  context 'with non#each source' do
34
71
  let(:source) { stub :source, :harvest => nil }
35
- let(:index) { described_class.new :some_name, source: source }
72
+ let(:index) do
73
+ the_source = source
74
+ described_class.new :some_name do
75
+ source the_source
76
+ end
77
+ end
36
78
 
37
79
  it 'does things in order' do
38
80
  category = stub :category
@@ -51,9 +93,11 @@ describe Picky::Indexes::Index do
51
93
 
52
94
  context "with categories" do
53
95
  before(:each) do
54
- @source = []
96
+ the_source = []
55
97
 
56
- @index = described_class.new :some_name, source: @source
98
+ @index = described_class.new :some_name do
99
+ source the_source
100
+ end
57
101
  @index.define_category :some_category_name1
58
102
  @index.define_category :some_category_name2
59
103
  end
@@ -64,9 +108,11 @@ describe Picky::Indexes::Index do
64
108
  end
65
109
  describe 'define_source' do
66
110
  it 'can be set with this method' do
67
- @index.define_source :some_other_source
111
+ source = stub :source, :each => [].each
112
+
113
+ @index.define_source source
68
114
 
69
- @index.source.should == :some_other_source
115
+ @index.source.should == source
70
116
  end
71
117
  end
72
118
  describe 'find' do
@@ -95,7 +141,9 @@ describe Picky::Indexes::Index do
95
141
 
96
142
  context "no categories" do
97
143
  it "works" do
98
- described_class.new :some_name, source: []
144
+ described_class.new :some_name do
145
+ source []
146
+ end
99
147
  end
100
148
  end
101
149
 
@@ -8,31 +8,37 @@ describe Picky::Indexes::Index do
8
8
 
9
9
  context 'initializer' do
10
10
  it 'works' do
11
- expect { described_class.new :some_index_name, source: some_source }.to_not raise_error
11
+ the_source = some_source
12
+ expect { described_class.new :some_index_name do source the_source end }.to_not raise_error
12
13
  end
13
14
  it 'fails correctly' do
14
15
  expect { described_class.new 0, some_source }.to raise_error
15
16
  end
16
- it 'fails correctly' do
17
- expect { described_class.new :some_index_name, source: :some_source }.to raise_error
18
- end
19
17
  it 'fails correctly' do
20
18
  expect { described_class.new :some_index_name, some_source }.to raise_error
21
19
  end
22
20
  it 'does not fail' do
23
- expect { described_class.new :some_index_name, source: [] }.to_not raise_error
21
+ expect { described_class.new :some_index_name do source [] end }.to_not raise_error
24
22
  end
25
23
  it 'registers with the indexes' do
26
24
  @api = described_class.allocate
27
25
 
28
26
  Picky::Indexes.should_receive(:register).once.with @api
29
27
 
30
- @api.send :initialize, :some_index_name, source: some_source
28
+ the_source = some_source
29
+ @api.send :initialize, :some_index_name do
30
+ source the_source
31
+ end
31
32
  end
32
33
  end
33
34
 
34
35
  context 'unit' do
35
- let(:api) { described_class.new :some_index_name, source: some_source }
36
+ let(:api) do
37
+ the_source = some_source
38
+ described_class.new :some_index_name do
39
+ source the_source
40
+ end
41
+ end
36
42
 
37
43
  describe 'geo_categories' do
38
44
  it 'delegates correctly' do
@@ -8,7 +8,7 @@ describe Picky::Indexes::Redis do
8
8
 
9
9
  describe 'initialize' do
10
10
  it 'works' do
11
- described_class.new :some_name, source: some_source
11
+ described_class.new :some_name
12
12
  end
13
13
  end
14
14
 
@@ -3,7 +3,7 @@ require 'spec_helper'
3
3
  describe Picky::Indexing::Bundle::Memory do
4
4
 
5
5
  before(:each) do
6
- @index = Picky::Indexes::Memory.new :some_index, source: []
6
+ @index = Picky::Indexes::Memory.new :some_index
7
7
  @category = Picky::Category.new :some_category, @index
8
8
 
9
9
  @partial_strategy = Picky::Generators::Partial::Substring.new :from => 1
@@ -3,7 +3,7 @@ require 'spec_helper'
3
3
  describe Picky::Indexing::Bundle::Memory do
4
4
 
5
5
  before(:each) do
6
- @index = Picky::Indexes::Memory.new :some_index, source: []
6
+ @index = Picky::Indexes::Memory.new :some_index
7
7
  @category = Picky::Category.new :some_category, @index
8
8
 
9
9
  @partial = stub :partial
@@ -3,7 +3,7 @@ require 'spec_helper'
3
3
  describe Picky::Indexing::Bundle::Redis do
4
4
 
5
5
  before(:each) do
6
- @index = Picky::Indexes::Memory.new :some_index, source: []
6
+ @index = Picky::Indexes::Memory.new :some_index
7
7
  @category = Picky::Category.new :some_category, @index
8
8
 
9
9
  @partial = stub :partial
@@ -42,12 +42,6 @@ describe Picky::Search do
42
42
  end
43
43
  context 'tokenizer predefined' do
44
44
  let(:predefined) { stub(:tokenizer, :tokenize => nil) }
45
- context 'by way of hash' do
46
- let(:search) { described_class.new(tokenizer: predefined) }
47
- it 'returns the predefined tokenizer' do
48
- search.tokenizer.should == predefined
49
- end
50
- end
51
45
  context 'by way of DSL' do
52
46
  let(:search) { pre = predefined; described_class.new { searching pre } }
53
47
  it 'returns the predefined tokenizer' do
@@ -62,7 +56,11 @@ describe Picky::Search do
62
56
  let(:search) { described_class.new }
63
57
  it 'returns a specific Combination for a specific input' do
64
58
  some_source = stub(:source, :harvest => nil)
65
- search.combinations_type_for([Picky::Indexes::Memory.new(:gu, source: some_source)]).should == Picky::Query::Combinations::Memory
59
+ search.combinations_type_for([
60
+ Picky::Indexes::Memory.new(:gu) do
61
+ source some_source
62
+ end]
63
+ ).should == Picky::Query::Combinations::Memory
66
64
  end
67
65
  it 'just works on the same types' do
68
66
  search.combinations_type_for([:blorf, :blarf]).should == Picky::Query::Combinations::Memory
@@ -89,42 +87,44 @@ describe Picky::Search do
89
87
  search.weights.should be_kind_of(Picky::Query::Weights)
90
88
  end
91
89
  it "handles :weights options when not yet wrapped" do
92
- search = described_class.new :weights => { [:a, :b] => +3 }
90
+ search = described_class.new do boost [:a, :b] => +3 end
93
91
 
94
92
  search.weights.should be_kind_of(Picky::Query::Weights)
95
93
  end
96
94
  it "handles :weights options when already wrapped" do
97
- search = described_class.new :weights => Picky::Query::Weights.new([:a, :b] => +3)
95
+ search = described_class.new do boost Picky::Query::Weights.new([:a, :b] => +3) end
98
96
 
99
97
  search.weights.should be_kind_of(Picky::Query::Weights)
100
98
  end
101
99
  end
102
100
 
103
- describe "search_with_text" do
101
+ describe "search" do
104
102
  before(:each) do
105
103
  @search = described_class.new
106
104
  end
107
- it "delegates to search" do
105
+ it "delegates to search_with" do
108
106
  @search.stub! :tokenized => :tokens
109
107
 
110
- @search.should_receive(:search).once.with :tokens, 20, 0
108
+ @search.should_receive(:search_with).once.with :tokens, 20, 0
111
109
 
112
- @search.search_with_text :text, 20, 0
110
+ @search.search :text, 20, 0
113
111
  end
114
112
  it "uses the tokenizer" do
115
- @search.stub! :search
113
+ @search.stub! :search_with
116
114
 
117
115
  @search.should_receive(:tokenized).once.with :text
118
116
 
119
- @search.search_with_text :text, 20 # (unimportant)
117
+ @search.search :text, 20 # (unimportant)
120
118
  end
121
119
  end
122
120
 
123
121
  describe 'initializer' do
124
122
  context 'with tokenizer' do
125
123
  before(:each) do
126
- @tokenizer = stub :tokenizer, :tokenize => :some_tokenized_text
127
- @search = described_class.new @index, tokenizer: @tokenizer
124
+ tokenizer = stub :tokenizer, :tokenize => :some_tokenized_text
125
+ @search = described_class.new @index do
126
+ searching tokenizer
127
+ end
128
128
  end
129
129
  it 'should tokenize using the tokenizer' do
130
130
  @search.tokenized('some text').should == :some_tokenized_text
@@ -138,7 +138,7 @@ describe Picky::Search do
138
138
  end
139
139
  context 'with weights' do
140
140
  before(:each) do
141
- @search = described_class.new @index, weights: :some_weights
141
+ @search = described_class.new @index do boost :some_weights end
142
142
  end
143
143
  it 'works correctly' do
144
144
  @search.to_s.should == 'Picky::Search(some_index, weights: some_weights)'
@@ -5,7 +5,7 @@ require 'spec_helper'
5
5
  describe Picky::Tokenizers::Base do
6
6
 
7
7
  context 'with special instance' do
8
- let (:tokenizer) { described_class.new reject_token_if: lambda { |token| token.to_s.length < 2 || token == :hello }, case_sensitive: true }
8
+ let (:tokenizer) { described_class.new rejects_token_if: lambda { |token| token.to_s.length < 2 || token == :hello }, case_sensitive: true }
9
9
  it 'rejects tokens with length < 2' do
10
10
  tokenizer.reject([:'', :a, :ab, :abc]).should == [:ab, :abc]
11
11
  end
@@ -46,12 +46,12 @@ EXPECTED
46
46
  end
47
47
  end
48
48
 
49
- describe 'reject_token_if' do
49
+ describe 'rejects_token_if' do
50
50
  it 'rejects empty tokens by default' do
51
51
  tokenizer.reject(['a', nil, '', 'b']).should == ['a', 'b']
52
52
  end
53
53
  it 'rejects tokens based on the given rejection criteria if set' do
54
- tokenizer.reject_token_if &:nil?
54
+ tokenizer.rejects_token_if &:nil?
55
55
 
56
56
  tokenizer.reject(['a', nil, '', 'b']).should == ['a', '', 'b']
57
57
  end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: picky
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease: 6
5
- version: 3.0.0.pre1
5
+ version: 3.0.0.pre2
6
6
  platform: ruby
7
7
  authors:
8
8
  - Florian Hanke
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-08-07 00:00:00 +10:00
13
+ date: 2011-08-11 00:00:00 +10:00
14
14
  default_executable: picky
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
@@ -32,7 +32,7 @@ dependencies:
32
32
  requirements:
33
33
  - - "="
34
34
  - !ruby/object:Gem::Version
35
- version: 3.0.0.pre1
35
+ version: 3.0.0.pre2
36
36
  type: :development
37
37
  version_requirements: *id002
38
38
  description: Fast Ruby semantic text search engine with comfortable single field interface.
@@ -129,7 +129,6 @@ files:
129
129
  - lib/picky/indexing/wrappers/category/location.rb
130
130
  - lib/picky/interfaces/live_parameters.rb
131
131
  - lib/picky/loader.rb
132
- - lib/picky/loggers/search.rb
133
132
  - lib/picky/no_source_specified_exception.rb
134
133
  - lib/picky/performant.rb
135
134
  - lib/picky/query/allocation.rb
@@ -240,7 +239,6 @@ files:
240
239
  - spec/lib/indexing/bundle/redis_spec.rb
241
240
  - spec/lib/interfaces/live_parameters_spec.rb
242
241
  - spec/lib/loader_spec.rb
243
- - spec/lib/loggers/search_spec.rb
244
242
  - spec/lib/query/allocation_spec.rb
245
243
  - spec/lib/query/allocations_spec.rb
246
244
  - spec/lib/query/combination_spec.rb
@@ -368,7 +366,6 @@ test_files:
368
366
  - spec/lib/indexing/bundle/redis_spec.rb
369
367
  - spec/lib/interfaces/live_parameters_spec.rb
370
368
  - spec/lib/loader_spec.rb
371
- - spec/lib/loggers/search_spec.rb
372
369
  - spec/lib/query/allocation_spec.rb
373
370
  - spec/lib/query/allocations_spec.rb
374
371
  - spec/lib/query/combination_spec.rb
@@ -1,26 +0,0 @@
1
- # encoding: utf-8
2
- #
3
- module Picky
4
-
5
- # TODO Remove?
6
- #
7
- module Loggers # :nodoc:all
8
-
9
- # Log Proxy
10
- #
11
- class Search
12
-
13
- attr_reader :logger
14
-
15
- def initialize logger
16
- @logger = logger
17
- end
18
-
19
- def log message
20
- logger.info message
21
- end
22
-
23
- end
24
- end
25
-
26
- end