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.
Instance Method Summary collapse
Methods inherited from Base
#enabled?, #file_changed?, #generate, #initialize, #log, #log_running, #repetitive?, #store_file_hash, #tasks
Constructor Details
This class inherits a constructor from EasyHtmlGenerator::Generator::Base
Class Method Details
.copy(input_file, output_file) ⇒ Object
30 31 32 33 34 35 36 |
# File 'lib/easy_html_generator/generator/copy.rb', line 30 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
16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/easy_html_generator/generator/copy.rb', line 16 def self.copy_r(src_path, dest_path, selector) return unless File.exist? src_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) FileUtils.mkdir_p File.dirname(output_file) copy(input_file, output_file) end end |
Instance Method Details
#generate!(config) ⇒ Object
9 10 11 12 13 |
# File 'lib/easy_html_generator/generator/copy.rb', line 9 def generate!(config) selector = config.key?(:selector) ? config[:selector] : '**/*' self.class.copy_r(config.source, config.target, selector) end |