Sha256: 99b4e1673a435af682915f6d4ef6bb4f4e44f5401ef6e2ac995f4221e86ec4ac

Contents?: true

Size: 625 Bytes

Versions: 1

Compression:

Stored size: 625 Bytes

Contents

require "rails_finder/gemfile"
require "rails_finder/environment_file"

module RailsFinder
  class App
    attr_reader :root

    def initialize(root)
      @root = root
    end

    def basename
      File.basename(root)
    end

    def rails_version
      if gemfile.exists?
        gemfile.rails_version
      elsif envfile.exists?
        envfile.rails_version
      else
        "n/a"
      end
    end

    private

    def gemfile
      @gemfile ||= Gemfile.new(File.join(root, "Gemfile"))
    end

    def envfile
      @envfile ||= EnvironmentFile.new(File.join(root, "config", "environment.rb"))
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rails_finder-0.0.1 lib/rails_finder/app.rb