lib/evertils/router.rb in evertils-1.0.12 vs lib/evertils/router.rb in evertils-2.0.0

- old
+ new

@@ -10,16 +10,13 @@ # Prepare for routing def pre_exec @request = Request.new begin - # include the controller - require "evertils/controllers/#{@request.controller}" - # include helpers - require "evertils/helpers/#{@request.controller}" if File.exist? "evertils/helpers/#{@request.controller}" + update_config if uses_local_configuration? - update_config if uses_config_file? + require "evertils/controllers/#{@request.controller}" unless uses_local_configuration? # perform all required checks must_pass = Helper::Results.new @config.get(:required).each do |key, _| must_pass.add(send("verify_#{key}")) @@ -43,11 +40,10 @@ # Create object context and pass it the required command line arguments begin unless @request.controller.nil? controller = Evertils::Controller.const_get @request.controller.capitalize - controller = Evertils::Controller::Render if @config.exist?(:path) # create an instance of the requested controller context = controller.new(@config, @request) if context.can_exec? @request.command, @config @@ -68,10 +64,10 @@ rescue NameError => e Notify.error("#{e}\n#{e.backtrace.join("\n")}", show_time: false) end end - def uses_config_file? + def uses_local_configuration? @config_file_path = File.expand_path("~/.evertils/templates/type/#{@request.command}.yml") File.exist? @config_file_path end def update_config