Firendly Backtrace (где команда) с помощью ruby ​​byebug - PullRequest
3 голосов
/ 07 апреля 2019

Я использую byebug, чтобы узнать источник определенного вызова, но когда я использую where, я получаю полную обратную трассировку .

Есть ли способ отфильтровать команду where, чтобы показать только мой код?

Например, это типичный результат where, он показывает 127 строк, но я бы хотел видеть строки № 0, № 1, № 64 и № 74, потому что только эти строки являются моими «вызовами кода»

(byebug) where
--> #0  Account.last_transactions at /home/albert/druby/bankbox/app/models/account.rb:31
    #1  Api::V1::TransactionsController.index at /home/albert/druby/bankbox/app/controllers/api/v1/transactions_controller.rb:11
    #2  ActionController::BasicImplicitRender.send_action(method#String, *args#Array) at /home/albert/.rvm/gems/ruby-2.6.0@5.2.2/gems/actionpack-5.2.2/lib/action_controller/metal/basic_implicit_render.rb:6
    #3  AbstractController::Base.process_action(method_name#String, *args#Array) at /home/albert/.rvm/gems/ruby-2.6.0@5.2.2/gems/actionpack-5.2.2/lib/abstract_controller/base.rb:194
    #4  ActionController::Rendering.process_action(*args) at /home/albert/.rvm/gems/ruby-2.6.0@5.2.2/gems/actionpack-5.2.2/lib/action_controller/metal/rendering.rb:30
    #5  block in AbstractController::Callbacks.block in process_action(*args#Array) at /home/albert/.rvm/gems/ruby-2.6.0@5.2.2/gems/actionpack-5.2.2/lib/abstract_controller/callbacks.rb:42
    #6  ActiveSupport::Callbacks.run_callbacks(kind#Symbol) at /home/albert/.rvm/gems/ruby-2.6.0@5.2.2/gems/activesupport-5.2.2/lib/active_support/callbacks.rb:132
    #7  AbstractController::Callbacks.process_action(*args#Array) at /home/albert/.rvm/gems/ruby-2.6.0@5.2.2/gems/actionpack-5.2.2/lib/abstract_controller/callbacks.rb:41
    #8  ActionController::Rescue.process_action(*args#Array) at /home/albert/.rvm/gems/ruby-2.6.0@5.2.2/gems/actionpack-5.2.2/lib/action_controller/metal/rescue.rb:22
.... 
55 more lines
....
    #63 block (2 levels) in Rails::Controller::Testing::Integration.block (2 levels) in <module:Integration>(*args#Array) at /home/albert/.rvm/gems/ruby-2.6.0@5.2.2/gems/rails-controller-testing-1.0.4/lib/rails/controller/testing/integration.rb:13
    #64 block (2 levels) in RSpec::ExampleGroups::GETApiV1AccountsAccountIdTransactions::LetDefinitions.block (2 levels) in <main> at /home/albert/druby/bankbox/spec/requests/api/v1/transactions/index_spec.rb:7
    #65 block (2 levels) in RSpec::ExampleGroups::GETApiV1AccountsAccountIdTransactions.block (2 levels) in let at /home/albert/.rvm/gems/ruby-2.6.0@5.2.2/gems/rspec-core-3.8.0/lib/rspec/core/memoized_helpers.rb:298
    #66 block (3 levels) in RSpec::Core::MemoizedHelpers::ThreadsafeMemoized.block (3 levels) in fetch_or_store(key#Symbol) at /home/albert/.rvm/gems/ruby-2.6.0@5.2.2/gems/rspec-core-3.8.0/lib/rspec/core/memoized_helpers.rb:157
    ͱ-- #67 Hash.fetch(*args) at /home/albert/.rvm/gems/ruby-2.6.0@5.2.2/gems/rspec-core-3.8.0/lib/rspec/core/memoized_helpers.rb:157
    #68 block (2 levels) in RSpec::Core::MemoizedHelpers::ThreadsafeMemoized.block (2 levels) in fetch_or_store(key#Symbol) at /home/albert/.rvm/gems/ruby-2.6.0@5.2.2/gems/rspec-core-3.8.0/lib/rspec/core/memoized_helpers.rb:157
    #69 RSpec::Support::ReentrantMutex.synchronize at /home/albert/.rvm/gems/ruby-2.6.0@5.2.2/gems/rspec-support-3.8.0/lib/rspec/support/reentrant_mutex.rb:23
    #70 block in RSpec::Core::MemoizedHelpers::ThreadsafeMemoized.block in fetch_or_store(key#Symbol) at /home/albert/.rvm/gems/ruby-2.6.0@5.2.2/gems/rspec-core-3.8.0/lib/rspec/core/memoized_helpers.rb:156
    ͱ-- #71 Hash.fetch(*args) at /home/albert/.rvm/gems/ruby-2.6.0@5.2.2/gems/rspec-core-3.8.0/lib/rspec/core/memoized_helpers.rb:155
    #72 RSpec::Core::MemoizedHelpers::ThreadsafeMemoized.fetch_or_store(key#Symbol) at /home/albert/.rvm/gems/ruby-2.6.0@5.2.2/gems/rspec-core-3.8.0/lib/rspec/core/memoized_helpers.rb:155
    #73 block in RSpec::ExampleGroups::GETApiV1AccountsAccountIdTransactions.block in let at /home/albert/.rvm/gems/ruby-2.6.0@5.2.2/gems/rspec-core-3.8.0/lib/rspec/core/memoized_helpers.rb:298
    #74 block (3 levels) in block (3 levels) in <main> at /home/albert/druby/bankbox/spec/requests/api/v1/transactions/index_spec.rb:16
    ͱ-- #75 BasicObject.instance_exec(*args) at /home/albert/.rvm/gems/ruby-2.6.0@5.2.2/gems/rspec-core-3.8.0/lib/rspec/core/example.rb:447
    #76 RSpec::Core::Example.instance_exec(*args#Array, &block#Proc) at /home/albert/.rvm/gems/ruby-2.6.0@5.2.2/gems/rspec-core-3.8.0/lib/rspec/core/example.rb:447
    #77 RSpec::Core::Hooks::BeforeHook.run(example#RSpec::Core::Example) at /home/albert/.rvm/gems/ruby-2.6.0@5.2.2/gems/rspec-core-3.8.0/lib/rspec/core/hooks.rb:348
    #78 block in RSpec::Core::Hooks::HookCollections.block in run_owned_hooks_for(position#Symbol, scope#Symbol, example_or_group#RSpec::Core::Example) at /home/albert/.rvm/gems/ruby-2.6.0@5.2.2/gems/rspec-core-3.8.0/lib/rspec/core/hooks.rb:507
    ͱ-- #79 Array.each at /home/albert/.rvm/gems/ruby-2.6.0@5.2.2/gems/rspec-core-3.8.0/lib/rspec/core/hooks.rb:506
    #80 RSpec::Core::Hooks::HookCollections.run_owned_hooks_for(position#Symb
....
47 more lines
.....

Спасибо

...