diff --git a/lib/vmdb/plugins.rb b/lib/vmdb/plugins.rb index 1912834df6a..9d02ffa2943 100644 --- a/lib/vmdb/plugins.rb +++ b/lib/vmdb/plugins.rb @@ -7,8 +7,8 @@ class Plugins include Enumerable - def self.method_missing(m, ...) - instance.respond_to?(m) ? instance.send(m, ...) : super + def self.method_missing(meth, ...) + instance.respond_to?(meth) ? instance.send(meth, ...) : super end def self.respond_to_missing?(*args) @@ -30,8 +30,8 @@ def init end def details - each_with_object({}) do |engine, hash| - hash[engine] = { + index_with do |engine| + { :name => engine.name, :version => version(engine), :path => engine.root.to_s @@ -70,13 +70,11 @@ def ansible_content # Ansible content (playbooks and roles) for internal use by provider plugins, # not exposed to Automate, and to be run by ansible_runner def ansible_runner_content - @ansible_runner_content ||= begin - map do |engine| - content_dir = engine.root.join("content", "ansible_runner") - next unless File.exist?(content_dir.join("roles/requirements.yml")) + @ansible_runner_content ||= filter_map do |engine| + content_dir = engine.root.join("content", "ansible_runner") + next unless File.exist?(content_dir.join("roles/requirements.yml")) - [engine, content_dir] - end.compact + [engine, content_dir] end end @@ -96,7 +94,7 @@ def automate_domains end def miq_widgets_content - @miq_widgets_content ||= Dir.glob(Rails.root.join("product/dashboard/widgets/*")) + flat_map { |engine| content_directories(engine, "dashboard/widgets") } + @miq_widgets_content ||= Rails.root.join("product/dashboard/widgets").glob("*").map(&:to_s) + flat_map { |engine| content_directories(engine, "dashboard/widgets") } end def provider_plugins @@ -110,7 +108,7 @@ def ui_plugins def asset_paths @asset_paths ||= begin require_relative 'plugins/asset_path' - map { |engine| AssetPath.new(engine) if AssetPath.asset_path?(engine) }.compact + filter_map { |engine| AssetPath.new(engine) if AssetPath.asset_path?(engine) } end end @@ -122,9 +120,7 @@ def server_role_paths end def systemd_units - @systemd_units ||= begin - flat_map { |engine| engine.root.join("systemd").glob("*.*") } - end + @systemd_units ||= flat_map { |engine| engine.root.join("systemd").glob("*.*") } end def load_inflections