Class: Senren::Rails::ComponentCopier
- Inherits:
-
Object
- Object
- Senren::Rails::ComponentCopier
- Defined in:
- lib/senren/rails/component_copier.rb
Overview
Copies component files from the gem’s templates/ tree into the host Rails app, and updates .senren/installed_components.yml.
Instance Attribute Summary collapse
-
#paths ⇒ Object
readonly
Returns the value of attribute paths.
-
#registry ⇒ Object
readonly
Returns the value of attribute registry.
-
#stdout ⇒ Object
readonly
Returns the value of attribute stdout.
Instance Method Summary collapse
-
#initialize(registry: Registry.load!, paths: HostPaths.new, stdout: $stdout) ⇒ ComponentCopier
constructor
A new instance of ComponentCopier.
-
#install(component_names, client_override: nil, force: false) ⇒ Object
Installs a list of components (with deps), respecting the override flag.
Constructor Details
#initialize(registry: Registry.load!, paths: HostPaths.new, stdout: $stdout) ⇒ ComponentCopier
Returns a new instance of ComponentCopier.
14 15 16 17 18 |
# File 'lib/senren/rails/component_copier.rb', line 14 def initialize(registry: Registry.load!, paths: HostPaths.new, stdout: $stdout) @registry = registry @paths = paths @stdout = stdout end |
Instance Attribute Details
#paths ⇒ Object (readonly)
Returns the value of attribute paths.
12 13 14 |
# File 'lib/senren/rails/component_copier.rb', line 12 def paths @paths end |
#registry ⇒ Object (readonly)
Returns the value of attribute registry.
12 13 14 |
# File 'lib/senren/rails/component_copier.rb', line 12 def registry @registry end |
#stdout ⇒ Object (readonly)
Returns the value of attribute stdout.
12 13 14 |
# File 'lib/senren/rails/component_copier.rb', line 12 def stdout @stdout end |
Instance Method Details
#install(component_names, client_override: nil, force: false) ⇒ Object
Installs a list of components (with deps), respecting the override flag. Returns the ordered list of component names actually installed.
22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/senren/rails/component_copier.rb', line 22 def install(component_names, client_override: nil, force: false) wanted = registry.dependencies(*component_names) paths.ensure_dirs! wanted.each do |name| comp = registry.fetch(name) install_component(comp, client_override: client_override, force: force) end update_installed_ledger(wanted, client_override: client_override) wanted end |