Class: RailsDoctor::Adapters::Base
- Inherits:
-
Object
- Object
- RailsDoctor::Adapters::Base
- Defined in:
- lib/rails_doctor/adapters/base.rb
Direct Known Subclasses
Brakeman, BundlerAudit, DependencyFreshness, Flay, Flog, Reek, Rubocop, StrongMigrations, TestCoverage, TestRunner, Zeitwerk
Instance Attribute Summary collapse
-
#changed_files ⇒ Object
readonly
Returns the value of attribute changed_files.
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#profile ⇒ Object
readonly
Returns the value of attribute profile.
-
#project ⇒ Object
readonly
Returns the value of attribute project.
-
#runner ⇒ Object
readonly
Returns the value of attribute runner.
Instance Method Summary collapse
- #available? ⇒ Boolean
- #command ⇒ Object
-
#initialize(project:, config:, runner:, profile:, changed_files: []) ⇒ Base
constructor
A new instance of Base.
- #install_guidance ⇒ Object
- #name ⇒ Object
- #run ⇒ Object
- #unavailable_reason ⇒ Object
Constructor Details
#initialize(project:, config:, runner:, profile:, changed_files: []) ⇒ Base
Returns a new instance of Base.
10 11 12 13 14 15 16 |
# File 'lib/rails_doctor/adapters/base.rb', line 10 def initialize(project:, config:, runner:, profile:, changed_files: []) @project = project @config = config @runner = runner @profile = profile @changed_files = changed_files end |
Instance Attribute Details
#changed_files ⇒ Object (readonly)
Returns the value of attribute changed_files.
8 9 10 |
# File 'lib/rails_doctor/adapters/base.rb', line 8 def changed_files @changed_files end |
#config ⇒ Object (readonly)
Returns the value of attribute config.
8 9 10 |
# File 'lib/rails_doctor/adapters/base.rb', line 8 def config @config end |
#profile ⇒ Object (readonly)
Returns the value of attribute profile.
8 9 10 |
# File 'lib/rails_doctor/adapters/base.rb', line 8 def profile @profile end |
#project ⇒ Object (readonly)
Returns the value of attribute project.
8 9 10 |
# File 'lib/rails_doctor/adapters/base.rb', line 8 def project @project end |
#runner ⇒ Object (readonly)
Returns the value of attribute runner.
8 9 10 |
# File 'lib/rails_doctor/adapters/base.rb', line 8 def runner @runner end |
Instance Method Details
#available? ⇒ Boolean
26 27 28 29 30 |
# File 'lib/rails_doctor/adapters/base.rb', line 26 def available? return false if command.to_s.strip.empty? declared_gems.any? { |gem| project.gem_declared?(gem) } || executable_names.any? { |exe| project.command_available?(exe) } end |
#command ⇒ Object
22 23 24 |
# File 'lib/rails_doctor/adapters/base.rb', line 22 def command config.command(name) end |
#install_guidance ⇒ Object
36 37 38 |
# File 'lib/rails_doctor/adapters/base.rb', line 36 def install_guidance "Run rails-doctor init to add #{declared_gems.first || name} to the appropriate development/test group." end |
#name ⇒ Object
18 19 20 |
# File 'lib/rails_doctor/adapters/base.rb', line 18 def name self.class::NAME end |
#run ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/rails_doctor/adapters/base.rb', line 40 def run command_result = runner.run(command, timeout_seconds: timeout_seconds) { tool_run: ToolRun.new( name: name, available: true, skipped: false, command: command, exit_status: command_result.exit_status, duration_ms: command_result.duration_ms, stdout: command_result.stdout, stderr: command_result.stderr, metadata: (command_result) ), findings: parse(command_result) } end |
#unavailable_reason ⇒ Object
32 33 34 |
# File 'lib/rails_doctor/adapters/base.rb', line 32 def unavailable_reason "#{name} is not installed or available in this project." end |