Class: Yoker::Detectors::RailsDetector
- Inherits:
-
Object
- Object
- Yoker::Detectors::RailsDetector
- Defined in:
- lib/yoker/detectors/rails_detector.rb
Class Method Summary collapse
Class Method Details
.rails_api_only? ⇒ Boolean
38 39 40 41 42 43 44 45 |
# File 'lib/yoker/detectors/rails_detector.rb', line 38 def self.rails_api_only? return false unless rails_app? app_rb = File.read("config/application.rb") app_rb.include?("config.api_only = true") rescue false end |
.rails_app? ⇒ Boolean
6 7 8 9 10 |
# File 'lib/yoker/detectors/rails_detector.rb', line 6 def self.rails_app? File.exist?("config/application.rb") && File.exist?("Gemfile") && File.read("Gemfile").include?("rails") end |
.rails_version ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/yoker/detectors/rails_detector.rb', line 12 def self.rails_version return nil unless rails_app? # Try to get version from Gemfile.lock first if File.exist?("Gemfile.lock") gemfile_lock = File.read("Gemfile.lock") # Look for the rails gem specifically in the GEM section # Format: " rails (8.1.0.beta1)" if gemfile_lock =~ /^\s{4}rails\s+\(([^)]+)\)/ return $1 end end # Fallback to checking Rails constant if available begin require_relative File.("config/application", Dir.pwd) return Rails::VERSION::STRING if defined?(Rails::VERSION::STRING) rescue nil end nil rescue nil end |