Class: Sunrise::Generators::InstallGenerator
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- Sunrise::Generators::InstallGenerator
- Includes:
- Rails::Generators::Migration
- Defined in:
- lib/generators/sunrise/install_generator.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#add_routes ⇒ Object
Add devise routes.
- #autoload_paths ⇒ Object
- #copy_configurations ⇒ Object
- #copy_helpers ⇒ Object
-
#copy_images ⇒ Object
copy images.
-
#copy_javascripts ⇒ Object
copy javascripts.
-
#copy_models ⇒ Object
copy models.
-
#copy_stylesheets ⇒ Object
copy stylesheets.
-
#copy_views ⇒ Object
copy views.
-
#create_migrations ⇒ Object
copy migration files.
- #dependent_generators ⇒ Object
- #download_rails_js ⇒ Object
Class Method Details
.current_time ⇒ Object
101 102 103 104 |
# File 'lib/generators/sunrise/install_generator.rb', line 101 def self.current_time @current_time ||= Time.now @current_time += 1.minute end |
.next_migration_number(dirname) ⇒ Object
93 94 95 96 97 98 99 |
# File 'lib/generators/sunrise/install_generator.rb', line 93 def self.next_migration_number(dirname) if ActiveRecord::Base. current_time.utc.strftime("%Y%m%d%H%M%S") else "%.3d" % (current_migration_number(dirname) + 1) end end |
Instance Method Details
#add_routes ⇒ Object
Add devise routes
76 77 78 79 80 |
# File 'lib/generators/sunrise/install_generator.rb', line 76 def add_routes route "devise_for :users" route "resources :pages, :only => [:show]" route 'root :to => "welcome#index"' end |
#autoload_paths ⇒ Object
82 83 84 85 86 87 88 89 90 91 |
# File 'lib/generators/sunrise/install_generator.rb', line 82 def autoload_paths log :autoload_paths, "models/defaults" sentinel = /\.autoload_paths\s+\+=\s+\%W\(\#\{config\.root\}\/extras\)\s*$/ code = 'config.autoload_paths += %W(#{config.root}/app/models/defaults)' in_root do inject_into_file 'config/application.rb', " #{code}\n", { :after => sentinel, :verbose => false } end end |
#copy_configurations ⇒ Object
34 35 36 37 38 39 40 41 42 |
# File 'lib/generators/sunrise/install_generator.rb', line 34 def copy_configurations copy_file('config/seeds.rb', 'db/seeds.rb') copy_file('config/sunrise.rb', 'config/initializers/sunrise.rb') template('config/application.yml', 'config/application.yml.sample') template('config/database.yml', 'config/database.yml.sample') template('config/logrotate-config', 'config/logrotate-config.sample') template('config/nginx-config-passenger', 'config/nginx-config-passenger.sample') end |
#copy_helpers ⇒ Object
44 45 46 |
# File 'lib/generators/sunrise/install_generator.rb', line 44 def copy_helpers directory('helpers', 'app/helpers') end |
#copy_images ⇒ Object
copy images
15 16 17 |
# File 'lib/generators/sunrise/install_generator.rb', line 15 def copy_images directory "images/manage", "public/images/manage" end |
#copy_javascripts ⇒ Object
copy javascripts
20 21 22 |
# File 'lib/generators/sunrise/install_generator.rb', line 20 def copy_javascripts directory "javascripts", "public/javascripts" end |
#copy_models ⇒ Object
copy models
49 50 51 |
# File 'lib/generators/sunrise/install_generator.rb', line 49 def copy_models directory "models", "app/models" end |
#copy_stylesheets ⇒ Object
copy stylesheets
25 26 27 |
# File 'lib/generators/sunrise/install_generator.rb', line 25 def copy_stylesheets directory "stylesheets", "public/stylesheets" end |
#copy_views ⇒ Object
copy views
30 31 32 |
# File 'lib/generators/sunrise/install_generator.rb', line 30 def copy_views directory "views", "app/views" end |
#create_migrations ⇒ Object
copy migration files
59 60 61 62 63 64 65 |
# File 'lib/generators/sunrise/install_generator.rb', line 59 def create_migrations if .migrations [:users, :roles, :structures, :pages, :assets, :headers].each do |item| migration_template "migrate/create_#{item}.rb", File.join('db/migrate', "sunrise_create_#{item}.rb") end end end |
#dependent_generators ⇒ Object
67 68 69 70 71 72 73 |
# File 'lib/generators/sunrise/install_generator.rb', line 67 def dependent_generators say_status("invoke dependent generators", "", :green) generate("simple_form:install") generate("sunrise:file_upload:install") generate("devise:install") end |
#download_rails_js ⇒ Object
53 54 55 56 |
# File 'lib/generators/sunrise/install_generator.rb', line 53 def download_rails_js say_status("fetching rails.js", "", :green) get "https://github.com/rails/jquery-ujs/raw/master/src/rails.js", "public/javascripts/rails.js" end |