Class: ActiveRecordDoctor::Rake::Task
- Inherits:
-
Rake::TaskLib
- Object
- Rake::TaskLib
- ActiveRecordDoctor::Rake::Task
- Defined in:
- lib/active_record_doctor/rake/task.rb
Overview
A Rake task for calling active_record_doctor detectors.
The three supported attributes are:
- deps - project-specific Rake dependencies, e.g. :environment in Rails.
- config_path - active_record_doctor configuration file path.
- setup - a callable (responding to #call) responsible for finishing.
the setup process after deps are invoked, e.g. preloading models.
The dependencies between Rake tasks are:
active_record_doctor:<detector> => active_record_doctor:setup => <deps>
active_record_doctor:setup is where the setup callable is called.
Instance Attribute Summary collapse
-
#config_path ⇒ Object
Returns the value of attribute config_path.
-
#deps ⇒ Object
Returns the value of attribute deps.
-
#setup ⇒ Object
Returns the value of attribute setup.
Instance Method Summary collapse
- #define ⇒ Object
-
#initialize {|_self| ... } ⇒ Task
constructor
A new instance of Task.
Constructor Details
#initialize {|_self| ... } ⇒ Task
Returns a new instance of Task.
24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/active_record_doctor/rake/task.rb', line 24 def initialize super @deps = [] @config_path = nil @setup = nil yield(self) define end |
Instance Attribute Details
#config_path ⇒ Object
Returns the value of attribute config_path.
22 23 24 |
# File 'lib/active_record_doctor/rake/task.rb', line 22 def config_path @config_path end |
#deps ⇒ Object
Returns the value of attribute deps.
22 23 24 |
# File 'lib/active_record_doctor/rake/task.rb', line 22 def deps @deps end |
#setup ⇒ Object
Returns the value of attribute setup.
22 23 24 |
# File 'lib/active_record_doctor/rake/task.rb', line 22 def setup @setup end |
Instance Method Details
#define ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/active_record_doctor/rake/task.rb', line 36 def define namespace :active_record_doctor do task :setup => deps do @setup&.call config end ActiveRecordDoctor.detectors.each do |name, detector| desc detector.description task name => :"active_record_doctor:setup" do runner.run_one(name) or exit(1) end namespace name do desc "Show help for #{name}" task :help => :"active_record_doctor:setup" do runner.help(name) end end end end desc "Run all active_record_doctor detectors" task :active_record_doctor => :"active_record_doctor:setup" do runner.run_all or exit(1) end end |