Class: Boostx::Core::Builder
- Inherits:
-
Object
- Object
- Boostx::Core::Builder
- Defined in:
- lib/boostx/core/builder.rb
Instance Method Summary collapse
- #init(project_name) ⇒ Object
- #make_dir(folder_name) ⇒ Object
- #make_file(file_name, path = Dir.pwd, extension = '.rb', content = nil) ⇒ Object
Instance Method Details
#init(project_name) ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/boostx/core/builder.rb', line 35 def init(project_name) directions = ['lib', "lib/#{project_name}"] directions.each do |dir| self.make_dir(dir) end make_file('Gemfile', Dir.pwd, '') create_yaml(project_name) create_module(project_name) end |
#make_dir(folder_name) ⇒ Object
13 14 15 |
# File 'lib/boostx/core/builder.rb', line 13 def make_dir(folder_name) FileUtils::mkdir_p folder_name end |
#make_file(file_name, path = Dir.pwd, extension = '.rb', content = nil) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/boostx/core/builder.rb', line 17 def make_file(file_name, path = Dir.pwd, extension = '.rb', content = nil) unless File.directory?(path) self.make_dir(path) end if path != Dir.pwd path << '/' else path = '' end path << "#{file_name}#{extension}" new_file = File.new(path, 'w') new_file.write(content) unless content.nil? new_file.close end |