[Prototype-core] Re: Adding Prototype.Revision
Wrote a stand-alone function for calculating the signature of a version string. Works from 0 to 99.99.99.99_S99, where _ is any/no filler and S is 'a', 'b', 'g', 'r', or 'rc' [case-insensitive]. Tested it in both IE7 and FF2 (I don't have any others installed, atm). I'm sure it could use some revamping; so, let me know what you think. Current test results: 900 : 0 0 : 0a 900 : 0h 201 : 0.0.0.0_g1 900 : 99.99.99.99 899 : 99.99.99.99_RC99 105900 : 1.5.0 1050100801 : 1.5.1_rc1 1050100802 : 1.5.1_rc2 1050100803 : 1.5.1_rc3 1050100804 : 1.5.1_rc4 1050100900 : 1.5.1 1050101900 : 1.5.1.1 1050102900 : 1.5.1.2 106800 : 1.6.0_rc0 106801 : 1.6.0_rc1 106900 : 1.6.0 1060001900 : 1.6.0.1 1060002900 : 1.6.0.2 var Version = { signature : function (vstr) { // VVvvRRrrSss or VVvvRRBBSss // or: version, sub-version, release, revision or build, stage, stage number var stages = { 's' : 9, // stable 'r' : 8, // release candidate 'g' : 2, // gamma 'b' : 1, // beta 'a' : 0 // alpha }; var sig = 0; var vers = vstr === String(vstr) ? vstr : this.version; var vnum, rnum = /^\s*[0-9\.]+/; // version number var vstg, rstg = /(r(c)?|g|b|a)[0-9]*\s*$/i; // version stage var vsch, vsnm; // version stage character and number var vspl;// version number split if (!!vers.match(rnum)) { vnum = vers.match(rnum)[0]; vstg = !!vers.match(rstg) ? vers.match(rstg)[0] : ''; vsch = !vstg.match(/^[a-z]+/i) ? 's' : vstg.match(/^[a-z]+/i) [0].charAt(0).toLowerCase(); vsnm = !vstg.match(/[0-9]+$/) ? '0' : vstg.match(/[0-9]+$/); vspl = vnum.split('.').slice(0, 4); vspl = vspl.concat([0, 0, 0, 0].splice(0, (4 - vspl.length))); sig += (parseInt(vspl[0], 10) % 100) * Math.pow(10, 9); sig += (parseInt(vspl[1], 10) % 100) * Math.pow(10, 7); sig += (parseInt(vspl[2], 10) % 100) * Math.pow(10, 5); sig += (parseInt(vspl[3], 10) % 100) * Math.pow(10, 3); sig += (!!stages[vsch] ? stages[vsch] : 0) * 100; sig += parseInt(vsnm, 10) % 100; } return sig; } }; - Jon L. On Feb 11, 7:41 pm, Jon L. [EMAIL PROTECTED] wrote: An alternative could be to use the release date: var Prototype = { Version: '1.6.0.2', Release: '01/25/2008' ... }; if(Date(Prototype.Release) = Date('11/07/2007')) { // 1.6.0 (November 7, 2007) ... } On Feb 11, 6:55 pm, tancurrom [EMAIL PROTECTED] wrote: Build: '5234724' Be cautious with the use of strings. e.g. Prototype.Build = '6102' returns false ('5' '6'). - Jon L. On Feb 11, 6:55 pm, tancurrom [EMAIL PROTECTED] wrote: I think using a build number is considerably easier to manipulate in the code. Its considerably more specific that a version number. But include both var Prototype = { Build: '5234724', Version: '1.6.0.3', ... or var Prototype = { Build: '5234724', // v1.6.0.3 ... I can actually think when I'm going to need to call the Prototype.Version for my code. Let the librarys match it easier. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Prototype: Core group. To post to this group, send email to prototype-core@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/prototype-core?hl=en -~--~~~~--~~--~--~---
[Prototype-core] Re: Adding Prototype.Revision
[corrections] 1) var stages = { 's' : 9, // stable 'r' : 8, // release candidate 'g' : 3, // gamma 'b' : 2, // beta 'a' : 1 // alpha }; 2) var vers = vstr === String(vstr) ? vstr : ''; 1) the function shouldn't return 0 unless the string passed to it can't be parsed 2) originally wrote it as part of an object with a version key. - Jon L. On Feb 23, 10:11 pm, Jon L. [EMAIL PROTECTED] wrote: Wrote a stand-alone function for calculating the signature of a version string. Works from 0 to 99.99.99.99_S99, where _ is any/no filler and S is 'a', 'b', 'g', 'r', or 'rc' [case-insensitive]. Tested it in both IE7 and FF2 (I don't have any others installed, atm). I'm sure it could use some revamping; so, let me know what you think. Current test results: 900 : 0 0 : 0a 900 : 0h 201 : 0.0.0.0_g1 900 : 99.99.99.99 899 : 99.99.99.99_RC99 105900 : 1.5.0 1050100801 : 1.5.1_rc1 1050100802 : 1.5.1_rc2 1050100803 : 1.5.1_rc3 1050100804 : 1.5.1_rc4 1050100900 : 1.5.1 1050101900 : 1.5.1.1 1050102900 : 1.5.1.2 106800 : 1.6.0_rc0 106801 : 1.6.0_rc1 106900 : 1.6.0 1060001900 : 1.6.0.1 1060002900 : 1.6.0.2 var Version = { signature : function (vstr) { // VVvvRRrrSss or VVvvRRBBSss // or: version, sub-version, release, revision or build, stage, stage number var stages = { 's' : 9, // stable 'r' : 8, // release candidate 'g' : 2, // gamma 'b' : 1, // beta 'a' : 0 // alpha }; var sig = 0; var vers = vstr === String(vstr) ? vstr : this.version; var vnum, rnum = /^\s*[0-9\.]+/; // version number var vstg, rstg = /(r(c)?|g|b|a)[0-9]*\s*$/i; // version stage var vsch, vsnm; // version stage character and number var vspl;// version number split if (!!vers.match(rnum)) { vnum = vers.match(rnum)[0]; vstg = !!vers.match(rstg) ? vers.match(rstg)[0] : ''; vsch = !vstg.match(/^[a-z]+/i) ? 's' : vstg.match(/^[a-z]+/i) [0].charAt(0).toLowerCase(); vsnm = !vstg.match(/[0-9]+$/) ? '0' : vstg.match(/[0-9]+$/); vspl = vnum.split('.').slice(0, 4); vspl = vspl.concat([0, 0, 0, 0].splice(0, (4 - vspl.length))); sig += (parseInt(vspl[0], 10) % 100) * Math.pow(10, 9); sig += (parseInt(vspl[1], 10) % 100) * Math.pow(10, 7); sig += (parseInt(vspl[2], 10) % 100) * Math.pow(10, 5); sig += (parseInt(vspl[3], 10) % 100) * Math.pow(10, 3); sig += (!!stages[vsch] ? stages[vsch] : 0) * 100; sig += parseInt(vsnm, 10) % 100; } return sig; } }; - Jon L. On Feb 11, 7:41 pm, Jon L. [EMAIL PROTECTED] wrote: An alternative could be to use the release date: var Prototype = { Version: '1.6.0.2', Release: '01/25/2008' ... }; if(Date(Prototype.Release) = Date('11/07/2007')) { // 1.6.0 (November 7, 2007) ... } On Feb 11, 6:55 pm, tancurrom [EMAIL PROTECTED] wrote: Build: '5234724' Be cautious with the use of strings. e.g. Prototype.Build = '6102' returns false ('5' '6'). - Jon L. On Feb 11, 6:55 pm, tancurrom [EMAIL PROTECTED] wrote: I think using a build number is considerably easier to manipulate in the code. Its considerably more specific that a version number. But include both var Prototype = { Build: '5234724', Version: '1.6.0.3', ... or var Prototype = { Build: '5234724', // v1.6.0.3 ... I can actually think when I'm going to need to call the Prototype.Version for my code. Let the librarys match it easier. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Prototype: Core group. To post to this group, send email to prototype-core@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/prototype-core?hl=en -~--~~~~--~~--~--~---
[Prototype-core] Re: Adding Prototype.Revision
An alternative could be to use the release date: var Prototype = { Version: '1.6.0.2', Release: '01/25/2008' ... }; if(Date(Prototype.Release) = Date('11/07/2007')) { // 1.6.0 (November 7, 2007) ... } On Feb 11, 6:55 pm, tancurrom [EMAIL PROTECTED] wrote: Build: '5234724' Be cautious with the use of strings. e.g. Prototype.Build = '6102' returns false ('5' '6'). - Jon L. On Feb 11, 6:55 pm, tancurrom [EMAIL PROTECTED] wrote: I think using a build number is considerably easier to manipulate in the code. Its considerably more specific that a version number. But include both var Prototype = { Build: '5234724', Version: '1.6.0.3', ... or var Prototype = { Build: '5234724', // v1.6.0.3 ... I can actually think when I'm going to need to call the Prototype.Version for my code. Let the librarys match it easier. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Prototype: Core group. To post to this group, send email to prototype-core@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/prototype-core?hl=en -~--~~~~--~~--~--~---
[Prototype-core] Re: Adding Prototype.Revision
I think using a build number is considerably easier to manipulate in the code. Its considerably more specific that a version number. But include both var Prototype = { Build: '5234724', Version: '1.6.0.3', ... or var Prototype = { Build: '5234724', // v1.6.0.3 ... I can actually think when I'm going to need to call the Prototype.Version for my code. Let the librarys match it easier. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Prototype: Core group. To post to this group, send email to prototype-core@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/prototype-core?hl=en -~--~~~~--~~--~--~---
[Prototype-core] Re: Adding Prototype.Revision
Based on Mislavs function here's on that also handles special cases like _rc1. function vnum(vstring) { var v = vstring.replace(/_.*|\./g, ''); v = parseInt(v + '0'.times(4-v.length)); return vstring.indexOf('_') -1 ? v-1 : v; } vnum('1.6.0') vnum('1.6.0_rc1') //- true vnum('1.6.0') //- 1600 vnum('1.6.0.2') //- 1602 vnum('1.6.0_rc1') //- 1599 --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Prototype: Core group. To post to this group, send email to prototype-core@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/prototype-core?hl=en -~--~~~~--~~--~--~---
[Prototype-core] Re: Adding Prototype.Revision
Latest Prototype here: http://prototypejs.org/assets/2008/1/25/prototype-1.6.0.2.js has following lines at the top: var Prototype = { Version: '1.6.0.2', Isn't this enough? I think using revision number is mostly replacing one readable number with another unreadable. I believe versions are already mapped to specific revisions, and using intermediate revisions is a dangerous way to go. But if someone really needs this - why not? Except that usually such specific needs aren't put in the core, afaik. I recently wrote a patch for Scriptaculous that allows version checking beyond the x.x.x scope. It allows to check for 1.6.0.2 instead of just 1.6.0, this will help to inform people when they use incompatible version of prototype/scriptaculous. http://dev.rubyonrails.org/ticket/10966 Tobie suggested to add the svn changeset number to Prototype. I think that is a much better way to go. Adding something like Prototype.Revision will help Scriptaculous and other extensions to write proper version checks. What do you think, is it something worth adding? -- arty ( http://arty.name ) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Prototype: Core group. To post to this group, send email to prototype-core@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/prototype-core?hl=en -~--~~~~--~~--~--~---
[Prototype-core] Re: Adding Prototype.Revision
A build number based on both version and svn changeset could prevent those issues with backported bugfixes. A suggestion: Prototype.Build: 1602.8769 On 3 feb, 17:13, Tobie Langel [EMAIL PROTECTED] wrote: Hi Artemy, The version number is just a pain to parse. A build number also happens to be much more machine readable, which is the use case here. I'd like to have other core members' opinion on this. And contrary to what I mentioned earlier, I'm not sure if the svn changset number is the way to go as we sometimes backport bug fixes to earlier versions of Prototype. Best, Tobie On Feb 3, 4:39 pm, artemy tregoubenko [EMAIL PROTECTED] wrote: Latest Prototype here:http://prototypejs.org/assets/2008/1/25/prototype-1.6.0.2.js has following lines at the top: var Prototype = { Version: '1.6.0.2', Isn't this enough? I think using revision number is mostly replacing one readable number with another unreadable. I believe versions are already mapped to specific revisions, and using intermediate revisions is a dangerous way to go. But if someone really needs this - why not? Except that usually such specific needs aren't put in the core, afaik. I recently wrote a patch for Scriptaculous that allows version checking beyond the x.x.x scope. It allows to check for 1.6.0.2 instead of just 1.6.0, this will help to inform people when they use incompatible version of prototype/scriptaculous. http://dev.rubyonrails.org/ticket/10966 Tobie suggested to add the svn changeset number to Prototype. I think that is a much better way to go. Adding something like Prototype.Revision will help Scriptaculous and other extensions to write proper version checks. What do you think, is it something worth adding? -- arty (http://arty.name) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Prototype: Core group. To post to this group, send email to prototype-core@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/prototype-core?hl=en -~--~~~~--~~--~--~---
[Prototype-core] Re: Adding Prototype.Revision
I think we should have both version string and SVN revision from which it was built. Also, Prototype versions could simply be compared like integers in this fashion: function vnum(vstring) { return parseInt(vstring.replace(/\./g, '') + '0'.times(4-(vstring.length/2).ceil())) } vnum('1.6') //- 1600 vnum('1.6.0.2') //- 1602 That is because none of the version fragments will ever be bigger than 9. That's nice. I went into more trouble to make so Scriptaculous' version could be checked, it sometimes has '_pre1' or '_beta2' in it's version string. But I see a little more regex could do the same there, good idea. Even though it could be that simple, a build number will make this more user friendly. You could then simply do: Prototype.Build Prototype.Build = 1602 --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Prototype: Core group. To post to this group, send email to prototype-core@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/prototype-core?hl=en -~--~~~~--~~--~--~---
[Prototype-core] Re: Adding Prototype.Revision
I previously had success at comparing version numbers as string like that: '1.6' '1.6.0.2' true '1.5.0.1' '1.6' true Thus I am surprised that you parse these strings On Sun, 03 Feb 2008 21:39:56 +0300, Nick Stakenburg [EMAIL PROTECTED] wrote: I think we should have both version string and SVN revision from which it was built. Also, Prototype versions could simply be compared like integers in this fashion: function vnum(vstring) { return parseInt(vstring.replace(/\./g, '') + '0'.times(4-(vstring.length/2).ceil())) } vnum('1.6') //- 1600 vnum('1.6.0.2') //- 1602 That is because none of the version fragments will ever be bigger than 9. That's nice. I went into more trouble to make so Scriptaculous' version could be checked, it sometimes has '_pre1' or '_beta2' in it's version string. But I see a little more regex could do the same there, good idea. Even though it could be that simple, a build number will make this more user friendly. You could then simply do: Prototype.Build Prototype.Build = 1602 -- arty ( http://arty.name ) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Prototype: Core group. To post to this group, send email to prototype-core@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/prototype-core?hl=en -~--~~~~--~~--~--~---
[Prototype-core] Re: Adding Prototype.Revision
Hi, You will have problems in a few releases: '1.6' '1.10.1' false However I don't see a reason for Nicks patch. If you need to check the 4th digit of version number due to compatibility issues then we have an issue .: Fabian -Original Message- From: [EMAIL PROTECTED] om [mailto:[EMAIL PROTECTED] groups.com] On Behalf Of artemy tregoubenko Sent: Sonntag, 3. Februar 2008 20:22 To: prototype-core@googlegroups.com Subject: [Prototype-core] Re: Adding Prototype.Revision I previously had success at comparing version numbers as string like that: '1.6' '1.6.0.2' true '1.5.0.1' '1.6' true Thus I am surprised that you parse these strings On Sun, 03 Feb 2008 21:39:56 +0300, Nick Stakenburg [EMAIL PROTECTED] wrote: I think we should have both version string and SVN revision from which it was built. Also, Prototype versions could simply be compared like integers in this fashion: function vnum(vstring) { return parseInt(vstring.replace(/\./g, '') + '0'.times(4-(vstring.length/2).ceil())) } vnum('1.6') //- 1600 vnum('1.6.0.2') //- 1602 That is because none of the version fragments will ever be bigger than 9. That's nice. I went into more trouble to make so Scriptaculous' version could be checked, it sometimes has '_pre1' or '_beta2' in it's version string. But I see a little more regex could do the same there, good idea. Even though it could be that simple, a build number will make this more user friendly. You could then simply do: Prototype.Build Prototype.Build = 1602 -- arty ( http://arty.name ) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Prototype: Core group. To post to this group, send email to prototype-core@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/prototype-core?hl=en -~--~~~~--~~--~--~---
[Prototype-core] Re: Adding Prototype.Revision
Artemy, 1.6.0 1.6.0_rc1 false Best, Tobie On Feb 3, 8:22 pm, artemy tregoubenko [EMAIL PROTECTED] wrote: I previously had success at comparing version numbers as string like that: '1.6' '1.6.0.2' true '1.5.0.1' '1.6' true Thus I am surprised that you parse these strings On Sun, 03 Feb 2008 21:39:56 +0300, Nick Stakenburg [EMAIL PROTECTED] wrote: I think we should have both version string and SVN revision from which it was built. Also, Prototype versions could simply be compared like integers in this fashion: function vnum(vstring) { return parseInt(vstring.replace(/\./g, '') + '0'.times(4-(vstring.length/2).ceil())) } vnum('1.6') //- 1600 vnum('1.6.0.2') //- 1602 That is because none of the version fragments will ever be bigger than 9. That's nice. I went into more trouble to make so Scriptaculous' version could be checked, it sometimes has '_pre1' or '_beta2' in it's version string. But I see a little more regex could do the same there, good idea. Even though it could be that simple, a build number will make this more user friendly. You could then simply do: Prototype.Build Prototype.Build = 1602 -- arty (http://arty.name) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Prototype: Core group. To post to this group, send email to prototype-core@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/prototype-core?hl=en -~--~~~~--~~--~--~---
[Prototype-core] Re: Adding Prototype.Revision
I see, thanks Artemy, 1.6.0 1.6.0_rc1 false Best, Tobie On Feb 3, 8:22 pm, artemy tregoubenko [EMAIL PROTECTED] wrote: I previously had success at comparing version numbers as string like that: '1.6' '1.6.0.2' true '1.5.0.1' '1.6' true Thus I am surprised that you parse these strings -- arty ( http://arty.name ) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Prototype: Core group. To post to this group, send email to prototype-core@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/prototype-core?hl=en -~--~~~~--~~--~--~---
[Prototype-core] Re: Adding Prototype.Revision
However I don't see a reason for Nicks patch. If you need to check the 4th digit of version number due to compatibility issues then we have an issue .: Fabian A lot of questions on irc #prototype relate to people not using the correct version of prototype/scriptaculous together. Even though Scriptaculous packs the latest build of Prototype, not everyone uses that one. So informing them to upgrade for everything to work correctly is important. Another example is that in some of my extensions I require 1.6.0.2 to get document.viewport.getDimensions to work correctly. The 4 digit releases are just as important. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Prototype: Core group. To post to this group, send email to prototype-core@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/prototype-core?hl=en -~--~~~~--~~--~--~---
[Prototype-core] Re: Adding Prototype.Revision
On Sun, 03 Feb 2008 22:47:59 +0300, Fabian Lange [EMAIL PROTECTED] wrote: You will have problems in a few releases: '1.6' '1.10.1' false On Sun, 03 Feb 2008 20:00:47 +0300, Mislav Marohnić [EMAIL PROTECTED] wrote: That is because none of the version fragments will ever be bigger than 9. -- arty ( http://arty.name ) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Prototype: Core group. To post to this group, send email to prototype-core@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/prototype-core?hl=en -~--~~~~--~~--~--~---