Class: ActiveConfigRails::Generators::InstallGenerator

Inherits:
Rails::Generators::Base
  • Object
show all
Defined in:
lib/active_config_rails.rb

Instance Method Summary collapse

Instance Method Details

#convert_database_yamlObject



41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/active_config_rails.rb', line 41

def convert_database_yaml
  empty_directory('etc')
  FileUtils.cp(relative_to_original_destination_root('config/database.yml'),'etc/database.yml')
  remove_file('config/database.yml')
  copy_file 'database.yml', 'config/database.yml'
  copy_file 'rails.yml', 'etc/rails.yml'


  #comment = "\n  # Set the logging destination(s)\n  %s\n"
  #insert_into_file 'config/environments/development.rb', comment % 'config.log_to = %w[stdout file]', :before => %r/^end\s*$/
  #insert_into_file 'config/environments/production.rb', comment % 'config.log_to = %w[file]', :before => %r/^end\s*$/
end

#generate_configObject



32
33
34
# File 'lib/active_config_rails.rb', line 32

def generate_config
  template 'active_config_initializer.rb', 'config/initializers/active_config.rb'
end

#insert_to_applicationObject



36
37
38
39
40
# File 'lib/active_config_rails.rb', line 36

def insert_to_application
  ln = "require File.expand_path('../initializers/active_config', __FILE__)\n"
  prepend_to_file 'config/application.rb', ln
  append_to_file 'config/boot.rb', ln
end