Class: RailsFinder::Gemfile
- Inherits:
-
Object
- Object
- RailsFinder::Gemfile
- Defined in:
- lib/rails_finder/gemfile.rb
Instance Attribute Summary collapse
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Instance Method Summary collapse
- #exists? ⇒ Boolean
-
#initialize(path) ⇒ Gemfile
constructor
A new instance of Gemfile.
- #rails_version ⇒ Object
Constructor Details
#initialize(path) ⇒ Gemfile
Returns a new instance of Gemfile.
5 6 7 |
# File 'lib/rails_finder/gemfile.rb', line 5 def initialize(path) @path = path end |
Instance Attribute Details
#path ⇒ Object (readonly)
Returns the value of attribute path.
3 4 5 |
# File 'lib/rails_finder/gemfile.rb', line 3 def path @path end |
Instance Method Details
#exists? ⇒ Boolean
9 10 11 |
# File 'lib/rails_finder/gemfile.rb', line 9 def exists? File.exists?(path) end |
#rails_version ⇒ Object
13 14 15 16 17 18 19 20 21 |
# File 'lib/rails_finder/gemfile.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 |