Class: Externals::RailsDetector

Inherits:
Object
  • Object
show all
Defined in:
lib/externals/project_types/rails.rb

Class Method Summary collapse

Class Method Details

.detected?Boolean

Returns:

  • (Boolean)


19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/externals/project_types/rails.rb', line 19

def self.detected?
  application_path = File.join('config', 'application.rb')
  if File.exist?(application_path)
    open(application_path) do |f|
      f.read =~ /<\s*Rails::Application/
    end
  else
    boot_path = File.join('config', 'boot.rb')
    if File.exist?(boot_path)
      open(boot_path) do |f|
        f.read =~ /^\s*module\s+Rails/
      end
    end
  end
end