Class: Hone::Analyzer
- Inherits:
-
Object
- Object
- Hone::Analyzer
- Defined in:
- lib/hone/analyzer.rb
Overview
Orchestrates the full analysis pipeline: Scanner -> MethodMap -> Profiler -> Correlator -> Reporter
Defined Under Namespace
Classes: Result
Constant Summary collapse
- PROFILE_DIR =
Default directory for cached profile files
"tmp/hone"
Instance Method Summary collapse
-
#initialize(path, profile: nil, memory_profile: nil, format: :text, color: nil, quiet: false, verbose: false, top: nil, hot_only: false, show_cold: false, fail_on: :hot, diff: nil, baseline: nil, rails: false) ⇒ Analyzer
constructor
A new instance of Analyzer.
-
#run ⇒ Result
Run the analysis pipeline.
Constructor Details
#initialize(path, profile: nil, memory_profile: nil, format: :text, color: nil, quiet: false, verbose: false, top: nil, hot_only: false, show_cold: false, fail_on: :hot, diff: nil, baseline: nil, rails: false) ⇒ Analyzer
Returns a new instance of Analyzer.
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/hone/analyzer.rb', line 41 def initialize(path, profile: nil, memory_profile: nil, format: :text, color: nil, quiet: false, verbose: false, top: nil, hot_only: false, show_cold: false, fail_on: :hot, diff: nil, baseline: nil, rails: false) @path = path @profile_path = profile || auto_detect_profile(:cpu) @memory_profile_path = memory_profile || auto_detect_profile(:memory) @format = format.to_sym @color = color @quiet = quiet @verbose = verbose @top = top @hot_only = hot_only @show_cold = show_cold @fail_on = fail_on.to_sym @diff = diff @baseline = baseline @rails = rails end |
Instance Method Details
#run ⇒ Result
Run the analysis pipeline
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 |
# File 'lib/hone/analyzer.rb', line 61 def run validate_input! # Step 1: Scan for patterns findings = scan_path # Step 2: Build method map for correlation method_map = build_method_map # Step 3: Load profile data (if available) profiles = load_profiles # Step 4: Correlate findings with profile correlator = Correlator.new( method_map: method_map, cpu_profile: profiles[:cpu], memory_profile: profiles[:memory] ) = correlator.correlate(findings) # Step 5: Apply filtering filtered = apply_filters() # Step 6: Generate output output = generate_output(filtered) # Step 7: Calculate exit code exit_code = calculate_exit_code(filtered) Result.new(findings: filtered, output: output, exit_code: exit_code) rescue Error => e Result.new(findings: [], output: "Error: #{e.}", exit_code: ExitCodes::ERROR) rescue => e Result.new(findings: [], output: "Error: #{e.}\n#{e.backtrace.first(5).join("\n")}", exit_code: ExitCodes::ERROR) end |