Merge pull request #1293 from dsander/optional-spring

Allow to use spring by setting SPRING in .env

Dominik Sander 8 years ago
parent
commit
800e055b47
7 changed files with 49 additions and 12 deletions
  1. 16 11
      Gemfile
  2. 5 0
      Gemfile.lock
  3. 1 1
      Guardfile
  4. 4 0
      bin/rails
  5. 4 0
      bin/rake
  6. 4 0
      bin/rspec
  7. 15 0
      bin/spring

+ 16 - 11
Gemfile

@@ -12,6 +12,17 @@ GemfileHelper.load_dotenv do |dotenv_dir|
12 12
   end
13 13
 end
14 14
 
15
+# Introduces a scope for gem loading based on a condition
16
+def if_true(condition)
17
+  if condition
18
+    yield
19
+  else
20
+    # When not including the gems, we still want our Gemfile.lock
21
+    # to include them, so we scope them to an unsupported platform.
22
+    platform :ruby_18, &proc
23
+  end
24
+end
25
+
15 26
 # Optional libraries.  To conserve RAM, comment out any that you don't need,
16 27
 # then run `bundle` and commit the updated Gemfile and Gemfile.lock.
17 28
 gem 'twilio-ruby', '~> 3.11.5'    # TwilioAgent
@@ -118,6 +129,11 @@ group :development do
118 129
   gem 'capistrano-rails', '~> 1.1'
119 130
   gem 'capistrano-bundler', '~> 1.1.4'
120 131
 
132
+  if_true(ENV['SPRING']) do
133
+    gem 'spring-commands-rspec', '~> 1.0.4'
134
+    gem 'spring', '~> 1.6.3'
135
+  end
136
+
121 137
   group :test do
122 138
     gem 'coveralls', require: false
123 139
     gem 'delorean'
@@ -147,17 +163,6 @@ gem 'tzinfo', '>= 1.2.0'	# required by rails; 1.2.0 has support for *BSD and Sol
147 163
 gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw]
148 164
 
149 165
 
150
-# Introduces a scope for gem loading based on a condition
151
-def if_true(condition)
152
-  if condition
153
-    yield
154
-  else
155
-    # When not including the gems, we still want our Gemfile.lock
156
-    # to include them, so we scope them to an unsupported platform.
157
-    platform :ruby_18, &proc
158
-  end
159
-end
160
-
161 166
 on_heroku = ENV['ON_HEROKU'] ||
162 167
             ENV['HEROKU_POSTGRESQL_ROSE_URL'] ||
163 168
             ENV['HEROKU_POSTGRESQL_GOLD_URL'] ||

+ 5 - 0
Gemfile.lock

@@ -496,6 +496,9 @@ GEM
496 496
     slop (3.6.0)
497 497
     spectrum-rails (1.3.4)
498 498
       railties (>= 3.1)
499
+    spring (1.6.3)
500
+    spring-commands-rspec (1.0.4)
501
+      spring (>= 0.9.1)
499 502
     sprockets (3.5.2)
500 503
       concurrent-ruby (~> 1.0)
501 504
       rack (> 1, < 3)
@@ -653,6 +656,8 @@ DEPENDENCIES
653 656
   shoulda-matchers
654 657
   slack-notifier (~> 1.0.0)
655 658
   spectrum-rails
659
+  spring (~> 1.6.3)
660
+  spring-commands-rspec (~> 1.0.4)
656 661
   string-scrub
657 662
   therubyracer (~> 0.12.2)
658 663
   tumblr_client!

+ 1 - 1
Guardfile

@@ -8,7 +8,7 @@ guard 'livereload' do
8 8
   watch(%r{(app|vendor)(/assets/\w+/(.+\.(css|js|html|png|jpg))).*}) { |m| "/assets/#{m[3]}" }
9 9
 end
10 10
 
11
-guard :rspec, cmd: 'bundle exec rspec' do
11
+guard :rspec, cmd: ENV['SPRING'] ? 'bundle exec spring rspec' : 'bundle exec rspec' do
12 12
   watch(%r{^spec/.+_spec\.rb$})
13 13
   watch(%r{^lib/(.+)\.rb$})     { |m| "spec/lib/#{m[1]}_spec.rb" }
14 14
   watch('spec/spec_helper.rb')  { "spec" }

+ 4 - 0
bin/rails

@@ -1,4 +1,8 @@
1 1
 #!/usr/bin/env ruby
2
+begin
3
+  load File.expand_path("../spring", __FILE__)
4
+rescue LoadError
5
+end
2 6
 APP_PATH = File.expand_path('../../config/application',  __FILE__)
3 7
 require_relative '../config/boot'
4 8
 require 'rails/commands'

+ 4 - 0
bin/rake

@@ -1,4 +1,8 @@
1 1
 #!/usr/bin/env ruby
2
+begin
3
+  load File.expand_path("../spring", __FILE__)
4
+rescue LoadError
5
+end
2 6
 require_relative '../config/boot'
3 7
 require 'rake'
4 8
 Rake.application.run

+ 4 - 0
bin/rspec

@@ -1,3 +1,7 @@
1 1
 #!/usr/bin/env ruby
2
+begin
3
+  load File.expand_path("../spring", __FILE__)
4
+rescue LoadError
5
+end
2 6
 require 'bundler/setup'
3 7
 load Gem.bin_path('rspec-core', 'rspec')

+ 15 - 0
bin/spring

@@ -0,0 +1,15 @@
1
+#!/usr/bin/env ruby
2
+
3
+# This file loads spring without using Bundler, in order to be fast.
4
+# It gets overwritten when you run the `spring binstub` command.
5
+
6
+unless defined?(Spring)
7
+  require "rubygems"
8
+  require "bundler"
9
+
10
+  if match = Bundler.default_lockfile.read.match(/^GEM$.*?^    (?:  )*spring \((.*?)\)$.*?^$/m)
11
+    Gem.paths = { "GEM_PATH" => [Bundler.bundle_path.to_s, *Gem.path].uniq }
12
+    gem "spring", match[1]
13
+    require "spring/binstub"
14
+  end
15
+end