Class: Moku6::Initializer
- Inherits:
-
Object
- Object
- Moku6::Initializer
- Defined in:
- lib/moku6/initializer.rb
Overview
Backs ‘moku6 init`. Copies templates/init into ./ (never overwrites existing files).
Constant Summary collapse
- TEMPLATE_DIR =
: String
File.("../../templates/init", __dir__.to_s)
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Initializer
constructor
: (?Hash[Symbol, untyped] options) -> void.
-
#run ⇒ Object
: () -> void.
Constructor Details
#initialize(options = {}) ⇒ Initializer
: (?Hash[Symbol, untyped] options) -> void
15 16 17 18 |
# File 'lib/moku6/initializer.rb', line 15 def initialize( = {}) @options = @dest_root = Dir.pwd end |
Instance Method Details
#run ⇒ Object
: () -> void
21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/moku6/initializer.rb', line 21 def run entries.each do |src| rel = src.delete_prefix("#{TEMPLATE_DIR}/") dest = File.join(@dest_root, rel) if File.exist?(dest) puts "skip (exists): #{rel}" next end FileUtils.mkdir_p(File.dirname(dest)) FileUtils.cp(src, dest) puts "create: #{rel}" end end |