Class: Dumptruck::Load
- Inherits:
-
Object
- Object
- Dumptruck::Load
- Defined in:
- lib/dumptruck/load.rb
Instance Attribute Summary collapse
-
#database ⇒ Object
Specify a Database [TODO] if database isn’t specified then –all-databases is used.
Instance Method Summary collapse
- #add_ignored_table(table) ⇒ Object
- #add_option(option) ⇒ Object
- #ignored_tables ⇒ Object
-
#initialize(params = {}) ⇒ Load
constructor
A new instance of Load.
- #options ⇒ Object
Constructor Details
#initialize(params = {}) ⇒ Load
Returns a new instance of Load.
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/dumptruck/load.rb', line 6 def initialize(params = {}) defaults = { options: ["--single-transaction", "--opt", "--skip-comments"], }.merge!(params) = defaults[:options] @database = params[:database] || '--all-databases' unless params[:options].nil? params[:options].each do |o| add_option(o) end end unless params[:ignored_tables].nil? params[:ignored_tables].each do |t| add_ignored_table(t) end end end |
Instance Attribute Details
#database ⇒ Object
Specify a Database [TODO] if database isn’t specified then –all-databases is used
4 5 6 |
# File 'lib/dumptruck/load.rb', line 4 def database @database end |
Instance Method Details
#add_ignored_table(table) ⇒ Object
28 29 30 31 |
# File 'lib/dumptruck/load.rb', line 28 def add_ignored_table(table) @ignored_tables = [] unless @ignored_tables @ignored_tables << table end |
#add_option(option) ⇒ Object
33 34 35 36 |
# File 'lib/dumptruck/load.rb', line 33 def add_option(option) = [] unless << option end |
#ignored_tables ⇒ Object
46 47 48 49 50 51 52 53 |
# File 'lib/dumptruck/load.rb', line 46 def ignored_tables return nil unless @ignored_tables tables = "" @ignored_tables.each do |e| tables << "--ignore-table=#{@database}.#{e} " end tables.strip end |
#options ⇒ Object
38 39 40 41 42 43 44 |
# File 'lib/dumptruck/load.rb', line 38 def cmd = "" .each do |o| cmd << "#{o} " end cmd.strip end |