Skip to content

Commit

Permalink
[merb-core] Less verbose 'Loading ...' message
Browse files Browse the repository at this point in the history
[#1030 state:resolved]
  • Loading branch information
snusnu committed Sep 27, 2009
1 parent c421ccc commit 5ee0e35
Showing 1 changed file with 23 additions and 2 deletions.
25 changes: 23 additions & 2 deletions merb-core/lib/merb-core/bootloader.rb
Expand Up @@ -497,7 +497,8 @@ def self.env_config?
# :api: private
def self.load_env_config
if env_config?
STDOUT.puts "Loading #{env_config}" unless Merb.testing?
env_config_path = relative_to_merb_path(env_config)
STDOUT.puts "Loading #{env_config_path}" unless Merb.testing?
load(env_config)
end
nil
Expand Down Expand Up @@ -527,7 +528,8 @@ def self.initfile
def self.load_initfile
return nil if Merb.const_defined?("INIT_RB_LOADED")
if File.exists?(initfile)
STDOUT.puts "Loading init file from #{initfile}" unless Merb.testing?
initfile_path = relative_to_merb_path(initfile)
STDOUT.puts "Loading init file from #{initfile_path}" unless Merb.testing?
load(initfile)
Merb.const_set("INIT_RB_LOADED", true)
elsif !Merb.testing?
Expand Down Expand Up @@ -558,6 +560,25 @@ def self.expand_ruby_path
@ran = true
nil
end

# Converts an absolute path to an path relative to Merbs root, if
# the path is in the Merb root dir. Otherwise it will return the
# absolute path.
#
# ==== Returns
# String:: Relative path or absolute
#
# :api: private
def self.relative_to_merb_path(path)
absolute_path = File.expand_path(path)
merb_root = File.expand_path(Merb.root)
if absolute_path.slice(0, merb_root.length) == merb_root
'.' + absolute_path.slice(merb_root.length..-1)
else
absolute_path
end
end

end

class Merb::BootLoader::MixinSession < Merb::BootLoader
Expand Down

0 comments on commit 5ee0e35

Please sign in to comment.