Permalink
Browse files

Track modules independent of gems and care less about gems

  • Loading branch information...
skade committed Jan 21, 2013
1 parent edd39d2 commit 74fdf09ea18bbaff25d6a4661a2cc1c6f8b1d7f5
@@ -182,16 +182,25 @@ def use(m, *args, &block)
# @returns The root path of the loaded gem
def gem(name, main_module)
_,spec = Gem.loaded_specs.find { |spec_name, spec| spec_name == name }
gems << [main_module, spec]
gems << spec
modules << main_module
spec.full_gem_path
end
##
# Returns all currently known padrino gems.
#
# @returns [Module, Gem::Specification]
# @returns [Gem::Specification]
def gems
@gems ||= []
end
##
# All loaded Padrino modules.
#
# @returns [<Padrino::Module>]
def modules
@modules ||= []
end
end # self
end # Padrino
@@ -200,8 +200,8 @@ def dependency_paths
"#{root}/config/database.rb", "#{root}/lib/**/*.rb", "#{root}/shared/lib/**/*.rb",
"#{root}/models/**/*.rb", "#{root}/shared/models/**/*.rb", "#{root}/config/apps.rb"
]
gem_paths = Padrino.gems.map { |mod,_| mod.dependency_paths }.flatten!
@_dependency_paths ||= (@_dependency_paths_was + Array(gem_paths))
module_paths = Padrino.modules.map(&:dependency_paths).flatten!
@_dependency_paths ||= (@_dependency_paths_was + Array(module_paths))
end
##
@@ -32,7 +32,6 @@ def gem!(name)
def root(*args)
File.expand_path(File.join(@root, *args))
end
##
# Returns the list of path globs to load as dependencies
@@ -161,12 +161,11 @@ def locate_app_file
candidates << app_constant.app_file if app_constant.respond_to?(:app_file) && File.exist?(app_constant.app_file.to_s)
candidates << Padrino.first_caller if File.identical?(Padrino.first_caller.to_s, Padrino.called_from.to_s)
candidates << Padrino.mounted_root(name.downcase, "app.rb")
Padrino.gems.each do |_, spec|
next if @gem && spec.name != @gem
simple_name = name.split("::").last.downcase
if path = spec.require_paths.grep(%r|#{simple_name}/?$|)
candidates << File.expand_path(File.join(spec.full_gem_path, path, "app.rb"))
simple_name = name.split("::").last.downcase
mod_name = name.split("::")[0..-2].join("::")
Padrino.modules.each do |mod|
if mod.name == mod_name
candidates << mod.root(simple_name, "app.rb")
end
end
candidates << Padrino.root("app", "app.rb")

0 comments on commit 74fdf09

Please sign in to comment.