简体   繁体   English

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

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

I'm trying out the gem https://github.com/toptal/disqus_api for use on this project , but struggling to get it to accept my auth details. 我正在尝试在该项目上使用宝石https://github.com/toptal/disqus_api ,但正在努力使其接受我的身份验证详细信息。 That might end up being a separate question, but for now I wanted to explore the source code and do some manual debugging. 那可能最终是一个单独的问题,但是现在我想探索源代码并进行一些手动调试。

The trouble is, something odd is happening when I bundle open disqus_api . 问题是,当我bundle open disqus_api时,发生了一些奇怪的事情。 It's seemingly finding the files, but when I make any change to them (eg a interrupting with a debugger), it's not being picked up (and when it raises an error that should consequently be shifted a line down, the line number is unchanged). 它似乎在查找文件,但是当我对其进行任何更改(例如,调试器中断)时,它没有被拾取(并且当它引发错误,因此应向下移动一行时,该行号不变) 。

That said, one sign that I might not be in completely the wrong place is that when I temporarily delete the gem's entire lib directory, while it still loads the core DisqusApi class, pry's 'show-source' method on the class now outputs Error: Couldn't locate a definition for DisqusApi! 就是说,有一个迹象表明我可能并没有完全放错地方,那就是当我临时删除gem的整个lib目录时,尽管它仍加载核心DisqusApi类,但该类上pry的'show-source'方法现在输出Error: Couldn't locate a definition for DisqusApi! .

(Edited to add): (编辑添加):

To be specific, it's line 70 of this file 具体来说,是此文件的第70行

So after I've edited it, we have: 因此,在我对其进行编辑之后,我们可以:

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

But it errs like this: 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 block 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如下所示: 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

What's going on? 这是怎么回事?

Use the byebug gem 使用byebug宝石

  1. On your project's Gemfile.rb 在您项目的Gemfile.rb中

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

     bundle open disqus_api 
  3. On the gem's lib/disqus_api.rb require the byebug gem. 在gem的lib / disqus_api.rb上,需要byebug gem。

     require 'byebug' 
  4. Place your debugger call on the line you want to debug debugger调用放在要调试的行上

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

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