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
@@ -3,16 +3,13 @@ require 'spec_helper'
3
3
  describe Query::Full do
4
4
 
5
5
  before(:each) do
6
- @index = stub :index
6
+ @type = stub :type
7
+ @index = stub :index, :index => @type
7
8
  end
8
9
 
9
10
  describe 'result_type' do
10
11
  before(:each) do
11
- @tokens = [
12
- Query::Token.processed('some'),
13
- Query::Token.processed('query')
14
- ]
15
- @query = Query::Full.new @tokens, @index
12
+ @query = Query::Full.new @index
16
13
  end
17
14
  it "should return a specific type" do
18
15
  @query.result_type.should == Results::Full
@@ -5,12 +5,13 @@ describe Query::Live do
5
5
  before(:each) do
6
6
  # @category1 = Index::Category.new
7
7
  # @type_index = Index::Type.new :some_name, :some_result_type, @category1
8
- @index = stub :index
8
+ @type = stub :type
9
+ @index = stub :index, :index => @type
9
10
  end
10
11
 
11
12
  describe 'result_type' do
12
13
  before(:each) do
13
- @query = Query::Live.new 'some query', 0, @index
14
+ @query = Query::Live.new @index
14
15
  end
15
16
  it "should return a specific type" do
16
17
  @query.result_type.should == Results::Live
@@ -40,7 +41,7 @@ describe Query::Live do
40
41
  describe "results_from" do
41
42
  describe "with empty ids" do
42
43
  before(:each) do
43
- @query = Query::Live.new 'some query', @index
44
+ @query = Query::Live.new @index
44
45
  @allocations = stub :allocations, :total => 0, :ids => [], :to_result => :some_results, :process! => nil
45
46
  end
46
47
  it "should generate a result" do
@@ -0,0 +1,35 @@
1
+ require 'spec_helper'
2
+
3
+ describe Sources::Wrappers::Base do
4
+
5
+ context "with backend" do
6
+ it "doesn't fail" do
7
+ lambda { Sources::Wrappers::Base.new(:something) }.should_not raise_error
8
+ end
9
+ before(:each) do
10
+ @backend = stub :backend
11
+ @wrapper = Sources::Wrappers::Base.new @backend
12
+ end
13
+ it "delegates harvest" do
14
+ @backend.should_receive(:harvest).once.with :some_type, :some_field
15
+
16
+ @wrapper.harvest :some_type, :some_field
17
+ end
18
+ it "delegates take_snapshot" do
19
+ @backend.should_receive(:take_snapshot).once.with :some_type
20
+
21
+ @wrapper.take_snapshot :some_type
22
+ end
23
+ it "delegates connect_backend" do
24
+ @backend.should_receive(:connect_backend).once.with # nothing
25
+
26
+ @wrapper.connect_backend
27
+ end
28
+ end
29
+ context "without backend" do
30
+ it "fails" do
31
+ lambda { Sources::Wrappers::Base.new }.should raise_error(ArgumentError)
32
+ end
33
+ end
34
+
35
+ end
@@ -0,0 +1,68 @@
1
+ require 'spec_helper'
2
+
3
+ describe Sources::Wrappers::Location do
4
+
5
+ context "with backend" do
6
+ before(:each) do
7
+ @backend = stub :backend
8
+ end
9
+ context "without grid option" do
10
+ it "fails" do
11
+ lambda { Sources::Wrappers::Location.new(:something) }.should raise_error
12
+ end
13
+ end
14
+ context "with grid option" do
15
+ before(:each) do
16
+ @wrapper = Sources::Wrappers::Location.new @backend, grid:10
17
+ end
18
+ it "uses a default of 1 on the precision" do
19
+ @wrapper.precision.should == 1
20
+ end
21
+ it "delegates harvest" do
22
+ @backend.should_receive(:harvest).once.with :some_type, :some_field
23
+
24
+ @wrapper.harvest :some_type, :some_field
25
+ end
26
+ it "delegates take_snapshot" do
27
+ @backend.should_receive(:take_snapshot).once.with :some_type
28
+
29
+ @wrapper.take_snapshot :some_type
30
+ end
31
+ it "delegates connect_backend" do
32
+ @backend.should_receive(:connect_backend).once.with # nothing
33
+
34
+ @wrapper.connect_backend
35
+ end
36
+ end
37
+ context "with grid and precision option" do
38
+ before(:each) do
39
+ @wrapper = Sources::Wrappers::Location.new @backend, grid:4, precision:2
40
+ end
41
+ it "uses the given precision" do
42
+ @wrapper.precision.should == 2
43
+ end
44
+
45
+ describe "locations_for" do
46
+ before(:each) do
47
+ @wrapper.instance_variable_set :@min, -3
48
+ @wrapper.marginize
49
+ end
50
+ it "returns the right array" do
51
+ @wrapper.locations_for(17).should == [13, 14, 15, 16, 17] # TODO Correct?
52
+ end
53
+ it "returns the right array" do
54
+ @wrapper.locations_for(-3).should == [0, 1, 2, 3, 4]
55
+ end
56
+ it "returns the right array" do
57
+ @wrapper.locations_for(20).should == [14, 15, 16, 17, 18]
58
+ end
59
+ end
60
+ end
61
+ end
62
+ context "without backend" do
63
+ it "fails" do
64
+ lambda { Sources::Wrappers::Location.new }.should raise_error(ArgumentError)
65
+ end
66
+ end
67
+
68
+ end
@@ -39,11 +39,7 @@ describe Tokenizers::Index do
39
39
 
40
40
  describe "reject!" do
41
41
  it "should reject tokens if blank" do
42
- t1 = stub(:token, :to_s => '')
43
- t2 = stub(:token, :to_s => 'not blank')
44
- t3 = stub(:token, :to_s => '')
45
-
46
- @tokenizer.reject([t1, t2, t3]).should == [t2]
42
+ @tokenizer.reject(['', 'not blank', '']).should == ['not blank']
47
43
  end
48
44
  end
49
45
 
@@ -68,6 +64,7 @@ describe Tokenizers::Index do
68
64
  #
69
65
  it_should_tokenize_token "splitting on \\s", [:splitting, :on, :"\\s"]
70
66
  it_should_tokenize_token 'und', [:und]
67
+ it_should_tokenize_token '7', [:'7']
71
68
  end
72
69
  end
73
70
 
metadata CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
4
4
  prerelease: false
5
5
  segments:
6
6
  - 0
7
- - 10
8
- - 5
9
- version: 0.10.5
7
+ - 11
8
+ - 0
9
+ version: 0.11.0
10
10
  platform: ruby
11
11
  authors:
12
12
  - Florian Hanke
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-11-03 00:00:00 +01:00
17
+ date: 2010-11-08 00:00:00 +01:00
18
18
  default_executable: picky
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -42,7 +42,9 @@ files:
42
42
  - lib/bundling.rb
43
43
  - lib/constants.rb
44
44
  - lib/deployment.rb
45
+ - lib/picky/alias_instances.rb
45
46
  - lib/picky/application.rb
47
+ - lib/picky/bundle.rb
46
48
  - lib/picky/cacher/convenience.rb
47
49
  - lib/picky/cacher/generator.rb
48
50
  - lib/picky/cacher/partial/default.rb
@@ -60,11 +62,11 @@ files:
60
62
  - lib/picky/cacher/weights/strategy.rb
61
63
  - lib/picky/cacher/weights_generator.rb
62
64
  - lib/picky/character_substitution/european.rb
63
- - lib/picky/configuration/field.rb
64
65
  - lib/picky/configuration/indexes.rb
65
66
  - lib/picky/configuration/queries.rb
66
67
  - lib/picky/configuration/type.rb
67
68
  - lib/picky/cores.rb
69
+ - lib/picky/ext/maybe_compile.rb
68
70
  - lib/picky/ext/ruby19/extconf.rb
69
71
  - lib/picky/extensions/array.rb
70
72
  - lib/picky/extensions/hash.rb
@@ -76,6 +78,7 @@ files:
76
78
  - lib/picky/helpers/gc.rb
77
79
  - lib/picky/helpers/measuring.rb
78
80
  - lib/picky/index/bundle.rb
81
+ - lib/picky/index/categories.rb
79
82
  - lib/picky/index/category.rb
80
83
  - lib/picky/index/file/basic.rb
81
84
  - lib/picky/index/file/json.rb
@@ -83,14 +86,18 @@ files:
83
86
  - lib/picky/index/file/text.rb
84
87
  - lib/picky/index/files.rb
85
88
  - lib/picky/index/type.rb
89
+ - lib/picky/index/types.rb
86
90
  - lib/picky/index/wrappers/exact_first.rb
87
91
  - lib/picky/indexers/base.rb
88
92
  - lib/picky/indexers/default.rb
89
93
  - lib/picky/indexers/field.rb
90
94
  - lib/picky/indexers/no_source_specified_error.rb
91
95
  - lib/picky/indexers/solr.rb
92
- - lib/picky/indexes.rb
93
- - lib/picky/initializers/ext.rb
96
+ - lib/picky/indexing/bundle.rb
97
+ - lib/picky/indexing/categories.rb
98
+ - lib/picky/indexing/category.rb
99
+ - lib/picky/indexing/type.rb
100
+ - lib/picky/indexing/types.rb
94
101
  - lib/picky/loader.rb
95
102
  - lib/picky/loggers/search.rb
96
103
  - lib/picky/query/allocation.rb
@@ -98,7 +105,6 @@ files:
98
105
  - lib/picky/query/base.rb
99
106
  - lib/picky/query/combination.rb
100
107
  - lib/picky/query/combinations.rb
101
- - lib/picky/query/combinator.rb
102
108
  - lib/picky/query/full.rb
103
109
  - lib/picky/query/live.rb
104
110
  - lib/picky/query/qualifiers.rb
@@ -119,9 +125,13 @@ files:
119
125
  - lib/picky/sources/csv.rb
120
126
  - lib/picky/sources/db.rb
121
127
  - lib/picky/sources/delicious.rb
128
+ - lib/picky/sources/wrappers/base.rb
129
+ - lib/picky/sources/wrappers/location.rb
122
130
  - lib/picky/tokenizers/base.rb
123
131
  - lib/picky/tokenizers/index.rb
124
132
  - lib/picky/tokenizers/query.rb
133
+ - lib/picky/type.rb
134
+ - lib/picky/types.rb
125
135
  - lib/picky-tasks.rb
126
136
  - lib/picky.rb
127
137
  - lib/tasks/application.rake
@@ -161,9 +171,7 @@ files:
161
171
  - spec/lib/cacher/weights/logarithmic_spec.rb
162
172
  - spec/lib/cacher/weights_generator_spec.rb
163
173
  - spec/lib/character_substitution/european_spec.rb
164
- - spec/lib/configuration/field_spec.rb
165
174
  - spec/lib/configuration/indexes_spec.rb
166
- - spec/lib/configuration/type_spec.rb
167
175
  - spec/lib/cores_spec.rb
168
176
  - spec/lib/extensions/array_spec.rb
169
177
  - spec/lib/extensions/hash_spec.rb
@@ -174,7 +182,6 @@ files:
174
182
  - spec/lib/helpers/cache_spec.rb
175
183
  - spec/lib/helpers/gc_spec.rb
176
184
  - spec/lib/helpers/measuring_spec.rb
177
- - spec/lib/index/bundle_partial_generation_speed_spec.rb
178
185
  - spec/lib/index/bundle_spec.rb
179
186
  - spec/lib/index/category_spec.rb
180
187
  - spec/lib/index/file/basic_spec.rb
@@ -186,6 +193,11 @@ files:
186
193
  - spec/lib/index/wrappers/exact_first_spec.rb
187
194
  - spec/lib/indexers/base_spec.rb
188
195
  - spec/lib/indexers/field_spec.rb
196
+ - spec/lib/indexing/bundle_partial_generation_speed_spec.rb
197
+ - spec/lib/indexing/bundle_spec.rb
198
+ - spec/lib/indexing/categories_spec.rb
199
+ - spec/lib/indexing/category_spec.rb
200
+ - spec/lib/indexing/type_spec.rb
189
201
  - spec/lib/loader_spec.rb
190
202
  - spec/lib/loggers/search_spec.rb
191
203
  - spec/lib/query/allocation_spec.rb
@@ -193,7 +205,6 @@ files:
193
205
  - spec/lib/query/base_spec.rb
194
206
  - spec/lib/query/combination_spec.rb
195
207
  - spec/lib/query/combinations_spec.rb
196
- - spec/lib/query/combinator_spec.rb
197
208
  - spec/lib/query/full_spec.rb
198
209
  - spec/lib/query/live_spec.rb
199
210
  - spec/lib/query/qualifiers_spec.rb
@@ -210,6 +221,8 @@ files:
210
221
  - spec/lib/sources/csv_spec.rb
211
222
  - spec/lib/sources/db_spec.rb
212
223
  - spec/lib/sources/delicious_spec.rb
224
+ - spec/lib/sources/wrappers/base_spec.rb
225
+ - spec/lib/sources/wrappers/location_spec.rb
213
226
  - spec/lib/tokenizers/base_spec.rb
214
227
  - spec/lib/tokenizers/index_spec.rb
215
228
  - spec/lib/tokenizers/query_spec.rb
@@ -260,9 +273,7 @@ test_files:
260
273
  - spec/lib/cacher/weights/logarithmic_spec.rb
261
274
  - spec/lib/cacher/weights_generator_spec.rb
262
275
  - spec/lib/character_substitution/european_spec.rb
263
- - spec/lib/configuration/field_spec.rb
264
276
  - spec/lib/configuration/indexes_spec.rb
265
- - spec/lib/configuration/type_spec.rb
266
277
  - spec/lib/cores_spec.rb
267
278
  - spec/lib/extensions/array_spec.rb
268
279
  - spec/lib/extensions/hash_spec.rb
@@ -273,7 +284,6 @@ test_files:
273
284
  - spec/lib/helpers/cache_spec.rb
274
285
  - spec/lib/helpers/gc_spec.rb
275
286
  - spec/lib/helpers/measuring_spec.rb
276
- - spec/lib/index/bundle_partial_generation_speed_spec.rb
277
287
  - spec/lib/index/bundle_spec.rb
278
288
  - spec/lib/index/category_spec.rb
279
289
  - spec/lib/index/file/basic_spec.rb
@@ -285,6 +295,11 @@ test_files:
285
295
  - spec/lib/index/wrappers/exact_first_spec.rb
286
296
  - spec/lib/indexers/base_spec.rb
287
297
  - spec/lib/indexers/field_spec.rb
298
+ - spec/lib/indexing/bundle_partial_generation_speed_spec.rb
299
+ - spec/lib/indexing/bundle_spec.rb
300
+ - spec/lib/indexing/categories_spec.rb
301
+ - spec/lib/indexing/category_spec.rb
302
+ - spec/lib/indexing/type_spec.rb
288
303
  - spec/lib/loader_spec.rb
289
304
  - spec/lib/loggers/search_spec.rb
290
305
  - spec/lib/query/allocation_spec.rb
@@ -292,7 +307,6 @@ test_files:
292
307
  - spec/lib/query/base_spec.rb
293
308
  - spec/lib/query/combination_spec.rb
294
309
  - spec/lib/query/combinations_spec.rb
295
- - spec/lib/query/combinator_spec.rb
296
310
  - spec/lib/query/full_spec.rb
297
311
  - spec/lib/query/live_spec.rb
298
312
  - spec/lib/query/qualifiers_spec.rb
@@ -309,6 +323,8 @@ test_files:
309
323
  - spec/lib/sources/csv_spec.rb
310
324
  - spec/lib/sources/db_spec.rb
311
325
  - spec/lib/sources/delicious_spec.rb
326
+ - spec/lib/sources/wrappers/base_spec.rb
327
+ - spec/lib/sources/wrappers/location_spec.rb
312
328
  - spec/lib/tokenizers/base_spec.rb
313
329
  - spec/lib/tokenizers/index_spec.rb
314
330
  - spec/lib/tokenizers/query_spec.rb
@@ -1,73 +0,0 @@
1
- module Configuration
2
-
3
- # Describes the configuration of a "field", a category
4
- # (title is a category of a books index, for example).
5
- #
6
- class Field
7
- attr_reader :name, :indexed_name, :virtual, :tokenizer
8
- attr_accessor :type # convenience TODO Still needed?
9
- def initialize name, options = {}
10
- @name = name.to_sym
11
- @tokenizer = options[:tokenizer] || Tokenizers::Index.default
12
-
13
- # TODO Dup the options?
14
-
15
- @source = options.delete :source
16
-
17
- @indexer_class = options.delete(:indexer) || Indexers::Default
18
-
19
- @indexed_name = options.delete(:indexed_field) || name # TODO Rename to indexed_as?
20
- @virtual = options.delete(:virtual) || false
21
-
22
- qualifiers = generate_qualifiers_from options
23
- Query::Qualifiers.add(name, qualifiers) if qualifiers
24
-
25
- # @remove = options[:remove] || false
26
- # @filter = options[:filter] || true
27
-
28
- @options = options
29
- end
30
- def generate_qualifiers_from options
31
- options[:qualifiers] || options[:qualifier] && [options[:qualifier]] || [name]
32
- end
33
- def source
34
- @source || type.source
35
- end
36
- def generate
37
- Index::Category.new self.name, type, @options
38
- end
39
- # TODO Duplicate code in bundle. Move to application.
40
- #
41
- # TODO Move to type, and use in bundle from there.
42
- #
43
- def search_index_root
44
- File.join PICKY_ROOT, 'index'
45
- end
46
- # TODO Move to config. Duplicate Code in field.rb.
47
- #
48
- def cache_directory
49
- File.join search_index_root, PICKY_ENVIRONMENT, type.name.to_s
50
- end
51
- def search_index_file_name
52
- File.join cache_directory, "prepared_#{name}_index.txt"
53
- end
54
- def index
55
- prepare_cache_directory
56
- indexer.index
57
- end
58
- def prepare_cache_directory
59
- FileUtils.mkdir_p cache_directory
60
- end
61
- def cache
62
- prepare_cache_directory
63
- generate.generate_caches
64
- end
65
- def indexer
66
- @indexer || @indexer = @indexer_class.new(type, self)
67
- end
68
- def virtual?
69
- !!virtual
70
- end
71
- end
72
-
73
- end
data/lib/picky/indexes.rb DELETED
@@ -1,179 +0,0 @@
1
- # TODO I should really do a Types collector class which does all this!
2
- #
3
- module Indexes
4
-
5
- mattr_accessor :configuration, :types, :type_mapping
6
-
7
- # Takes a snapshot of the originating table.
8
- #
9
- def self.take_snapshot *args
10
- configuration.take_snapshot *args
11
- end
12
- # Runs the indexers in parallel (index + cache).
13
- #
14
- def self.index randomly = true
15
- Indexes.take_snapshot
16
-
17
- # Run in parallel.
18
- #
19
- # TODO Make option to also use non-random.
20
- # rake index:random (default)
21
- # rake index:ordered
22
- #
23
- timed_exclaim "INDEXING USING #{Cores.max_processors} PROCESSORS, IN #{randomly ? 'RANDOM' : 'GIVEN'} ORDER."
24
- Cores.forked self.fields, { randomly: randomly } do |field, cores|
25
- field.index
26
- field.cache
27
- end
28
- timed_exclaim "INDEXING FINISHED."
29
- end
30
- def self.index_solr
31
- configuration.index_solr
32
- end
33
-
34
- # Returns an array of fields.
35
- #
36
- # TODO Rewrite.
37
- #
38
- def self.fields
39
- result = []
40
- configuration.types.each do |type|
41
- type.fields.inject(result) do |total, field|
42
- total << field
43
- end
44
- end
45
- result
46
- end
47
-
48
- #
49
- #
50
- # TODO Rewrite.
51
- #
52
- def self.find type_name, field_name
53
- type_name = type_name.to_sym
54
- field_name = field_name.to_sym
55
- configuration.types.each do |type|
56
- next unless type.name == type_name
57
- type.fields.each do |field|
58
- next unless field.name == field_name
59
- return field
60
- end
61
- end
62
- end
63
-
64
- # Backup / Restore.
65
- #
66
- def self.backup_caches
67
- each_category do |category|
68
- category.exact.backup
69
- category.partial.backup
70
- end
71
- end
72
- def self.restore_caches
73
- each_category do |category|
74
- category.exact.restore
75
- category.partial.restore
76
- end
77
- end
78
-
79
- # Use these if you need to index / cache a single index.
80
- #
81
- def self.generate_index_only type_name, field_name
82
- Indexes.configuration.types.each do |type|
83
- next unless type_name == type.name
84
- type.fields.each do |field|
85
- field.index if field_name == field.name
86
- end
87
- end
88
- end
89
- def self.generate_cache_only type_name, category_name
90
- Indexes.each do |type|
91
- next unless type_name == type.name
92
- type.categories.each do |category|
93
- category.generate_caches if category_name == category.name
94
- end
95
- end
96
- end
97
-
98
- # Runs the index cache generation.
99
- #
100
- # TODO Needed?
101
- #
102
- def self.generate_caches
103
- each &:generate_caches
104
- end
105
- # Loads all indexes from the caches.
106
- #
107
- # TODO Rename load_indexes.
108
- #
109
- def self.load_from_cache
110
- each &:load_from_cache
111
- end
112
- def self.reload
113
- load_from_cache
114
- end
115
-
116
- # Checks if the caches are there.
117
- #
118
- def self.check_caches
119
- each do |type|
120
- type.categories.each do |category|
121
- category.exact.raise_unless_cache_exists
122
- category.partial.raise_unless_cache_exists
123
- end
124
- end
125
- end
126
-
127
- # Removes the cache files.
128
- #
129
- def self.clear_caches
130
- each_bundle do |exact, partial|
131
- exact.delete
132
- partial.delete
133
- end
134
- end
135
-
136
- # Creates the directory structure for the indexes.
137
- #
138
- # TODO Should be on type?
139
- #
140
- def self.create_directory_structure
141
- each_bundle do |exact, partial|
142
- exact.create_directory
143
- partial.create_directory
144
- end
145
- end
146
-
147
- #
148
- #
149
- def self.clear
150
- self.types = [] # TODO self.types = Types.new
151
- end
152
-
153
-
154
- def self.each &block
155
- types.each &block
156
- end
157
- def self.each_category &block
158
- each do |type|
159
- type.categories.each &block
160
- end
161
- end
162
- def self.each_bundle
163
- each_category do |category|
164
- yield category.exact, category.partial
165
- end
166
- end
167
-
168
- def self.add type
169
- self.type_mapping ||= {}
170
- self.types ||= []
171
-
172
- self.type_mapping[type.name] = type
173
- self.types << type
174
- end
175
- def self.[] type_name
176
- self.type_mapping[type_name]
177
- end
178
-
179
- end
@@ -1 +0,0 @@
1
- require File.expand_path '../../ext/ruby19/performant', __FILE__