Module: Txnap::CallSite
- Defined in:
- lib/txnap/call_site.rb
Constant Summary collapse
- LIB_ROOT =
File.("..", __dir__)
Class Method Summary collapse
- .application_location?(location) ⇒ Boolean
- .capture(locations = caller_locations(2, 80)) ⇒ Object
- .display_path(location) ⇒ Object
Class Method Details
.application_location?(location) ⇒ Boolean
16 17 18 19 20 21 22 23 |
# File 'lib/txnap/call_site.rb', line 16 def application_location?(location) path = location.absolute_path || location.path return false if path.nil? || path.start_with?(LIB_ROOT) return false if path.include?("/gems/activerecord-") || path.include?("/gems/activesupport-") return false if path.include?("/gems/bundler-") || path.start_with?("<internal:") true end |
.capture(locations = caller_locations(2, 80)) ⇒ Object
9 10 11 12 13 14 |
# File 'lib/txnap/call_site.rb', line 9 def capture(locations = caller_locations(2, 80)) location = locations.find { |candidate| application_location?(candidate) } return unless location "#{display_path(location)}:#{location.lineno}" end |
.display_path(location) ⇒ Object
25 26 27 28 29 |
# File 'lib/txnap/call_site.rb', line 25 def display_path(location) path = location.absolute_path || location.path working_directory = "#{Dir.pwd}/" path.start_with?(working_directory) ? path.delete_prefix(working_directory) : path end |