Class: CaptiveStackDetector::GemfileAnalyzer
- Inherits:
-
Object
- Object
- CaptiveStackDetector::GemfileAnalyzer
- Defined in:
- lib/captive_stack_detector/gemfile_analyzer.rb
Constant Summary collapse
- ASSET_GEMS =
%w[ sprockets sprockets-rails propshaft importmap-rails cssbundling-rails jsbundling-rails dartsass-rails tailwindcss-rails ].freeze
- REDIS_GEMS =
%w[redis redis-client sidekiq].freeze
Instance Method Summary collapse
- #database ⇒ Object
-
#initialize(gemfile) ⇒ GemfileAnalyzer
constructor
A new instance of GemfileAnalyzer.
- #queue ⇒ Object
- #rails? ⇒ Boolean
- #subtype ⇒ Object
- #worker_command(procfile) ⇒ Object
Constructor Details
#initialize(gemfile) ⇒ GemfileAnalyzer
Returns a new instance of GemfileAnalyzer.
12 13 14 |
# File 'lib/captive_stack_detector/gemfile_analyzer.rb', line 12 def initialize(gemfile) @gemfile = gemfile end |
Instance Method Details
#database ⇒ Object
18 |
# File 'lib/captive_stack_detector/gemfile_analyzer.rb', line 18 def database = gem?("pg") ? "postgres" : nil |
#queue ⇒ Object
19 |
# File 'lib/captive_stack_detector/gemfile_analyzer.rb', line 19 def queue = REDIS_GEMS.any? { |g| gem?(g) } ? "redis" : nil |
#rails? ⇒ Boolean
16 |
# File 'lib/captive_stack_detector/gemfile_analyzer.rb', line 16 def rails? = gem?("rails") |
#subtype ⇒ Object
17 |
# File 'lib/captive_stack_detector/gemfile_analyzer.rb', line 17 def subtype = ASSET_GEMS.any? { |g| gem?(g) } ? "app" : "api" |
#worker_command(procfile) ⇒ Object
21 22 23 24 25 26 27 28 29 |
# File 'lib/captive_stack_detector/gemfile_analyzer.rb', line 21 def worker_command(procfile) if procfile procfile.each_line do |line| m = line.match(/^worker:\s*(.+)$/) return m[1].strip if m end end gem?("sidekiq") ? "bundle exec sidekiq" : nil end |