Class: Dbmanager::Adapters::Mysql::Dumper
- Inherits:
-
Object
- Object
- Dbmanager::Adapters::Mysql::Dumper
- Includes:
- Connectable
- Defined in:
- lib/dbmanager/adapters/mysql.rb
Instance Attribute Summary collapse
-
#filename ⇒ Object
readonly
Returns the value of attribute filename.
- #mysqldump_version ⇒ Object
-
#source ⇒ Object
readonly
Returns the value of attribute source.
Instance Method Summary collapse
- #dump_command ⇒ Object
- #dump_command_ssh ⇒ Object
- #extract_version(version) ⇒ Object
- #ignoretables ⇒ Object
-
#initialize(source, filename) ⇒ Dumper
constructor
A new instance of Dumper.
- #run ⇒ Object
Methods included from Connectable
Constructor Details
#initialize(source, filename) ⇒ Dumper
Returns a new instance of Dumper.
22 23 24 25 |
# File 'lib/dbmanager/adapters/mysql.rb', line 22 def initialize(source, filename) @source = source @filename = filename end |
Instance Attribute Details
#filename ⇒ Object (readonly)
Returns the value of attribute filename.
19 20 21 |
# File 'lib/dbmanager/adapters/mysql.rb', line 19 def filename @filename end |
#mysqldump_version ⇒ Object
31 32 33 |
# File 'lib/dbmanager/adapters/mysql.rb', line 31 def mysqldump_version @mysqldump_version ||= extract_version Dbmanager.execute('mysqldump --version') end |
#source ⇒ Object (readonly)
Returns the value of attribute source.
19 20 21 |
# File 'lib/dbmanager/adapters/mysql.rb', line 19 def source @source end |
Instance Method Details
#dump_command ⇒ Object
40 41 42 |
# File 'lib/dbmanager/adapters/mysql.rb', line 40 def dump_command "mysqldump #{ignoretables} #{set_gtid_purged_off} #{params(source)} > '#{filename}'" end |
#dump_command_ssh ⇒ Object
44 45 46 |
# File 'lib/dbmanager/adapters/mysql.rb', line 44 def dump_command_ssh "mysqldump #{ignoretables} #{set_gtid_purged_off} #{params(source)}" end |
#extract_version(version) ⇒ Object
35 36 37 38 |
# File 'lib/dbmanager/adapters/mysql.rb', line 35 def extract_version(version) version =~ /Distrib\s+(\d+\.\d+)/ $1.to_f end |
#ignoretables ⇒ Object
48 49 50 51 52 53 54 |
# File 'lib/dbmanager/adapters/mysql.rb', line 48 def ignoretables if source.ignoretables.present? source.ignoretables.inject [] do |arr, table| arr << "--ignore-table=#{source.database}.#{table}" end.join ' ' end end |