Sha256: b9411271a06efb279d3aef6fad8ee41f0123a84a9f317f80a1c04873cba3ed1b
Contents?: true
Size: 1.15 KB
Versions: 2
Compression:
Stored size: 1.15 KB
Contents
require 'fileutils' module Miso module Commands class UsageError < RuntimeError; end class New def initialize(path, options = {}) path.nil? && (raise UsageError.new('path not specified')) fail("#{path} already exists") if File.exist?(path) @path = path @options = options end def template_root File.expand_path('../../template', File.dirname(__FILE__)) end def copy_template(src, dest) FileUtils.cp(File.join(template_root, src), dest) end def copy_templates(templates) templates.each { |src, dest| copy_template(src, dest) } end def make_directories %w[_app/miso _site].each do |dir| FileUtils.mkdir_p(File.join(@path, dir)) end end def execute make_directories templates = { 'config.ru' => "#{@path}/config.ru", '_app/miso/config.ru' => "#{@path}/_app/miso/config.ru", '_app/miso/miso.erb' => "#{@path}/_app/miso/miso.erb", '_site/index.html' => "#{@path}/_site/index.html" } copy_templates(templates) end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
misosoup-0.1.1 | lib/miso/commands.rb |
misosoup-0.1.0 | lib/miso/commands.rb |