Monday, November 15, 2010

Climate Change – Think about it for a second

At least change electricity bulbs in your house. Everyone should be involved. Thumbs up the video.

 

Also you can check a lot of internet flash games related to eco-system. For example these games.

There is also a game which will be out in 2011 which whole subject is Ecology and disastrous state: Fate of the World.

P.S. You can comment out what exactly do you think we could do, to save the planet, but something doable which depends on us, not those big corporations.

Tuesday, November 2, 2010

Ruby Challenge 2010: Installing Ruby and its tools on Windows

Hi,

Today I decided to install all the prerequisites and to show you how I’ve done this, may be for some people it will be useful. And I’m doing it by reproducing the Rails 3.0 tutorial but for Windows.

1. Text editor / IDE

From various IDEs and Unix-style editors like vi or emacs or whatever. I decided to go with a full IDE solution so … the nominees are

  1. Aptana Studio 2.0 – standalone version
  2. NetBeans 6.9.1 – ruby version
  3. RubyMine 2.0 – from JetBrains (creators of Resharper, TeamCity and a lot of other cool software for programmers).

I wanted to go with RubyMine because I already know the difference Resharper brings in my development process, but it’s a 30-days trial, and I don’t want to switch to something new in next few months, so no. I don’t have previous experience with Aptana Studio, and may be I will try it some day, but I had a pleasant experience with NetBeans so for now I will go with that.

NetBeansDownload

2. Git

Ruby community uses intensely a version control system called Git, so I will install it too. For windows part it is very simple. You go to http://code.google.com/p/msysgit/. Click “Downloads” and choose current version Git.exe installer.

DownloadingGitForWindows

Install process is Windows-style - very simple as well. We don’t have to manually compile something or edit, everything goes quite simple.

InstallingGit

3. Installing Ruby

First we need to be sure that our system doesn’t already has Ruby installed. Let’s try it.

C:\Users\user_name>ruby -v
'ruby' is not recognized as an internal or external command,
operable program or batch file.

Well looks like I don’t have it installed. Not a problem. First we’ll install Ruby 1.8.7 which works well with Rails 2.3. We’ll go to Download Ruby page search for “Ruby on Windows” section and select Ruby 1.8.7-p302 RubyInstaller. Installation goes smoothly. I associated my *.rb files with ruby and added Ruby executables to my path.

Now we see this in our command line:

C:\Users\user_name>ruby -v
ruby 1.8.7 (2010-08-16 patchlevel 302) [i386-mingw32]
4. Installing and using Pik

pikScreenshot

What is Pik? Pik is a Windows alternative to Ruby Version Manager (RVM) which allows us to have multiple Ruby versions installed at the same time, as I said before we need Ruby 1.8.7 to work with Rails 2.3 and Ruby 1.9.2 to work with Rails 3.0.1 and Pik will help us in dealing with this. You can download Pik from github. Also be sure to check its Wiki page “Usage”.

Now when we run the first time pik it adds the default Ruby path which right now points to version 1.8.7. I also set Pik default install directory to “C:\Rubies” and I also show how to add an existing ruby installation to pik with the “add” command.

C:\Users\user_name>pik
** Adding:  187: ruby 1.8.7 (2010-08-16 patchlevel 302) [i386-mingw32]
 Located at:  C:\Rubies\Ruby187\bin
Usage: pik command [options]

To get help with a command

  pik help (command)

To list all commands and descriptions:

  pik help commands

    -V, --version                    Pik version
    -d, --debug                      Outputs debug information

C:\Users\user_name>pik config installs="C:\Rubies"

C:\Users\user_name>pik add C:\Rubies\Ruby-1.9.2dev-p3-i386-mingw32\bin
** Adding:  192: ruby 1.9.2dev (2010-05-31) [i386-mingw32]
 Located at:  C:\Rubies\Ruby-1.9.2dev-p3-i386-mingw32\bin

Next I show how to install a Ruby version using “install” command. In my particular case I installed IronRuby specifying the version, and then not specifying it. When you don’t specify it then Pik downloads the latest version. (although at the moment the latest version of IronRuby is 1.1.1, don’t know what is wrong there). Than I show how to list all the available Rubies installations (note that * marks the default ruby used at the moment), how to remove a Ruby install from Pik management, and how to switch to another Ruby installation.

C:\Users\user_name>pik install IronRuby 1.0.0
** Downloading:  http://rubyforge.org/frs/download.php/69853/ironruby-1.0.0rc.zi
p
   to:  C:\Users\user_name\.pik\downloads\ironruby-1.0.0rc.zip

ironruby-1.0.0rc.zip: 100% |ooooooooooooooooooo|   4.7MB/  4.7MB Time: 00:00:06

** Extracting:  C:\Users\user_name\.pik\downloads\ironruby-1.0.0rc.zip
   to:  C:\rubies\IronRuby-100rc
done

Couldn't find a Ruby version at C:\rubies\IronRuby-100rc\bin

C:\Users\user_name>pik add C:\Rubies\IronRuby-100rc\ironruby\bin
** Adding:  100: IronRuby 1.0.0.0 on .NET 2.0.50727.4454
 Located at:  C:\Rubies\IronRuby-100rc\ironruby\bin

C:\Users\user_name>pik install IronRuby
** Downloading:  http://rubyforge.org/frs/download.php/70181/ironruby-1.0v4.zip

   to:  C:\Users\user_name\.pik\downloads\ironruby-1.0v4.zip

ironruby-1.0v4.zip: 100% |ooooooooooooooooooooo|   2.9MB/  2.9MB Time: 00:00:04

** Extracting:  C:\Users\user_name\.pik\downloads\ironruby-1.0v4.zip
   to:  C:\rubies\IronRuby-10v4
done

** Adding:  100: IronRuby 1.0.0.0 on .NET 4.0.30319.1
 Located at:  C:\rubies\IronRuby-10v4\bin

C:\Users\user_name>pik remove C:\Rubies\IronRuby-100rc\ironruby\bin

Quitting...

C:\Users\user_name>pik help commands

  add             Adds another ruby location to pik.
  benchmark|bench Runs bencmarks with all versions that pik is aware of.
  config          Adds/modifies configuration options.
  default         Switches back to the default settings.
  devkit          Configures devkit settings
  gem             Runs the gem command with all versions that pik is aware of.
  gemsync         Synchronizes gems from the version specified to the current ve
rsion.
  help            Displays help information.
  implode         Removes your pik configuration.
  info|checkup|cu Displays information about the current ruby version.
  install|in      Downloads and installs different ruby versions.
  list|ls         Lists ruby versions that pik is aware of.
  rake            Runs the rake command with all versions that pik is aware of.
  remove|rm       Removes a ruby location from pik.
  ruby|rb         Runs ruby with all versions that pik is aware of.
  run             Runs command with all versions of ruby that pik is aware of.
  tag             Adds the given tag to the current version.
  tags            Runs the pik command against the given tags.
  uninstall|unin  Deletes a ruby version from the filesystem and removes it from
 Pik.
  update|up       updates pik.
  use|switch|sw   Switches ruby versions based on patterns.

For help on a particular command, use 'pik help COMMAND'.

C:\Users\user_name>pik list
  100: IronRuby 1.0.0.0 on .NET 2.0.50727.4454
  100: IronRuby 1.0.0.0 on .NET 4.0.30319.1
* 187: ruby 1.8.7 (2010-08-16 patchlevel 302) [i386-mingw32]
  192: ruby 1.9.2dev (2010-05-31) [i386-mingw32]

C:\Users\user_name>pik remove 100
Select which Ruby you want:
1. 100: IronRuby 1.0.0.0 on .NET 2.0.50727.4454
2. 100: IronRuby 1.0.0.0 on .NET 4.0.30319.1
?  1
Are you sure you'd like to remove '100: IronRuby 1.0.0.0 on .NET 2.0.50727.4454'
?  |yes|

100: IronRuby 1.0.0.0 on .NET 2.0.50727.4454 removed.

C:\Users\user_name>pik use 192

C:\Users\user_name>pik list
  100: IronRuby 1.0.0.0 on .NET 4.0.30319.1
  187: ruby 1.8.7 (2010-08-16 patchlevel 302) [i386-mingw32]
* 192: ruby 1.9.2dev (2010-05-31) [i386-mingw32]

The only thing that I can’t find is an alternative to RVM –create command which is often convenient to create separate gemsets. 

5. Installing and using RubyGems

gems

UPDATE: After installing any version of Ruby you already should have RubyGems installed. You can check it up by using “gem –v” command. I talk about installing RubyGems here just because I was having errors with default installation of gem. 

After everything done I already have gems installed but it has some errors so I will download the latest version from here. After that you unpack it somewhere cd into its directory and say

ruby setup.rb

Now gems should be installed. Next thing you could do is see what is your Gems environment with “gem env” command, or see the gems sources with “gem sources” command. Finally you could do “gem list” for list of local gems, “gem list –r” for remote gems, and “gem list STRING” which will bring you the list of gems starting with string.

6. Installing Rails

rails

Now having Gems installed it’s really easy to install Rails. You should just say

gem install rails

Or

gem install rails --version 3.0.1

Now everything should be prepared and installed. You can verify it by writing “rails –v” and have the rails version.

Well that’s a lot of things to do, especially if you’re used already with Windows way of installing things. Hope this post will help someone.

Next time we’ll do our first application in RoR (Ruby on Rails), so stay tuned!