Class: DataMiner
- Inherits:
-
Object
- Object
- DataMiner
- Includes:
- Singleton
- Defined in:
- lib/data_miner.rb,
lib/data_miner/run.rb,
lib/data_miner/step.rb,
lib/data_miner/script.rb,
lib/data_miner/version.rb,
lib/data_miner/step/tap.rb,
lib/data_miner/attribute.rb,
lib/data_miner/dictionary.rb,
lib/data_miner/step/import.rb,
lib/data_miner/step/process.rb,
lib/data_miner/run/column_statistic.rb,
lib/data_miner/active_record_class_methods.rb
Overview
A singleton class that holds global configuration for data mining.
All of its instance methods are delegated to DataMiner.instance
, so you can call DataMiner.model_names
, for example.
Defined Under Namespace
Modules: ActiveRecordClassMethods Classes: Attribute, Dictionary, Run, Script, Step
Constant Summary collapse
- INNER_SPACE =
/[ ]+/
- VERSION =
'2.1.2'
Instance Attribute Summary collapse
-
#logger ⇒ Logger
Where DataMiner logs to.
Instance Method Summary collapse
-
#model_names ⇒ Set<String>
Names of the models that have defined a data miner script.
-
#per_column_statistics=(boolean) ⇒ Object
Turn on or off per-column stats.
-
#per_column_statistics? ⇒ Boolean
Whether per-column stats like max, min, average, standard deviation, etc are enabled.
-
#start(model_names = DataMiner.model_names) ⇒ Array<DataMiner::Run>
(also: #run)
Run data miner scripts on models identified by their names.
Instance Attribute Details
#logger ⇒ Logger
Where DataMiner logs to. Defaults to Rails.logger
or ActiveRecord::Base.logger
if either is available.
75 76 77 78 79 80 81 82 83 84 85 86 |
# File 'lib/data_miner.rb', line 75 def logger @logger || ::Thread.exclusive do @logger ||= if defined?(::Rails) ::Rails.logger elsif defined?(::ActiveRecord) and active_record_logger = ::ActiveRecord::Base.logger active_record_logger else require 'logger' ::Logger.new $stderr end end end |
Instance Method Details
#model_names ⇒ Set<String>
Models won’t appear here until the files containing their data miner scripts have been require
‘d.
Names of the models that have defined a data miner script.
93 94 95 96 97 |
# File 'lib/data_miner.rb', line 93 def model_names @model_names || ::Thread.exclusive do @model_names ||= ::Set.new end end |
#per_column_statistics=(boolean) ⇒ Object
Turn on or off per-column stats.
105 106 107 |
# File 'lib/data_miner.rb', line 105 def per_column_statistics=(boolean) @per_column_statistics = boolean end |
#per_column_statistics? ⇒ Boolean
Whether per-column stats like max, min, average, standard deviation, etc are enabled.
100 101 102 |
# File 'lib/data_miner.rb', line 100 def per_column_statistics? @per_column_statistics == true end |
#start(model_names = DataMiner.model_names) ⇒ Array<DataMiner::Run> Also known as: run
Run data miner scripts on models identified by their names. Defaults to all models.
61 62 63 64 65 66 67 |
# File 'lib/data_miner.rb', line 61 def start(model_names = DataMiner.model_names) Script.uniq do model_names.map do |model_name| model_name.constantize.run_data_miner! end end end |