Class: RedisConfigGenerator

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

Instance Method Summary collapse

Instance Method Details

#create_redis_fileObject



2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/generators/redis_config_generator.rb', line 2

def create_redis_file
  file_name = 'config/redis.yml'
  unless File.exists?(File.expand_path(file_name))
    p "Creating #{file_name}"
    File.open(file_name, 'w') do |f|
      f.puts "redis: &redis"
      f.puts "  redis_port: 6379"
      f.puts "  redis_namespace: 'redis'"
      f.puts "  redis_db: 0"
      f.puts ""
      f.puts "test: "
      f.puts "  <<: *redis"
      f.puts "  redis_host: 'localhost'"
      f.puts ""
      f.puts "development: "
      f.puts "  <<: *redis"
      f.puts "  redis_host: 'localhost'"
      f.puts ""
      f.puts "production: "
      f.puts "  <<: *redis"
      f.puts "  redis_host: 'localhost'"
    end
  else
    puts "Skipping #{file_name}, it already exists"
  end
end