Sha256: 5c502ce97093942e43bebb1e2ee14bc356d7974fa3016f0c148097cc7c0823d1

Contents?: true

Size: 908 Bytes

Versions: 33

Compression:

Stored size: 908 Bytes

Contents

config = YAML.load_file(File.expand_path("../config/database.yml", __FILE__))
host, port, username, password, database = config.values_at *%w(host port username password database)
db = File.expand_path("../db", __FILE__)

begin
  ActiveRecord::Base.establish_connection config.merge("database" => nil)
  ActiveRecord::Base.connection.create_database database, {:charset => "utf8", :collation => "utf8_unicode_ci"}

  puts "Installing #{database} ..."

  `#{
    [
      "mysql",
     ("-h #{host}" unless host.blank?), ("-P #{port}" unless port.blank?),
      "-u #{username || "root"}", ("-p#{password}" unless password.blank?),
      "#{database} < #{db}/database.sql"
    ].compact.join(" ")
  }`

rescue Exception => e
  raise e unless e.message.include?("database exists")
end

ActiveRecord::Base.establish_connection config

Dir[File.expand_path("../app/**/*.rb", __FILE__)].each{|file| require file}

Version data entries

33 entries across 33 versions & 1 rubygems

Version Path
directiverecord-0.1.12 test/application/boot.rb
directiverecord-0.1.11 test/application/boot.rb
directiverecord-0.1.10 test/application/boot.rb
directiverecord-0.1.9 test/application/boot.rb
directiverecord-0.1.8 test/application/boot.rb
directiverecord-0.1.7 test/application/boot.rb
directiverecord-0.1.6 test/application/boot.rb
directiverecord-0.1.5 test/application/boot.rb
directiverecord-0.1.4 test/application/boot.rb
directiverecord-0.1.3 test/application/boot.rb
directiverecord-0.1.2 test/application/boot.rb
directiverecord-0.1.1 test/application/boot.rb
directiverecord-0.1.0 test/application/boot.rb