class Blueprint::Generator::Base
Attributes
config[R]
name[R]
Public Class Methods
new(name:)
click to toggle source
# File lib/blueprint/generator/base.rb, line 8 def initialize(name:) @name = name @config = {} end
template_path()
click to toggle source
# File lib/blueprint/generator/base.rb, line 18 def self.template_path '' end
Public Instance Methods
run!()
click to toggle source
# File lib/blueprint/generator/base.rb, line 13 def run! ask_questions execute end
Private Instance Methods
ask_questions()
click to toggle source
# File lib/blueprint/generator/base.rb, line 24 def ask_questions end
cd_path(path)
click to toggle source
# File lib/blueprint/generator/base.rb, line 49 def cd_path(path) cmd_title("Cnahge the current directory to #{path}") FileUtils.cd(path) end
cmd_title(title)
click to toggle source
# File lib/blueprint/generator/base.rb, line 58 def cmd_title(title) puts puts title puts end
copy_file(from, to = nil)
click to toggle source
# File lib/blueprint/generator/base.rb, line 35 def copy_file(from, to = nil) cmd_title("Copy file #{from}") to = from if to.nil? FileUtils.cp(template_path + from, to) end
copy_file_from_template(from, to = nil)
click to toggle source
# File lib/blueprint/generator/base.rb, line 41 def copy_file_from_template(from, to = nil) cmd_title("Copy file #{from} from template") to = from if to.nil? template = TemplateRendering.new(name, config) template.save(template_path + from + '.erb', to) end
execute()
click to toggle source
# File lib/blueprint/generator/base.rb, line 27 def execute end
shell(cmd)
click to toggle source
# File lib/blueprint/generator/base.rb, line 30 def shell(cmd) cmd_title("Run #{cmd}") system(cmd) end
template_path()
click to toggle source
# File lib/blueprint/generator/base.rb, line 54 def template_path File.expand_path(File.dirname(__FILE__)) + '/templates/' + self.class.template_path + '/' end