Introduce `Rails.gem_version`

This method returns a `Gem::Version` object, which is useful when
performing a comparison between versions. This was originally
introduced as `.version` by @charliesome in #8501, but got reverted in
#10002 since it was not backward compatible.

Also, updating template for `rake update_versions`.

---

This is the same as #14101, but for `4-1-stable`.