]> git.openstreetmap.org Git - rails.git/blob - vendor/gems/composite_primary_keys-2.2.2/scripts/console.rb
Fixup some error handling in map bugs
[rails.git] / vendor / gems / composite_primary_keys-2.2.2 / scripts / console.rb
1 #!/usr/bin/env ruby
2
3 #
4 # if run as script, load the file as library while starting irb 
5 #
6 if __FILE__ == $0
7   irb = RUBY_PLATFORM =~ /(:?mswin|mingw)/ ? 'irb.bat' : 'irb'
8   ENV['ADAPTER'] = ARGV[0]
9   exec "#{irb} -f -r #{$0} --simple-prompt"
10 end
11
12 #
13 # check if the given adapter is supported (default: mysql)
14 #
15 adapters = %w[mysql sqlite oracle oracle_enhanced postgresql ibm_db]
16 adapter = ENV['ADAPTER'] || 'mysql'
17 unless adapters.include? adapter
18   puts "Usage: #{__FILE__} <adapter>"
19   puts ''
20   puts 'Adapters: '
21   puts adapters.map{ |adapter| "    #{adapter}" }.join("\n")
22   exit 1
23 end
24
25 #
26 # load all necessary libraries
27 #
28 require 'rubygems'
29 require 'local/database_connections'
30
31 $LOAD_PATH.unshift 'lib'
32
33 begin
34   require 'local/paths'
35   $LOAD_PATH.unshift "#{ENV['EDGE_RAILS_DIR']}/activerecord/lib"  if ENV['EDGE_RAILS_DIR']
36   $LOAD_PATH.unshift "#{ENV['EDGE_RAILS_DIR']}/activesupport/lib" if ENV['EDGE_RAILS_DIR']
37 rescue
38 end
39
40 require 'active_support'
41 require 'active_record'
42
43 require "test/connections/native_#{adapter}/connection"
44 require 'composite_primary_keys'
45
46 PROJECT_ROOT = File.join(File.dirname(__FILE__), '..')
47 Dir[File.join(PROJECT_ROOT,'test/fixtures/*.rb')].each { |model| require model }
48