picky 0.10.5 → 0.11.0

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 (52) hide show
  1. data/lib/picky/alias_instances.rb +1 -0
  2. data/lib/picky/application.rb +6 -7
  3. data/lib/picky/bundle.rb +31 -0
  4. data/lib/picky/configuration/indexes.rb +30 -41
  5. data/lib/picky/configuration/type.rb +6 -40
  6. data/lib/picky/ext/maybe_compile.rb +9 -0
  7. data/lib/picky/index/bundle.rb +1 -139
  8. data/lib/picky/{query/combinator.rb → index/categories.rb} +16 -18
  9. data/lib/picky/index/category.rb +20 -46
  10. data/lib/picky/index/type.rb +16 -12
  11. data/lib/picky/index/types.rb +41 -0
  12. data/lib/picky/index/wrappers/exact_first.rb +5 -1
  13. data/lib/picky/indexers/base.rb +9 -8
  14. data/lib/picky/indexing/bundle.rb +152 -0
  15. data/lib/picky/indexing/categories.rb +36 -0
  16. data/lib/picky/indexing/category.rb +145 -0
  17. data/lib/picky/indexing/type.rb +45 -0
  18. data/lib/picky/indexing/types.rb +74 -0
  19. data/lib/picky/loader.rb +17 -7
  20. data/lib/picky/query/base.rb +5 -4
  21. data/lib/picky/sources/wrappers/base.rb +23 -0
  22. data/lib/picky/sources/wrappers/location.rb +92 -0
  23. data/lib/picky/tokenizers/index.rb +4 -1
  24. data/lib/picky/type.rb +46 -0
  25. data/lib/picky/types.rb +38 -0
  26. data/lib/tasks/index.rake +4 -0
  27. data/project_prototype/Gemfile +1 -1
  28. data/project_prototype/app/application.rb +12 -12
  29. data/spec/lib/application_spec.rb +6 -9
  30. data/spec/lib/configuration/indexes_spec.rb +0 -85
  31. data/spec/lib/index/bundle_spec.rb +2 -94
  32. data/spec/lib/index/category_spec.rb +7 -86
  33. data/spec/lib/index/type_spec.rb +14 -26
  34. data/spec/lib/index/wrappers/exact_first_spec.rb +12 -12
  35. data/spec/lib/{index → indexing}/bundle_partial_generation_speed_spec.rb +2 -2
  36. data/spec/lib/indexing/bundle_spec.rb +174 -0
  37. data/spec/lib/{query/combinator_spec.rb → indexing/categories_spec.rb} +30 -34
  38. data/spec/lib/indexing/category_spec.rb +257 -0
  39. data/spec/lib/indexing/type_spec.rb +32 -0
  40. data/spec/lib/loader_spec.rb +0 -2
  41. data/spec/lib/query/base_spec.rb +8 -17
  42. data/spec/lib/query/full_spec.rb +3 -6
  43. data/spec/lib/query/live_spec.rb +4 -3
  44. data/spec/lib/sources/wrappers/base_spec.rb +35 -0
  45. data/spec/lib/sources/wrappers/location_spec.rb +68 -0
  46. data/spec/lib/tokenizers/index_spec.rb +2 -5
  47. metadata +32 -16
  48. data/lib/picky/configuration/field.rb +0 -73
  49. data/lib/picky/indexes.rb +0 -179
  50. data/lib/picky/initializers/ext.rb +0 -1
  51. data/spec/lib/configuration/field_spec.rb +0 -208
  52. data/spec/lib/configuration/type_spec.rb +0 -49
@@ -1,208 +0,0 @@
1
- require 'spec_helper'
2
- describe Configuration::Field do
3
-
4
- context "unit specs" do
5
- describe "virtual?" do
6
- context "with virtual true" do
7
- before(:each) do
8
- @field = Configuration::Field.new :some_name, :virtual => true
9
- end
10
- it "returns the right value" do
11
- @field.virtual?.should == true
12
- end
13
- end
14
- context "with virtual object" do
15
- before(:each) do
16
- @field = Configuration::Field.new :some_name, :virtual => 123.6
17
- end
18
- it "returns the right value" do
19
- @field.virtual?.should == true
20
- end
21
- end
22
- context "with virtual nil" do
23
- before(:each) do
24
- @field = Configuration::Field.new :some_name, :virtual => nil
25
- end
26
- it "returns the right value" do
27
- @field.virtual?.should == false
28
- end
29
- end
30
- context "with virtual false" do
31
- before(:each) do
32
- @field = Configuration::Field.new :some_name, :virtual => false
33
- end
34
- it "returns the right value" do
35
- @field.virtual?.should == false
36
- end
37
- end
38
- end
39
- describe "tokenizer" do
40
- context "with specific tokenizer" do
41
- before(:each) do
42
- @field = Configuration::Field.new :some_name, tokenizer: Tokenizers::Index.new
43
-
44
- @field.type = :some_type
45
- end
46
- it "caches" do
47
- @field.tokenizer.should == @field.tokenizer
48
- end
49
- it "returns an instance" do
50
- @field.tokenizer.should be_kind_of(Tokenizers::Index)
51
- end
52
- end
53
- end
54
- describe "indexer" do
55
- context "with default indexer" do
56
- before(:each) do
57
- @field = Configuration::Field.new :some_name
58
- end
59
- it "caches" do
60
- @field.indexer.should == @field.indexer
61
- end
62
- end
63
- context "with specific indexer" do
64
- before(:each) do
65
- @field = Configuration::Field.new :some_name, tokenizer: Indexers::Default
66
-
67
- @field.type = :some_type
68
- end
69
- it "caches" do
70
- @field.indexer.should == @field.indexer
71
- end
72
- it "returns an instance" do
73
- @field.indexer.should be_kind_of(Indexers::Default)
74
- end
75
- it "creates a new instance of the right class" do
76
- Indexers::Default.should_receive(:new).once.with :some_type, @field
77
-
78
- @field.indexer
79
- end
80
- end
81
- end
82
- describe "cache" do
83
- before(:each) do
84
- @field = Configuration::Field.new :some_name
85
- @field.stub! :prepare_cache_directory
86
-
87
- @generated = stub :generated, :generate_caches => nil
88
- @field.stub! :generate => @generated
89
- end
90
- it "prepares the cache directory" do
91
- @field.should_receive(:prepare_cache_directory).once.with
92
-
93
- @field.cache
94
- end
95
- it "tells the indexer to index" do
96
- @generated.should_receive(:generate_caches).once.with
97
-
98
- @field.cache
99
- end
100
- end
101
- describe "prepare_cache_directory" do
102
- before(:each) do
103
- @field = Configuration::Field.new :some_name
104
-
105
- @field.stub! :cache_directory => :some_cache_directory
106
- end
107
- it "tells the FileUtils to mkdir_p" do
108
- FileUtils.should_receive(:mkdir_p).once.with :some_cache_directory
109
-
110
- @field.prepare_cache_directory
111
- end
112
- end
113
- describe "index" do
114
- before(:each) do
115
- @field = Configuration::Field.new :some_name
116
- @field.stub! :prepare_cache_directory
117
-
118
- @indexer = stub :indexer, :index => nil
119
- @field.stub! :indexer => @indexer
120
- end
121
- it "prepares the cache directory" do
122
- @field.should_receive(:prepare_cache_directory).once.with
123
-
124
- @field.index
125
- end
126
- it "tells the indexer to index" do
127
- @indexer.should_receive(:index).once.with
128
-
129
- @field.index
130
- end
131
- end
132
- describe "source" do
133
- context "with source" do
134
- before(:each) do
135
- @field = Configuration::Field.new :some_name, :source => :some_given_source
136
-
137
- @type = stub :type, :name => :some_type
138
- @field.type = @type
139
- end
140
- it "returns the given source" do
141
- @field.source.should == :some_given_source
142
- end
143
- end
144
- context "without source" do
145
- before(:each) do
146
- @field = Configuration::Field.new :some_name
147
-
148
- @type = stub :type, :name => :some_type, :source => :some_type_source
149
- @field.type = @type
150
- end
151
- it "returns the type's source" do
152
- @field.source.should == :some_type_source
153
- end
154
- end
155
- end
156
- context "name symbol" do
157
- before(:each) do
158
- @field = Configuration::Field.new :some_name
159
-
160
- @type = stub :type, :name => :some_type
161
- @field.type = @type
162
- end
163
- describe "search_index_file_name" do
164
- it "returns the right file name" do
165
- @field.search_index_file_name.should == 'some/search/root/index/test/some_type/prepared_some_name_index.txt'
166
- end
167
- end
168
- describe "generate_qualifiers_from" do
169
- context "with qualifiers" do
170
- it "uses the qualifiers" do
171
- @field.generate_qualifiers_from(:qualifiers => :some_qualifiers).should == :some_qualifiers
172
- end
173
- end
174
- context "without qualifiers" do
175
- context "with qualifier" do
176
- it "uses the [qualifier]" do
177
- @field.generate_qualifiers_from(:qualifier => :some_qualifier).should == [:some_qualifier]
178
- end
179
- end
180
- context "without qualifier" do
181
- context "with name" do
182
- it "uses the [name]" do
183
- @field.generate_qualifiers_from(:nork => :blark).should == [:some_name]
184
- end
185
- end
186
- end
187
- end
188
- end
189
- end
190
- context "name string" do
191
- before(:each) do
192
- @field = Configuration::Field.new 'some_name'
193
- end
194
- describe "generate_qualifiers_from" do
195
- context "without qualifiers" do
196
- context "without qualifier" do
197
- context "with name" do
198
- it "uses the [name]" do
199
- @field.generate_qualifiers_from(:nork => :blark).should == [:some_name]
200
- end
201
- end
202
- end
203
- end
204
- end
205
- end
206
- end
207
-
208
- end
@@ -1,49 +0,0 @@
1
- # encoding: utf-8
2
- require 'spec_helper'
3
-
4
- describe Configuration::Type do
5
-
6
- before(:each) do
7
- @field = stub :field, :type= => nil, :virtual? => false
8
- @field.stub! :dup => @field
9
-
10
- @virtual_field = stub :virtual_field, :type= => nil, :virtual? => true
11
- @virtual_field.stub! :dup => @virtual_field
12
- @type = Configuration::Type.new :some_name,
13
- :some_indexing_select,
14
- @field,
15
- @virtual_field,
16
- :after_indexing => "some after indexing",
17
- :result_type => :some_result_type,
18
- :weights => :some_weights,
19
- :ignore_unassigned_tokens => :some_ignore_unassigned_tokens_option,
20
- :solr => :some_solr_option
21
- end
22
-
23
- # describe 'solr_fields' do
24
- # it 'should return all non-virtual fields' do
25
- # @type.solr_fields.should == [@field]
26
- # end
27
- # end
28
-
29
- # describe 'index_solr' do
30
- # it 'should get a new solr indexer and start it' do
31
- # solr = mock :solr
32
- # Indexers::Solr.should_receive(:new).once.with(@type).and_return solr
33
- #
34
- # solr.should_receive(:index).once.with
35
- #
36
- # @type.index_solr
37
- # end
38
- # end
39
-
40
- describe 'index' do
41
- it 'should index each of the fields' do
42
- @field.should_receive(:index).once.with
43
- @virtual_field.should_receive(:index).once.with
44
-
45
- @type.index
46
- end
47
- end
48
-
49
- end