class GoGoGo::Project
Public Class Methods
new(name)
click to toggle source
# File gogogo.rb, line 12 def initialize(name) @name = name @underscored_name = @name.tr("-", "_") @constant_name = @name. gsub(/-[_-]*(?![_-]|$)/) { "::" }. gsub(/([_-]+|(::)|^)(.|$)/) { $2.to_s + $3.upcase } end
Public Instance Methods
create!()
click to toggle source
# File gogogo.rb, line 21 def create! template_path = File.expand_path("../template", __FILE__) # copy the template FileUtils.cp_r template_path, @name # rename the files FileUtils.mv( File.join(@name, "app.rb"), File.join(@name, "#{@underscored_name}.rb") ) # apply templates [ File.join(@name, "Guardfile"), File.join(@name, "#{@underscored_name}.rb"), ].each { |file| render_template_to_file file, binding } end
Private Instance Methods
render_template_to_file(template, context)
click to toggle source
# File gogogo.rb, line 42 def render_template_to_file(template, context) t = File.read(template) File.open(template, "w") do |f| f << ERB.new(t, nil, "-").result(context) end end