Sha256: ef34374a3e20629365ea06ac8800c51afc3cf0eabb9f5a074b88d16ac7346ecc

Contents?: true

Size: 760 Bytes

Versions: 1

Compression:

Stored size: 760 Bytes

Contents

# Detects the current version of Rails that is being used
#
# You can pass it in as an ENV variable or it will use
# the current Gemfile.lock to find it

unless defined?(RAILS_VERSION_FILE)
  RAILS_VERSION_FILE = File.expand_path("../../../.rails-version", __FILE__)
end

unless defined?(DEFAULT_RAILS_VERSION)
  DEFAULT_RAILS_VERSION = "3.1.3"
end

def detect_rails_version
  detected_version = if File.exists?(RAILS_VERSION_FILE)
    version = File.read(RAILS_VERSION_FILE).chomp.strip
    version != "" ? version : DEFAULT_RAILS_VERSION
  else
    DEFAULT_RAILS_VERSION
  end

  puts "Detected Rails: #{detected_version}" if ENV['DEBUG']

  detected_version
end

def write_rails_version(version)
  File.open(RAILS_VERSION_FILE, "w+"){|f| f << version }
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
andrewroth_activeadmin-0.3.4.4 spec/support/detect_rails_version.rb