Module: Picky::Loader

Defined in:
lib/picky/loader.rb

Overview

Loads the search engine and it

Class Method Summary collapse

Class Method Details

.load_apiObject

All things API related.



203
204
205
206
207
# File 'lib/picky/loader.rb', line 203

def load_api
  load_relative 'api/tokenizer/character_substituter',
                'api/tokenizer/stemmer',
                'api/search/boost'
end

.load_application(file = 'app') ⇒ Object

Load the user’s application.



45
46
47
48
49
50
# File 'lib/picky/loader.rb', line 45

def load_application file = 'app'
  load_user file
rescue LoadError => e
  exclaim "\nBy default, Picky needs/loads the <Picky.root>/app.rb file as the app.\n\n"
  raise e
end

.load_c_codeObject

Loads the compiled C code.

Note: Picky already tries to compile when installing the gem.



57
58
59
# File 'lib/picky/loader.rb', line 57

def load_c_code
  require_relative '../try_compile'
end

.load_extensionsObject



60
61
62
63
64
65
66
67
# File 'lib/picky/loader.rb', line 60

def load_extensions
  load_relative 'extensions/object',
                'extensions/array',
                'extensions/symbol',
                'extensions/string',
                'extensions/module',
                'extensions/class'
end

.load_frameworkObject

Loads the framework.



289
290
291
292
# File 'lib/picky/loader.rb', line 289

def load_framework
  load_framework_internals
  load_user_interface
end

.load_framework_internalsObject

Loads the internal parts of the framework. (Not for the user)



185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
# File 'lib/picky/loader.rb', line 185

def load_framework_internals
  load_c_code
  load_extensions
  load_helpers
  load_relative 'pool'
  load_relative 'calculations/location' # Calculations
  load_index_generation_strategies
  load_index_stores
  load_indexes
  load_wrappers
  load_relative 'query/token' # Token related.
  load_relative 'query/tokens'
  load_relative 'query/or'
  load_query
end

.load_generatorsObject



216
217
218
219
220
221
# File 'lib/picky/loader.rb', line 216

def load_generators
  load_relative 'generators/weights'
  load_relative 'generators/partial'
  load_relative 'generators/similarity'
  load_relative 'generators/aliases'
end

.load_helpersObject



68
69
70
71
72
73
74
75
# File 'lib/picky/loader.rb', line 68

def load_helpers
  load_relative 'helpers/measuring',
                'helpers/indexing',
                'helpers/identification',
                'splitter',
                'optimizers',
                'optimizers/memory/array_deduplicator'
end

.load_index_generation_strategiesObject



76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
# File 'lib/picky/loader.rb', line 76

def load_index_generation_strategies
  load_relative 'indexers/base',
                'indexers/serial',
                'indexers/parallel'
  
  load_relative 'generators/strategy'
  
  # Partial index generation strategies.
  #
  load_relative 'generators/partial/strategy',
                'generators/partial/none',
                'generators/partial/substring',
                'generators/partial/postfix',
                'generators/partial/infix',
                'generators/partial/default'
  
  # Weight index generation strategies.
  #
  load_relative 'generators/weights/strategy',
                'generators/weights/stub',
                'generators/weights/dynamic',
                'generators/weights/constant',
                'generators/weights/logarithmic',
                'generators/weights/default'
  
  # Similarity index generation strategies.
  #
  load_relative 'generators/similarity/strategy',
                'generators/similarity/none',
                'generators/similarity/phonetic',
                'generators/similarity/metaphone',
                'generators/similarity/double_metaphone',
                'generators/similarity/soundex',
                'generators/similarity/default'
end

.load_index_storesObject

Loads the index store handling.



114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
# File 'lib/picky/loader.rb', line 114

def load_index_stores
  load_relative 'backends/helpers/file',
                'backends/backend'

  load_relative 'backends/prepared/text'

  load_relative 'backends/memory',
                'backends/memory/basic',
                'backends/memory/marshal',
                'backends/memory/json'

  load_relative 'backends/file',
                'backends/file/basic',
                'backends/file/json'

  load_relative 'backends/redis',
                'backends/redis/directly_manipulable',
                'backends/redis/basic',
                'backends/redis/list',
                'backends/redis/string',
                'backends/redis/float'

  load_relative 'backends/sqlite',
                'backends/sqlite/directly_manipulable',
                'backends/sqlite/basic',
                'backends/sqlite/array',
                'backends/sqlite/value',
                'backends/sqlite/string_key_array',
                'backends/sqlite/integer_key_array'
end

.load_indexesObject

Indexing and Indexed things.



147
148
149
150
151
152
# File 'lib/picky/loader.rb', line 147

def load_indexes
  load_relative 'bundle',
                'bundle_indexing',
                'bundle_indexed',
                'bundle_realtime'
end

.load_inner_apiObject



223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
# File 'lib/picky/loader.rb', line 223

def load_inner_api
  load_relative 'qualifier_mapper'
  
  load_relative 'category',
                'category_indexed',
                'category_indexing',
                'category_realtime',
                'category_convenience'

  load_relative 'categories',
                'categories_indexed',
                'categories_indexing',
                'categories_realtime',
                'categories_convenience'

  load_relative 'indexes',
                'indexes_indexed',
                'indexes_indexing',
                'indexes_convenience'
  
  load_relative 'index',
                'index_indexed',
                'index_indexing',
                'index_realtime',
                'index_facets',
                'index_convenience'
end

.load_interfacesObject



261
262
263
264
# File 'lib/picky/loader.rb', line 261

def load_interfaces
  load_relative 'interfaces/live_parameters/master_child',
                'interfaces/live_parameters/unicorn'
end

.load_loggingObject



209
210
211
212
213
214
# File 'lib/picky/loader.rb', line 209

def load_logging
  load_relative 'loggers/silent',
                'loggers/concise',
                'loggers/verbose',
                'loggers/default'
end

.load_queryObject

Query combinations, qualifiers, weigher.



168
169
170
171
172
173
174
175
176
177
178
179
180
# File 'lib/picky/loader.rb', line 168

def load_query
  load_relative 'query/combination',
                'query/combinations',
                'query/combination/or'

  load_relative 'query/allocation',
                'query/allocations'

  load_relative 'query/boosts'

  load_relative 'query/indexes',
                'query/indexes/check'
end

.load_relative(*filenames_without_rb) ⇒ Object

Load a file relative to this.



31
32
33
34
35
# File 'lib/picky/loader.rb', line 31

def load_relative *filenames_without_rb
  filenames_without_rb.each do |filename_without_rb|
    Kernel.load File.join(File.dirname(__FILE__), "#{filename_without_rb}.rb")
  end
end

.load_resultsObject



251
252
253
254
# File 'lib/picky/loader.rb', line 251

def load_results
  load_relative 'results',
                'results/exact_first'
end

.load_searchObject



256
257
258
259
# File 'lib/picky/loader.rb', line 256

def load_search
  load_relative 'search',
                'search_facets'
end

.load_selfObject

Loads this file anew.



25
26
27
# File 'lib/picky/loader.rb', line 25

def load_self
  Kernel.load __FILE__
end

.load_user(filename) ⇒ Object

Load a user file.



39
40
41
# File 'lib/picky/loader.rb', line 39

def load_user filename
  Kernel.load File.join(Picky.root, "#{filename}.rb")
end

.load_user_interfaceObject

Loads the user interface parts.



268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
# File 'lib/picky/loader.rb', line 268

def load_user_interface
  load_api
  load_logging
  load_relative 'source'
  load_relative 'tokenizer/regexp_wrapper'
  load_relative 'tokenizer'
  # load_relative 'rack/harakiri' # Needs to be explicitly loaded/required.
  load_relative 'character_substituters/base'
  load_relative 'character_substituters/west_european'
  load_relative 'character_substituters/polish'
  load_relative 'splitters/automatic'
  load_generators
  load_inner_api
  load_results
  load_search
  load_interfaces
  load_relative 'scheduler'
end

.load_wrappersObject

Index wrappers.



156
157
158
159
160
161
162
163
164
# File 'lib/picky/loader.rb', line 156

def load_wrappers
  load_relative 'category/location'

  load_relative 'wrappers/bundle/delegators',
                'wrappers/bundle/wrapper',
                'wrappers/bundle/calculation',
                'wrappers/bundle/location',
                'wrappers/bundle/exact_partial'
end

.reload(app_file = 'app') ⇒ Object Also known as: load

Reloads the whole app. First itself, then the app.



12
13
14
15
16
17
18
19
20
# File 'lib/picky/loader.rb', line 12

def reload app_file = 'app'
  Dir.chdir Picky.root
  exclaim 'Reloading loader.'
  load_self
  exclaim 'Reloading framework.'
  load_framework
  exclaim "Reloading application in #{File.expand_path(app_file)}."
  load_application app_file
end