corrade-nucleus-nucleons – Blame information for rev 20
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
20 | office | 1 | function Version(version) { |
2 | var args = arguments; |
||
3 | this.components = typeof version === "string" ? |
||
4 | version.split(".").map(function(x){return parseInt(x, 10);}) : |
||
5 | Object.keys(arguments).map(function(k){return args[k];}); |
||
6 | |||
7 | var len = this.components.length; |
||
8 | this.major = len ? this.components[0] : 0; |
||
9 | this.minor = len > 1 ? this.components[1] : 0; |
||
10 | this.build = len > 2 ? this.components[2] : 0; |
||
11 | this.revision = len > 3 ? this.components[3] : 0; |
||
12 | |||
13 | if (typeof version !== "string") { |
||
14 | return; |
||
15 | } |
||
16 | |||
17 | var ext = version.split("-"); |
||
18 | if (ext.length === 2) { |
||
19 | this.configuration = ext[1]; |
||
20 | } |
||
21 | } |
||
22 | |||
23 | Version.prototype = { |
||
24 | toString: function() { |
||
25 | var version = this.components.join("."); |
||
26 | if (typeof this.configuration !== "undefined") { |
||
27 | version += "-" + this.configuration; |
||
28 | } |
||
29 | return version; |
||
30 | }, |
||
31 | gte: function(other){ |
||
32 | if (this.major < other.major) { |
||
33 | return false; |
||
34 | } |
||
35 | if (this.minor < other.minor) { |
||
36 | return false; |
||
37 | } |
||
38 | if (this.build < other.build) { |
||
39 | return false; |
||
40 | } |
||
41 | if (this.revision < other.revision) { |
||
42 | return false; |
||
43 | } |
||
44 | return true; |
||
45 | } |
||
46 | }; |
||
47 | |||
48 | module.exports = Version; |