class Makanai::Generator
Constants
- APP_TEMPLATE
- DIRECTORY_NAMES
- GEMFILE_TEMPLATE
- RAKEFILE_TEMPLATE
- ROOT_PATH
Attributes
path[R]
Public Class Methods
new(path = Dir.pwd)
click to toggle source
# File lib/makanai/generator.rb, line 15 def initialize(path = Dir.pwd) @path = path end
Public Instance Methods
create_app_directories(directory_names = DIRECTORY_NAMES)
click to toggle source
# File lib/makanai/generator.rb, line 21 def create_app_directories(directory_names = DIRECTORY_NAMES) directory_names.map do |name| dir_path = File.join(path, name) Dir.mkdir(dir_path) file_path = File.join(dir_path, '.keep') create_file(file_path, nil) file_path end end
create_app_rb(template = APP_TEMPLATE)
click to toggle source
# File lib/makanai/generator.rb, line 31 def create_app_rb(template = APP_TEMPLATE) File.join(path, 'app.rb').tap do |file_path| create_file(file_path, ERB.new(template).result) end end
create_gemfile(template = GEMFILE_TEMPLATE)
click to toggle source
# File lib/makanai/generator.rb, line 43 def create_gemfile(template = GEMFILE_TEMPLATE) File.join(path, 'Gemfile').tap do |file_path| create_file(file_path, ERB.new(template).result) end end
create_rakefile(template = RAKEFILE_TEMPLATE)
click to toggle source
# File lib/makanai/generator.rb, line 37 def create_rakefile(template = RAKEFILE_TEMPLATE) File.join(path, 'Rakefile').tap do |file_path| create_file(file_path, ERB.new(template).result) end end
Private Instance Methods
create_file(file_path, content)
click to toggle source
# File lib/makanai/generator.rb, line 51 def create_file(file_path, content) File.open(file_path, 'w') { |f| f.puts content } end