From where does "apt-get install package_name" download packages?

Solution 1:

Type:

apt-cache policy package_name

And it'll tell you. On Ubuntu, it's usually archive.ubuntu.com, but you may have other sources set up.

Solution 2:

cat /etc/apt/sources.list
cat /etc/apt/sources.d/*

should show you the repos used. I don't know how rubygems.org was protected but here is some useful pieces of advice on apt: http://wiki.debian.org/SecureApt it's for debian but it also applies to Ubuntu which uses the same packet manager.