]> source.dussan.org Git - redmine.git/commitdiff
Refactor: Simplify the code (#38707).
authorGo MAEDA <maeda@farend.jp>
Fri, 6 Oct 2023 06:14:37 +0000 (06:14 +0000)
committerGo MAEDA <maeda@farend.jp>
Fri, 6 Oct 2023 06:14:37 +0000 (06:14 +0000)
Patch by Nishida Yuya.

git-svn-id: https://svn.redmine.org/redmine/trunk@22329 e93f8b46-1217-0410-a6f0-8f06a7374b81

config/routes.rb

index 3bc012a3e12d4049212812c453b06b560901ddf2..6176fdfaeef31104041fff09df8c786e90b9b345 100644 (file)
@@ -404,15 +404,11 @@ Rails.application.routes.draw do
 
   get 'robots', :to => 'welcome#robots'
 
-  Dir.glob(File.expand_path("#{Redmine::Plugin.directory}/*")).sort.each do |plugin_dir|
-    file = File.join(plugin_dir, "config/routes.rb")
-    if File.exist?(file)
-      begin
-        instance_eval File.read(file)
-      rescue SyntaxError, StandardError => e
-        puts "An error occurred while loading the routes definition of #{File.basename(plugin_dir)} plugin (#{file}): #{e.message}."
-        exit 1
-      end
-    end
+  Redmine::Plugin.directory.glob("*/config/routes.rb").sort.each do |plugin_routes_path|
+    instance_eval(plugin_routes_path.read, plugin_routes_path.to_s)
+  rescue SyntaxError, StandardError => e
+    plugin_name = plugin_routes_path.parent.parent.basename.to_s
+    puts "An error occurred while loading the routes definition of #{plugin_name} plugin (#{plugin_routes_path}): #{e.message}."
+    exit 1
   end
 end