Skip to content

Commit

Permalink
add springified binstubs
Browse files Browse the repository at this point in the history
also switch rails3 lockfile to the default, so the spring binstub can
use the default lockfile and see itself

Change-Id: Id10cbc3df010671a59c73137a77583e2c2e0e5a8
Reviewed-on: https://gerrit.instructure.com/37802
Tested-by: Jenkins <[email protected]>
Reviewed-by: Cameron Sutter <[email protected]>
Product-Review: Cody Cutrer <[email protected]>
QA-Review: Cody Cutrer <[email protected]>
  • Loading branch information
ccutrer committed Jul 21, 2014
1 parent a55d538 commit 51e987d
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 3 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
/db/*sql
/exports/
Gemfile.lock
Gemfile.lock2
Gemfile.lock3
/log/
/public/app/
Expand Down
6 changes: 3 additions & 3 deletions Gemfile.d/_before.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,12 @@
ruby '1.9.3', :engine => 'ruby', :engine_version => '1.9.3'
end

# force a different lockfile for rails 3
if CANVAS_RAILS3
# force a different lockfile for rails 2
if CANVAS_RAILS2
Bundler::SharedHelpers.class_eval do
class << self
def default_lockfile
Pathname.new("#{Bundler.default_gemfile}.lock3")
Pathname.new("#{Bundler.default_gemfile}.lock2")
end
end
end
Expand Down
10 changes: 10 additions & 0 deletions bin/rails
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/usr/bin/env ruby
begin
load File.expand_path("../spring", __FILE__)
rescue LoadError
end
# This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.

APP_PATH = File.expand_path('../../config/application', __FILE__)
require File.expand_path('../../config/boot', __FILE__)
require 'rails/commands'
7 changes: 7 additions & 0 deletions bin/rake
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/usr/bin/env ruby
begin
load File.expand_path("../spring", __FILE__)
rescue LoadError
end
require 'bundler/setup'
load Gem.bin_path('rake', 'rake')
7 changes: 7 additions & 0 deletions bin/rspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/usr/bin/env ruby
begin
load File.expand_path("../spring", __FILE__)
rescue LoadError
end
require 'bundler/setup'
load Gem.bin_path('rspec-core', 'rspec')
18 changes: 18 additions & 0 deletions bin/spring
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/usr/bin/env ruby

# This file loads spring without using Bundler, in order to be fast
# It gets overwritten when you run the `spring binstub` command

unless defined?(Spring)
require "rubygems"
require "bundler"

if match = Bundler.default_lockfile.read.match(/^GEM$.*?^ (?: )*spring \((.*?)\)$.*?^$/m)
ENV["GEM_PATH"] = ([Bundler.bundle_path.to_s] + Gem.path).join(File::PATH_SEPARATOR)
ENV["GEM_HOME"] = ""
Gem.paths = ENV

gem "spring", match[1]
require "spring/binstub"
end
end

0 comments on commit 51e987d

Please sign in to comment.