Class: RailsFinder::IsolateFile

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ IsolateFile

Returns a new instance of IsolateFile.



5
6
7
# File 'lib/rails_finder/isolate_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/isolate_file.rb', line 3

def path
  @path
end

Instance Method Details

#exists?Boolean

Returns:

  • (Boolean)


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

def exists?
  File.exists?(path)
end

#rails_versionObject



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

def rails_version
  return @rails_version if @rails_version
  line = File.readlines(path).find { |l| l =~ /^gem.+rails/i }
  if line
    @rails_version = line[/\d+\.\d+(\.\d+)?/] || "n/a"
  else
    @rails_version = "n/a"
  end
end