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:
Make
GoRun
a top levelmodule
, used purely for namespacing. Move the logic that lives in the current logic into its ownclass
, for examplego_run/cli.rb
. Thego_run.rb
file is then kept as a sort of manifest file, that requires the classes of your project.Use the nested
module
- andclass
syntax. This will define the outer module if it isn't already.Use a
spec_helper.rb
file that bootstraps your project usingrequire 'go_run'
, to make sure everything is properly loaded before running your tests.
Related Topics
Getting All Links of a Webpage Using Ruby
How to Download a Ruby Gem Without Installing It Automatically
How to Declare a Rake Task That Depends on a Parameterized Task
Elegant Command-Parsing in an Oop-Based Text Game
Working with a Large Data Object Between Ruby Processes
How to Calculate Next, Previous Business Day in Rails
Ror, Can't Iterate from Datetime/Timewithzone
Port in Use When Not Using a Port
Detecting Linux Distribution/Platform in Ruby
Solving Dependency Constraints
Calling a Class Method Within a Class
Best Way to Remove File Extension
How to Parse a Number from a String That May Have a Leading Zero
Application.CSS Not Being Served as an Asset
Heroku Won't Reset My Database
Access Localhost on MAC from Xcode? Phonegap Communicating with Ajax to a Local Rails App