Module: DataMiner

Defined in:
lib/data_miner.rb,
lib/data_miner/run.rb,
lib/data_miner/tap.rb,
lib/data_miner/base.rb,
lib/data_miner/import.rb,
lib/data_miner/schema.rb,
lib/data_miner/process.rb,
lib/data_miner/attribute.rb,
lib/data_miner/dictionary.rb

Defined Under Namespace

Classes: Attribute, Base, Dictionary, Finish, Import, MissingHashColumn, Process, Run, Schema, Skip, Tap

Class Method Summary collapse

Class Method Details

.backtick_with_reporting(cmd) ⇒ Object

TODO this should probably live somewhere else



84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
# File 'lib/data_miner.rb', line 84

def self.backtick_with_reporting(cmd)
  cmd = cmd.gsub /[ ]*\n[ ]*/m, ' '
  output = `#{cmd}`
  if not $?.success?
    raise %{
From the data_miner gem...

Command failed:
#{cmd}

Output:
#{output}
}
  end
end

.log_debug(message) ⇒ Object



70
71
72
# File 'lib/data_miner.rb', line 70

def self.log_debug(message)
  logger.debug "[data_miner gem] #{message}"
end

.log_info(message) ⇒ Object



66
67
68
# File 'lib/data_miner.rb', line 66

def self.log_info(message)
  logger.info "[data_miner gem] #{message}"
end

.log_or_raise(message) ⇒ Object



57
58
59
60
61
62
63
64
# File 'lib/data_miner.rb', line 57

def self.log_or_raise(message)
  message = "[data_miner gem] #{message}"
  if ENV['RAILS_ENV'] == 'production' or ENV['DONT_RAISE'] == 'true'
    logger.error message
  else
    raise message
  end
end

.resource_namesObject



79
80
81
# File 'lib/data_miner.rb', line 79

def self.resource_names
  DataMiner::Base.resource_names
end

.run(options = {}) ⇒ Object



74
75
76
77
# File 'lib/data_miner.rb', line 74

def self.run(options = {})
  DataMiner::Base.run options.merge(:preserve_call_stack_between_runs => true)
  DataMiner::Base.call_stack.clear
end

.start_loggingObject



39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/data_miner.rb', line 39

def self.start_logging
  return if logger

  if defined? Rails
    self.logger = Rails.logger
  else
    class_eval { include Log4r }
    info_outputter = FileOutputter.new 'f1', :filename => 'data_miner.log'
    error_outputter = Outputter.stderr
    info_outputter.only_at DEBUG, INFO
    error_outputter.only_at WARN, ERROR, FATAL
    
    self.logger = Logger.new 'data_miner'
    logger.add info_outputter, error_outputter
    ActiveRecord::Base.logger = logger
  end
end