Class: Frame::Generators::SecretGenerator

Inherits:
Base
  • Object
show all
Includes:
Rails::Generators::Migration
Defined in:
lib/generators/frame/secret/secret_generator.rb

Instance Method Summary collapse

Methods inherited from Base

banner, source_root

Instance Method Details

#create_databaseObject

def opt

puts options.force

end



17
18
19
20
21
22
23
24
25
26
# File 'lib/generators/frame/secret/secret_generator.rb', line 17

def create_database
  config = YAML.load_file(File.expand_path(File.join(File.dirname(__FILE__), 'templates', 'database.yml')))

  ['development','test','production'].each do |i|
    config["#{i}"]["database"] = Rails.application.class.parent_name.downcase
    config["#{i}"]["username"] = "#{Rails.application.class.parent_name.downcase}admin"
  end

  create_file 'config/database.yml', YAML.dump(config)
end

#create_rake_fileObject



33
34
35
36
37
# File 'lib/generators/frame/secret/secret_generator.rb', line 33

def create_rake_file
  #@title = Rails.application.class.parent_name.downcase
  template('Rakefile')
  gsub_file 'Rakefile', /Rails\.application\.class\.parent_name\:\:Application\.load_tasks/, "#{Rails.application.class.parent_name}::Application.load_tasks"
end

#create_secret_tokenObject



28
29
30
31
# File 'lib/generators/frame/secret/secret_generator.rb', line 28

def create_secret_token
  secret = `rake secret`.rstrip
  initializer("secret_token.rb", "#{Rails.application.class.parent_name}::Application.config.secret_token = '#{secret}'")
end