Sha256: 435297b1c03d91d1f549582a782777172e7d0df8287030c722815d6d6590b603

Contents?: true

Size: 990 Bytes

Versions: 3

Compression:

Stored size: 990 Bytes

Contents

# frozen_string_literal: true

module Specimen
  module Generator
    class ProjectGeneratorBase < GeneratorBase
      argument :config

      no_commands do
        def root_path
          @root_path ||= config[:root_path]
        end

        def create_directories(dirs, destination_path = root_path)
          empty_directory(destination_path)

          inside destination_path do
            dirs.each { |dir| empty_directory(dir) }
          end
        end

        def create_files_by_templates(templates_dir, templates = [], destination_path = root_path)
          template_paths = templates.map { |template| "#{templates_dir}/#{template}" }

          template_paths.each do |template|
            file_destination = template.gsub(templates_dir, '').delete_prefix('/')
            file_destination_path = "#{destination_path}/#{file_destination}"

            create_file_by_template(template, file_destination_path, config)
          end
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
specimen-0.0.4.alpha lib/specimen/generator/project_generator_base.rb
specimen-0.0.3.alpha lib/specimen/generator/project_generator_base.rb
specimen-0.0.2.alpha lib/specimen/generator/project_generator_base.rb