Module: ActiveGroonga::Railties::Configurable — activegroonga - ラングバ

Module: ActiveGroonga::Railties::Configurable

Defined in:
lib/active_groonga/railties/configurable.rb

Instance Method Summary (collapse)

Instance Method Details

- (Object) groonga_configurations



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/active_groonga/railties/configurable.rb', line 21

def groonga_configurations
  groonga_yml = paths["config/groonga"].first
  unless File.exist?(groonga_yml)
    groonga_yml_example = "#{groonga_yml}.example"
    if File.exist?(groonga_yml_example)
      FileUtils.cp(groonga_yml_example, groonga_yml)
    else
      File.open(groonga_yml, "w") do |yml|
        yml.puts(<<-EOC)
development:
  database: db/groonga/development/db

# Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake".
# Do not set this db to the same as development or production.
test:
  database: db/groonga/test/db

production:
  database: db/groonga/production/db
        EOC
      end
    end
  end
  YAML.load(ERB.new(IO.read(groonga_yml)).result)
end