Hi, I would like to know exactly how this snippets work in Ruby script. gem 'mechanize', '=1.0.0' require File.dirname(__FILE__) + "/logo.rb" require "rubygems" require "cashew" I can guess the lines (2~4) will require external ruby files. But the first line that is using "gem" is horrible thing to me. When this ruby file gets executed, 'mechanize' gem would be installed? Or you will have to install that gem beforehand? I would very appreciate if you can explain further details. Thanks in advance, Christopher
on 2013-03-11 11:29
on 2013-03-11 11:36
information: you should require "rubygems" first before you call the gem method if you want to use ruby1.8 on newer ruby, require "rubygems" is mostly useless
on 2013-03-11 12:32
On Mon, 11 Mar 2013 11:29:43 +0100, Christopher Frost <firstname.lastname@example.org> wrote: > gem 'mechanize', '=1.0.0' > When this ruby file gets executed, 'mechanize' gem would be installed? > Or you will have to install that gem beforehand? It won't be installed, and it won't even be `require`-d. This line just checks if you have the gem installed in that version, and if you don't, it raises an exception. This is also useful when you have multiple gem versions installed locally, and want to use a particular (and not latest) one – any subsequent call to `require 'mechanize'` or similar will load Mechanize in that precise version.