繁体   English   中英

捆绑包打开disqus_api无法访问真实源代码?

[英]bundle open disqus_api not accessing real source code?

我正在尝试在该项目上使用宝石https://github.com/toptal/disqus_api ,但正在努力使其接受我的身份验证详细信息。 那可能最终是一个单独的问题,但是现在我想探索源代码并进行一些手动调试。

问题是,当我bundle open disqus_api时,发生了一些奇怪的事情。 它似乎在查找文件,但是当我对其进行任何更改(例如,调试器中断)时,它没有被拾取(并且当它引发错误,因此应向下移动一行时,该行号不变) 。

就是说,有一个迹象表明我可能并没有完全放错地方,那就是当我临时删除gem的整个lib目录时,尽管它仍加载核心DisqusApi类,但该类上pry的'show-source'方法现在输出Error: Couldn't locate a definition for DisqusApi!

(编辑添加):

具体来说,是此文件的第70行

因此,在我对其进行编辑之后,我们可以:

def perform_request #line 68
  require 'byebug' #69
  byebug #70
  yield.tap do |response| #71
    raise InvalidApiRequestError.new(response) if response['code'] != 0 #72
  end
end

但它会DisqusApi::InvalidApiRequestError: {"code"=>5, "response"=>"Invalid API key"} from /Users/sashacooper/.rvm/gems/ruby-2.3.1/gems/disqus_api-0.0.5/lib/disqus_api/api.rb:70:in如下所示: DisqusApi::InvalidApiRequestError: {"code"=>5, "response"=>"Invalid API key"} from /Users/sashacooper/.rvm/gems/ruby-2.3.1/gems/disqus_api-0.0.5/lib/disqus_api/api.rb:70:in in perform_request DisqusApi::InvalidApiRequestError: {"code"=>5, "response"=>"Invalid API key"} from /Users/sashacooper/.rvm/gems/ruby-2.3.1/gems/disqus_api-0.0.5/lib/disqus_api/api.rb:70:in

这是怎么回事?

使用byebug宝石

  1. 在您项目的Gemfile.rb中

     group :development do gem 'byebug' end 
  2. 在终端上, 打开disqus_api gem

     bundle open disqus_api 
  3. 在gem的lib / disqus_api.rb上,需要byebug gem。

     require 'byebug' 
  4. debugger调用放在要调试的行上

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM