Sha256: 5188b1c9f4dc2d1d227a334b43811fbc94a70d597480dc9ca9006ea4a85c13d9

Contents?: true

Size: 440 Bytes

Versions: 2

Compression:

Stored size: 440 Bytes

Contents

module RailsFinder
  class Gemfile
    attr_reader :path

    def initialize(path)
      @path = path
    end

    def exists?
      File.exists?(path)
    end

    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
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rails_finder-0.0.3 lib/rails_finder/gemfile.rb
rails_finder-0.0.2 lib/rails_finder/gemfile.rb