简体   繁体   中英

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. 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 . 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! .

(Edited to add):

To be specific, it's line 70 of this file

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'`

What's going on?

Use the byebug gem

  1. On your project's Gemfile.rb

     group :development do gem 'byebug' end 
  2. On the terminal open the disqus_api gem

     bundle open disqus_api 
  3. On the gem's lib/disqus_api.rb require the byebug gem.

     require 'byebug' 
  4. Place your debugger call on the line you want to debug

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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