Class: Kryptonite::InstallGenerator

Inherits:
Rails::Generators::Base
  • Object
show all
Includes:
Rails::Generators::Migration
Defined in:
lib/generators/kryptonite/install/install_generator.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.next_migration_number(dirname) ⇒ Object



7
8
9
10
11
12
13
# File 'lib/generators/kryptonite/install/install_generator.rb', line 7

def self.next_migration_number dirname
  if ActiveRecord::Base.timestamped_migrations
    Time.now.utc.strftime("%Y%m%d%H%M%S")
  else
    "%.3d" % (current_migration_number(dirname) + 1)
  end
end

Instance Method Details

#generate_filesObject



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/generators/kryptonite/install/install_generator.rb', line 15

def generate_files
  puts "*** WARNING - Generating configuration files. Make sure you have backed up any files before overwriting them. ***"
  
  #config helper
  copy_file "app/helpers/kryptonite/config_helper.rb", "app/helpers/kryptonite/config_helper.rb"

  #initial view partials
  copy_file "app/views/kryptonite/layouts/_left_navigation.html.erb", "app/views/kryptonite/layouts/_left_navigation.html.erb"
  copy_file "app/views/kryptonite/layouts/_right_navigation.html.erb", "app/views/kryptonite/layouts/_right_navigation.html.erb"

  #robots.txt
  puts " ** Overwrite if you haven't yet modified your robots.txt, otherwise add disallow rules for /kryptonite and /admin manually **"
  copy_file "public/robots.txt", "public/robots.txt"

  #blank stylesheets and JavaScript files
  			copy_file "public/kryptonite/stylesheets/custom.css", "app/assets/kryptonite/stylesheets/custom.css"
  			copy_file "public/kryptonite/javascripts/custom.js", "app/assets/kryptonite/javascripts/custom.js"
			
  			#migrations
  			migration_template 'db/migrate/kryptonite_create_users.rb', "db/migrate/kryptonite_create_users.rb"
end