Class: RailsDoctor::Init::Runner
- Inherits:
-
Object
- Object
- RailsDoctor::Init::Runner
- Defined in:
- lib/rails_doctor/init/runner.rb
Constant Summary collapse
- RECOMMENDED_GEMS =
{ "rubocop" => "development,test", "rubocop-rails" => "development,test", "brakeman" => "development,test", "bundler-audit" => "development,test", "reek" => "development,test", "strong_migrations" => "development,test", "prosopite" => "development,test", "simplecov" => "development,test", "flog" => "development,test", "flay" => "development,test" }.freeze
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#project ⇒ Object
readonly
Returns the value of attribute project.
-
#runner ⇒ Object
readonly
Returns the value of attribute runner.
Instance Method Summary collapse
-
#initialize(project:, config:, runner:, options:) ⇒ Runner
constructor
A new instance of Runner.
- #run ⇒ Object
Constructor Details
#initialize(project:, config:, runner:, options:) ⇒ Runner
Returns a new instance of Runner.
24 25 26 27 28 29 |
# File 'lib/rails_doctor/init/runner.rb', line 24 def initialize(project:, config:, runner:, options:) @project = project @config = config @runner = runner @options = end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
22 23 24 |
# File 'lib/rails_doctor/init/runner.rb', line 22 def config @config end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
22 23 24 |
# File 'lib/rails_doctor/init/runner.rb', line 22 def @options end |
#project ⇒ Object (readonly)
Returns the value of attribute project.
22 23 24 |
# File 'lib/rails_doctor/init/runner.rb', line 22 def project @project end |
#runner ⇒ Object (readonly)
Returns the value of attribute runner.
22 23 24 |
# File 'lib/rails_doctor/init/runner.rb', line 22 def runner @runner end |
Instance Method Details
#run ⇒ Object
31 32 33 34 35 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 63 64 65 66 67 68 69 |
# File 'lib/rails_doctor/init/runner.rb', line 31 def run changes = planned_changes lines = [] lines << "Rails Doctor init" lines << "Profile: #{.fetch(:profile, "recommended")}" lines << "" lines << "Planned file changes" changes.each do |change| lines << "- #{change.fetch(:path)} (#{change.fetch(:action)})" end lines << "" missing = missing_gems if missing.any? lines << "Missing recommended gems" missing.each { |gem| lines << "- #{gem} (#{RECOMMENDED_GEMS.fetch(gem)})" } lines << "" end if [:dry_run] lines << "Dry run only. No files were changed." return lines.join("\n") + "\n" end if [:yes] || confirm?("Apply Rails Doctor configuration? [y/N] ") changes.each { |change| write_change(change) } lines << "Wrote Rails Doctor configuration." else lines << "Skipped file changes." end if missing.any? && should_install_missing? install_missing(missing, lines) elsif missing.any? lines << "Skipped gem installation. Run rails-doctor init --install to install missing tools." end lines.join("\n") + "\n" end |