semver_dialects 1.5.0 → 1.5.1

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: 28ee5ec66f887446314abeffcac8cff51161d7b2040eb06139efc5bbf48b2cc3
4
- data.tar.gz: c8328e39e774b98b3e4b0b1eb5c2da35952fbdcf98a1ae76d0f8b4d01749c358
3
+ metadata.gz: c1cb3a87022079c747bcd293b3cd933d77895a57d588d8f8ce2c810c64c6887d
4
+ data.tar.gz: effb283d7ac372fe8d5f4ca591502587093e46351f14865d2aba2bec9c76bc19
5
5
  SHA512:
6
- metadata.gz: 17d70269cfc9c4174cd7e9807b8dc79834e9864c5e09ea5d655c006edb9319ef9c3e234e340b4368be7dc4671c254b4e1bfae2874c55420add7f023f7e0e719d
7
- data.tar.gz: df0798ecfef4d791201da8348df7262d610346a94f56da96f6624b305b1221c27cef175ed97a96462a6dba50fa703610335ab68f4685c43114f1fff3b7620be1
6
+ metadata.gz: 93c31bfb3463782eaf8a2a18c1f37f47a6b5e8963fc4f1be7079a82171182562f6055546a54b6415120d13fec5810b1892be269bfc98ef90efc56bbc17bdd768
7
+ data.tar.gz: 235385f7356dbc06085b370de6998606771aedcfff40b88ec79578bf1e1ef931cf568d1ab66abb49350075960b129c6a5515d7bb3970d6f4715b3db23dee0fcf
@@ -2,19 +2,22 @@ require_relative "version_cut"
2
2
  require_relative "version_interval"
3
3
 
4
4
  module VersionParser
5
- def self.parse(versionstring)
6
- if (versionstring == "=*")
7
- # special case = All Versions
8
- return VersionInterval.new(IntervalType::LEFT_OPEN | IntervalType::RIGHT_OPEN, BelowAll.new(), AboveAll.new())
9
- end
5
+ VERSION_SPECIFIER_REGEX = /(?<op>[><=]+) *(?<version>[a-zA-Z0-9\-_\.\*]+)/
6
+
7
+ def self.parse(version_constraint)
8
+ return self.all_versions if version_constraint == "=*"
9
+
10
+ interval = self.all_versions
11
+
12
+ version_constraint.split(" ").each do |version_specifier|
13
+ matches = VERSION_SPECIFIER_REGEX.match(version_specifier)
14
+
15
+ if matches.nil? || matches.size == 0
16
+ raise SemverDialects::Error, "could not parse version specifier \"#{version_specifier}\" from version constraint \"#{version_constraint}\""
17
+ end
10
18
 
11
- version_items = versionstring.split(" ")
12
- interval = VersionInterval.new(IntervalType::LEFT_OPEN | IntervalType::RIGHT_OPEN, BelowAll.new(), AboveAll.new())
13
- version_items.each do
14
- |version_item|
15
- matches = version_item.match /(?<op>[><=]+) *(?<version>[a-zA-Z0-9\-_\.\*]+)/
16
- version_string = matches[:version]
17
- case matches[:op]
19
+ op, version_string = matches[:op], matches[:version]
20
+ case op
18
21
  when ">="
19
22
  new_interval = VersionInterval.new(IntervalType::LEFT_CLOSED | IntervalType::RIGHT_OPEN, VersionCut.new(version_string), AboveAll.new())
20
23
  interval = interval.intersect(new_interval)
@@ -32,6 +35,13 @@ module VersionParser
32
35
  interval = interval.intersect(new_interval)
33
36
  end
34
37
  end
38
+
35
39
  interval
36
40
  end
41
+
42
+ private
43
+
44
+ def self.all_versions
45
+ VersionInterval.new(IntervalType::LEFT_OPEN | IntervalType::RIGHT_OPEN, BelowAll.new(), AboveAll.new())
46
+ end
37
47
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module SemverDialects
4
- VERSION = '1.5.0'
4
+ VERSION = '1.5.1'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: semver_dialects
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.0
4
+ version: 1.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Julian Thome
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: exe
12
12
  cert_chain: []
13
- date: 2023-11-06 00:00:00.000000000 Z
13
+ date: 2024-01-11 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: pastel