platform.rb regex issues #142

Closed
djberg96 opened this Issue Jul 29, 2011 · 3 comments

Projects

None yet

2 participants

@djberg96
Contributor

Hi,

I noticed in platform.rb we have what appears to a redundant regular expression and some things that are too strict. Regarding the redundant regex I see this on line 75-76 of platform.rb:

when /^dotnet$/ then             [ 'dotnet',    nil ]
when /^dotnet([\d.]*)/ then      [ 'dotnet',    $1  ]

What case does the first one cover that the second one doesn't?

Also, it seems the regexen for aix, freebsd, hpux, openbsd and solaris are too strict. If no version is specified the os will come back as "unknown". For example:

irb(main):001:0> Gem::Platform.new("universal-solaris10.2")
=> Gem::Platform:0x85988c @cpu="universal", @os="solaris", @version="10.2"

irb(main):002:0> Gem::Platform.new("universal-solaris")
=> Gem::Platform:0x857780 @cpu="universal", @os="unknown", @version=nil

Other platforms allow an OS to be set with a nil version. Why not those? I can get around it manually, but would rather not have to. I would suggest that these be modified to make the digits optional as they currently are for darwin.

Regards,

Dan

@drbrain drbrain was assigned Aug 26, 2011
@drbrain
Member
drbrain commented Sep 2, 2011

I think the regexp idea is broken and should only be used to normalize recognized compatible platforms, unrecognized platforms should be passed through unmolested.

@djberg96
Contributor

It would seem that the preferred way is to use a two-element array instead of a string. That approach does seem to pass the platform through unmolested, and also has the advantage of setting the version to nil.

@djberg96
Contributor
djberg96 commented Oct 6, 2014

This appears to have been fixed at some point. Closing.

@djberg96 djberg96 closed this Oct 6, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment