Sha256: 8ab5643cd86eb150e8910b1775b85e031aa2c4e77ab41faeaf186d8e68c16fcc

Contents?: true

Size: 1.12 KB

Versions: 9

Compression:

Stored size: 1.12 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.

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

unless File.exists?(gem_lock_file)
  # Generate it
  cmd "rm Gemfile.lock" if file_or_symlink?("Gemfile.lock")
  cmd "export RAILS=#{version} && bundle install"
  cmd "mv Gemfile.lock #{gem_lock_file}"
end

cmd("rm Gemfile.lock") if file_or_symlink?("Gemfile.lock")
cmd("ln -s #{gem_lock_file} Gemfile.lock")
cmd("bundle")

Version data entries

9 entries across 9 versions & 2 rubygems

Version Path
andrewroth_activeadmin-0.3.4.3 script/use_rails
andrewroth_activeadmin-0.3.4.2 script/use_rails
andrewroth_activeadmin-0.3.4.1 script/use_rails
andrewroth_activeadmin-0.3.4 script/use_rails
activeadmin-0.3.4 script/use_rails
activeadmin-0.3.3 script/use_rails
activeadmin-0.3.2 script/use_rails
activeadmin-0.3.1 script/use_rails
activeadmin-0.3.0 script/use_rails