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/sql.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/unit_converter.rb,
lib/data_miner/run/column_statistic.rb,
lib/data_miner/unit_converter/alchemist.rb,
lib/data_miner/unit_converter/conversions.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, UnitConverter
Constant Summary collapse
- INNER_SPACE =
/[ ]+/
- ONE_SPACE =
' '
- VERSION =
'2.4.1'
Instance Attribute Summary collapse
-
#logger ⇒ Logger
Where DataMiner logs to.
Class Method Summary collapse
-
.unit_converter ⇒ #convert?
The user-selected unit converter or nil.
-
.unit_converter=(conversion_library) ⇒ nil
Set the unit converter.
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.
94 95 96 97 98 99 100 101 102 103 104 105 |
# File 'lib/data_miner.rb', line 94 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 |
Class Method Details
.unit_converter ⇒ #convert?
Returns The user-selected unit converter or nil.
63 64 65 |
# File 'lib/data_miner.rb', line 63 def unit_converter @unit_converter end |
.unit_converter=(conversion_library) ⇒ nil
As of 2012-05-30, there are problems with the alchemist gem and the use of the conversions gem instead is recommended.
Set the unit converter.
57 58 59 60 |
# File 'lib/data_miner.rb', line 57 def unit_converter=(conversion_library) @unit_converter = UnitConverter.load conversion_library nil 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.
112 113 114 115 116 |
# File 'lib/data_miner.rb', line 112 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.
124 125 126 |
# File 'lib/data_miner.rb', line 124 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.
119 120 121 |
# File 'lib/data_miner.rb', line 119 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.
80 81 82 83 84 85 86 |
# File 'lib/data_miner.rb', line 80 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 |