Sha256: 228dc18037665992cf377a240d59d12dd8f5a2652bb396b452687cd682aa95b6

Contents?: true

Size: 1014 Bytes

Versions: 45

Compression:

Stored size: 1014 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 'psych'
  filename = File.exists?('.travis.yml') ? '.travis.yml' : '../../../.travis.yml'
  TRAVIS_CONFIG = Psych.load File.read filename
  TRAVIS_RAILS_VERSIONS = TRAVIS_CONFIG['env'].grep(/RAILS=(.*)/){ $1 }.sort
end

unless defined? DEFAULT_RAILS_VERSION
  DEFAULT_RAILS_VERSION = TRAVIS_RAILS_VERSIONS.last
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

45 entries across 45 versions & 1 rubygems

Version Path
lalala-4.0.0.dev.141 vendor/deps/active_admin/spec/support/detect_rails_version.rb
lalala-4.0.0.dev.136 vendor/deps/active_admin/spec/support/detect_rails_version.rb
lalala-4.0.0.dev.135 vendor/deps/active_admin/spec/support/detect_rails_version.rb
lalala-4.0.0.dev.134 vendor/deps/active_admin/spec/support/detect_rails_version.rb
lalala-4.0.0.dev.133 vendor/deps/active_admin/spec/support/detect_rails_version.rb
lalala-4.0.0.dev.132 vendor/deps/active_admin/spec/support/detect_rails_version.rb
lalala-4.0.0.dev.131 vendor/deps/active_admin/spec/support/detect_rails_version.rb
lalala-4.0.0.dev.129 vendor/deps/active_admin/spec/support/detect_rails_version.rb
lalala-4.0.0.dev.128 vendor/deps/active_admin/spec/support/detect_rails_version.rb
lalala-4.0.0.dev.126 vendor/deps/active_admin/spec/support/detect_rails_version.rb
lalala-4.0.0.dev.125 vendor/deps/active_admin/spec/support/detect_rails_version.rb
lalala-4.0.0.dev.124 vendor/deps/active_admin/spec/support/detect_rails_version.rb
lalala-4.0.0.dev.123 vendor/deps/active_admin/spec/support/detect_rails_version.rb
lalala-4.0.0.dev.118 vendor/deps/active_admin/spec/support/detect_rails_version.rb
lalala-4.0.0.dev.116 vendor/deps/active_admin/spec/support/detect_rails_version.rb
lalala-4.0.0.dev.114 vendor/deps/active_admin/spec/support/detect_rails_version.rb
lalala-4.0.0.dev.113 vendor/deps/active_admin/spec/support/detect_rails_version.rb
lalala-4.0.0.dev.111 vendor/deps/active_admin/spec/support/detect_rails_version.rb
lalala-4.0.0.dev.109 vendor/deps/active_admin/spec/support/detect_rails_version.rb
lalala-4.0.0.dev.107 vendor/deps/active_admin/spec/support/detect_rails_version.rb