Module: RubyLsp::DependencyDetector
- Extended by:
- T::Sig
- Defined in:
- lib/ruby_lsp/requests/support/dependency_detector.rb
Class Method Summary collapse
- .detected_formatter ⇒ Object
- .detected_test_library ⇒ Object
- .direct_dependency?(gem_pattern) ⇒ Boolean
Class Method Details
.detected_formatter ⇒ Object
10 11 12 13 14 15 16 17 18 19 |
# File 'lib/ruby_lsp/requests/support/dependency_detector.rb', line 10 def detected_formatter # NOTE: Intentionally no $ at end, since we want to match rubocop-shopify, etc. if direct_dependency?(/^rubocop/) "rubocop" elsif direct_dependency?(/^syntax_tree$/) "syntax_tree" else "none" end end |
.detected_test_library ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/ruby_lsp/requests/support/dependency_detector.rb', line 22 def detected_test_library # A Rails app may have a dependency on minitest, but we would instead want to use the Rails test runner provided # by ruby-lsp-rails. if direct_dependency?(/^rails$/) "rails" # NOTE: Intentionally ends with $ to avoid mis-matching minitest-reporters, etc. in a Rails app. elsif direct_dependency?(/^minitest$/) "minitest" elsif direct_dependency?(/^test-unit/) "test-unit" elsif direct_dependency?(/^rspec/) "rspec" else "unknown" end end |
.direct_dependency?(gem_pattern) ⇒ Boolean
40 41 42 43 44 45 |
# File 'lib/ruby_lsp/requests/support/dependency_detector.rb', line 40 def direct_dependency?(gem_pattern) Bundler.with_original_env { Bundler.default_gemfile } && Bundler.locked_gems.dependencies.keys.grep(gem_pattern).any? rescue Bundler::GemfileNotFound false end |