Class: ODSP
- Inherits:
-
Object
- Object
- ODSP
- Defined in:
- lib/odsp.rb
Instance Method Summary collapse
-
#initialize(save_config: { make: { folder: 'make', op_file: 'make_all.sql'}, drop: { folder: 'drop', op_file: 'drop_all.sql'} }, connections: { dest: nil, src: nil}, params: nil, debug_opt: { time: true, console: true, commit: false, comment: true }) ⇒ ODSP
constructor
A new instance of ODSP.
- #produce ⇒ Object
Constructor Details
#initialize(save_config: { make: { folder: 'make', op_file: 'make_all.sql'}, drop: { folder: 'drop', op_file: 'drop_all.sql'} }, connections: { dest: nil, src: nil}, params: nil, debug_opt: { time: true, console: true, commit: false, comment: true }) ⇒ ODSP
Returns a new instance of ODSP.
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/odsp.rb', line 4 def initialize( save_config: { make: { folder: 'make', op_file: 'make_all.sql'}, drop: { folder: 'drop', op_file: 'drop_all.sql'} }, connections: { dest: nil, src: nil}, params: nil, debug_opt: { time: true, console: true, commit: false, comment: true } ) raise "Connections can not be defined as nil!" if connections.any? { |c| !c } @connections = connections @save_config = save_config @params = params || default_params @params.all? { |hsh| check_param_hsh(hsh) } @debug_opt = debug_opt end |
Instance Method Details
#produce ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/odsp.rb', line 22 def produce @save_config.each do |op_name, config| raise "#{op_name} op_file or folder name can not be nil!" unless config[:op_file] || config[:folder] Dir.mkdir(config[:folder]) unless Dir.exist?(config[:folder]) File.open(config[:op_file], 'w') { |f| f.write("-- script cleaned at #{Time.new}\n") if @debug_opt[:comment] } end @params.each { |params| process_hsh(params) } true end |