Class: Snfn::Generator
- Inherits:
-
Thor::Group
- Object
- Thor::Group
- Snfn::Generator
- Includes:
- Thor::Actions
- Defined in:
- lib/snfn.rb
Class Method Summary collapse
Instance Method Summary collapse
- #create_app ⇒ Object
- #create_config ⇒ Object
- #create_database_initializer ⇒ Object
- #create_db_config ⇒ Object
-
#create_empty_directories ⇒ Object
Create empty directories.
- #create_gemfile ⇒ Object
- #create_lib_gitkeep ⇒ Object
- #create_procfile ⇒ Object
- #create_public_directory ⇒ Object
- #create_rakefile ⇒ Object
- #create_readme ⇒ Object
- #create_redis_config ⇒ Object
- #create_redis_initializer ⇒ Object
- #create_server_config ⇒ Object
- #create_view_directory ⇒ Object
-
#setup ⇒ Object
Creates instance variables from options passed to snfn.
Class Method Details
.source_root ⇒ Object
22 23 24 |
# File 'lib/snfn.rb', line 22 def self.source_root File.(File.join(File.dirname(__FILE__), "..", "lib", "templates")) end |
Instance Method Details
#create_app ⇒ Object
43 44 45 |
# File 'lib/snfn.rb', line 43 def create_app template "app.rb", File.join(@app_path, "#{@name}.rb") end |
#create_config ⇒ Object
47 48 49 |
# File 'lib/snfn.rb', line 47 def create_config template "config.ru", File.join(@app_path, "config.ru") end |
#create_database_initializer ⇒ Object
75 76 77 |
# File 'lib/snfn.rb', line 75 def create_database_initializer template("config/initializers/database.rb", File.join(@app_path, "config/initializers/database.rb")) unless @no_database end |
#create_db_config ⇒ Object
71 72 73 |
# File 'lib/snfn.rb', line 71 def create_db_config template("config/db.yml", File.join(@app_path, "config/db.yml")) unless @no_database end |
#create_empty_directories ⇒ Object
Create empty directories
27 28 29 30 31 |
# File 'lib/snfn.rb', line 27 def create_empty_directories %w{config/initializers db/migrate lib log tmp}.each do |dir| empty_directory File.join(@app_path, dir) end end |
#create_gemfile ⇒ Object
51 52 53 |
# File 'lib/snfn.rb', line 51 def create_gemfile template "Gemfile", File.join(@app_path, "Gemfile") end |
#create_lib_gitkeep ⇒ Object
87 88 89 |
# File 'lib/snfn.rb', line 87 def create_lib_gitkeep create_file File.join(@app_path, "lib", ".gitkeep") end |
#create_procfile ⇒ Object
55 56 57 |
# File 'lib/snfn.rb', line 55 def create_procfile copy_file("Procfile", File.join(@app_path, "Procfile")) unless @no_heroku end |
#create_public_directory ⇒ Object
33 34 35 36 37 |
# File 'lib/snfn.rb', line 33 def create_public_directory %w{public/css public/js public/img}.each do |dir| directory dir, File.join(@app_path, dir) end end |
#create_rakefile ⇒ Object
59 60 61 |
# File 'lib/snfn.rb', line 59 def create_rakefile copy_file "Rakefile", File.join(@app_path, "Rakefile") end |
#create_readme ⇒ Object
63 64 65 |
# File 'lib/snfn.rb', line 63 def create_readme copy_file "README.mdown", File.join(@app_path, "README.mdown") end |
#create_redis_config ⇒ Object
79 80 81 |
# File 'lib/snfn.rb', line 79 def create_redis_config copy_file("config/redis.yml", File.join(@app_path, "config/redis.yml")) if @redis end |
#create_redis_initializer ⇒ Object
83 84 85 |
# File 'lib/snfn.rb', line 83 def create_redis_initializer template("config/initializers/redis.rb", File.join(@app_path, "config/initializers/redis.rb")) if @redis end |
#create_server_config ⇒ Object
67 68 69 |
# File 'lib/snfn.rb', line 67 def create_server_config template "config/unicorn.rb", File.join(@app_path, "config/unicorn.rb") end |
#create_view_directory ⇒ Object
39 40 41 |
# File 'lib/snfn.rb', line 39 def create_view_directory directory "views", File.join(@app_path, "views") end |
#setup ⇒ Object
Creates instance variables from options passed to snfn.
15 16 17 18 19 20 |
# File 'lib/snfn.rb', line 15 def setup @name = @app_path = name.file_name .each do |key, value| instance_variable_set "@#{key.to_s}".to_sym, value end end |