Class: RubyCoded::Commands::Catalog
- Inherits:
-
Object
- Object
- RubyCoded::Commands::Catalog
- Defined in:
- lib/ruby_coded/commands/catalog.rb
Overview
Merges core, plugin, and markdown commands into a single catalog. rubocop:disable Metrics/ClassLength
Constant Summary collapse
- SOURCE_PRIORITY =
{ markdown: 1, plugin: 2, core: 3 }.freeze
Instance Method Summary collapse
- #all_definitions ⇒ Object
- #command_descriptions ⇒ Object
- #command_map ⇒ Object
- #definitions_for_source(source) ⇒ Object
- #find(name) ⇒ Object
-
#initialize(project_root:, plugin_registry:) ⇒ Catalog
constructor
A new instance of Catalog.
- #last_reload_report ⇒ Object
- #reload! ⇒ Object
Constructor Details
#initialize(project_root:, plugin_registry:) ⇒ Catalog
Returns a new instance of Catalog.
18 19 20 21 22 |
# File 'lib/ruby_coded/commands/catalog.rb', line 18 def initialize(project_root:, plugin_registry:) @project_root = project_root @plugin_registry = plugin_registry @last_reload_report = nil end |
Instance Method Details
#all_definitions ⇒ Object
24 25 26 |
# File 'lib/ruby_coded/commands/catalog.rb', line 24 def all_definitions merged.values.sort_by { |definition| definition.name.downcase } end |
#command_descriptions ⇒ Object
32 33 34 |
# File 'lib/ruby_coded/commands/catalog.rb', line 32 def command_descriptions all_definitions.to_h { |definition| [definition.name, definition.description] } end |
#command_map ⇒ Object
28 29 30 |
# File 'lib/ruby_coded/commands/catalog.rb', line 28 def command_map all_definitions.filter_map { |definition| command_pair(definition) }.to_h end |
#definitions_for_source(source) ⇒ Object
40 41 42 |
# File 'lib/ruby_coded/commands/catalog.rb', line 40 def definitions_for_source(source) all_definitions.select { |definition| definition.source == source } end |
#find(name) ⇒ Object
36 37 38 |
# File 'lib/ruby_coded/commands/catalog.rb', line 36 def find(name) merged[name.downcase] end |
#last_reload_report ⇒ Object
51 52 53 |
# File 'lib/ruby_coded/commands/catalog.rb', line 51 def last_reload_report @last_reload_report || default_reload_report end |
#reload! ⇒ Object
44 45 46 47 48 49 |
# File 'lib/ruby_coded/commands/catalog.rb', line 44 def reload! previous_markdown_names = cached_markdown_names clear_cached_reports! current_markdown_names = markdown_names @last_reload_report = build_reload_report(previous_markdown_names, current_markdown_names) end |