Sha256: 9092be8928757e44c7b500d32b22941b94987b4c9eca76fb4abd157da69d714b

Contents?: true

Size: 1.28 KB

Versions: 56

Compression:

Stored size: 1.28 KB

Contents

#!/usr/bin/env ruby
#
# Switches the development environment to use the given
# version of rails. Caches the Gemfile.locks so that 
# switching it very fast.
#
require File.expand_path("../../spec/support/detect_rails_version", __FILE__)

def cmd(command)
  puts command
  exit 1 unless system command
end

version = ARGV[0]

unless version
  puts "USAGE: ./script/#{__FILE__} VERSION [OPTIONS]"
  puts
  puts "Options:"
  puts "  --clobber   Add this flag to remove the existing Gemfile.lock before running"
  exit(1)
end

def file_or_symlink?(path)
  File.exist?(path) || File.symlink?(path)
end

gem_lock_dir = ".gemfile-locks"
gem_lock_file = "#{gem_lock_dir}/Gemfile-#{version}.lock"

# Ensure our lock dir is created
cmd "mkdir #{gem_lock_dir}" unless File.exists?(gem_lock_dir)

# --clobber passed in
if File.exists?(gem_lock_file) && ARGV.include?('--clobber')
  cmd "rm #{gem_lock_file}"
end

write_rails_version(version)

# Ensure that bundler installs
ENV['RUBYOPT'] = ''

if File.exists?(gem_lock_file)
  cmd("rm Gemfile.lock") if file_or_symlink?("Gemfile.lock")
  cmd("ln -s #{gem_lock_file} Gemfile.lock")
  cmd("bundle")
else
  cmd "rm Gemfile.lock" if file_or_symlink?("Gemfile.lock")
  cmd "bundle install"
  cmd "mv Gemfile.lock #{gem_lock_file}"
  cmd("ln -s #{gem_lock_file} Gemfile.lock")
end

Version data entries

56 entries across 56 versions & 3 rubygems

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