Skip to content

Commit

Permalink
Moved config to settings.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
igkuz committed Mar 9, 2019
1 parent bceeaa4 commit 1dfcc4d
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 12 deletions.
2 changes: 1 addition & 1 deletion Rakefile
Expand Up @@ -3,7 +3,7 @@ require 'rom/sql/rake_task'

namespace :db do
task :setup do
configuration = ROM::Configuration.new(:sql, "mysql2:///#{DB_CONFIG[:name]}", DB_CONFIG)
configuration = ROM::Configuration.new(:sql, "mysql2:///#{CONFIG['db']['name']}", CONFIG['db'])
ROM::SQL::RakeSupport.env = configuration
end
end
14 changes: 4 additions & 10 deletions boot.rb
Expand Up @@ -4,15 +4,9 @@
require 'bundler'
Bundler.require(:default, ENV['RACK_ENV'].to_sym)

require 'yaml'
CONFIG = YAML.load(File.open(File.join(APP_ROOT, 'settings.yml')))[ENV['RACK_ENV']]

Dir[File.join(APP_ROOT, '/lib/**/*.rb')].each do |f|
require f
end

DB_CONFIG = {
name: 'rom_app_development',
host: 'db',
username: 'root',
password: '',
port: 3306,
encoding: 'utf8mb4'
}
end
2 changes: 1 addition & 1 deletion console
@@ -1,7 +1,7 @@
#!/usr/bin/env ruby
require_relative 'boot'

configuration = ROM::Configuration.new(:sql, "mysql2:///#{DB_CONFIG[:name]}", DB_CONFIG)
configuration = ROM::Configuration.new(:sql, "mysql2:///#{CONFIG['db']['name']}", CONFIG['db'])
configuration.register_relation(Companies, Posts)
configuration.register_command(CreateCompany, DeleteCompany)
configuration.register_command(CreatePost, UpdatePost, DeletePost)
Expand Down
16 changes: 16 additions & 0 deletions settings.yml
@@ -0,0 +1,16 @@
development:
db:
host: 'db'
port: 3306
name: 'rom_app_development'
username: 'root'
password: ''
encoding: 'utf8mb4'

test:
host: 'db'
port: 3306
name: 'rom_app_test'
username: 'root'
password: ''
encoding: 'utf8mb4'

0 comments on commit 1dfcc4d

Please sign in to comment.