lib/jsroutes_middleware.rb
# Check if routes.js should be regenerated.
# ONLY REGENERATE when these conditions are met:
#
# # Cache file doesn't exist
# # Route files and cache size are different (files were removed/added)
# # Routes file has been updated
#
Check if routes.js should be regenerated.
ONLY REGENERATE when these conditions are met.

Cache file doesn't exist
Route files and cache size are different (files were removed/added)
Routes file has been updated
Check if routes . js should be regenerated . ONLY REGENERATE when these conditions are met . Cache file doesn ' t exist Route files and cache size are different ( files were removed / added ) Routes file has been updated
def verify_route_files!
      valid_cache = []
      new_cache = {}
      valid_cache.push(cache_path.exist?)
      valid_cache.push(@route_files.uniq.size == cache.size)
      @route_files.each do |path|
        changed_at = File.mtime(path).to_i
        valid_cache.push(changed_at == cache[path])
        new_cache[path] = changed_at
      end
      return if valid_cache.all?
      save_cache(new_cache)
      JsRoutes.generate!
    end
def verify_route_files! valid_cache = [ ] new_cache = { } valid_cache . push ( cache_path . exist? ) valid_cache . push ( @route_files . uniq . size == cache . size ) @route_files . each do | path | changed_at = File . mtime ( path ) . to_i valid_cache . push ( changed_at == cache [ path ] ) new_cache [ path ] = changed_at end return if valid_cache . all? save_cache ( new_cache ) JsRoutes . generate! end
Check if routes.js should be regenerated.
Check if routes . js should be regenerated .