Class: Gubed::BreakpointScanner
- Inherits:
-
Object
- Object
- Gubed::BreakpointScanner
- Defined in:
- lib/gubed/breakpoint_scanner.rb
Constant Summary collapse
- BREAKPOINT_PATTERNS =
{ "binding.pry" => /^\s*(?:#\s*)?binding\.pry\b/, "binding.irb" => /^\s*(?:#\s*)?binding\.irb\b/, "binding.break" => /^\s*(?:#\s*)?binding\.break\b/, "debugger" => /^\s*(?:#\s*)?debugger\b/, "byebug" => /^\s*(?:#\s*)?byebug\b/, "debug" => /^\s*(?:#\s*)?(?:require\s+['"]debug['"];\s*)?binding\.break\b/ }.freeze
- RUBY_FILE_EXTENSIONS =
%w[.rb .rake .gemspec].freeze
- DIR_TO_SKIP =
%w[.git vendor node_modules tmp].freeze
Instance Method Summary collapse
-
#initialize(root_path = ".") ⇒ BreakpointScanner
constructor
A new instance of BreakpointScanner.
- #scan ⇒ Object
Constructor Details
#initialize(root_path = ".") ⇒ BreakpointScanner
Returns a new instance of BreakpointScanner.
33 34 35 |
# File 'lib/gubed/breakpoint_scanner.rb', line 33 def initialize(root_path = ".") @root_path = File.(root_path) end |
Instance Method Details
#scan ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/gubed/breakpoint_scanner.rb', line 37 def scan breakpoints = [] Find.find(@root_path) do |path| if File.directory?(path) Find.prune if DIR_TO_SKIP.any? { |dir| path.include?(dir) } next end next unless ruby_file?(path) breakpoints.concat(scan_file(path)) end breakpoints.sort_by(&:location) end |