Module: RubyUiScaffold::ComponentInstaller
- Included in:
- Generators::InstallGenerator, Generators::ScaffoldGenerator
- Defined in:
- lib/ruby_ui_scaffold/component_installer.rb
Overview
Shared helpers for generators that install ruby_ui components. Mixed into both the install generator (base set) and the scaffold generator (column/flag-specific set). Relies on the including class exposing ‘destination_root` (every Rails generator does).
Instance Method Summary collapse
-
#component_installed?(name) ⇒ Boolean
A ruby_ui component is considered installed once its package directory (or single-file component) exists under app/components/ruby_ui/.
-
#uninstalled_components(names) ⇒ Object
The subset of ‘names` not yet installed, preserving order.
Instance Method Details
#component_installed?(name) ⇒ Boolean
A ruby_ui component is considered installed once its package directory (or single-file component) exists under app/components/ruby_ui/. Guarding on this is essential: ‘ruby_ui:component` copies files WITHOUT –force, so re-installing a present component prompts interactively — which would hang a non-interactive subprocess.
14 15 16 17 |
# File 'lib/ruby_ui_scaffold/component_installer.rb', line 14 def component_installed?(name) base = File.join(destination_root, "app/components/ruby_ui", name) Dir.exist?(base) || File.exist?("#{base}.rb") end |
#uninstalled_components(names) ⇒ Object
The subset of ‘names` not yet installed, preserving order.
20 21 22 |
# File 'lib/ruby_ui_scaffold/component_installer.rb', line 20 def uninstalled_components(names) names.reject { |name| component_installed?(name) } end |