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 =
"1.2.2"
Instance Method Summary collapse
- #create_config_file ⇒ Object
- #create_cuba_file ⇒ Object
- #create_dir ⇒ Object
- #create_gemfile ⇒ Object
- #create_gitignore ⇒ Object
- #create_postgres_file ⇒ Object
- #create_sqlite_file ⇒ 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 18 19 |
# 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 create_gemfile create_gitignore puts "Created your Cuba #{@type} at /#{@project_name} directory. Rock on!" end |
Instance Method Details
#create_config_file ⇒ Object
25 26 27 28 29 |
# File 'lib/cuba/generator.rb', line 25 def create_config_file File.open("./#{@project_name}/config.ru", 'w+') do |file| file.write setup_config end end |
#create_cuba_file ⇒ Object
31 32 33 34 35 |
# File 'lib/cuba/generator.rb', line 31 def create_cuba_file File.open("./#{@project_name}/#{@project_name}.rb", 'w+') do |file| file.write setup_cuba end end |
#create_dir ⇒ Object
21 22 23 |
# File 'lib/cuba/generator.rb', line 21 def create_dir Dir.mkdir(@project_name) end |
#create_gemfile ⇒ Object
37 38 39 40 41 |
# File 'lib/cuba/generator.rb', line 37 def create_gemfile File.open("./#{@project_name}/Gemfile", 'w+') do |file| file.write setup_gemfile end end |
#create_gitignore ⇒ Object
43 44 45 46 47 |
# File 'lib/cuba/generator.rb', line 43 def create_gitignore File.open("./#{@project_name}/.gitignore", 'w+') do |file| file.write setup_gitignore end end |
#create_postgres_file ⇒ Object
49 50 51 52 53 |
# File 'lib/cuba/generator.rb', line 49 def create_postgres_file File.open("./#{@project_name}/postgres.rb", 'w+') do |file| file.write setup_postgres end end |
#create_sqlite_file ⇒ Object
55 56 57 58 59 |
# File 'lib/cuba/generator.rb', line 55 def create_sqlite_file File.open("./#{@project_name}/sqlite.rb", 'w+') do |file| file.write setup_sqlite end end |