Class: Cuba::Generator
- Inherits:
-
Object
- Object
- Cuba::Generator
- Defined in:
- lib/cuba/generator.rb,
lib/cuba/generator/version.rb
Constant Summary collapse
- APPROOT =
File.(File.dirname(__FILE__))
- VERSION =
"0.0.7"
Instance Method Summary collapse
- #create_config_file ⇒ Object
- #create_cuba_file ⇒ Object
- #create_database_file ⇒ Object
- #create_dir ⇒ Object
-
#initialize(name, type) ⇒ Generator
constructor
A new instance of Generator.
Constructor Details
#initialize(name, type) ⇒ Generator
Returns a new instance of Generator.
10 11 12 13 14 15 16 17 |
# File 'lib/cuba/generator.rb', line 10 def initialize(name, type) @project_name = name.downcase @type = type create_dir create_config_file create_cuba_file puts "Created your Cuba #{@type} at /#{@project_name} directory. Rock on!" end |
Instance Method Details
#create_config_file ⇒ Object
23 24 25 26 27 |
# File 'lib/cuba/generator.rb', line 23 def create_config_file File.open("./#{@project_name}/config.ru", 'w+') do |file| file.write setup_config end end |
#create_cuba_file ⇒ Object
29 30 31 32 33 |
# File 'lib/cuba/generator.rb', line 29 def create_cuba_file File.open("./#{@project_name}/#{@project_name}.rb", 'w+') do |file| file.write setup_cuba end end |
#create_database_file ⇒ Object
35 36 37 38 39 40 41 42 |
# File 'lib/cuba/generator.rb', line 35 def create_database_file File.open("./#{@project_name}/database.rb", 'w+') do |file| file.write setup_database end File.open("./#{@project_name}/Gemfile", 'w+') do |file| file.write setup_gemfile end end |
#create_dir ⇒ Object
19 20 21 |
# File 'lib/cuba/generator.rb', line 19 def create_dir Dir.mkdir(@project_name) end |