semver_check 0.1.2 → 0.1.4

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: a788698d2408013afa250c7bb1b15d6db802abecb51d4809c4a71952c90da500
4
- data.tar.gz: a46a370c61e3470815ceeb7ddefc1f8049c17b83feaec5829fdd4aa6fb3e2cd8
3
+ metadata.gz: c0beaf52c8261fbe56e672991ce08cfe4fb7ec93da4cdb6f18f729e3d9ccd9bb
4
+ data.tar.gz: ecec76c30f606258d7c5544587409b46bb89b4743fd3e94cb0787205062c43a6
5
5
  SHA512:
6
- metadata.gz: 4cfb9ba6a08f638cf26338ed6e1e499d655d155d278c51b13edba1a6eb4c2520cf2aff422e67f5220676dd650c5da4a6de71320cbb39b38ffc4a845c6d5fe561
7
- data.tar.gz: c48338806955d42f6ed67d32bebb5a924aa567d9fbb82682a176e66350341e6982c9c12f844f1aaa327836e35ecc6021c43b65062ad2ff664af5fc2740e0db4c
6
+ metadata.gz: d353ba6864a640cb0b2de68bcc85374709b210488455ac903022557df8b746e1d23d38b51cea78ca62bcf3205a5f52906c308914f4f7364c7bdd00bfe3d012f0
7
+ data.tar.gz: b305f2fac503a4d9273a928a73cb1f39804ed654012de7223ff6e5ec3a9a34ad75f76770235439b62e3da3095c660a01e739c65c020980762d509928322e0975
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [0.1.1] - [0.1.4] - 2022-12-26
4
+
5
+ - Small performance improvements
6
+
3
7
  ## [0.1.0] - 2022-12-25
4
8
 
5
9
  - Initial release
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # SemverCheck
2
2
 
3
- TODO: Delete this and the text above, and describe your gem
3
+ A simple gem containing one class `SemverCheck::Compare` to compare SemVer strings.
4
4
 
5
5
  ## Installation
6
6
 
@@ -14,7 +14,19 @@ If bundler is not being used to manage dependencies, install the gem by executin
14
14
 
15
15
  ## Usage
16
16
 
17
- TODO: Write usage instructions here
17
+ The Compare class includes the Comparable module, so all methods from there and in addition != are available.
18
+
19
+ ```ruby
20
+ SemverCheck::Compare.new("1.2.3") < SemverCheck::Compare.new("1.2.4") # true
21
+ SemverCheck::Compare.new("1.2.3") > SemverCheck::Compare.new("1.2.2") # true
22
+ SemverCheck::Compare.new("1.2.3") <= SemverCheck::Compare.new("1.2.3") # true
23
+ SemverCheck::Compare.new("1.2.3") >= SemverCheck::Compare.new("1.2.3") # true
24
+ # works also with prerelease
25
+ SemverCheck::Compare.new("1.2.3-alpha") < SemverCheck::Compare.new("1.2.3-beta") # true
26
+ SemverCheck::Compare.new("1.2.3-alpha.2") > SemverCheck::Compare.new("1.2.3-alpha.1") # true
27
+ ```
28
+
29
+ You get the idea. If you wanna know more check out the [test/test_compare.rb](https://github.com/the-pulli/semver_check/blob/main/test/test_compare.rb) file.
18
30
 
19
31
  ## Development
20
32
 
@@ -24,7 +36,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
24
36
 
25
37
  ## Contributing
26
38
 
27
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/semver_check.
39
+ Bug reports and pull requests are welcome on GitHub at https://github.com/the-pulli/semver_check.
28
40
 
29
41
  ## License
30
42
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module SemverCheck
4
- VERSION = "0.1.2"
4
+ VERSION = "0.1.4"
5
5
  end
data/lib/semver_check.rb CHANGED
@@ -23,16 +23,16 @@ module SemverCheck
23
23
  \Z/x
24
24
 
25
25
  MAPPING_TABLE = [
26
- %w[n 1],
27
- %w[sn 1],
28
- %w[ssn 1],
29
- %w[o -1],
30
- %w[so -1],
31
- %w[sso -1],
32
- %w[sss 0]
26
+ ["n", 1],
27
+ ["sn", 1],
28
+ ["ssn", 1],
29
+ ["o", -1],
30
+ ["so", -1],
31
+ ["sso", -1],
32
+ ["sss", 0]
33
33
  ].freeze
34
34
 
35
- ORDER = %i[major minor patch prerelease].freeze
35
+ VERSION_PARTS = %i[major minor patch].freeze
36
36
 
37
37
  attr_reader :version
38
38
 
@@ -57,7 +57,7 @@ module SemverCheck
57
57
  private
58
58
 
59
59
  def comparison(other)
60
- comparison = ORDER.take(3).map do |part|
60
+ comparison = VERSION_PARTS.map do |part|
61
61
  if @version[part] == other.version[part]
62
62
  "s"
63
63
  elsif @version[part] > other.version[part]
@@ -106,7 +106,7 @@ module SemverCheck
106
106
  def match(comparison)
107
107
  MAPPING_TABLE.find do |m|
108
108
  comparison.start_with?(m.first)
109
- end.last.to_i
109
+ end.last
110
110
  end
111
111
 
112
112
  def prepare_version(version)
@@ -115,7 +115,7 @@ module SemverCheck
115
115
 
116
116
  version = version.named_captures.transform_keys(&:to_sym)
117
117
  # convert major, minor and patch to int
118
- ORDER.first(3).each { |part| version[part] = version[part].to_i }
118
+ VERSION_PARTS.each { |part| version[part] = version[part].to_i }
119
119
  version
120
120
  end
121
121
  end
@@ -0,0 +1,39 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "lib/semver_check/version"
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "semver_check"
7
+ spec.version = SemverCheck::VERSION
8
+ spec.authors = ["PuLLi"]
9
+ spec.email = ["the@pulli.dev"]
10
+
11
+ spec.summary = "Little gem to compare two SemVer strings."
12
+ spec.description = "Fun project to compare two SemVer strings with a bit of regex magic."
13
+ spec.homepage = "https://github.com/the-pulli/semver_check"
14
+ spec.license = "MIT"
15
+ spec.required_ruby_version = ">= 2.6.0"
16
+
17
+ spec.metadata["allowed_push_host"] = "https://rubygems.org"
18
+
19
+ spec.metadata["homepage_uri"] = spec.homepage
20
+ spec.metadata["source_code_uri"] = "https://github.com/the-pulli/semver_check"
21
+ spec.metadata["changelog_uri"] = "https://github.com/the-pulli/semver_check/blob/main/CHANGELOG.md"
22
+
23
+ # Specify which files should be added to the gem when it is released.
24
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
25
+ spec.files = Dir.chdir(__dir__) do
26
+ `git ls-files -z`.split("\x0").reject do |f|
27
+ (f == __FILE__) || f.match(%r{\A(?:(?:bin|test|spec|features)/|\.(?:git|travis|circleci)|appveyor)})
28
+ end
29
+ end
30
+ spec.bindir = "exe"
31
+ spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
32
+ spec.require_paths = ["lib"]
33
+
34
+ # Uncomment to register a new dependency of your gem
35
+ # spec.add_dependency "example-gem", "~> 1.0"
36
+
37
+ # For more information and examples about making a new gem, check out our
38
+ # guide at: https://bundler.io/guides/creating_gem.html
39
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: semver_check
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - PuLLi
@@ -24,6 +24,7 @@ files:
24
24
  - Rakefile
25
25
  - lib/semver_check.rb
26
26
  - lib/semver_check/version.rb
27
+ - semver_check.gemspec
27
28
  - sig/semver_check.rbs
28
29
  homepage: https://github.com/the-pulli/semver_check
29
30
  licenses:
@@ -32,7 +33,7 @@ metadata:
32
33
  allowed_push_host: https://rubygems.org
33
34
  homepage_uri: https://github.com/the-pulli/semver_check
34
35
  source_code_uri: https://github.com/the-pulli/semver_check
35
- changelog_uri: https://github.com/the-pulli/semver_check/CHANGELOG.md
36
+ changelog_uri: https://github.com/the-pulli/semver_check/blob/main/CHANGELOG.md
36
37
  post_install_message:
37
38
  rdoc_options: []
38
39
  require_paths: