Tuesday, December 11

Ruby on Rails Installing Ruby

Though you continue to work/experiment more on the online ruby editor, today we see how we would install the ruby on windows OS.
Recollect "Ruby is portable, which means can be installed on all OS's possible"

Ruby Installer for Windows. Download the executable ruby186-25.exe and double-click this file to install Ruby on your PC. (Accept all the defaults.)
Once you have installed your Ruby software, the System Environment Variable path is already set to point to the bin folder of Ruby. The installation also includes the First Edition of Programming Ruby book and the SciTE editor.

Just recollect what we had done and what's the Ruby Environment looks like.

Assuming that you installed Ruby in the folder c:/ruby, then the installation creates a number of sub-folders. See the list below.

c:/ruby/bin : Here the Ruby executables (including ruby and irb) have been installed.
c:/ruby/src : Here you get the Ruby source code.
c:/ruby/lib/ruby/gems : Here are the Ruby-Gems.
c:/ruby/lib/ruby/1.8 : Here you'll find program files written in Ruby. These files provide standard library facilities, which you can require from your own programs if you need the functionality they provide.
c:/ruby/lib/ruby/1.8/i386-mswin32 : Here you find architecture-specific extensions and libraries. These files are C-language extensions to Ruby; or, more precisely, they are the binary, runtime-loadable files generated from Ruby's C-language extension code, compiled into binary form as part of the Ruby installation process.
c:/ruby/lib/ruby/site_ruby : Here you store third-party extensions and libraries. This include your own code or some third party.
c:/ruby/samples/RubySrc-1.8.6/sample : Well, here you will find some sample Ruby programs.

From now we can also execute ruby snippets on the locally installed SciTE editor.
Open the Editor: start/Programs/Ruby-186-25/SciTE.
Press F8 to open an output window.

Create a folder named, say. rubyexamples on your C:\ and will keep all our programs in this folder. Let us repeat the our first program, that we had done yesterday online. That is

puts "Hello World!"

Now save the file as "hello.rb" under c:\rubyexamples folder. Note all ruby source files have the .rb extension.

Pressing on F5 would execute the program and outputs the string "Hello World!" on right side window.

  1. # hello.rb
  2. puts 'Hello'

Alternatively you can also type command "ruby hello.rb" to execute the hello.rb file.

Having installed the ruby on local system now repeat the yesterdays examples and practice more for better understanding.

Download the pdf version of Installing Ruby post.


No comments: