Class: Mysql2postgres
- Inherits:
-
Object
- Object
- Mysql2postgres
- Defined in:
- lib/mysql2postgres.rb,
lib/mysql2postgres/version.rb,
lib/mysql2postgres/converter.rb,
lib/mysql2postgres/connection.rb,
lib/mysql2postgres/mysql_reader.rb,
lib/mysql2postgres/postgres_writer.rb,
lib/mysql2postgres/postgres_db_writer.rb,
lib/mysql2postgres/postgres_file_writer.rb
Defined Under Namespace
Classes: Connection, Converter, MysqlReader, PostgresDbWriter, PostgresFileWriter, PostgresWriter
Constant Summary collapse
- VERSION =
'0.4.1'
Instance Attribute Summary collapse
-
#config_file ⇒ Object
readonly
Returns the value of attribute config_file.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#reader ⇒ Object
readonly
Returns the value of attribute reader.
-
#writer ⇒ Object
readonly
Returns the value of attribute writer.
Instance Method Summary collapse
- #convert ⇒ Object
-
#initialize(yaml, config_file = nil) ⇒ Mysql2postgres
constructor
A new instance of Mysql2postgres.
Constructor Details
#initialize(yaml, config_file = nil) ⇒ Mysql2postgres
Returns a new instance of Mysql2postgres.
24 25 26 27 |
# File 'lib/mysql2postgres.rb', line 24 def initialize(yaml, config_file = nil) @config_file = config_file @options = yaml end |
Instance Attribute Details
#config_file ⇒ Object (readonly)
Returns the value of attribute config_file.
22 23 24 |
# File 'lib/mysql2postgres.rb', line 22 def config_file @config_file end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
22 23 24 |
# File 'lib/mysql2postgres.rb', line 22 def @options end |
#reader ⇒ Object (readonly)
Returns the value of attribute reader.
22 23 24 |
# File 'lib/mysql2postgres.rb', line 22 def reader @reader end |
#writer ⇒ Object (readonly)
Returns the value of attribute writer.
22 23 24 |
# File 'lib/mysql2postgres.rb', line 22 def writer @writer end |
Instance Method Details
#convert ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/mysql2postgres.rb', line 29 def convert @reader = MysqlReader.new puts "mysql2postgres #{Mysql2postgres::VERSION}" puts "Config file: #{config_file}" puts "Dumpfile: #{dump_file}" @writer = if to_file? puts 'Target: File' PostgresFileWriter.new dump_file, [:destination] else puts "Target: PostgreSQL DB (#{adapter})" PostgresDbWriter.new dump_file, [:destination] end Converter.new(reader, writer, ).convert File.delete dump_file if [:remove_dump_file] && File.exist?(dump_file) end |