semantic_range 2.1.0 → 2.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ec95fe31851133a57a3c90992bb3124739ce82c0
4
- data.tar.gz: 3a137c6d5e47ab85b4845bb4162d8c5f9253a180
3
+ metadata.gz: 7bc94bd09732c4890fab1c01af561c7211be2334
4
+ data.tar.gz: 9c5cf0e2692244711a88b44135567dc37805a2bd
5
5
  SHA512:
6
- metadata.gz: f50a2b6cdd8dafbc675b0e43b7f6dd74cbdb6f70b88d51350b9c2e1977ca9c6192533863a7c48170ef0f4db580afa9d1de3c7d2810b855d97d497ecc41c44f3a
7
- data.tar.gz: '07929eadc26321cdb53da674de931e7449dba9a264e9b8ba007ed47a1cd1469755c4b39ecab0fce43edf61aaf6c28c15c3ab93f9d343904c1797518dcde37bca'
6
+ metadata.gz: 4680d6cbe31ffb6e9a431a81ae9d50a765180fb9b2e82922d437564e509a076b866b4fa06c9266ddac5bb4d1c9d2f60d2089f30449449f27611e1138141c99d8
7
+ data.tar.gz: afe0038b4961eceeea34ff9d24184739dff228bbc30f6f2a4f280a34d471cc33bb6273d13a2391b6075a39ac3fc9144ee47d84d50f749534dcefb28009b659d4
data/README.md CHANGED
@@ -24,9 +24,9 @@ Or install it yourself as:
24
24
  SemanticRange.valid('1.2.3') # '1.2.3'
25
25
  SemanticRange.valid('a.b.c') # nil
26
26
  SemanticRange.clean(' =v1.2.3 ') # '1.2.3'
27
- SemanticRange.satisfies('1.2.3', '1.x || >=2.5.0 || 5.0.0 - 7.2.3') # true
28
- SemanticRange.gt('1.2.3', '9.8.7') # false
29
- SemanticRange.lt('1.2.3', '9.8.7') # true
27
+ SemanticRange.satisfies?('1.2.3', '1.x || >=2.5.0 || 5.0.0 - 7.2.3') # true
28
+ SemanticRange.gt?('1.2.3', '9.8.7') # false
29
+ SemanticRange.lt?('1.2.3', '9.8.7') # true
30
30
  ```
31
31
 
32
32
  ## Development
@@ -50,12 +50,12 @@ module SemanticRange
50
50
  class InvalidComparator < StandardError; end
51
51
  class InvalidRange < StandardError; end
52
52
 
53
- def self.ltr(version, range, loose = false, platform = nil)
54
- outside(version, range, '<', loose, platform)
53
+ def self.ltr?(version, range, loose = false, platform = nil)
54
+ outside?(version, range, '<', loose, platform)
55
55
  end
56
56
 
57
- def self.gtr(version, range, loose = false, platform = nil)
58
- outside(version, range, '>', loose, platform)
57
+ def self.gtr?(version, range, loose = false, platform = nil)
58
+ outside?(version, range, '>', loose, platform)
59
59
  end
60
60
 
61
61
  def self.cmp(a, op, b, loose = false)
@@ -69,27 +69,27 @@ module SemanticRange
69
69
  b = b.version if !b.is_a?(String)
70
70
  a != b
71
71
  when '', '=', '=='
72
- eq(a, b, loose)
72
+ eq?(a, b, loose)
73
73
  when '!='
74
- neq(a, b, loose)
74
+ neq?(a, b, loose)
75
75
  when '>'
76
- gt(a, b, loose)
76
+ gt?(a, b, loose)
77
77
  when '>='
78
- gte(a, b, loose)
78
+ gte?(a, b, loose)
79
79
  when '<'
80
- lt(a, b, loose)
80
+ lt?(a, b, loose)
81
81
  when '<='
82
- lte(a, b, loose)
82
+ lte?(a, b, loose)
83
83
  else
84
84
  raise 'Invalid operator: ' + op
85
85
  end
86
86
  end
87
87
 
88
- def self.outside(version, range, hilo, loose = false, platform = nil)
88
+ def self.outside?(version, range, hilo, loose = false, platform = nil)
89
89
  version = Version.new(version, loose)
90
90
  range = Range.new(range, loose, platform)
91
91
 
92
- return false if satisfies(version, range, loose, platform)
92
+ return false if satisfies?(version, range, loose, platform)
93
93
 
94
94
  case hilo
95
95
  when '>'
@@ -114,15 +114,15 @@ module SemanticRange
114
114
 
115
115
  case hilo
116
116
  when '>'
117
- if gt(comparator.semver, high.semver, loose)
117
+ if gt?(comparator.semver, high.semver, loose)
118
118
  high = comparator
119
- elsif lt(comparator.semver, low.semver, loose)
119
+ elsif lt?(comparator.semver, low.semver, loose)
120
120
  low = comparator
121
121
  end
122
122
  when '<'
123
- if lt(comparator.semver, high.semver, loose)
123
+ if lt?(comparator.semver, high.semver, loose)
124
124
  high = comparator
125
- elsif gt(comparator.semver, low.semver, loose)
125
+ elsif gt?(comparator.semver, low.semver, loose)
126
126
  low = comparator
127
127
  end
128
128
  end
@@ -132,15 +132,15 @@ module SemanticRange
132
132
 
133
133
  case hilo
134
134
  when '>'
135
- if (low.operator.empty? || low.operator == comp) && lte(version, low.semver, loose)
135
+ if (low.operator.empty? || low.operator == comp) && lte?(version, low.semver, loose)
136
136
  return false;
137
- elsif (low.operator == ecomp && lt(version, low.semver, loose))
137
+ elsif (low.operator == ecomp && lt?(version, low.semver, loose))
138
138
  return false;
139
139
  end
140
140
  when '<'
141
- if (low.operator.empty? || low.operator == comp) && gte(version, low.semver, loose)
141
+ if (low.operator.empty? || low.operator == comp) && gte?(version, low.semver, loose)
142
142
  return false;
143
- elsif low.operator == ecomp && gt(version, low.semver, loose)
143
+ elsif low.operator == ecomp && gt?(version, low.semver, loose)
144
144
  return false;
145
145
  end
146
146
  end
@@ -148,14 +148,14 @@ module SemanticRange
148
148
  true
149
149
  end
150
150
 
151
- def self.satisfies(version, range, loose = false, platform = nil)
151
+ def self.satisfies?(version, range, loose = false, platform = nil)
152
152
  return false if !valid_range(range, loose, platform)
153
153
  Range.new(range, loose, platform).test(version)
154
154
  end
155
155
 
156
156
  def self.max_satisfying(versions, range, loose = false, platform = nil)
157
157
  versions.select { |version|
158
- satisfies(version, range, loose, platform)
158
+ satisfies?(version, range, loose, platform)
159
159
  }.sort { |a, b|
160
160
  rcompare(a, b, loose)
161
161
  }[0] || nil
@@ -191,27 +191,27 @@ module SemanticRange
191
191
  # TODO
192
192
  end
193
193
 
194
- def self.lt(a, b, loose = false)
194
+ def self.lt?(a, b, loose = false)
195
195
  compare(a, b, loose) < 0
196
196
  end
197
197
 
198
- def self.gt(a, b, loose = false)
198
+ def self.gt?(a, b, loose = false)
199
199
  compare(a, b, loose) > 0
200
200
  end
201
201
 
202
- def self.eq(a, b, loose = false)
202
+ def self.eq?(a, b, loose = false)
203
203
  compare(a, b, loose) == 0
204
204
  end
205
205
 
206
- def self.neq(a, b, loose = false)
206
+ def self.neq?(a, b, loose = false)
207
207
  compare(a, b, loose) != 0
208
208
  end
209
209
 
210
- def self.gte(a, b, loose = false)
210
+ def self.gte?(a, b, loose = false)
211
211
  compare(a, b, loose) >= 0
212
212
  end
213
213
 
214
- def self.lte(a, b, loose = false)
214
+ def self.lte?(a, b, loose = false)
215
215
  compare(a, b, loose) <= 0
216
216
  end
217
217
 
@@ -267,4 +267,18 @@ module SemanticRange
267
267
  comp.map(&:to_s)
268
268
  end
269
269
  end
270
+
271
+ class << self
272
+ # Support for older non-inquisitive method versions
273
+ alias_method :gt, :gt?
274
+ alias_method :gtr, :gtr?
275
+ alias_method :gte, :gte?
276
+ alias_method :lt, :lt?
277
+ alias_method :ltr, :ltr?
278
+ alias_method :lte, :lte?
279
+ alias_method :eq, :eq?
280
+ alias_method :neq, :neq?
281
+ alias_method :outside, :outside?
282
+ alias_method :satisfies, :satisfies?
283
+ end
270
284
  end
@@ -30,15 +30,15 @@ module SemanticRange
30
30
  @semver = !m[2] ? ANY : Version.new(m[2], @loose)
31
31
  end
32
32
 
33
- def intersects(comp, loose = false, platform = nil)
33
+ def intersects?(comp, loose = false, platform = nil)
34
34
  comp = Comparator.new(comp, loose)
35
35
 
36
36
  if @operator == ''
37
37
  range_b = Range.new(comp.value, loose, platform)
38
- SemanticRange.satisfies(@value, range_b, loose, platform)
38
+ SemanticRange.satisfies?(@value, range_b, loose, platform)
39
39
  elsif comp.operator == ''
40
40
  range_a = Range.new(@value, loose, platform)
41
- SemanticRange.satisfies(comp.semver, range_a, loose, platform)
41
+ SemanticRange.satisfies?(comp.semver, range_a, loose, platform)
42
42
  else
43
43
  same_direction_increasing = (@operator == '>=' || @operator == '>') && (comp.operator == '>=' || comp.operator == '>')
44
44
  same_direction_decreasing = (@operator == '<=' || @operator == '<') && (comp.operator == '<=' || comp.operator == '<')
@@ -54,14 +54,18 @@ module SemanticRange
54
54
  end
55
55
  end
56
56
 
57
- def satisfies_range(range, loose = false, platform = nil)
57
+ def satisfies_range?(range, loose = false, platform = nil)
58
58
  range = Range.new(range, loose, platform)
59
59
 
60
60
  range.set.any? do |comparators|
61
61
  comparators.all? do |comparator|
62
- intersects(comparator, loose, platform)
62
+ intersects?(comparator, loose, platform)
63
63
  end
64
64
  end
65
65
  end
66
+
67
+ # Support for older non-inquisitive method versions
68
+ alias_method :intersects, :intersects?
69
+ alias_method :satisfies_range, :satisfies_range?
66
70
  end
67
71
  end
@@ -1,5 +1,5 @@
1
1
  module SemanticRange
2
- VERSION = "2.1.0"
2
+ VERSION = "2.2.0"
3
3
 
4
4
  class Version
5
5
  attr_reader :major, :minor, :patch, :prerelease
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: semantic_range
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.0
4
+ version: 2.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Nesbitt
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-09-24 00:00:00.000000000 Z
11
+ date: 2019-03-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler