Class: EasyHtmlGenerator::Generator::Copy
- Defined in:
- lib/easy_html_generator/generator/copy.rb
Overview
this generator copies files from src ro dist folder
Instance Attribute Summary
Attributes inherited from Base
Class Method Summary collapse
- .copy(input_file, output_file) ⇒ Object
-
.copy_r(src_path, dest_path, selector) ⇒ Object
cannot use copy_entry or cp_r with symbolic existent links in target FileUtils::copy_entry(src_dir, output_folder, true, false, true) if File.directory? src_dir.
Instance Method Summary collapse
Methods inherited from Base
#dest_path, #do_file, #do_input, #initialize, #input_to_output_file, #log, #log_running, #resolve_path_prefix, #should_do_file?, #src_path, #walk_files
Constructor Details
This class inherits a constructor from EasyHtmlGenerator::Generator::Base
Class Method Details
.copy(input_file, output_file) ⇒ Object
37 38 39 40 41 42 43 |
# File 'lib/easy_html_generator/generator/copy.rb', line 37 def self.copy(input_file, output_file) if File.directory? input_file FileUtils.mkdir_p(output_file) unless File.exist? output_file else FileUtils.copy input_file, output_file end end |
.copy_r(src_path, dest_path, selector) ⇒ Object
cannot use copy_entry or cp_r with symbolic existent links in target FileUtils::copy_entry(src_dir, output_folder, true, false, true) if File.directory? src_dir
23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/easy_html_generator/generator/copy.rb', line 23 def self.copy_r(src_path, dest_path, selector) return unless File.exist? src_path FileUtils.mkdir_p dest_path Dir[File.join(src_path, selector)].each do |input_file| next if input_file.empty? output_file = input_file.sub(src_path, dest_path) copy(input_file, output_file) end end |
Instance Method Details
#generate ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/easy_html_generator/generator/copy.rb', line 7 def generate return unless @config.enabled log_running @config.dirs.each do |config| src_path = resolve_path_prefix(config.source, @project.src_path) dest_path = resolve_path_prefix(config.target, @project.dist_path) self.class.copy_r(src_path, dest_path, config.selector) end end |