versionub 0.0.2 → 0.0.2.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -64,7 +64,7 @@ class Type
64
64
  @name = name
65
65
  @instance = Class.new(Instance)
66
66
 
67
- @instance.instance_eval &block
67
+ @instance.class_eval &block
68
68
  end
69
69
 
70
70
  def parse (text)
@@ -76,7 +76,6 @@ class Type
76
76
 
77
77
  @instance.new(name, text, data)
78
78
  end
79
-
80
79
  end
81
80
 
82
81
  end
@@ -0,0 +1,57 @@
1
+ #--
2
+ # Copyleft meh. [http://meh.paranoid.pk | meh@paranoici.org]
3
+ #
4
+ # This file is part of versionub.
5
+ #
6
+ # versionub is free software: you can redistribute it and/or modify
7
+ # it under the terms of the GNU Affero General Public License as published
8
+ # by the Free Software Foundation, either version 3 of the License, or
9
+ # (at your option) any later version.
10
+ #
11
+ # versionub is distributed in the hope that it will be useful,
12
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ # GNU Affero General Public License for more details.
15
+ #
16
+ # You should have received a copy of the GNU Affero General Public License
17
+ # along with versionub. If not, see <http://www.gnu.org/licenses/>.
18
+ #++
19
+
20
+ Versionub.register :windows do
21
+ parser do
22
+ rule(:part) { match['0-9'].repeat }
23
+
24
+ rule(:separator) { match['.-_\s'] }
25
+
26
+ rule(:version) {
27
+ part.as(:major) >> separator.maybe >>
28
+ str('SP').maybe >> part.as(:minor)
29
+ }
30
+
31
+ root :version
32
+ end
33
+
34
+ def major
35
+ @data[:major].to_s if @data[:major]
36
+ end
37
+
38
+ def minor
39
+ @data[:minor].to_s if @data[:minor]
40
+ end
41
+
42
+ include Comparable
43
+
44
+ def <=> (value)
45
+ value = Versionub.parse(value)
46
+
47
+ if (tmp = (minor <=> value.minor)) != 0
48
+ return tmp
49
+ end
50
+
51
+ if (tmp = (major <=> value.major)) != 0
52
+ return tmp
53
+ end
54
+
55
+ 0
56
+ end
57
+ end
@@ -0,0 +1,23 @@
1
+ #--
2
+ # Copyleft meh. [http://meh.paranoid.pk | meh@paranoici.org]
3
+ #
4
+ # This file is part of versionub.
5
+ #
6
+ # versionub is free software: you can redistribute it and/or modify
7
+ # it under the terms of the GNU Affero General Public License as published
8
+ # by the Free Software Foundation, either version 3 of the License, or
9
+ # (at your option) any later version.
10
+ #
11
+ # versionub is distributed in the hope that it will be useful,
12
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ # GNU Affero General Public License for more details.
15
+ #
16
+ # You should have received a copy of the GNU Affero General Public License
17
+ # along with versionub. If not, see <http://www.gnu.org/licenses/>.
18
+ #++
19
+
20
+ require 'versionub/type'
21
+
22
+ require 'versionub/types/standard'
23
+ require 'versionub/types/windows'
data/lib/versionub.rb CHANGED
@@ -17,8 +17,6 @@
17
17
  # along with versionub. If not, see <http://www.gnu.org/licenses/>.
18
18
  #++
19
19
 
20
- require 'versionub/type'
21
-
22
20
  module Versionub
23
21
  Types = {}
24
22
 
@@ -31,4 +29,4 @@ module Versionub
31
29
  end
32
30
  end
33
31
 
34
- require 'versionub/types/standard'
32
+ require 'versionub/types'
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: versionub
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.0.2
5
+ version: 0.0.2.1
6
6
  platform: ruby
7
7
  authors:
8
8
  - meh.
@@ -33,6 +33,8 @@ extra_rdoc_files: []
33
33
 
34
34
  files:
35
35
  - lib/versionub.rb
36
+ - lib/versionub/types.rb
37
+ - lib/versionub/types/windows.rb
36
38
  - lib/versionub/types/standard.rb
37
39
  - lib/versionub/type.rb
38
40
  homepage: http://github.com/meh/versionub