module AutoRest # This is a require "replacement" to easily chain directories to the required file. # Pass a list of directories and a final filename. # First parameter should always be __FILE__, as the method is intented to be # used to load a file that is located in a directory relative to the one you are # standing. def ar_require_relative *args path= File.dirname(args.shift) args.each { |arg| path= File.join(path, arg) } require path end module_function :ar_require_relative end #------------------------------------------------------------------------------- # Various "Patches". #------------------------------------------------------------------------------- # Array permutations addon to Array class. Used on rails resources patch. AutoRest.ar_require_relative __FILE__, 'base_ruby', 'array_perm.rb' # This is a *very* simple patch to class ActionController::Resources::Resource # that rails usec to process routes.rb. # The patch replaces the constructor of that class so the objects generated are # stored in a special container class AutoRest::RailsResources instead of # forgetting about them (the current rails behavior) AutoRest.ar_require_relative __FILE__, 'patches', 'rails', 'rails_resources.rb' # Allows usage of link_to_remote instead of link_to in will_paginate to enable # ajax pagination. AutoRest.ar_require_relative __FILE__, 'patches', 'will_paginate', 'patch.rb' # Not really a patch but an addon method to allow pagination of ferret search # results AutoRest.ar_require_relative __FILE__, 'patches', 'acts_as_ferret', 'ferret_will_paginate.rb' #------------------------------------------------------------------------------- # Main entry point #------------------------------------------------------------------------------- AutoRest.ar_require_relative __FILE__, 'components', 'main.rb' #------------------------------------------------------------------------------- # Loads Rspec Helpers #------------------------------------------------------------------------------- AutoRest.ar_require_relative __FILE__, 'rspec_helpers', 'specs_helper.rb' #------------------------------------------------------------------------------- # If loaded as a gem, this code will be executed before the routes are drawed. # but AutoRest Needs Routes to be drawed before configuring the plugin, # so I clear anything that may be loaded in AutoRest::RailsResources and reload the routes. AutoRest::RailsResources.clear ActionController::Routing::Routes.reload