Class: DataMiner::Tap

Inherits:
Object
  • Object
show all
Defined in:
lib/data_miner/tap.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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, options = {})
  options.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 = options
end

Instance Attribute Details

#baseObject (readonly)

Returns the value of attribute base.



4
5
6
# File 'lib/data_miner/tap.rb', line 4

def base
  @base
end

#descriptionObject (readonly)

Returns the value of attribute description.



6
7
8
# File 'lib/data_miner/tap.rb', line 6

def description
  @description
end

#optionsObject (readonly)

Returns the value of attribute options.



8
9
10
# File 'lib/data_miner/tap.rb', line 8

def options
  @options
end

#position_in_runObject (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

#sourceObject (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

#inspectObject



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