if_test_foo 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/semver_dialects/cli.rb +34 -0
- data/lib/semver_dialects/command.rb +122 -0
- data/lib/semver_dialects/commands/check_version.rb +35 -0
- data/lib/semver_dialects/semantic_version/semantic_version.rb +323 -0
- data/lib/semver_dialects/semantic_version/version_cut.rb +176 -0
- data/lib/semver_dialects/semantic_version/version_interval.rb +286 -0
- data/lib/semver_dialects/semantic_version/version_parser.rb +37 -0
- data/lib/semver_dialects/semantic_version/version_range.rb +191 -0
- data/lib/semver_dialects/semantic_version/version_translator.rb +172 -0
- data/lib/semver_dialects/version.rb +5 -0
- data/lib/semver_dialects.rb +56 -0
- data/lib/utils.rb +41 -0
- metadata +18 -7
- data/lib/foo.rb +0 -5
@@ -0,0 +1,56 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'semver_dialects/version'
|
4
|
+
require 'semver_dialects/semantic_version/version_translator'
|
5
|
+
require 'semver_dialects/semantic_version/version_parser'
|
6
|
+
require 'semver_dialects/semantic_version/version_range'
|
7
|
+
|
8
|
+
module SemverDialects
|
9
|
+
# Captures all errors that could be possibly raised
|
10
|
+
class Error < StandardError
|
11
|
+
def initialize(msg)
|
12
|
+
super(msg)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
# A utiltity module that helps with version matching
|
17
|
+
module VersionChecker
|
18
|
+
def self.version_translate(typ, version_string)
|
19
|
+
case typ
|
20
|
+
when 'maven'
|
21
|
+
VersionTranslator.translate_maven(version_string)
|
22
|
+
when 'npm'
|
23
|
+
VersionTranslator.translate_npm(version_string)
|
24
|
+
when 'conan'
|
25
|
+
VersionTranslator.translate_conan(version_string)
|
26
|
+
when 'nuget'
|
27
|
+
VersionTranslator.translate_nuget(version_string)
|
28
|
+
when 'go'
|
29
|
+
VersionTranslator.translate_go(version_string)
|
30
|
+
when 'gem'
|
31
|
+
VersionTranslator.translate_gem(version_string)
|
32
|
+
when 'pypi'
|
33
|
+
VersionTranslator.translate_pypi(version_string)
|
34
|
+
when 'packagist'
|
35
|
+
VersionTranslator.translate_packagist(version_string)
|
36
|
+
else
|
37
|
+
raise SemverDialects::Error, "unsupported package type '#{typ}'"
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
def self.version_sat?(typ, raw_ver, raw_constraint)
|
42
|
+
version_constraint = version_translate(typ, raw_constraint)
|
43
|
+
raise SemverDialects::Error, 'malformed constraint' if version_constraint.nil? || version_constraint.empty?
|
44
|
+
|
45
|
+
version = VersionParser.parse('=' + raw_ver)
|
46
|
+
raise SemverDialects::Error, 'malformed constraint' if version.nil? || version.empty?
|
47
|
+
|
48
|
+
constraint = VersionRange.new
|
49
|
+
version_constraint.each do |version_interval_str|
|
50
|
+
constraint << VersionParser.parse(version_interval_str)
|
51
|
+
end
|
52
|
+
|
53
|
+
constraint.overlaps_with?(version)
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
data/lib/utils.rb
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# monkey-patch String class
|
4
|
+
class String
|
5
|
+
def unwrap
|
6
|
+
s = self
|
7
|
+
s = s[1..s.length - 1] if s.start_with?('(')
|
8
|
+
s = s[0..s.length - 2] if s.end_with?(')')
|
9
|
+
s
|
10
|
+
end
|
11
|
+
|
12
|
+
def range_present?
|
13
|
+
!empty?
|
14
|
+
end
|
15
|
+
|
16
|
+
def number?
|
17
|
+
true if Integer(self)
|
18
|
+
rescue StandardError
|
19
|
+
false
|
20
|
+
end
|
21
|
+
|
22
|
+
def initial
|
23
|
+
self[0, 1]
|
24
|
+
end
|
25
|
+
|
26
|
+
def unquote
|
27
|
+
delete_suffix('"').delete_prefix('"').delete_suffix('\'').delete_prefix('\'')
|
28
|
+
end
|
29
|
+
|
30
|
+
def csv_unquote
|
31
|
+
unquote.unquote.unquote
|
32
|
+
end
|
33
|
+
|
34
|
+
def remove_trailing_number
|
35
|
+
gsub(/([^\d]*)\d+$/, '\1')
|
36
|
+
end
|
37
|
+
|
38
|
+
def chars_only
|
39
|
+
gsub(/[^0-9A-Za-z]/, '')
|
40
|
+
end
|
41
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: if_test_foo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Igor Frenkel
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-09-
|
11
|
+
date: 2023-09-19 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: test publishing to rubygems
|
14
14
|
email:
|
@@ -17,12 +17,23 @@ executables: []
|
|
17
17
|
extensions: []
|
18
18
|
extra_rdoc_files: []
|
19
19
|
files:
|
20
|
-
- lib/
|
20
|
+
- lib/semver_dialects.rb
|
21
|
+
- lib/semver_dialects/cli.rb
|
22
|
+
- lib/semver_dialects/command.rb
|
23
|
+
- lib/semver_dialects/commands/check_version.rb
|
24
|
+
- lib/semver_dialects/semantic_version/semantic_version.rb
|
25
|
+
- lib/semver_dialects/semantic_version/version_cut.rb
|
26
|
+
- lib/semver_dialects/semantic_version/version_interval.rb
|
27
|
+
- lib/semver_dialects/semantic_version/version_parser.rb
|
28
|
+
- lib/semver_dialects/semantic_version/version_range.rb
|
29
|
+
- lib/semver_dialects/semantic_version/version_translator.rb
|
30
|
+
- lib/semver_dialects/version.rb
|
31
|
+
- lib/utils.rb
|
21
32
|
homepage: https://rubygems.org/gems/if_test_foo
|
22
33
|
licenses:
|
23
34
|
- MIT
|
24
35
|
metadata: {}
|
25
|
-
post_install_message:
|
36
|
+
post_install_message:
|
26
37
|
rdoc_options: []
|
27
38
|
require_paths:
|
28
39
|
- lib
|
@@ -37,8 +48,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
37
48
|
- !ruby/object:Gem::Version
|
38
49
|
version: '0'
|
39
50
|
requirements: []
|
40
|
-
rubygems_version: 3.
|
41
|
-
signing_key:
|
51
|
+
rubygems_version: 3.2.33
|
52
|
+
signing_key:
|
42
53
|
specification_version: 4
|
43
54
|
summary: test publishing
|
44
55
|
test_files: []
|