40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
|
# File 'lib/doing/changelog/version.rb', line 40
def compare(other, comp, inclusive: false)
case comp
when :older
if @maj <= other.maj
if @maj < other.maj
true
elsif @maj == other.maj && (other.min.nil? || @min < other.min)
true
elsif @maj == other.maj && @min == other.min
if other.patch.nil?
false
else
inclusive ? @patch <= other.patch : @patch < other.patch
end
else
false
end
else
false
end
when :newer
if @maj >= other.maj
if @maj > other.maj
true
elsif @maj == other.maj && (other.min.nil? || @min > other.min)
true
elsif @maj == other.maj && @min == other.min
if other.patch.nil?
false
else
inclusive ? @patch >= other.patch : @patch > other.patch
end
else
false
end
else
false
end
when :equal
if @maj == other.maj
if other.min.nil?
true
elsif wild?(other.min)
@min.to_s =~ /^#{other.min}/ ? true : false
else
if @min == other.min
if other.patch.nil?
true
elsif wild?(other.patch)
@patch.to_s =~ /^#{other.patch}/ ? true : false
else
@patch == other.patch
end
else
false
end
end
end
end
end
|