Sha256: 6f1a84c02922e6ad3406bdbf75daae8bdc6d1d2789785a2aea95c8ce1dfddf08

Contents?: true

Size: 749 Bytes

Versions: 4

Compression:

Stored size: 749 Bytes

Contents

module ZombieScout
  class MethodCallFinder

    def initialize(ruby_project)
      @ruby_project = ruby_project
    end

    def count_calls(method_name)
      method_name = method_name.to_s
      method_name.sub!(/=$/, ' *=')
      find_occurrances(method_name).size
    end

    private

    def find_occurrances(method_name)
      # TODO somehow expose some of this config for end-users
      command = "grep -rnw --include=\"*.rb\" --include=\"*.erb\" --binary-files=without-match \"#{method_name}\" #{files_to_search} "
      #  grep -r --include="*.rb" --include="*.erb" -nw PATTERN app lib

      grep_lines = `#{command}`
      grep_lines.split("\n")
    end

    def files_to_search
      @ruby_project.folders.join(' ')
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
zombie_scout-0.0.4 lib/zombie_scout/method_call_finder.rb
zombie_scout-0.0.3 lib/zombie_scout/method_call_finder.rb
zombie_scout-0.0.2 lib/zombie_scout/method_call_finder.rb
zombie_scout-0.0.1 lib/zombie_scout/method_call_finder.rb