Class: DataMiner
- Inherits:
-
Object
- Object
- DataMiner
- Includes:
- Singleton
- Defined in:
- lib/data_miner.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/step/test.rb,
lib/data_miner/step/import.rb,
lib/data_miner/step/process.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, Script, Step
Constant Summary collapse
- INNER_SPACE =
/[ ]+/
- ONE_SPACE =
' '
- VERSION =
'3.0.0'
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.
-
#start(model_names = DataMiner.model_names) ⇒ Object
(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.
77 78 79 80 81 82 83 84 85 86 87 88 |
# File 'lib/data_miner.rb', line 77 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>
Note:
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.
95 96 97 98 99 |
# File 'lib/data_miner.rb', line 95 def model_names @model_names || ::Thread.exclusive do @model_names ||= ::Set.new end end |
#start(model_names = DataMiner.model_names) ⇒ Object Also known as: run
Run data miner scripts on models identified by their names. Defaults to all models.
62 63 64 65 66 67 68 69 |
# File 'lib/data_miner.rb', line 62 def start(model_names = DataMiner.model_names) Script.uniq do model_names.map do |model_name| model_name.constantize.run_data_miner! end end nil end |