semantic_range 3.0.0 → 3.1.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
  SHA256:
3
- metadata.gz: 67ae11bb60e5aa3341d7d83eae4e7f100262878f2ef6612391b4e18ce3ee5801
4
- data.tar.gz: d25d1b605ddf68eed7979808d0ce1bebbaac5e7025e47ac9d81564dbabb21ca6
3
+ metadata.gz: 5570448573eca2548f2ce0b071f6202556de21a96c7c3681691f24e919c9fe2d
4
+ data.tar.gz: 26d2d05d0d10001a0e210eabf5d1e66d192f5f2a97a4435785f0e2d2e4f23920
5
5
  SHA512:
6
- metadata.gz: 873719a7f9a4af750cd6deda9a59a7953566d87558f3c7b9825cb3001f188d6453dfca58ce429fb013ffe664ea1806ebefbd081c4c2eadfee734e87dc1d167cf
7
- data.tar.gz: dff74a1adac2232a3425e6e6d9b7de0412dadd574a3dee8a114d008b9a003c9070db6a69444142980e16e7c7586f7d50f409769e616b18c298b47fb8ce25877d
6
+ metadata.gz: 1c8bbe048f7289c9277410e7c09f0f5eab4b202949bff9ef7a696cee493e9bc814b9137ee9677e794df7567d4f0b6646c21cb42780c33a1cb67daafea600e595
7
+ data.tar.gz: 9d31e3ae5fe35330179bf1e5d3776550aafa82b3dd5468222e9620b22606e52f1ee2198c037f9cdfb061475ceedb1c766f002a1624cf27665b46638d6eba498a
data/README.md CHANGED
@@ -26,6 +26,8 @@ Or install it yourself as:
26
26
  ## Usage
27
27
 
28
28
  ```ruby
29
+ SemanticRange.valid?('1.2.3') # true
30
+ SemanticRange.valid?('a.b.c') # false
29
31
  SemanticRange.valid('1.2.3') # '1.2.3'
30
32
  SemanticRange.valid('a.b.c') # nil
31
33
  SemanticRange.clean(' =v1.2.3 ') # '1.2.3'
@@ -62,7 +62,7 @@ module SemanticRange
62
62
  end
63
63
 
64
64
  def last_number_index
65
- parts.rindex { |e| e.is_a? Fixnum }
65
+ parts.rindex { |e| e.is_a? Integer }
66
66
  end
67
67
 
68
68
  def increment!(identifier = nil)
@@ -80,7 +80,7 @@ module SemanticRange
80
80
  # 1.2.0-beta.1 bumps to 1.2.0-beta.2,
81
81
  # 1.2.0-beta.fooblz or 1.2.0-beta bumps to 1.2.0-beta.0
82
82
  if parts[0] == identifier
83
- unless parts[1].kind_of?(Fixnum)
83
+ unless parts[1].kind_of?(Integer)
84
84
  @parts = [identifier, 0]
85
85
  end
86
86
  else
@@ -1,5 +1,5 @@
1
1
  module SemanticRange
2
- VERSION = "3.0.0"
2
+ VERSION = "3.1.0"
3
3
 
4
4
  class Version
5
5
  attr_reader :major, :minor, :patch, :prerelease
@@ -149,6 +149,9 @@ module SemanticRange
149
149
  end
150
150
 
151
151
  def self.satisfies?(version, range, loose: false, platform: nil)
152
+ if valid?(range, loose: loose)
153
+ return version == range
154
+ end
152
155
  return false if !valid_range(range, loose: loose, platform: platform)
153
156
  Range.new(range, loose: loose, platform: platform).test(version)
154
157
  end
@@ -221,6 +224,16 @@ module SemanticRange
221
224
  compare(a, b, loose: loose) <= 0
222
225
  end
223
226
 
227
+ def self.valid?(version, loose: false)
228
+ return false unless version.is_a?(String)
229
+
230
+ stripped_version = version.strip
231
+ return false if stripped_version.length > MAX_LENGTH
232
+
233
+ rxp = loose ? LOOSE : FULL
234
+ return rxp.match?(stripped_version)
235
+ end
236
+
224
237
  def self.valid(version, loose: false)
225
238
  v = parse(version, loose: loose)
226
239
  return v ? v.version : nil
@@ -233,17 +246,9 @@ module SemanticRange
233
246
 
234
247
  def self.parse(version, loose: false)
235
248
  return version if version.is_a?(Version)
249
+ return nil unless valid?(version, loose: loose)
236
250
 
237
- return nil unless version.is_a?(String)
238
-
239
- stripped_version = version.strip
240
-
241
- return nil if stripped_version.length > MAX_LENGTH
242
-
243
- rxp = loose ? LOOSE : FULL
244
- return nil if !rxp.match(stripped_version)
245
-
246
- Version.new(stripped_version, loose: loose)
251
+ Version.new(version.strip, loose: loose)
247
252
  end
248
253
 
249
254
  def self.increment!(version, release, identifier, loose: false)
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: 3.0.0
4
+ version: 3.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Nesbitt
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-03-04 00:00:00.000000000 Z
11
+ date: 2024-10-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec
@@ -24,7 +24,7 @@ dependencies:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '3.4'
27
- description:
27
+ description:
28
28
  email:
29
29
  - andrewnez@gmail.com
30
30
  executables: []
@@ -42,7 +42,7 @@ homepage: https://libraries.io/github/librariesio/semantic_range
42
42
  licenses:
43
43
  - MIT
44
44
  metadata: {}
45
- post_install_message:
45
+ post_install_message:
46
46
  rdoc_options: []
47
47
  require_paths:
48
48
  - lib
@@ -57,8 +57,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
57
57
  - !ruby/object:Gem::Version
58
58
  version: '0'
59
59
  requirements: []
60
- rubygems_version: 3.1.2
61
- signing_key:
60
+ rubygems_version: 3.5.16
61
+ signing_key:
62
62
  specification_version: 4
63
63
  summary: node-semver rewritten in ruby, for comparison and inclusion of semantic versions
64
64
  and ranges