Undefined Method 'Reset' for Rdoc::Toplevel:Class When Installing a New Ruby Gem

How to make --no-ri --no-rdoc the default for gem install?

You just add the following line to your local ~/.gemrc file (it is in your home folder):

gem: --no-document

by

echo 'gem: --no-document' >> ~/.gemrc

or you can add this line to the global gemrc config file.

Here is how to find it (in Linux):

strace gem source 2>&1 | grep gemrc

The --no-document option is documented in the RubyGems CLI Reference.

Am I missing something by not installing ri and rdoc for gems?

The point of installing ri documentation is simply that you can use the "ri" command to access method-by-method documentation. For an example, try: "ri String#reverse". Exit by pressing "q".

To try out RDoc documentation, run "gem server" and then connect to localhost:8808 in your browser. I find it useful - you can even click on a method name to see the source code. Of course, you can just go into your gems folder and open the HTML files in the doc folder.

An alternate way to access RDoc is the gemdoc command. See http://www.stephencelis.com/2008/06/12/bashfully-yours-gem-shortcuts.html. That's quite handy, IMHO.

Anyway, you can be lazy and wait until you need the RDoc documentation, and then generate it with "gem rdoc ".

Pushing rdoc documentation to rubygems.org

When you upload your gem into rubygems.org, it automatically uploads the documentation in rubydoc.info

The guide to upload the gem: http://guides.rubygems.org/publishing/

hope it helps

Gem Server and Rails RDoc Not Found

Rails itself has no documentation while you can read rdocs about actionmailer, actionpack, activerecord, activeresource or activesupport.

Ruby gem is overriding standard library

If you want to get the constant in 'root' namespace, you can use :: operator, like this:

logger = ::Logger.new('my.log')

Ruby gem for monitoring HTTP calls by other gems?

I don't know that gem, but you could recreate that functionality quite easily by opening up ruby's Net::HTTP class, aliasing existing methods and adding some logging calls before the actual HTTP calls.

For example, here's how you could print calls to GET to stdout:


require 'rubygems'
require 'net/http'

class Net::HTTP
# Note that you have to be in the singleton class to alias a class method
class << self
alias_method :orig_get, :get

def get(uri_or_host, path=nil, port=nil)
# here's where you log theactivity, before calling the original method
puts "GET: #{uri_or_host}#{':' + port if port}#{path}"
orig_get(uri_or_host, path, port)
end
end
end

Require paths for rspec tests in a Ruby Gem

The problem is originating in lib/go_run/parser.rb rather than from the test itself. Whenever Ruby finds the GoRun::Parser definition, it goes looking for GoRun in the constant lookup table, but it won't be there, and so the program exits with an error.

Note that using lib/go_run.rb as an entry point also will not work, because go_run/parser.rb is required before GoRun is defined.

Part of the problem is using GoRun as both the project level namespace, and an entry point class.


There are a couple of idioms you should consider to fix this situation:

  1. Make GoRun a top level module, used purely for namespacing. Move the logic that lives in the current logic into its own class, for example go_run/cli.rb. The go_run.rb file is then kept as a sort of manifest file, that requires the classes of your project.

  2. Use the nested module- and class syntax. This will define the outer module if it isn't already.

  3. Use a spec_helper.rb file that bootstraps your project using require 'go_run', to make sure everything is properly loaded before running your tests.



Related Topics



Leave a reply



Submit