semver_check 0.1.2 → 0.1.3

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: bdc39dd369f29e6ebe018a881038e1a0f0255be4238717016588ebfc68a92e5e
4
+ data.tar.gz: 549fc59387e661c8e2c0b7c7454fd12ca3f6993f142884b5773a14addbf4f832
5
5
  SHA512:
6
- metadata.gz: 4cfb9ba6a08f638cf26338ed6e1e499d655d155d278c51b13edba1a6eb4c2520cf2aff422e67f5220676dd650c5da4a6de71320cbb39b38ffc4a845c6d5fe561
7
- data.tar.gz: c48338806955d42f6ed67d32bebb5a924aa567d9fbb82682a176e66350341e6982c9c12f844f1aaa327836e35ecc6021c43b65062ad2ff664af5fc2740e0db4c
6
+ metadata.gz: 14e21f9954a5555fe8e233029e30008ca5f489db65c2cd0ff7c59dcd89c0a2e8c8d5a19c09a8f94cd26110f2338c5ceebafcc27bd05749aa5ff56bfe4fa90ce5
7
+ data.tar.gz: 17db55a207756a196f7a6b8a2f0ebabffb6c3d7c8415366909a8a8afe2cdd1e5a95cb9617a43a723ee57e8373f4d06c46741a3fbb585e44b6958fc8d56557e1b
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` 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.3"
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
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.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - PuLLi