I have downloaded the zip package for windows of pry an alternative for irb shell from github. I have unzipped the package.
How do i start the pry shell ?
You don't need the zip package, Pry is just a regular gem. In a terminal -- or whatever Windows calls those nowadays -- do the following (assuming you don't need something like sudo for Ruby on Windows):
gem install pry pry-doc
Done. Now start it with pry.
Related
Is there a way to tell rubygems to only look for gems locally on the disk from the ruby interpreter (irb or sketchup ruby console)?
example: Gem.install 'savon','=2.1.1','--local'
I believe the way to do that is to download the .gem file to your computer and then run:
gem install savon-*.gem
I'm trying to write a program with colorized output. I looked at a few, and the gem I found was colorize. I've done some research, but I can't find step-by-step instructions on how to install a gem, require it, and use it. The gem I want is colorize, and I also need to know if there's anything else it requires. All I have is the standard ruby console that comes in the Ruby21 file, and notepad++ to write and save it. I need to know how and where to install it, whether I type something into the terminal or download a file and put it somewhere, and how to require it and its prerequisites(if any) in a file.
You can install the gem using your CLI simply by typing: gem install colorize. You can then utilize the gem by requiring it, so at the top of your .rb file add require 'colorize'. Then just test it out by trying puts "This is blue".colorize(:blue).
Your .rb could look like this for example:
require 'colorize'
puts "This is blue".colorize(:blue)
Per http://guides.rubygems.org/rubygems-basics/, you can install the colorize gem with the following command (in terminal or at command prompt):
gem install colorize
To list local gems, run this command:
gem list
And--by adding require 'colorize' to the top of the respective .rb file--that gem's lib directory will be added to your $LOAD_PATH.
I've read about these great pry plugins (e.g. pry-debugger, pry-stack_explorer), but after nearly 30 minutes of searching, I can't find any documentation on how to install them. I've gone to their github site, the pry wiki and read/watched several tutorials, but there's nothing in there about installation.
Every pry plugin that start with pry- are auto-loaded. You just need to gem install pry-name.
Here is the link about plugins(creating plugins too) and exact quote:
A valid Pry plugin is a gem that has the pry- prefix (such as the
pry-doc gem)
If a Pry plugin is installed (i.e a gem with the pry- prefix is
installed) it will be loaded automatically when a session starts.
Note: pry has special command gem-install gem_name. You should use that command instead of .gem install gem_name in order to work. This (pry)command install and(!) reload gem cache.
If that won't work try installing gems from console then running pry.
ps. you can check installed plugins via pry --installed-plugins(in console) or in pry just type help and it will show you available commands.
I have a ruby script that I want to send to a couple of coworkers. Instead of telling them to install a few required gems, is there a safe way to have ruby install them if not found?
For example, a user doesn't have the yui-compressor gem. Instead of the terminal displaying an error when they run ruby example.rb it would automatically run gem install -r yui-compressor for them. Is there a way to handle this?
You could use a tool like bundler: http://gembundler.com/
I try to install nanoc http://nanoc.stoneship.org/docs/2-installation/
by typing in irb
gem install nano
it says undefined variable or method 'nanoc' ?
You need to install it from the shell, not IRB. Gem is a command, i.e.
% which gem
/usr/bin/gem
% gem install nanoc
ian.
That gem install command is meant to be run in your normal system shell (something like Bash, for example).
irb is a Ruby shell, it interactively executes Ruby code. You'll notice that the instructions you link to immediately tell you to quit irb after starting it (they only told you to run it to make sure Ruby was installed).