Where is the ruby documentation for gems? [closed] - ruby

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 7 years ago.
Improve this question
In python in an interactive console like ipython i can just type ? and get documentation on pretty much any library or function.
How do I do this in ruby? Whether I'm using pry or irb I can't find much useful documentation at all.
I'm trying to use Faraday but typing ri Faraday doesn't give any documentation. Typing ri String gives documentation for String, but gems like faraday don't produce any documentation whatsoever.
What am I doing wrong?

If you install the gem using gem install --ri faraday then the ri documentation will be generated for you.
This should be the default, but since Ri doc generation can take a while, a lot of people disable it by putting a line in ~/.gemrc saying gem: --no-ri --no-rdoc (providing those options as defaults for the gem command).
Even if that's the case you can override it on a case by case basis by adding that parameter when you install a gem

Check out the pry-doc extension for pry.

If you want to read that doc, You'll are able to run
gem server
That will create a webservice in you host on port 8808, that you will be able to access via browser.
If you want to see where that info is located, run gem env you'll see all paths into GEM PATHS section.
gem env
RubyGems Environment:
.......2.2.2/etc
- RUBYGEMS PLATFORMS:
.....
- GEM PATHS:
- /home/hbranciforte/.rvm/gems/ruby-2.2.2
- /home/hbranciforte/.rvm/gems/ruby-2.2.2#global
- GEM CONFIGURATION:
.....
- REMOTE SOURCES:
- https://rubygems.org/
- SHELL PATH:
.....
and if you look at your GEM PATHS you will find a folder called doc.
hbranciforte#hbranciforte-MacBookPro:gems/ruby-2.2.2 $ cd /home/hbranciforte/.rvm/gems/ruby-2.2.2
hbranciforte#hbranciforte-MacBookPro:gems/ruby-2.2.2 $ ls
bin build_info cache doc environment extensions gems specifications wrappers
Sometimes (almost I usually do) run your project with bundle --path bundle/vendor
That creates a folder bundle/vendor where it will store your gems and doesn't store doc (that makes bundler much faster than gem install)

Related

`require': cannot load such file -- oj (LoadError) [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 5 years ago.
Improve this question
I only know the basics of the Ruby and trying to fix this error. There were same questions already but couldn't get it solved from those.
When I run following command in my Ruby Project
rerun 'ruby app.rb'
I got the following error.
[rerun] Webhook-receiver launched
/Users/myhome/.rbenv/versions/2.4.2/lib/ruby/2.4.0/
rubygems/core_ext/kernel_require.rb:55:
in `require': cannot load such file -- oj (LoadError)
from /Users/myhome/.rbenv/versions/2.4.2/lib/ruby/2.4.0/rubygems/
core_ext/kernel_require.rb:55:
in `require' from app.rb:2:in `<main>'
[rerun] Webhook-receiver Launch Failed
[rerun] Watching . for **/*.{rb,js,coffee,css,scss,sass,erb,html,haml,ru,yml,slim,md,feature}
How can I solve this?
Just with the intention of providing a detailed and structured answer for others, since you have already solved the issue. When developing a Ruby application, if code that lives in an external gem is required, you can use Bundler to keep track and manage your dependencies. It uses a file called Gemfile to register the dependencies that your project relies on, as well as the source from where these dependencies will be pulled to your machine. A basic syntax example of Gemfile.
# Registering the sources of gem packages
source 'https://rubygems.org'
[...]
# Requiring a gem for this project
gem 'package_1' # registers a dependency
gem 'package_2', '>=2.0.0' # registers a dependency, with minimum version required
gem 'package_3', '>= 1.5.0', '< 1.9.0' # registers a dependency, with minimum and maximum version required
[...]
With all this set up, when you run bundle install, the dependencies that are specified in your gemfile are pulled to your machine and you can run the program. If you want to check more information for a gem on your machine, you can run bundle info package (below an example for mysql gem)
* mysql (2.9.1)
Summary: This is the MySQL API module for Ruby
Homepage: http://github.com/luislavena/mysql-gem
Path: /var/lib/gems/2.3.0/gems/mysql-2.9.1

How to release large Ruby Gem?

I´m finishing a Ruby Gem that depends on Chromium (jxBrowser). Chromium is quite large and has versions for linux, mac and windows. Releasing this gem to RubyGem is not possible, as the gem size is larger than supported by RubyGem. So, are there any recommendations on where/how to release this? I´d love to keep it in RubyGem as my other gens were released there. Should I release an installer in RubyGem and put the files in GitHub? What´s the best way?
Thanks for any hints and suggestions....
You can ask your users to install the gem from git (bundler: http://bundler.io/git.html, Install Gem from Github Branch?).
This will result in a line like
gem 'hard_drive_expander', github: 'rodrigo/hard_drive_expander'
in a Gemfile (or a bit a lengthier process for gem install - do you intend 'library' kind of usage or standalone installations). Note that depending on your scenario you could have an installer gem that depends on the "github-hosted" gem, or downloads and builds/installs it (both seem like dirty solutions to me though, its not what I expect or commonly see).
Although github does place quotas on your repositories, you will probably not hit them (https://help.github.com/articles/what-is-my-disk-quota/).
Another option is to host it yourself (http://guides.rubygems.org/run-your-own-gem-server/).
Sorry for the "linky" answer.
However, #icguida and #engineersmnky s comments to your question are very worth considering: Do you really need to include chromium?
Update
There is a gem that will hook into gem to allow for usage like this: gem specific_install https://github.com/githubsvnclone/rdoc.git. The gem is called specific_install: https://github.com/rdp/specific_install .

Install gems in parallel (faster)

Bundler has a feature where you can install gems in parallel using the --jobs option. For example:
bundle install --jobs 4
Does a similar feature exist for RubyGems?
I want to be able to run gem update in the same way.
The root problem is that it takes FOREVER to update my global system gems.
No, this feature does not currently exist. However, there’s an unmerged pull request on RubyGems regarding downloading gems in parallel that may be integrated by the time you read this: https://github.com/rubygems/rubygems/pull/649. However, this PR does not address the installation of gems in parallel like Bundler does. So, some of functionality might partially be coming soon.
That said, telling RubyGems to do fewer things during installation is a good way to speed up installation. There are three relevant CLI options worth looking at.
Don't install documentation:
gem update --no-document
Don't attempt to upgrade gems already meeting version requirement:
gem update --conservative
Don't upgrade any dependencies that already meet version requirements:
gem update --minimal-deps
I recommend simply installing gems without documentation. The intent behind running a global gem update is usually “just give me all the latest stuff” so limiting the gems you’re updating would be in conflict that goal. However, many people don’t look at the RDocs generated for their installed gems, and it saves a lot of installation time.
http://guides.rubygems.org/command-reference/#gem-update

Cannot use ruby-debug19 with 1.9.3-p0? [duplicate]

This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
Rails 3.1 and Ruby 1.9.3p125: ruby-debug19 still crashes with “Symbol not found: _ruby_threadptr_data_type”
I run this:
gem install ruby-debug19
And in my cucumber env.rb file, I have this:
require 'ruby-debug'
When I try to run, though, I get this exception:
/home/skendall/.rvm/gems/ruby-1.9.3-p0/gems/ruby-debug-base19-0.11.25/lib/ruby_debug.so: undefined symbol: ruby_current_thread - /home/skendall/.rvm/gems/ruby-1.9.3-p0/gems/ruby-debug-base19-0.11.25/lib/ruby_debug.so (LoadError)
What do I need to do to get ruby-debug to work with 1.9.3-p0?
UPDATE: ruby-debug19 is not maintained anymore. This question and my answer have become irrelevant, it's far easier to use the 'debugger' gem instead.
See Debugging in ruby 1.9
I also ran into this, and found the solution in Ruby 1.9.3 and ruby-debug. You need to install not-yet-officially-released versions of ruby-debug-base19 and linecache19. The currently released versions indeed cause the exception you had.
Use this gist.
#To install ruby-debug on Ubuntu ruby-1.9.3 you need to download from http://rubyforge.org/frs/?group_id=8883
linecache19-0.5.13.gem
ruby_core_source-0.1.5.gem
ruby-debug19-0.11.6.gem
ruby-debug-base19-0.11.26.gem
#Then in your console
export RVM_SRC=/your/path/to/ruby-1.9.3
# Note, your source path should be something like /home/user/.rvm/src/ruby-1.9.3-p0
gem install archive-tar-minitar
gem install ruby_core_source-0.1.5.gem -- --with-ruby-include=/$RVM_SRC
gem install linecache19-0.5.13.gem -- --with-ruby-include=/$RVM_SRC
gem install ruby-debug-base19-0.11.26.gem -- --with-ruby-include=/$RVM_SRC
gem install ruby-debug19-0.11.6.gem -- --with-ruby-include=/$RVM_SRC
This is a known bug. There's reportedly some work arounds here, here and finally here.
If the workarounds are annoying and/or impossible due to your rvm/bundler setup, which is the case with me, consider pry, and optionally the pry-debug plugin. Pry might be a more generally useful tool than ruby-debug anyways.

Ruby : How to write a gem? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 7 years ago.
Improve this question
I'd like to write a package for Ruby and make it available as a gem.
What are the tools, steps and pitfalls ?
Are there any good tutorials, screencasts, etc., which helped you learning how to do it ?
Rubygems.org's Guides is one of the best resources for writing your own gem.
If you're using Bundler in your app, you might want to look at Ryan Bigg's guide to Developing a RubyGem using Bundler and the Railscast on creating gems with Bundler.
If you're interested in tools to help you write gems:
Jeweler - Opinionated tool for creating and managing Rubygem projects. There's also a Gemcutter and Jeweler Railscast.
Hoe - From the guys at seattlrb.
gem-this adds a bunch of helpful rake tasks.
Some tutorials/guides:
Creating Your First Gem
Using bundler and rvm to build a rubygem - Using bundler and rvm to create a gem
Gem Packaging: Best Practices
Ruby Gem Recipe - Intro guide to creating a gem using bundler and jeweler
How to build a ruby gem and host it on gemcutter - tutorial using echoe and gemcutter
The Truth About Gemspecs - goes over gemspecs and tips for dealing with them
Packaging with RubyGems - a quickstart guide for Jeweler
gem that - James Adam - reviews tools that help build gems (hoe, newgem, echoe, gemhub, jeweler, gem this)
Using Gemcutter's Api from the Commandline
New Gem with Bundler – Sample Rakefile - Useful rakefile for deploying and publishing a gem
Let's Write a Gem
How To Build A Ruby Gem With Bundler, Test-Driven Development, Travis CI And Coveralls, Oh My!
This is how I usually create and release Gems:
Sign-up for https://github.com
Sign-up for https://rubygems.org
$ gem install ore rubygems-tasks rdoc rspec
$ mine awesome_gem
cd awesome_gem/ and edit the README.rdoc and awesome_gem.gemspec, write code in lib/awesome_gem/ and adding RSpec tests in specs/.
when you're ready to release, update the ChangeLog.rdoc file, run rake spec and rake rerdoc, open up html/index.html and double-check for any typos.
rake release
(Optional) submit a link and explanation of your new awesome gem to http://rubyflow.com
Sit back and bask in the glory of your first Gem. :)
You need not start writing a gem, just write some code, write some tests, use it however you want, and once you are happy with it, use gem this to generate the relevant Rakefile.
It helps if you stick to the approaches other gems take (have a lib directory, avoid naming files in ways that could clash with other gems, write some tests if you can, have a readme), but it's not necessary.
Once you have something you want to share, put it on github and push it to gemcutter.
Don't over think it, don't use hoe or other overkill tools, have fun, don't to anything I wouldn't do.

Resources