Class: RubyCms::FileInstaller
- Inherits:
-
Object
- Object
- RubyCms::FileInstaller
- Defined in:
- lib/ruby_cms/file_installer.rb
Overview
Copies the template files belonging to a set of modules into a host app.
Instance Method Summary collapse
-
#initialize(templates_root:, app_root:) ⇒ FileInstaller
constructor
A new instance of FileInstaller.
-
#install(modules) ⇒ Object
modules: array of Manifest::Module.
Constructor Details
#initialize(templates_root:, app_root:) ⇒ FileInstaller
Returns a new instance of FileInstaller.
10 11 12 13 |
# File 'lib/ruby_cms/file_installer.rb', line 10 def initialize(templates_root:, app_root:) @templates_root = Pathname.new(templates_root) @app_root = Pathname.new(app_root) end |
Instance Method Details
#install(modules) ⇒ Object
modules: array of Manifest::Module. Returns array of app-relative paths written.
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/ruby_cms/file_installer.rb', line 16 def install(modules) written = [] modules.flat_map(&:files).uniq.each do |template_glob| (template_glob).each do |template_rel| src = @templates_root.join(template_rel) next unless src.file? dest = @app_root.join(PathMap.to_app(template_rel)) FileUtils.mkdir_p(dest.dirname) FileUtils.cp(src, dest) written << dest.relative_path_from(@app_root).to_s end end written end |