Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Ticket #10057 (closed enhancement: fixed)

Opened 2 years ago

Last modified 2 years ago

allow RubyGems Advanced Versioning for RAILS_GEM_VERSION

Reported by: thewoolleyman Assigned to: core
Priority: normal Milestone: 2.x
Component: Railties Version: edge
Severity: normal Keywords:
Cc: thewoolleyman@gmail.com

Description

See http://rubygems.org/read/chapter/16

Currently, RAILS_GEM_VERSION is hardcoded to always be an exactly equal version. This patch allows any advanced versioning to be used for RAILS_GEM_VERSION, either via a constant in environment.rb, or the RAILS_GEM_VERSION environment variable. It also allows spaces. The hardcoded equal in the 'gem' method version parameter was not needed for backward compatibility, that's the default anyway.

This will allow sophisticated use of RAILS_GEM_VERSION, such as specifying RAILS_GEM_VERISON='> 1.2.5' to float on the latest beta gem version.

Tests are provided, and I've manually tested it using various version specs in environment.rb and RAILS_GEM_VERSION environment var.

Thx, -- Chad

Attachments

ticket_10057_rails_gem_version_handling_enhancement.diff (2.4 kB) - added by thewoolleyman on 11/02/07 06:15:33.
patch to allow rubygems advanced versioning for RAILS_GEM_VERSION
ticket_10057_rails_gem_version_handling_enhancement_version_2.diff (2.4 kB) - added by thewoolleyman on 11/03/07 16:58:43.
version 2 of patch - improved regex with tighter match on valid version spec

Change History

11/02/07 06:15:33 changed by thewoolleyman

  • attachment ticket_10057_rails_gem_version_handling_enhancement.diff added.

patch to allow rubygems advanced versioning for RAILS_GEM_VERSION

11/02/07 10:24:06 changed by chuyeow

+1. Excellent patch.

I suggest you use this regex:

[!~<>=]+\s*[\d.]+

11/02/07 17:23:43 changed by thewoolleyman

Hi chuyeow,

Thanks for the +1.

Unfortunately, that regex breaks the existing tests when I try it.

I was intentionally pretty loose with the match, I just validate that they only put in acceptable characters, but don't enforce the ordering. If someone puts in an invalid version spec, the gem load will fail and it should be pretty obvious what the problem is.

The existing code also allows invalid versions (for example, I think 1..2. would pass), so I don't think it's a big deal.

11/03/07 03:34:25 changed by chuyeow

Ah my bad. Untested regex ;)

[!~<>=]*\s*[\d.]+

Will work (just tested it). I know what you mean too since the original regex itself is already very loose. Personally I'd use the more specific regex but like you say it's not a big issue :)

Thanks again for the good work :)

11/03/07 16:58:43 changed by thewoolleyman

  • attachment ticket_10057_rails_gem_version_handling_enhancement_version_2.diff added.

version 2 of patch - improved regex with tighter match on valid version spec

11/03/07 16:59:16 changed by thewoolleyman

cool, a new patch with your regex is attached :)

11/17/07 01:39:22 changed by bitsweat

  • status changed from new to closed.
  • resolution set to fixed.

(In [8160]) RAILS_GEM_VERSION may be set to any valid gem version specifier. Closes #10057.