Skip to content
This repository
tree: 0d5d8031d0
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 285 lines (234 sloc) 8.053 kb
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
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 filename_without_rb
        Kernel.load File.join(File.dirname(__FILE__), "#{filename_without_rb}.rb")
      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 internal parts of the framework.
      # (Not for the user)
      #
      def load_framework_internals
        # Load compiled C code.
        #
        require_relative '../performant'

        # Load extensions.
        #
        load_relative 'extensions/object'
        load_relative 'extensions/array'
        load_relative 'extensions/symbol'
        load_relative 'extensions/string'
        load_relative 'extensions/module'
        load_relative 'extensions/class'
        load_relative 'extensions/hash'

        # Requiring Helpers
        #
        load_relative 'helpers/measuring'
        load_relative 'helpers/indexing'

        # Extension Modules
        #
        load_relative 'pool'

        # Calculations.
        #
        load_relative 'calculations/location'

        # Index generation strategies.
        #
        load_relative 'indexers/base'
        load_relative 'indexers/serial'
        load_relative 'indexers/parallel'

        # Generators.
        #
        load_relative 'generators/strategy'

        # Partial index generation strategies.
        #
        load_relative 'generators/partial/strategy'
        load_relative 'generators/partial/none'
        load_relative 'generators/partial/substring'
        load_relative 'generators/partial/postfix'
        load_relative 'generators/partial/infix'
        load_relative 'generators/partial/default'

        # Weight index generation strategies.
        #
        load_relative 'generators/weights/strategy'
        load_relative 'generators/weights/stub'
        load_relative 'generators/weights/dynamic'
        load_relative 'generators/weights/constant'
        load_relative 'generators/weights/logarithmic'
        load_relative 'generators/weights/default'

        # Similarity index generation strategies.
        #
        load_relative 'generators/similarity/strategy'
        load_relative 'generators/similarity/none'
        load_relative 'generators/similarity/phonetic'
        load_relative 'generators/similarity/metaphone'
        load_relative 'generators/similarity/double_metaphone'
        load_relative 'generators/similarity/soundex'
        load_relative 'generators/similarity/default'

        # Index store handling.
        #
        load_relative 'backends/helpers/file'
        load_relative 'backends/backend'

        load_relative 'backends/prepared/text'

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

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

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

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

        # Indexing and Indexed things.
        #
        load_relative 'bundle'
        load_relative 'bundle_indexing'
        load_relative 'bundle_indexed'
        load_relative 'bundle_realtime'

        # Wrappers.
        #
        load_relative 'category/location'

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

        # Tokens.
        #
        load_relative 'query/token'
        load_relative 'query/tokens'

        # Query combinations, qualifiers, weigher.
        #
        load_relative 'query/combination'
        load_relative 'query/combinations'

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

        load_relative 'query/qualifier_category_mapper'

        load_relative 'query/boosts'

        load_relative 'query/indexes'
        load_relative 'query/indexes_check'
      end
      # Loads the user interface parts.
      #
      def load_user_interface
        # Load API parts.
        #
        load_relative 'api/tokenizer'
        load_relative 'api/tokenizer/character_substituter'
        load_relative 'api/source'
        load_relative 'api/category/weight'
        load_relative 'api/category/partial'
        load_relative 'api/category/similarity'
        load_relative 'api/search/boost'
        
        # Loggers.
        #
        load_relative 'loggers/silent'
        load_relative 'loggers/concise'
        load_relative 'loggers/verbose'
        load_relative 'loggers/default'

        # Tokenizer.
        #
        load_relative 'tokenizer'

        # Load harakiri.
        #
        load_relative 'rack/harakiri'

        # Character Substituters
        #
        load_relative 'character_substituters/west_european'

        # Convenience accessors for generators.
        #
        load_relative 'generators/aliases'

        # API.
        #
        load_relative 'category'
        load_relative 'category_indexed'
        load_relative 'category_indexing'
        load_relative 'category_realtime'
        load_relative 'category_convenience'

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

        load_relative 'indexes'
        load_relative 'indexes_indexed'
        load_relative 'indexes_indexing'
        load_relative 'indexes_convenience'

        load_relative 'index'
        load_relative 'index_indexed'
        load_relative 'index_indexing'
        load_relative 'index_realtime'
        load_relative 'index_facets'
        load_relative 'index_convenience'

        # Results.
        #
        load_relative 'results'
        load_relative 'results/exact_first'

        # Search.
        #
        load_relative 'search'
        load_relative 'search_facets'

        # Interfaces
        #
        load_relative 'interfaces/live_parameters/master_child'
        load_relative 'interfaces/live_parameters/unicorn'

        # Load tools. Load specifically?
        #
        load_relative 'scheduler'

        # Load migration notices.
        #
        load_relative 'migrations/from_30_to_31'
      end

      # Loads the framework.
      #
      def load_framework
        load_framework_internals
        load_user_interface
      end

    end

  end

end
Something went wrong with that request. Please try again.