Class: DataMiner::Tap
- Inherits:
-
Object
- Object
- DataMiner::Tap
- Defined in:
- lib/data_miner/tap.rb
Instance Attribute Summary collapse
-
#base ⇒ Object
readonly
Returns the value of attribute base.
-
#description ⇒ Object
readonly
Returns the value of attribute description.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#position_in_run ⇒ Object
readonly
Returns the value of attribute position_in_run.
-
#source ⇒ Object
readonly
Returns the value of attribute source.
Instance Method Summary collapse
-
#initialize(base, position_in_run, description, source, options = {}) ⇒ Tap
constructor
A new instance of Tap.
- #inspect ⇒ Object
- #run(run) ⇒ Object
Constructor Details
#initialize(base, position_in_run, description, source, options = {}) ⇒ Tap
Returns a new instance of Tap.
11 12 13 14 15 16 17 18 19 |
# File 'lib/data_miner/tap.rb', line 11 def initialize(base, position_in_run, description, source, = {}) .symbolize_keys! DataMiner.log_or_raise "Tap has to be the first step." unless position_in_run == 0 @base = base @position_in_run = position_in_run @description = description @source = source @options = end |
Instance Attribute Details
#base ⇒ Object (readonly)
Returns the value of attribute base.
4 5 6 |
# File 'lib/data_miner/tap.rb', line 4 def base @base end |
#description ⇒ Object (readonly)
Returns the value of attribute description.
6 7 8 |
# File 'lib/data_miner/tap.rb', line 6 def description @description end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
8 9 10 |
# File 'lib/data_miner/tap.rb', line 8 def @options end |
#position_in_run ⇒ Object (readonly)
Returns the value of attribute position_in_run.
5 6 7 |
# File 'lib/data_miner/tap.rb', line 5 def position_in_run @position_in_run end |
#source ⇒ Object (readonly)
Returns the value of attribute source.
7 8 9 |
# File 'lib/data_miner/tap.rb', line 7 def source @source end |
Instance Method Details
#inspect ⇒ Object
21 22 23 |
# File 'lib/data_miner/tap.rb', line 21 def inspect "Tap(#{resource}): #{description} (#{source})" end |
#run(run) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/data_miner/tap.rb', line 25 def run(run) [ source_table_name, resource.table_name ].each do |possible_obstacle| if connection.table_exists?(possible_obstacle) connection.drop_table possible_obstacle end end DataMiner.backtick_with_reporting taps_pull_cmd if needs_table_rename? connection.rename_table source_table_name, resource.table_name end DataMiner.log_info "ran #{inspect}" end |