Sha256: 5ad643547ce7b7402b19fe26d6110f0c8341cf4fbf19a42417e6b9a59c52a838

Contents?: true

Size: 760 Bytes

Versions: 5

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.2.0"
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

5 entries across 5 versions & 1 rubygems

Version Path
activeadmin-0.4.4 spec/support/detect_rails_version.rb
activeadmin-0.4.3 spec/support/detect_rails_version.rb
activeadmin-0.4.2 spec/support/detect_rails_version.rb
activeadmin-0.4.1 spec/support/detect_rails_version.rb
activeadmin-0.4.0 spec/support/detect_rails_version.rb