Class: Mysql2psql

Inherits:
Object
  • Object
show all
Defined in:
lib/mysql2psql.rb,
lib/mysql2psql/config.rb,
lib/mysql2psql/errors.rb,
lib/mysql2psql/writer.rb,
lib/mysql2psql/version.rb,
lib/mysql2psql/converter.rb,
lib/mysql2psql/config_base.rb,
lib/mysql2psql/mysql_reader.rb,
lib/mysql2psql/postgres_writer.rb,
lib/mysql2psql/postgres_db_writer.rb,
lib/mysql2psql/postgres_file_writer.rb

Defined Under Namespace

Modules: Version Classes: Config, ConfigBase, ConfigurationError, ConfigurationFileInitialized, ConfigurationFileNotFound, Converter, GeneralError, MysqlReader, PostgresDbWriter, PostgresFileWriter, PostgresWriter, UninitializedValueError, Writer

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args) ⇒ Mysql2psql

Returns a new instance of Mysql2psql.



16
17
18
19
20
# File 'lib/mysql2psql.rb', line 16

def initialize(args)
  help if args.length==1 && args[0] =~ /^-.?|^-*he?l?p?$/i 
  configfile = args[0] || File.expand_path('mysql2psql.yml')
  @options = Config.new( configfile, true )
end

Instance Attribute Details

#optionsObject (readonly)

Returns the value of attribute options.



14
15
16
# File 'lib/mysql2psql.rb', line 14

def options
  @options
end

#readerObject (readonly)

Returns the value of attribute reader.



14
15
16
# File 'lib/mysql2psql.rb', line 14

def reader
  @reader
end

#writerObject (readonly)

Returns the value of attribute writer.



14
15
16
# File 'lib/mysql2psql.rb', line 14

def writer
  @writer
end

Instance Method Details

#convertObject



22
23
24
25
26
27
28
29
30
31
32
# File 'lib/mysql2psql.rb', line 22

def convert
  @reader = MysqlReader.new( options )

  if options.destfile(nil)
    @writer = PostgresFileWriter.new(options.destfile)
  else
    @writer = PostgresDbWriter.new(options)
  end

  Converter.new(reader, writer, options).convert
end

#helpObject



34
35
36
37
38
39
40
# File 'lib/mysql2psql.rb', line 34

def help
  puts <<EOS
MySQL to PostgreSQL Conversion

EOS
  exit -2
end