class Zoku::Commands::New
Public Class Methods
new(target_path = '')
click to toggle source
Calls superclass method
# File lib/zoku/commands/new.rb, line 7 def initialize(target_path = '') super end
Public Instance Methods
init()
click to toggle source
# File lib/zoku/commands/new.rb, line 11 def init create_project customize_project #{}`git init --quiet && git add -A && \ #git commit -m \"Project setup with Zoku :paw_prints:\" --quiet` end
Private Instance Methods
create_project()
click to toggle source
# File lib/zoku/commands/new.rb, line 20 def create_project FileUtils.mkdir @target_path FileUtils.cd(@target_path) FileUtils.copy_entry "#{base_path}/templates/base", '.' end
customize_project()
click to toggle source
# File lib/zoku/commands/new.rb, line 26 def customize_project replacements = set_replacements Dir.glob("./**/*", File::FNM_DOTMATCH) do |file| next if file == '.' || file == '..' || File.directory?(file) text = File.read(file) replacements.each do |key, value| text.gsub!(key.to_s, value) end File.open(file, 'w') { |f| f.puts text } end end
set_replacements()
click to toggle source
# File lib/zoku/commands/new.rb, line 42 def set_replacements project_name = @target_path.to_s.dup { 'zoku_base' => Util.underscore(project_name), 'ZokuBase' => Util.classify(project_name), 'VERSION' => VERSION } end