Skip to content

Commit

Permalink
Merge pull request #97 from eric/guard-against-bundler
Browse files Browse the repository at this point in the history
Provide a simple way to prevent bundler auto-loading
  • Loading branch information
eric committed Sep 18, 2012
2 parents 8733f75 + 64a0ec2 commit b046fd8
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
4 changes: 3 additions & 1 deletion bin/god
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ STDOUT.sync = true

$:.unshift File.join(File.dirname(__FILE__), *%w[.. lib])

require 'rubygems'
require 'optparse'
require 'drb'
require 'yaml'
Expand Down Expand Up @@ -105,6 +104,9 @@ begin
abort("Invalid log level '#{options[:log_level]}'")
end

# Use this flag to actually load all of the god infrastructure
$load_god = true

# dispatch
if !options[:config] && options[:version]
require 'god'
Expand Down
10 changes: 8 additions & 2 deletions lib/god.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
$:.unshift File.dirname(__FILE__) # For use/testing when no gem is installed
# Bail out before loading anything unless this flag is set.
#
# We are doing this to guard against bundler autoloading because there is
# no value in loading god in most processes.
if $load_god

# core
require 'stringio'
Expand Down Expand Up @@ -726,7 +730,7 @@ def self.at_exit
# private

# Match a shortened pattern against a list of String candidates.
# The pattern is expanded into a regular expression by
# The pattern is expanded into a regular expression by
# inserting .* between each character.
#
# pattern - The String containing the abbreviation.
Expand Down Expand Up @@ -756,3 +760,5 @@ def self.pattern_match(pattern, list)
at_exit do
God.at_exit if $run
end

end
6 changes: 5 additions & 1 deletion test/helper.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
require 'rubygems'
$:.unshift File.expand_path('../../lib', __FILE__) # For use/testing when no gem is installed

# Use this flag to actually load all of the god infrastructure
$load_god = true

require File.join(File.dirname(__FILE__), *%w[.. lib god sys_logger])
require File.join(File.dirname(__FILE__), *%w[.. lib god])
God::EventHandler.load
Expand Down

0 comments on commit b046fd8

Please sign in to comment.