lib/rsense/server/load_path.rb in rsense-server-0.5.0 vs lib/rsense/server/load_path.rb in rsense-server-0.5.2

- old
+ new

@@ -1,6 +1,7 @@ require "pathname" +require "bundler" module Rsense module Server module LoadPath @@ -16,12 +17,15 @@ end def dependencies(project) @gemfile = find_gemfile(project) if @gemfile + start_dir = Dir.pwd + Dir.chdir(@gemfile.dirname) lockfile = Bundler::LockfileParser.new(Bundler.read_file(@gemfile)) gem_info(lockfile) + Dir.chdir(start_dir) end end def gem_info(lfile) lfile.specs.map do |s| @@ -44,18 +48,20 @@ paths = Gem.find_files(name) return paths unless paths.empty? && name.length > 1 find_paths(name.chop) end - def find_gemfile(project) + def find_gemfile(project, level=0) + level = level + 1 pth = Pathname.new(project).expand_path - lockfile = Dir.glob(pth.join("**/Gemfile.lock")).first - unless lockfile - unless pth.parent == pth - lockfile = find_gemfile(pth.parent) + lockfile = pth.join("Gemfile.lock") + if lockfile.exist? + return lockfile + else + unless level > 6 + lockfile = find_gemfile(pth.parent, level) end end - lockfile end end end end