/
loader.rb
296 lines (254 loc) · 8.74 KB
/
loader.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
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
111
112
113
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
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
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
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
module Picky
# Loads the search engine and it
#
module Loader
class << self
# Reloads the whole app.
# First itself, then the app.
#
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
alias load reload
# Loads this file anew.
#
def load_self
Kernel.load __FILE__
end
# Load a file relative to this.
#
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 a user file.
#
def load_user filename
Kernel.load File.join(Picky.root, "#{filename}.rb")
end
# Load the user's application.
#
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
# Loads the compiled C code.
#
# Note: Picky already tries to compile
# when installing the gem.
#
def load_c_code
require_relative '../try_compile'
end
def load_extensions
load_relative 'extensions/object',
'extensions/array',
'extensions/symbol',
'extensions/string',
'extensions/module',
'extensions/class'
end
def load_helpers
load_relative 'helpers/measuring',
'helpers/indexing',
'helpers/identification',
'splitter'
end
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
# Loads the index store handling.
#
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
# Indexing and Indexed things.
#
def load_indexes
load_relative 'bundle',
'bundle_indexing',
'bundle_indexed',
'bundle_realtime'
end
# Index wrappers.
#
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
# Query combinations, qualifiers, weigher.
#
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
# Loads the internal parts of the framework.
# (Not for the user)
#
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
# All things API related.
#
def load_api
load_relative 'api/tokenizer/character_substituter',
'api/tokenizer/stemmer',
'api/search/boost'
end
def load_logging
load_relative 'loggers/silent',
'loggers/concise',
'loggers/verbose',
'loggers/default'
end
def load_generators
load_relative 'generators/weights'
load_relative 'generators/partial'
load_relative 'generators/similarity'
load_relative 'generators/aliases'
end
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
def load_results
load_relative 'results',
'results/exact_first'
end
def load_search
load_relative 'search',
'search_facets'
end
def load_interfaces
load_relative 'interfaces/live_parameters/master_child',
'interfaces/live_parameters/unicorn'
end
# Loads the user interface parts.
#
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
# Loads the framework.
#
def load_framework
load_framework_internals
load_user_interface
end
end
end
end