semverse 3.0.0 → 3.0.2

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: a37f02dda073771ca1a404b4bf2742bb9aefa8b076bd5eef500032f30aa61a65
4
- data.tar.gz: a69871553baf90560aa8ca47c785e5f3f9c5269a925ec6f135e0789f9d47ebbb
3
+ metadata.gz: '09316f184e3324a8d50f438c3fd43e0c6f0715aa758d8d1a5d38449f2b6b630e'
4
+ data.tar.gz: 07ab4bde856d6aac8b6ab1560f7fb725dfc242d3a08321237e1ea1eb6d384c42
5
5
  SHA512:
6
- metadata.gz: 7d9c900303c6a18dc6d7e20b01d183ef1d7bff9c8f92b9e6ad5f009f93ec72b8ef6fcfa75e10f849dc91c72e0d195f31b5814a7d24b42ec713fda212f5a7b62b
7
- data.tar.gz: ab3c2512b621de9a29c25cd553f12c7409aa625a83a79a13e1a6120d7f4ffbc016e1d0ba16220406ae53b773aeb10f3d35d22763e2e701846d47959d4356f4dd
6
+ metadata.gz: a4f38485a85c633ffac447f373eae2bfb9ebe4288ccca68c7fc881213d8f0fe30ad98a7170c16815017845ad59d229d08e8420fefb330885b14559a2957d95f9
7
+ data.tar.gz: c1c37b15aa3027da06fb3e56bb122b9f27f4688d54f9ca5a02da7df25e1508742d70648747d9b54facca4e75bbc0cfa6614eb30707d20d226eb2e947191439e1
@@ -3,7 +3,7 @@ module Semverse
3
3
  class << self
4
4
  # Coerce the object into a constraint.
5
5
  #
6
- # @param [Constraint, String]
6
+ # @param [Constraint, String] object
7
7
  #
8
8
  # @return [Constraint]
9
9
  def coerce(object)
@@ -97,18 +97,18 @@ module Semverse
97
97
  def compare_approx(constraint, target_version)
98
98
  min = constraint.version
99
99
  max = if constraint.patch.nil?
100
- Version.new([min.major + 1, 0, 0, 0])
101
- elsif constraint.build
102
- identifiers = constraint.version.identifiers(:build)
103
- replace = identifiers.last.to_i.to_s == identifiers.last.to_s ? "-" : nil
104
- Version.new([min.major, min.minor, min.patch, min.pre_release, identifiers.fill(replace, -1).join('.')])
105
- elsif constraint.pre_release
106
- identifiers = constraint.version.identifiers(:pre_release)
107
- replace = identifiers.last.to_i.to_s == identifiers.last.to_s ? "-" : nil
108
- Version.new([min.major, min.minor, min.patch, identifiers.fill(replace, -1).join('.')])
109
- else
110
- Version.new([min.major, min.minor + 1, 0, 0])
111
- end
100
+ Version.new([min.major + 1, 0, 0, 0])
101
+ elsif constraint.build
102
+ identifiers = constraint.version.identifiers(:build)
103
+ replace = identifiers.last.to_i.to_s == identifiers.last.to_s ? "-" : nil
104
+ Version.new([min.major, min.minor, min.patch, min.pre_release, identifiers.fill(replace, -1).join(".")])
105
+ elsif constraint.pre_release
106
+ identifiers = constraint.version.identifiers(:pre_release)
107
+ replace = identifiers.last.to_i.to_s == identifiers.last.to_s ? "-" : nil
108
+ Version.new([min.major, min.minor, min.patch, identifiers.fill(replace, -1).join(".")])
109
+ else
110
+ Version.new([min.major, min.minor + 1, 0, 0])
111
+ end
112
112
  min <= target_version && target_version < max
113
113
  end
114
114
  end
@@ -116,7 +116,7 @@ module Semverse
116
116
  # The default constraint string.
117
117
  #
118
118
  # @return [String]
119
- DEFAULT_OPERATOR = '='.freeze
119
+ DEFAULT_OPERATOR = "=".freeze
120
120
 
121
121
  # The complete list of possible operators, paired with a proc to be used for
122
122
  # evaluation.
@@ -126,14 +126,14 @@ module Semverse
126
126
  #
127
127
  # @return [Hash<String, Proc>]
128
128
  OPERATORS = { #:nodoc:
129
- '=' => ->(c, v) { v == c.version },
130
- '!=' => ->(c, v) { v != c.version },
131
- '>' => ->(c, v) { v > c.version },
132
- '<' => ->(c, v) { v < c.version },
133
- '>=' => ->(c, v) { v >= c.version },
134
- '<=' => ->(c, v) { v <= c.version },
135
- '~' => method(:compare_approx),
136
- '~>' => method(:compare_approx),
129
+ "=" => ->(c, v) { v == c.version },
130
+ "!=" => ->(c, v) { v != c.version },
131
+ ">" => ->(c, v) { v > c.version },
132
+ "<" => ->(c, v) { v < c.version },
133
+ ">=" => ->(c, v) { v >= c.version },
134
+ "<=" => ->(c, v) { v <= c.version },
135
+ "~" => method(:compare_approx),
136
+ "~>" => method(:compare_approx),
137
137
  }.freeze
138
138
 
139
139
  # This is a magical regular expression that matches the Semantic versioning
@@ -165,24 +165,24 @@ module Semverse
165
165
  attr_reader :version
166
166
 
167
167
  # @param [#to_s] constraint
168
- def initialize(constraint = '>= 0.0.0')
168
+ def initialize(constraint = ">= 0.0.0")
169
169
  constraint = constraint.to_s
170
170
  if constraint.nil? || constraint.empty?
171
171
  constraint = ">= 0.0.0"
172
172
  end
173
173
  @operator, @major, @minor, @patch, @pre_release, @build = self.class.split(constraint)
174
174
 
175
- unless ['~>', '~'].include?(@operator)
175
+ unless ["~>", "~"].include?(@operator)
176
176
  @minor ||= 0
177
177
  @patch ||= 0
178
178
  end
179
179
 
180
180
  @version = Version.new([
181
- self.major,
182
- self.minor,
183
- self.patch,
184
- self.pre_release,
185
- self.build,
181
+ major,
182
+ minor,
183
+ patch,
184
+ pre_release,
185
+ build,
186
186
  ])
187
187
  end
188
188
 
@@ -195,7 +195,7 @@ module Semverse
195
195
  def satisfies?(target)
196
196
  target = Version.coerce(target)
197
197
 
198
- if !version.zero? && greedy_match?(target)
198
+ if !version.zero? && greedy_match?(target) # rubocop:disable Style/NumericPredicate
199
199
  return false
200
200
  end
201
201
 
@@ -211,8 +211,8 @@ module Semverse
211
211
  # @return [Boolean]
212
212
  def ==(other)
213
213
  other.is_a?(self.class) &&
214
- self.operator == other.operator &&
215
- self.version == other.version
214
+ operator == other.operator &&
215
+ version == other.version
216
216
  end
217
217
  alias_method :eql?, :==
218
218
 
@@ -220,7 +220,7 @@ module Semverse
220
220
  #
221
221
  # @return [String]
222
222
  def inspect
223
- "#<#{self.class.to_s} #{to_s}>"
223
+ "#<#{self.class} #{self}>"
224
224
  end
225
225
 
226
226
  # The string representation of this constraint.
@@ -243,10 +243,10 @@ module Semverse
243
243
  #
244
244
  # @param [Semverse::Version] target_version
245
245
  #
246
- def greedy_match?(target_version)
247
- !['<', '<='].include?(self.operator) &&
246
+ def greedy_match?(target_version)
247
+ !["<", "<="].include?(operator) &&
248
248
  target_version.pre_release? &&
249
249
  !version.pre_release?
250
- end
250
+ end
251
251
  end
252
252
  end
@@ -1,3 +1,4 @@
1
1
  module Semverse
2
- VERSION = "3.0.0"
2
+ VERSION = "3.0.2".freeze
3
3
  end
4
+
@@ -3,7 +3,7 @@ module Semverse
3
3
  class << self
4
4
  # Coerce the object into a version.
5
5
  #
6
- # @param [Version, String]
6
+ # @param [Version, String] object
7
7
  #
8
8
  # @return [Version]
9
9
  def coerce(object)
@@ -75,12 +75,13 @@ module Semverse
75
75
  #
76
76
  # @return [Integer]
77
77
  def <=>(other)
78
- [:major, :minor, :patch].each do |release|
79
- ans = self.send(release) <=> other.send(release)
78
+ %i{major minor patch}.each do |release|
79
+ ans = send(release) <=> other.send(release)
80
80
  return ans if ans != 0
81
81
  end
82
82
  ans = pre_release_and_build_presence_score <=> other.pre_release_and_build_presence_score
83
83
  return ans if ans != 0
84
+
84
85
  ans = identifiers_comparaison(other, :pre_release)
85
86
  return ans if ans != 0
86
87
  if build && other.build
@@ -88,12 +89,11 @@ module Semverse
88
89
  else
89
90
  return build.to_s <=> other.build.to_s
90
91
  end
91
- 0
92
92
  end
93
93
 
94
94
  # @return [Array]
95
95
  def identifiers(release)
96
- send(release).to_s.split('.').map do |str|
96
+ send(release).to_s.split(".").map do |str|
97
97
  str.to_i.to_s == str ? str.to_i : str
98
98
  end
99
99
  end
@@ -108,7 +108,11 @@ module Semverse
108
108
 
109
109
  # @return [Integer]
110
110
  def pre_release_and_build_presence_score
111
- pre_release ? 0 : (build.nil? ? 1 : 2)
111
+ if pre_release
112
+ 0
113
+ else
114
+ build.nil? ? 1 : 2
115
+ end
112
116
  end
113
117
 
114
118
  # @param [Semverse::Version] other
@@ -136,7 +140,7 @@ module Semverse
136
140
  end
137
141
 
138
142
  def inspect
139
- "#<#{self.class.to_s} #{to_s}>"
143
+ "#<#{self.class} #{self}>"
140
144
  end
141
145
 
142
146
  def to_s
data/lib/semverse.rb CHANGED
@@ -1,8 +1,8 @@
1
1
  module Semverse
2
- require_relative 'semverse/errors'
3
- require_relative 'semverse/gem_version'
4
- require_relative 'semverse/version'
5
- require_relative 'semverse/constraint'
2
+ require_relative "semverse/errors"
3
+ require_relative "semverse/gem_version"
4
+ require_relative "semverse/version"
5
+ require_relative "semverse/constraint"
6
6
 
7
- DEFAULT_CONSTRAINT = Semverse::Constraint.new('>= 0.0.0').freeze
7
+ DEFAULT_CONSTRAINT = Semverse::Constraint.new(">= 0.0.0").freeze
8
8
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: semverse
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.0
4
+ version: 3.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jamie Winsor
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-12-10 00:00:00.000000000 Z
11
+ date: 2022-05-23 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: An elegant library for representing and comparing SemVer versions and
14
14
  constraints
@@ -24,7 +24,7 @@ files:
24
24
  - lib/semverse/errors.rb
25
25
  - lib/semverse/gem_version.rb
26
26
  - lib/semverse/version.rb
27
- homepage: https://github.com/berkshelf/semverse/
27
+ homepage: https://github.com/chef/semverse/
28
28
  licenses:
29
29
  - Apache-2.0
30
30
  metadata: {}
@@ -36,15 +36,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
36
36
  requirements:
37
37
  - - ">="
38
38
  - !ruby/object:Gem::Version
39
- version: 2.2.0
39
+ version: 2.7.0
40
40
  required_rubygems_version: !ruby/object:Gem::Requirement
41
41
  requirements:
42
42
  - - ">="
43
43
  - !ruby/object:Gem::Version
44
44
  version: '0'
45
45
  requirements: []
46
- rubyforge_project:
47
- rubygems_version: 2.7.7
46
+ rubygems_version: 3.1.4
48
47
  signing_key:
49
48
  specification_version: 4
50
49
  summary: An elegant library for representing and comparing SemVer versions and constraints