Class: EasyHtmlGenerator::Generator::Combine

Inherits:
Base
  • Object
show all
Defined in:
lib/easy_html_generator/generator/combine.rb

Overview

this generator combines files in the dist folder

Instance Attribute Summary

Attributes inherited from Base

#config

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

Instance Method Details

#do_config(config) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/easy_html_generator/generator/combine.rb', line 19

def do_config(config)
  target_file = resolve_path_prefix(config.file, @project.dist_path)
  o = ''
  config.files.each do |file_pattern|
    resolved_pattern = resolve_path_prefix(file_pattern, @project.dist_path)
    Dir[resolved_pattern].each do |file|
      next if target_file == file
      o += File.read(file) + "\n"
    end
  end
  File.write(target_file, o)
end

#generateObject



9
10
11
12
13
14
15
16
17
# File 'lib/easy_html_generator/generator/combine.rb', line 9

def generate
  return unless @config.enabled

  log_running

  @config.packages.each do |config|
    do_config config
  end
end