Sha256: f4da32e3014b6cef805bd1b53700325375f7a3407e641bce8163ed1090c76bea

Contents?: true

Size: 985 Bytes

Versions: 11

Compression:

Stored size: 985 Bytes

Contents

# Detects the current version of Rails that is being used
#
#
unless defined? RAILS_VERSION_FILE
  RAILS_VERSION_FILE = File.expand_path("../../../.rails-version", __FILE__)
end

unless defined? TRAVIS_CONFIG
  require 'yaml'
  filename = File.expand_path("../../../.travis.yml", __FILE__)
  TRAVIS_CONFIG = YAML.load_file filename
  TRAVIS_RAILS_VERSIONS = TRAVIS_CONFIG['env'].grep(/RAILS=(.*)/){ $1 }
end

unless defined? DEFAULT_RAILS_VERSION
  DEFAULT_RAILS_VERSION = TRAVIS_RAILS_VERSIONS.first
end

def detect_rails_version
  version = version_from_file || version_from_env || DEFAULT_RAILS_VERSION

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

  version
end

def version_from_file
  if File.exists?(RAILS_VERSION_FILE)
    version = File.read(RAILS_VERSION_FILE).chomp.strip
    version = nil if version == ""

    version
  end
end

def version_from_env
  ENV['RAILS']
end

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

Version data entries

11 entries across 11 versions & 4 rubygems

Version Path
yousty-activeadmin-1.0.4.pre spec/support/detect_rails_version.rb
yousty-activeadmin-1.0.3.pre spec/support/detect_rails_version.rb
active_administration-0.0.3 spec/support/detect_rails_version.rb
activeadministration-0.0.2 spec/support/detect_rails_version.rb
active_administration-0.0.2 spec/support/detect_rails_version.rb
activeadministration-0.0.1 spec/support/detect_rails_version.rb
active_administration-0.0.1 spec/support/detect_rails_version.rb
yousty-activeadmin-1.0.2.pre spec/support/detect_rails_version.rb
yousty-activeadmin-1.0.1.pre spec/support/detect_rails_version.rb
yousty-activeadmin-1.0.0.pre spec/support/detect_rails_version.rb
aa-rails4-0.6.0 spec/support/detect_rails_version.rb