class Microframe::Generator
Attributes
app_name[R]
name[R]
type[R]
xtras[R]
Public Class Methods
source_root()
click to toggle source
# File lib/microframe/application/generators/generator.rb, line 9 def self.source_root File.join(__dir__, "samples") end
Public Instance Methods
g(type, name, *xtras)
click to toggle source
# File lib/microframe/application/generators/generator.rb, line 37 def g(type, name, *xtras) invoke :generate, [type, name, *xtras] end
generate(type, name, *xtras)
click to toggle source
# File lib/microframe/application/generators/generator.rb, line 21 def generate(type, name, *xtras) @type = type.downcase @name = name.downcase @xtras ||= xtras if type == "controller" template("sample_controller.tt", File.join(target_root, "controllers", "#{name}_controller.rb")) create_views elsif type == "model" template("sample_model.tt", File.join(target_root, "models", "#{name}.rb")) elsif type == "view" create_views end end
new(name)
click to toggle source
# File lib/microframe/application/generators/generator.rb, line 14 def new(name) @app_name = name directory("app_sample", "#{app_name}") init_with_shell_cmds end
Private Instance Methods
create_views()
click to toggle source
# File lib/microframe/application/generators/generator.rb, line 47 def create_views empty_directory(File.join(target_root, "views", name)) xtras.each { |f| template("blank.tt", File.join(target_root, "views", name, "#{f}.html.erb")) } end
init_with_shell_cmds()
click to toggle source
# File lib/microframe/application/generators/generator.rb, line 52 def init_with_shell_cmds Dir.chdir(app_name) run "bundle install" run "git init" end
target_root()
click to toggle source
# File lib/microframe/application/generators/generator.rb, line 43 def target_root "app/" end