Class: RailsFinder::EnvironmentFile

Inherits:
Object
  • Object
show all
Defined in:
lib/rails_finder/environment_file.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ EnvironmentFile

Returns a new instance of EnvironmentFile.



5
6
7
# File 'lib/rails_finder/environment_file.rb', line 5

def initialize(path)
  @path = path
end

Instance Attribute Details

#pathObject (readonly)

Returns the value of attribute path.



3
4
5
# File 'lib/rails_finder/environment_file.rb', line 3

def path
  @path
end

Instance Method Details

#exists?Boolean

Returns:

  • (Boolean)


9
10
11
# File 'lib/rails_finder/environment_file.rb', line 9

def exists?
  File.exists?(path)
end

#rails_versionObject



13
14
15
16
17
18
19
20
21
22
# File 'lib/rails_finder/environment_file.rb', line 13

def rails_version
  return @rails_version if @rails_version

  version_line = File.readlines(path).find { |l| l =~ /RAILS_GEM_VERSION/ }
  if version_line
    @rails_version = version_line[/\d+\.\d+(\.\d+)?/].strip
  else
    @rails_version = "n/a"
  end
end