Class: Aetherg::Generator
- Inherits:
-
Thor::Group
- Object
- Thor::Group
- Aetherg::Generator
- Includes:
- Thor::Actions
- Defined in:
- lib/aetherg/aetherg.rb
Class Method Summary collapse
Instance Method Summary collapse
- #create_app ⇒ Object
- #create_assets_config ⇒ Object
- #create_config_with_boot ⇒ Object
- #create_db_config ⇒ Object
-
#create_empty_directories ⇒ Object
Create empty directories.
- #create_gemfile ⇒ Object
- #create_gitignore ⇒ Object
- #create_gitkeep ⇒ Object
- #create_initializers ⇒ Object
- #create_rakefile ⇒ Object
- #create_readme ⇒ Object
- #create_redis_config_and_initializer ⇒ Object
- #create_server_config ⇒ Object
- #create_settings_config ⇒ Object
- #create_views_layout ⇒ Object
-
#setup ⇒ Object
Creates instance variables from options passed to Aether.
Class Method Details
.source_root ⇒ Object
21 22 23 |
# File 'lib/aetherg/aetherg.rb', line 21 def self.source_root File.(File.join(File.dirname(__FILE__), "..", "templates")) end |
Instance Method Details
#create_app ⇒ Object
36 37 38 39 |
# File 'lib/aetherg/aetherg.rb', line 36 def create_app template "application.rb", File.join(@app_path, "application.rb") template "app/routes/welcome.rb", File.join(@app_path, "/app/routes/welcome.rb") end |
#create_assets_config ⇒ Object
95 96 97 98 99 |
# File 'lib/aetherg/aetherg.rb', line 95 def create_assets_config unless @no_views template("config/initializers/assets.rb", File.join(@app_path, "config/initializers/assets.rb")) end end |
#create_config_with_boot ⇒ Object
47 48 49 50 |
# File 'lib/aetherg/aetherg.rb', line 47 def create_config_with_boot template "config.ru", File.join(@app_path, "config.ru") template "boot.rb", File.join(@app_path, "boot.rb") end |
#create_db_config ⇒ Object
68 69 70 71 |
# File 'lib/aetherg/aetherg.rb', line 68 def create_db_config template("config/database.yml", File.join(@app_path, "config/database.example.yml")) unless @no_database template("config/database.yml", File.join(@app_path, "config/database.yml")) unless @no_database end |
#create_empty_directories ⇒ Object
Create empty directories
26 27 28 29 30 31 32 33 34 |
# File 'lib/aetherg/aetherg.rb', line 26 def create_empty_directories %w{app/models app/helpers app/routes config/initializers db/migrate lib log tmp}.each do |dir| empty_directory File.join(@app_path, dir) end %w{app/assets app/assets/images app/assets/javascripts app/assets/stylesheets app/assets/fonts app/views app/views/layouts public}.each do |dir| empty_directory File.join(@app_path, dir) end unless @no_views end |
#create_gemfile ⇒ Object
52 53 54 |
# File 'lib/aetherg/aetherg.rb', line 52 def create_gemfile template "Gemfile", File.join(@app_path, "Gemfile") end |
#create_gitignore ⇒ Object
78 79 80 |
# File 'lib/aetherg/aetherg.rb', line 78 def create_gitignore copy_file "gitignore", File.join(@app_path, ".gitignore") end |
#create_gitkeep ⇒ Object
101 102 103 104 105 106 107 108 109 110 111 112 113 114 |
# File 'lib/aetherg/aetherg.rb', line 101 def create_gitkeep create_file File.join(@app_path, "app", "assets", "images", ".keep") unless @no_views create_file File.join(@app_path, "app", "assets", "stylesheets", ".keep") unless @no_views create_file File.join(@app_path, "app", "assets", "javascripts", ".keep") unless @no_views create_file File.join(@app_path, "app", "assets", "fonts", ".keep") unless @no_views create_file File.join(@app_path, "app", "models", ".keep") create_file File.join(@app_path, "app", "routes", ".keep") create_file File.join(@app_path, "log", ".keep") create_file File.join(@app_path, "tmp", ".keep") create_file File.join(@app_path, "app", "views", ".keep") unless @no_views create_file File.join(@app_path, "lib", ".keep") create_file File.join(@app_path, "db", "migrate", ".keep") create_file File.join(@app_path, "public", ".keep") unless @no_views end |
#create_initializers ⇒ Object
82 83 84 85 86 |
# File 'lib/aetherg/aetherg.rb', line 82 def create_initializers template("config/initializers/connection.rb", File.join(@app_path, "config/initializers/connection.rb")) unless @no_database template("config/initializers/environment.rb", File.join(@app_path, "config/initializers/environment.rb")) template("config/initializer.rb", File.join(@app_path, "config/initializer.rb")) end |
#create_rakefile ⇒ Object
56 57 58 |
# File 'lib/aetherg/aetherg.rb', line 56 def create_rakefile template "Rakefile", File.join(@app_path, "Rakefile") end |
#create_readme ⇒ Object
60 61 62 |
# File 'lib/aetherg/aetherg.rb', line 60 def create_readme template "README.md", File.join(@app_path, "README.md") end |
#create_redis_config_and_initializer ⇒ Object
88 89 90 91 92 93 |
# File 'lib/aetherg/aetherg.rb', line 88 def create_redis_config_and_initializer if @redis copy_file("config/redis.yml", File.join(@app_path, "config/redis.yml")) template("config/initializers/redis.rb", File.join(@app_path, "config/initializers/redis.rb")) end end |
#create_server_config ⇒ Object
64 65 66 |
# File 'lib/aetherg/aetherg.rb', line 64 def create_server_config copy_file "config/puma.rb", File.join(@app_path, "config/puma.example.rb") end |
#create_settings_config ⇒ Object
73 74 75 76 |
# File 'lib/aetherg/aetherg.rb', line 73 def create_settings_config template("config/settings.yml", File.join(@app_path, "config/settings.example.yml")) template("config/settings.yml", File.join(@app_path, "config/settings.yml")) end |
#create_views_layout ⇒ Object
41 42 43 44 45 |
# File 'lib/aetherg/aetherg.rb', line 41 def create_views_layout unless @no_views template "app/views/layouts/application.erb", File.join(@app_path, "/app/views/layouts/application.erb") end end |
#setup ⇒ Object
Creates instance variables from options passed to Aether
14 15 16 17 18 19 |
# File 'lib/aetherg/aetherg.rb', line 14 def setup @name = @app_path = name.filename .each do |key, value| instance_variable_set "@#{key.to_s}".to_sym, value end end |