version_compare 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +20 -12
- data/lib/version_compare/conversions.rb +3 -1
- data/lib/version_compare/version.rb +15 -18
- data/test/conversions_test.rb +24 -43
- data/test/test_helper.rb +1 -6
- data/test/version_compare_test.rb +143 -143
- metadata +19 -46
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bb866c1ed445858b022983875066a98b0875dcac
|
4
|
+
data.tar.gz: fff6ce85b9bb3f11bb9bd9ae352f24789dd040ee
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 974085d3d812048c6aa7d6435381750c488bec4fab4d00d203ecd88f586f57af4b5f50d28b67d4543f5596edabe68998c2278204f34b4528cf29d59583c6ef27
|
7
|
+
data.tar.gz: 6fad959c52815eccf38476c136d90ef40fec1b909f0c3e9edd7551a69ebec521c728a1f8968fc48e683eb85ff66915f352c8db9c14ffac967fb1de8e65f7ebb5
|
data/README.md
CHANGED
@@ -2,24 +2,26 @@
|
|
2
2
|
|
3
3
|
[](http://badge.fury.io/rb/version_compare)
|
4
4
|
|
5
|
-
Version Compare allows you to easily compare if one Version
|
6
|
-
|
7
|
-
|
8
|
-
to return one of the aforementioned types.
|
5
|
+
Version Compare allows you to easily compare if one Version (string) to another
|
6
|
+
Version (string). It aims to be as light and flexible as possible. Inputs can be
|
7
|
+
a String, Integer, Float, Array, or any object that defines `#to_version`.
|
9
8
|
|
10
|
-
|
11
|
-
|
9
|
+
For simplicity's sake, Version Compare only works with up to four numeric
|
10
|
+
values:
|
12
11
|
|
13
12
|
```ruby
|
14
13
|
"<major>.<minor>.<tiny>.<patch>"
|
14
|
+
[<major>, <minor>, <tiny>, <patch>]
|
15
15
|
```
|
16
16
|
|
17
|
+
|
17
18
|
## Compatibility
|
18
19
|
|
19
20
|
Tested with:
|
20
21
|
|
21
22
|
* Ruby: MRI 1.9.3
|
22
|
-
* Ruby: MRI 2
|
23
|
+
* Ruby: MRI 2+
|
24
|
+
|
23
25
|
|
24
26
|
## Installation
|
25
27
|
|
@@ -35,6 +37,7 @@ And then execute:
|
|
35
37
|
bundle
|
36
38
|
```
|
37
39
|
|
40
|
+
|
38
41
|
## Usage
|
39
42
|
|
40
43
|
To get started, you can either use `Version.new(<value>)` or `Version(<value>)`.
|
@@ -59,7 +62,7 @@ Or, to test on the Rails Console:
|
|
59
62
|
[2] pry(main)> Version(1.0) > Version(1)
|
60
63
|
=> false
|
61
64
|
|
62
|
-
# - OR (without using `include`) -
|
65
|
+
# - OR (without using `include ::Conversions`) -
|
63
66
|
|
64
67
|
[1] pry(main)> Conversions.Version(1.0) > Conversions.Version(1)
|
65
68
|
=> false
|
@@ -76,8 +79,11 @@ Version("1.2.3.4") <= Version("1.2.3.4") # => true
|
|
76
79
|
Version([1, 2]) == Version(["1", "2"]) # => true
|
77
80
|
Version("1.2.0.0") == Version(1.2) # => true
|
78
81
|
Version("1.0.0.0") != Version(1) # => false
|
82
|
+
[Version(1), Version("1.0.0.1"), Version(0.1)].sort # => ["0.1", "1", "1.0.0.1"]
|
83
|
+
[Version(1), Version("1.0.0.1"), Version(0.1)].sort { |a, b| b <=> a } # => ["1.0.0.1", "1", "0.1"]
|
79
84
|
```
|
80
85
|
|
86
|
+
|
81
87
|
### Wait, so what exactly is this `Version` ... constant?
|
82
88
|
|
83
89
|
`Version()` is actually a conversion function. It follows the Ruby convention of
|
@@ -97,11 +103,11 @@ version. For example:
|
|
97
103
|
Version.new(OpenStruct.new(a: 1)).to_s # => "0"
|
98
104
|
```
|
99
105
|
|
106
|
+
|
100
107
|
### Can I pass my own custom objects into `Version()`?
|
101
108
|
|
102
109
|
Yes! All you have to do is define a `#to_version` implicit conversion method in
|
103
|
-
your object
|
104
|
-
Array.
|
110
|
+
your object that creates a new Version object in the usual fashion.
|
105
111
|
|
106
112
|
```ruby
|
107
113
|
class MyObject
|
@@ -114,7 +120,8 @@ end
|
|
114
120
|
Version(MyObject.new) > Version(2.0) # => false
|
115
121
|
```
|
116
122
|
|
117
|
-
|
123
|
+
|
124
|
+
### Why do you seem so excited about the custom object thing?
|
118
125
|
|
119
126
|
Because, it opens up the world! Here's an example:
|
120
127
|
|
@@ -138,7 +145,8 @@ end
|
|
138
145
|
Version(Rails.application) > Version(1.0) # => true
|
139
146
|
```
|
140
147
|
|
141
|
-
So you see
|
148
|
+
So you see... the sky is the limit!
|
149
|
+
|
142
150
|
|
143
151
|
## Author
|
144
152
|
|
@@ -1,20 +1,22 @@
|
|
1
1
|
# Conversions is meant to be a common module used to define standard conversion
|
2
2
|
# methods. Anytime one of the standard conversion methods are needed, the
|
3
3
|
# Conversions module can be included and then used freely.
|
4
|
-
#
|
5
4
|
module Conversions
|
6
5
|
require_relative "version"
|
7
6
|
|
8
7
|
# The `Version()` conversion method is defined as a module_function so that it
|
9
8
|
# may also be called directly without needing to include the Conversions module
|
10
9
|
# if so desired.
|
10
|
+
#
|
11
11
|
# @example
|
12
12
|
# Conversions.Version(1.2).to_s # => "1.2"
|
13
13
|
module_function
|
14
14
|
|
15
15
|
# Strict conversion method for creating a `Version` object out of anything
|
16
16
|
# that sensibly is a Version.
|
17
|
+
#
|
17
18
|
# @param [Object] value the object to be converted
|
19
|
+
#
|
18
20
|
# @example
|
19
21
|
# Version(1) # => #<Version:0x007fd8144ea658 @major=1, @minor=nil, @tiny=nil, @patch=nil>
|
20
22
|
# Version(1.2) # => #<Version:0x007fd8144ea658 @major=1, @minor=2, @tiny=nil, @patch=nil>
|
@@ -6,34 +6,18 @@ class Version
|
|
6
6
|
|
7
7
|
attr_accessor *NAMES
|
8
8
|
|
9
|
-
def initialize(value)
|
10
|
-
@major, @minor, @tiny, @patch = begin
|
11
|
-
if value.respond_to?(:to_ary)
|
12
|
-
value.to_ary.map(&:to_i)
|
13
|
-
elsif value.respond_to?(:to_version)
|
14
|
-
value.to_version.to_a
|
15
|
-
else
|
16
|
-
value.to_s.split('.').map(&:to_i)
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
9
|
# Implicit conversion method
|
22
10
|
def to_version
|
23
11
|
self
|
24
12
|
end
|
25
13
|
|
26
14
|
def to_s
|
27
|
-
|
15
|
+
NAMES.map { |name| public_send(name) }.compact.join('.')
|
28
16
|
end
|
29
17
|
alias :to_str :to_s
|
30
18
|
|
31
|
-
def to_f
|
32
|
-
to_s.to_f
|
33
|
-
end
|
34
|
-
|
35
19
|
def to_a
|
36
|
-
NAMES.map { |name|
|
20
|
+
NAMES.map { |name| public_send(name) }.compact
|
37
21
|
end
|
38
22
|
alias :to_ary :to_a
|
39
23
|
|
@@ -53,4 +37,17 @@ class Version
|
|
53
37
|
end
|
54
38
|
0
|
55
39
|
end
|
40
|
+
|
41
|
+
private
|
42
|
+
|
43
|
+
def initialize(value)
|
44
|
+
@major, @minor, @tiny, @patch =
|
45
|
+
if value.respond_to?(:to_ary)
|
46
|
+
value.to_ary.map(&:to_i)
|
47
|
+
elsif value.respond_to?(:to_version)
|
48
|
+
value.to_version.to_a
|
49
|
+
else
|
50
|
+
value.to_s.split('.').map(&:to_i)
|
51
|
+
end
|
52
|
+
end
|
56
53
|
end
|
data/test/conversions_test.rb
CHANGED
@@ -3,79 +3,60 @@ require 'test_helper'
|
|
3
3
|
describe Conversions do
|
4
4
|
describe "conversion function" do
|
5
5
|
it "works on integers" do
|
6
|
-
|
6
|
+
Version(1).class.must_equal Version
|
7
7
|
end
|
8
8
|
|
9
9
|
it "works on floats" do
|
10
|
-
|
10
|
+
Version(1.2).class.must_equal Version
|
11
11
|
end
|
12
12
|
|
13
13
|
it "works on strings" do
|
14
|
-
|
14
|
+
Version("1.2.3.4").class.must_equal Version
|
15
15
|
end
|
16
16
|
|
17
17
|
it "works on arrays" do
|
18
|
-
|
19
|
-
|
20
|
-
|
18
|
+
Version([1, 2, 3, 4]).must_be_instance_of Version
|
19
|
+
Version([1, 2, 3, 4]).must_equal Version("1.2.3.4")
|
20
|
+
Version(["1", "2", "3", "4"]).must_equal Version("1.2.3.4")
|
21
21
|
end
|
22
22
|
|
23
23
|
it "works on Versions" do
|
24
|
-
|
25
|
-
|
24
|
+
Version(Version(1.2)).must_be_instance_of Version
|
25
|
+
Version(Version(1.2)).must_equal Version(1.2)
|
26
26
|
end
|
27
27
|
end
|
28
28
|
|
29
29
|
describe "explicit conversions" do
|
30
30
|
describe "#to_s" do
|
31
31
|
it "returns string regardless of input" do
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
describe "#to_f" do
|
39
|
-
it "returns float when major only" do
|
40
|
-
assert { Version(1).to_f == 1.0 }
|
41
|
-
end
|
42
|
-
|
43
|
-
it "returns float when major and minor" do
|
44
|
-
assert { Version(1.0).to_f == 1.0 }
|
45
|
-
assert { Version(1.2).to_f == 1.2 }
|
46
|
-
end
|
47
|
-
|
48
|
-
it "returns truncated float when more than just major and minor" do
|
49
|
-
assert { Version("1.0.0").to_f == 1.0 }
|
50
|
-
assert { Version("1.1.9").to_f == 1.1 }
|
51
|
-
assert { Version("1.0.0.0").to_f == 1.0 }
|
52
|
-
assert { Version("1.1.9.9").to_f == 1.1 }
|
32
|
+
Version(1).to_s.must_equal "1"
|
33
|
+
Version(1.2).to_s.must_equal "1.2"
|
34
|
+
Version("1.2.3").to_s.must_equal "1.2.3"
|
53
35
|
end
|
54
36
|
end
|
55
37
|
|
56
38
|
describe "#to_a" do
|
57
39
|
it "returns an array of integers" do
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
40
|
+
Version(1).to_a.must_equal [1]
|
41
|
+
Version(1.0).to_a.must_equal [1, 0]
|
42
|
+
Version("1.2.3").to_a.must_equal [1, 2, 3]
|
43
|
+
Version("1.2.3.4").to_a.must_equal [1, 2, 3, 4]
|
44
|
+
Version(["1", "2", "3", "4"]).to_a.must_equal [1, 2, 3, 4]
|
63
45
|
end
|
64
46
|
end
|
65
47
|
end
|
66
48
|
|
67
49
|
describe "implicit conversions" do
|
68
|
-
describe "string
|
69
|
-
it "
|
70
|
-
|
50
|
+
describe "string concatenation" do
|
51
|
+
it "concatenates" do
|
52
|
+
("version: " + Version("1.2.3.4")).must_equal "version: 1.2.3.4"
|
71
53
|
end
|
72
54
|
end
|
73
55
|
|
74
56
|
describe "CustomObjects" do
|
75
57
|
describe "without #to_version" do
|
76
58
|
it "raises TypeError when attempting to convert custom objects that don't implement #to_version" do
|
77
|
-
|
78
|
-
deny { rescuing { Version.new(Object.new) }.is_a?(StandardError) }
|
59
|
+
-> { Version(Object.new) }.must_raise TypeError
|
79
60
|
end
|
80
61
|
end
|
81
62
|
|
@@ -87,13 +68,13 @@ describe Conversions do
|
|
87
68
|
Version.new(VERSION.to_s)
|
88
69
|
end
|
89
70
|
end
|
90
|
-
|
91
|
-
@obj = CustomObject.new
|
92
71
|
end
|
93
72
|
|
73
|
+
subject { CustomObject.new }
|
74
|
+
|
94
75
|
it "returns a Version object" do
|
95
|
-
|
96
|
-
|
76
|
+
Version(subject).must_be_instance_of Version
|
77
|
+
Version.new(subject).must_be_instance_of Version
|
97
78
|
end
|
98
79
|
end
|
99
80
|
end
|
data/test/test_helper.rb
CHANGED
@@ -4,15 +4,10 @@ ENV["RAILS_ENV"] = "test"
|
|
4
4
|
require File.expand_path("../dummy/config/environment.rb", __FILE__)
|
5
5
|
require "rails/test_help"
|
6
6
|
require "minitest/rails"
|
7
|
-
require "minitest/ansi"
|
8
|
-
require "wrong/adapters/minitest"
|
9
7
|
|
10
8
|
include ::Conversions
|
11
9
|
|
12
|
-
MiniTest::ANSI.use!
|
13
|
-
Wrong.config.color
|
14
|
-
|
15
10
|
Rails.backtrace_cleaner.remove_silencers!
|
16
11
|
|
17
12
|
# Load support files
|
18
|
-
Dir[
|
13
|
+
Dir[Rails.root.join("test/support/**/*.rb")].each { |f| require f }
|
@@ -2,180 +2,180 @@ require 'test_helper'
|
|
2
2
|
|
3
3
|
describe VersionCompare do
|
4
4
|
describe "#>" do
|
5
|
-
it "returns true when
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
5
|
+
it "returns true when lvalue is greater than rvalue" do
|
6
|
+
Version(2).must_be :>, Version(1)
|
7
|
+
Version(2).must_be :>, Version(1.2)
|
8
|
+
Version(2).must_be :>, Version("1.2.3")
|
9
|
+
Version(2).must_be :>, Version("1.2.3.4")
|
10
|
+
|
11
|
+
Version(2.0).must_be :>, Version(1)
|
12
|
+
Version(2.0).must_be :>, Version(1.0)
|
13
|
+
Version(2.1).must_be :>, Version("2.0.3")
|
14
|
+
Version(2.1).must_be :>, Version("2.0.3.4")
|
15
|
+
|
16
|
+
Version("2.0.0").must_be :>, Version(1)
|
17
|
+
Version("2.1.0").must_be :>, Version(1.2)
|
18
|
+
Version("2.1.0").must_be :>, Version("1.2.0")
|
19
|
+
Version("2.1.1").must_be :>, Version("2.1.0.4")
|
20
|
+
|
21
|
+
Version("2.0.0.0").must_be :>, Version(1)
|
22
|
+
Version("2.1.0.0").must_be :>, Version(2.0)
|
23
|
+
Version("2.1.1.0").must_be :>, Version("2.1.0")
|
24
|
+
Version("2.1.3.0").must_be :>, Version("2.1.2.4")
|
25
|
+
|
26
|
+
Version(2).must_be :>, Version(1.99)
|
27
|
+
Version(1.3).must_be :>, Version("1.2.99")
|
28
|
+
Version("1.2.4").must_be :>, Version("1.2.3.99")
|
29
29
|
end
|
30
30
|
|
31
|
-
it "returns false when
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
31
|
+
it "returns false when lvalue is less than rvalue" do
|
32
|
+
Version(1).wont_be :>, Version(2)
|
33
|
+
Version(1.2).wont_be :>, Version(2)
|
34
|
+
Version("1.2.3").wont_be :>, Version(2)
|
35
|
+
Version("1.2.3.4").wont_be :>, Version(2)
|
36
|
+
|
37
|
+
Version(1).wont_be :>, Version(2.0)
|
38
|
+
Version(2.0).wont_be :>, Version(2.1)
|
39
|
+
Version("2.0.3").wont_be :>, Version(2.1)
|
40
|
+
Version("2.0.3.4").wont_be :>, Version(2.1)
|
41
|
+
|
42
|
+
Version(1).wont_be :>, Version("2.0.0")
|
43
|
+
Version(1.2).wont_be :>, Version("2.1.0")
|
44
|
+
Version("2.1.0").wont_be :>, Version("2.1.1")
|
45
|
+
Version("2.1.0.4").wont_be :>, Version("2.1.1")
|
46
|
+
|
47
|
+
Version(1).wont_be :>, Version("2.0.0.0")
|
48
|
+
Version(2.0).wont_be :>, Version("2.1.0.0")
|
49
|
+
Version("2.1.0").wont_be :>, Version("2.1.1.0")
|
50
|
+
Version("2.1.0.4").wont_be :>, Version("2.1.1.0")
|
51
|
+
|
52
|
+
Version(1.99).wont_be :>, Version(2)
|
53
|
+
Version("1.2.99").wont_be :>, Version(1.3)
|
54
|
+
Version("1.2.3.99").wont_be :>, Version("1.2.4")
|
55
55
|
end
|
56
56
|
|
57
|
-
it "returns false when
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
57
|
+
it "returns false when lvalue is equal to rvalue" do
|
58
|
+
Version(1).wont_be :>, Version(1.0)
|
59
|
+
Version(1.2).wont_be :>, Version("1.2.0")
|
60
|
+
Version("1.2.3").wont_be :>, Version("1.2.3.0")
|
61
|
+
Version("1.2.3.4").wont_be :>, Version("1.2.3.4")
|
62
62
|
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
63
|
+
Version(1.0).wont_be :>, Version(1)
|
64
|
+
Version("1.2.0").wont_be :>, Version(1.2)
|
65
|
+
Version("1.2.3").wont_be :>, Version("1.2.3.0")
|
66
|
+
Version("1.2.3.4").wont_be :>, Version("1.2.3.4")
|
67
67
|
end
|
68
68
|
end
|
69
69
|
|
70
70
|
describe "#==" do
|
71
|
-
it "returns false when
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
71
|
+
it "returns false when lvalue is less than rvalue" do
|
72
|
+
Version(1.2).wont_equal Version(2)
|
73
|
+
Version("1.2.3").wont_equal Version(2)
|
74
|
+
Version("1.2.3.4").wont_equal Version(2)
|
75
|
+
|
76
|
+
Version(1).wont_equal Version(2.0)
|
77
|
+
Version("2.0.3").wont_equal Version(2.1)
|
78
|
+
Version("2.0.3.4").wont_equal Version(2.1)
|
79
|
+
|
80
|
+
Version(1).wont_equal Version("2.0.0")
|
81
|
+
Version(1.2).wont_equal Version("2.1.0")
|
82
|
+
Version("2.1.0.4").wont_equal Version("2.1.1")
|
83
|
+
|
84
|
+
Version(1).wont_equal Version("2.0.0.0")
|
85
|
+
Version(2.0).wont_equal Version("2.1.0.0")
|
86
|
+
Version("2.1.0").wont_equal Version("2.1.1.0")
|
87
|
+
|
88
|
+
Version(1.99).wont_equal Version(2)
|
89
|
+
Version("1.2.99").wont_equal Version(1.3)
|
90
|
+
Version("1.2.3.99").wont_equal Version("1.2.4")
|
91
91
|
end
|
92
92
|
|
93
|
-
it "returns false when
|
94
|
-
|
95
|
-
|
96
|
-
|
93
|
+
it "returns false when lvalue is greater than rvalue" do
|
94
|
+
Version(2).wont_equal Version(1.2)
|
95
|
+
Version(2).wont_equal Version("1.2.3")
|
96
|
+
Version(2).wont_equal Version("1.2.3.4")
|
97
97
|
|
98
|
-
|
99
|
-
|
100
|
-
|
98
|
+
Version(2.0).wont_equal Version(1)
|
99
|
+
Version(2.1).wont_equal Version("2.0.3")
|
100
|
+
Version(2.1).wont_equal Version("2.0.3.4")
|
101
101
|
|
102
|
-
|
103
|
-
|
104
|
-
|
102
|
+
Version("2.0.0").wont_equal Version(1)
|
103
|
+
Version("2.1.0").wont_equal Version(1.2)
|
104
|
+
Version("2.1.1").wont_equal Version("2.1.0.4")
|
105
105
|
|
106
|
-
|
107
|
-
|
108
|
-
|
106
|
+
Version("2.0.0.0").wont_equal Version(1)
|
107
|
+
Version("2.1.0.0").wont_equal Version(2.0)
|
108
|
+
Version("2.1.1.0").wont_equal Version("2.1.0")
|
109
109
|
|
110
|
-
|
111
|
-
|
112
|
-
|
110
|
+
Version(2).wont_equal Version(1.99)
|
111
|
+
Version(1.3).wont_equal Version("1.2.99")
|
112
|
+
Version("1.2.4").wont_equal Version("1.2.3.99")
|
113
113
|
end
|
114
114
|
|
115
|
-
it "returns true when
|
116
|
-
|
117
|
-
|
118
|
-
|
115
|
+
it "returns true when lvalue is equal to rvalue" do
|
116
|
+
Version(1.0).must_equal Version(1)
|
117
|
+
Version("1.2.0").must_equal Version(1.2)
|
118
|
+
Version("1.2.3.0").must_equal Version("1.2.3")
|
119
119
|
|
120
|
-
|
121
|
-
|
122
|
-
|
120
|
+
Version(1).must_equal Version(1.0)
|
121
|
+
Version(1.2).must_equal Version("1.2.0")
|
122
|
+
Version("1.2.3").must_equal Version("1.2.3.0")
|
123
123
|
end
|
124
124
|
end
|
125
125
|
|
126
126
|
describe "#<" do
|
127
|
-
it "returns true when
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
127
|
+
it "returns true when lvalue is less than rvalue" do
|
128
|
+
Version(1.2).must_be :<, Version(2)
|
129
|
+
Version("1.2.3").must_be :<, Version(2)
|
130
|
+
Version("1.2.3.4").must_be :<, Version(2)
|
131
|
+
|
132
|
+
Version(1).must_be :<, Version(2.0)
|
133
|
+
Version("2.0.3").must_be :<, Version(2.1)
|
134
|
+
Version("2.0.3.4").must_be :<, Version(2.1)
|
135
|
+
|
136
|
+
Version(1).must_be :<, Version("2.0.0")
|
137
|
+
Version(1.2).must_be :<, Version("2.1.0")
|
138
|
+
Version("2.1.0.4").must_be :<, Version("2.1.1")
|
139
|
+
|
140
|
+
Version(1).must_be :<, Version("2.0.0.0")
|
141
|
+
Version(2.0).must_be :<, Version("2.1.0.0")
|
142
|
+
Version("2.1.0").must_be :<, Version("2.1.1.0")
|
143
|
+
|
144
|
+
Version(1.99).must_be :<, Version(2)
|
145
|
+
Version("1.2.99").must_be :<, Version(1.3)
|
146
|
+
Version("1.2.3.99").must_be :<, Version("1.2.4")
|
147
147
|
end
|
148
148
|
|
149
|
-
it "returns false when
|
150
|
-
|
151
|
-
|
152
|
-
|
149
|
+
it "returns false when lvalue is greater than rvalue" do
|
150
|
+
Version(2).wont_be :<, Version(1.2)
|
151
|
+
Version(2).wont_be :<, Version("1.2.3")
|
152
|
+
Version(2).wont_be :<, Version("1.2.3.4")
|
153
153
|
|
154
|
-
|
155
|
-
|
156
|
-
|
154
|
+
Version(2.0).wont_be :<, Version(1)
|
155
|
+
Version(2.1).wont_be :<, Version("2.0.3")
|
156
|
+
Version(2.1).wont_be :<, Version("2.0.3.4")
|
157
157
|
|
158
|
-
|
159
|
-
|
160
|
-
|
158
|
+
Version("2.0.0").wont_be :<, Version(1)
|
159
|
+
Version("2.1.0").wont_be :<, Version(1.2)
|
160
|
+
Version("2.1.1").wont_be :<, Version("2.1.0.4")
|
161
161
|
|
162
|
-
|
163
|
-
|
164
|
-
|
162
|
+
Version("2.0.0.0").wont_be :<, Version(1)
|
163
|
+
Version("2.1.0.0").wont_be :<, Version(2.0)
|
164
|
+
Version("2.1.1.0").wont_be :<, Version("2.1.0")
|
165
165
|
|
166
|
-
|
167
|
-
|
168
|
-
|
166
|
+
Version(2).wont_be :<, Version(1.99)
|
167
|
+
Version(1.3).wont_be :<, Version("1.2.99")
|
168
|
+
Version("1.2.4").wont_be :<, Version("1.2.3.99")
|
169
169
|
end
|
170
170
|
|
171
|
-
it "returns false when
|
172
|
-
|
173
|
-
|
174
|
-
|
171
|
+
it "returns false when lvalue is equal to rvalue" do
|
172
|
+
Version(1.0).wont_be :<, Version(1)
|
173
|
+
Version("1.2.0").wont_be :<, Version(1.2)
|
174
|
+
Version("1.2.3.0").wont_be :<, Version("1.2.3")
|
175
175
|
|
176
|
-
|
177
|
-
|
178
|
-
|
176
|
+
Version(1).wont_be :<, Version(1.0)
|
177
|
+
Version(1.2).wont_be :<, Version("1.2.0")
|
178
|
+
Version("1.2.3").wont_be :<, Version("1.2.3.0")
|
179
179
|
end
|
180
180
|
end
|
181
181
|
end
|
metadata
CHANGED
@@ -1,83 +1,55 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: version_compare
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Paul Dobbins
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2014-08-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: 3.0.0
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: 3.0.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: sqlite3
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '0'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- -
|
38
|
+
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: minitest-rails
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- -
|
45
|
+
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: '0'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- -
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
version: '0'
|
55
|
-
- !ruby/object:Gem::Dependency
|
56
|
-
name: minitest-ansi
|
57
|
-
requirement: !ruby/object:Gem::Requirement
|
58
|
-
requirements:
|
59
|
-
- - '>='
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: '0'
|
62
|
-
type: :development
|
63
|
-
prerelease: false
|
64
|
-
version_requirements: !ruby/object:Gem::Requirement
|
65
|
-
requirements:
|
66
|
-
- - '>='
|
67
|
-
- !ruby/object:Gem::Version
|
68
|
-
version: '0'
|
69
|
-
- !ruby/object:Gem::Dependency
|
70
|
-
name: wrong
|
71
|
-
requirement: !ruby/object:Gem::Requirement
|
72
|
-
requirements:
|
73
|
-
- - '>='
|
74
|
-
- !ruby/object:Gem::Version
|
75
|
-
version: '0'
|
76
|
-
type: :development
|
77
|
-
prerelease: false
|
78
|
-
version_requirements: !ruby/object:Gem::Requirement
|
79
|
-
requirements:
|
80
|
-
- - '>='
|
52
|
+
- - ">="
|
81
53
|
- !ruby/object:Gem::Version
|
82
54
|
version: '0'
|
83
55
|
description: Version Compare allows you to easily compare if one Version is >, >=,
|
@@ -88,13 +60,15 @@ executables: []
|
|
88
60
|
extensions: []
|
89
61
|
extra_rdoc_files: []
|
90
62
|
files:
|
91
|
-
- lib/version_compare/conversions.rb
|
92
|
-
- lib/version_compare/version.rb
|
93
|
-
- lib/version_compare.rb
|
94
63
|
- MIT-LICENSE
|
95
|
-
- Rakefile
|
96
64
|
- README.md
|
65
|
+
- Rakefile
|
66
|
+
- lib/version_compare.rb
|
67
|
+
- lib/version_compare/conversions.rb
|
68
|
+
- lib/version_compare/version.rb
|
97
69
|
- test/conversions_test.rb
|
70
|
+
- test/dummy/README.rdoc
|
71
|
+
- test/dummy/Rakefile
|
98
72
|
- test/dummy/app/assets/javascripts/application.js
|
99
73
|
- test/dummy/app/assets/stylesheets/application.css
|
100
74
|
- test/dummy/app/controllers/application_controller.rb
|
@@ -103,6 +77,7 @@ files:
|
|
103
77
|
- test/dummy/bin/bundle
|
104
78
|
- test/dummy/bin/rails
|
105
79
|
- test/dummy/bin/rake
|
80
|
+
- test/dummy/config.ru
|
106
81
|
- test/dummy/config/application.rb
|
107
82
|
- test/dummy/config/boot.rb
|
108
83
|
- test/dummy/config/database.yml
|
@@ -119,15 +94,12 @@ files:
|
|
119
94
|
- test/dummy/config/initializers/wrap_parameters.rb
|
120
95
|
- test/dummy/config/locales/en.yml
|
121
96
|
- test/dummy/config/routes.rb
|
122
|
-
- test/dummy/config.ru
|
123
97
|
- test/dummy/log/development.log
|
124
98
|
- test/dummy/log/test.log
|
125
99
|
- test/dummy/public/404.html
|
126
100
|
- test/dummy/public/422.html
|
127
101
|
- test/dummy/public/500.html
|
128
102
|
- test/dummy/public/favicon.ico
|
129
|
-
- test/dummy/Rakefile
|
130
|
-
- test/dummy/README.rdoc
|
131
103
|
- test/test_helper.rb
|
132
104
|
- test/version_compare_test.rb
|
133
105
|
homepage: https://github.com/pdobb/version_compare
|
@@ -140,17 +112,17 @@ require_paths:
|
|
140
112
|
- lib
|
141
113
|
required_ruby_version: !ruby/object:Gem::Requirement
|
142
114
|
requirements:
|
143
|
-
- -
|
115
|
+
- - ">="
|
144
116
|
- !ruby/object:Gem::Version
|
145
117
|
version: '0'
|
146
118
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
147
119
|
requirements:
|
148
|
-
- -
|
120
|
+
- - ">="
|
149
121
|
- !ruby/object:Gem::Version
|
150
122
|
version: '0'
|
151
123
|
requirements: []
|
152
124
|
rubyforge_project:
|
153
|
-
rubygems_version: 2.1
|
125
|
+
rubygems_version: 2.4.1
|
154
126
|
signing_key:
|
155
127
|
specification_version: 4
|
156
128
|
summary: Compare versions
|
@@ -191,3 +163,4 @@ test_files:
|
|
191
163
|
- test/dummy/README.rdoc
|
192
164
|
- test/test_helper.rb
|
193
165
|
- test/version_compare_test.rb
|
166
|
+
has_rdoc:
|