module Aladdin::Commands::New

@example

$> aladdin new path/to/lesson/root

Constants

COPY_FLAGS

Flags for {::FileUtils.cp_r}

DOT_FILES

Array of dot files to be copied over and renamed.

FILES

Array of skeleton files to be copied over.

Public Instance Methods

copy_files(dest, flags={}) click to toggle source

Copies skeleton files to given destination. @param [String] dest destination path @param [Hash] flags options for {::FileUtils.cp_r} @return [Void]

# File lib/aladdin/commands/new.rb, line 27
def copy_files(dest, flags={})
  flags = COPY_FLAGS.merge flags
  paths = FILES.map { |file| path_to file }
  FileUtils.cp_r paths, dest, flags
  DOT_FILES.each do |file|
    FileUtils.cp_r path_to(file), File.join(dest, '.' + file), flags
  end
end
new(argv=ARGV, opts={}) click to toggle source
# File lib/aladdin/commands/new.rb, line 56
def new(argv=ARGV, opts={})
  New.parse! argv
  New.copy_files(argv[0] || Dir.pwd, opts)
end
parse!(argv) click to toggle source

Parses the command line arguments. @param [Array] argv command line arguments @return [Void]

# File lib/aladdin/commands/new.rb, line 46
def parse!(argv)
  opt_parser = OptionParser.new do |opts|
    opts.banner = "Usage: aladdin new [options] [LESSON_PATH]"
  end
  opt_parser.parse! argv
end
path_to(file) click to toggle source

Prefixes file with the skeleton directory. @param [String] file name of file to resolve @return [String] path

# File lib/aladdin/commands/new.rb, line 39
def path_to(file)
  File.expand_path file, Aladdin::PATHS.skeleton
end