Skip to content

Commit

Permalink
Speed up source locating on 1.9.
Browse files Browse the repository at this point in the history
  • Loading branch information
phiggins committed Jul 8, 2012
1 parent 5e67bbc commit 1f48df9
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions lib/heckle.rb
Expand Up @@ -519,7 +519,7 @@ def current_tree

# Copied from Flay#process
def find_scope_and_method
expand_dirs_to_files('.').each do |file|
expand_dirs_to_files.each do |file|
#warn "Processing #{file}" if option[:verbose]

ext = File.extname(file).sub(/^\./, '')
Expand Down Expand Up @@ -602,12 +602,25 @@ def find_method sexp
nil
end

def expand_dirs_to_files *dirs
extensions = ['rb'] # + Flay.load_plugins
def expand_dirs_to_files
dirs = if Method.instance_methods.include? :source_location
class_method = method_name.to_s =~ /^self\./
clean_name = method_name.to_s.sub(/^self\./, '').to_sym

method = if class_method
klass.method(clean_name)
else
klass.instance_method(clean_name)
end

[method.source_location.first]
else
['.']
end

dirs.flatten.map { |p|
if File.directory? p then
Dir[File.join(p, '**', "*.{#{extensions.join(',')}}")]
Dir[File.join(p, '**', "*.rb")]
else
p
end
Expand Down

0 comments on commit 1f48df9

Please sign in to comment.