class Pakyow::Generator

Base class for generators.

Attributes

files[R]

Public Class Methods

new(source_path) click to toggle source
# File lib/pakyow/generator.rb, line 32
def initialize(source_path)
  @files = Dir.glob(::File.join(source_path, "**/*")).reject { |path|
    ::File.directory?(path)
  }.map { |path|
    File.new(path, source_path, context: self)
  }
end

Public Instance Methods

generate(destination_path, options) click to toggle source
# File lib/pakyow/generator.rb, line 40
def generate(destination_path, options)
  @destination_path = destination_path

  performing :generate do
    FileUtils.mkdir_p(destination_path)

    @files.each do |file|
      file.generate(destination_path, options)
    end
  end
end
run(command, message:) click to toggle source
# File lib/pakyow/generator.rb, line 52
def run(command, message:)
  Support::CLI::Runner.new(message: message).run(
    "cd #{@destination_path} && #{command}"
  )
end