semverse 1.2.1 → 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
- SHA1:
3
- metadata.gz: dd2cf18c6c57fd6cafb42a24eb98f8b7bf10ba31
4
- data.tar.gz: c9222204986cb821a09e73ce889369b054a66b5a
2
+ SHA256:
3
+ metadata.gz: '09316f184e3324a8d50f438c3fd43e0c6f0715aa758d8d1a5d38449f2b6b630e'
4
+ data.tar.gz: 07ab4bde856d6aac8b6ab1560f7fb725dfc242d3a08321237e1ea1eb6d384c42
5
5
  SHA512:
6
- metadata.gz: 614d1b76c8616308176bf894ccdc14223b085ddad832b81fcdb082cae91b04f4ba7b6dda0d3654cace0ebf6f0aeb25fed9c2e1b144ef6c165d992d3ec5746610
7
- data.tar.gz: 9dcb6b53997d79124c6aca69dafb60f590657d1d985ffada15e62d64ea5bfe8a95199182f7b5fb409c6b8b12d072c39e4a67de8d14331bf7140a349448816cb8
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 = "1.2.1"
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,43 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: semverse
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.1
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: 2014-08-04 00:00:00.000000000 Z
12
- dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: bundler
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - "~>"
18
- - !ruby/object:Gem::Version
19
- version: '1.5'
20
- type: :development
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - "~>"
25
- - !ruby/object:Gem::Version
26
- version: '1.5'
27
- - !ruby/object:Gem::Dependency
28
- name: rake
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - ">="
32
- - !ruby/object:Gem::Version
33
- version: '0'
34
- type: :development
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - ">="
39
- - !ruby/object:Gem::Version
40
- version: '0'
11
+ date: 2022-05-23 00:00:00.000000000 Z
12
+ dependencies: []
41
13
  description: An elegant library for representing and comparing SemVer versions and
42
14
  constraints
43
15
  email:
@@ -46,26 +18,15 @@ executables: []
46
18
  extensions: []
47
19
  extra_rdoc_files: []
48
20
  files:
49
- - ".gitignore"
50
- - ".travis.yml"
51
- - Gemfile
52
- - Guardfile
53
21
  - LICENSE
54
- - README.md
55
- - Rakefile
56
22
  - lib/semverse.rb
57
23
  - lib/semverse/constraint.rb
58
24
  - lib/semverse/errors.rb
59
25
  - lib/semverse/gem_version.rb
60
26
  - lib/semverse/version.rb
61
- - semverse.gemspec
62
- - spec/spec_helper.rb
63
- - spec/unit/semverse/constraint_spec.rb
64
- - spec/unit/semverse/version_spec.rb
65
- - spec/unit/semverse_spec.rb
66
- homepage: https://github.com/berkshelf/semverse
27
+ homepage: https://github.com/chef/semverse/
67
28
  licenses:
68
- - Apache 2.0
29
+ - Apache-2.0
69
30
  metadata: {}
70
31
  post_install_message:
71
32
  rdoc_options: []
@@ -75,21 +36,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
75
36
  requirements:
76
37
  - - ">="
77
38
  - !ruby/object:Gem::Version
78
- version: 1.9.1
39
+ version: 2.7.0
79
40
  required_rubygems_version: !ruby/object:Gem::Requirement
80
41
  requirements:
81
42
  - - ">="
82
43
  - !ruby/object:Gem::Version
83
44
  version: '0'
84
45
  requirements: []
85
- rubyforge_project:
86
- rubygems_version: 2.2.2
46
+ rubygems_version: 3.1.4
87
47
  signing_key:
88
48
  specification_version: 4
89
49
  summary: An elegant library for representing and comparing SemVer versions and constraints
90
- test_files:
91
- - spec/spec_helper.rb
92
- - spec/unit/semverse/constraint_spec.rb
93
- - spec/unit/semverse/version_spec.rb
94
- - spec/unit/semverse_spec.rb
95
- has_rdoc:
50
+ test_files: []
data/.gitignore DELETED
@@ -1,17 +0,0 @@
1
- *.gem
2
- *.rbc
3
- .bundle
4
- .config
5
- .yardoc
6
- Gemfile.lock
7
- InstalledFiles
8
- _yardoc
9
- coverage
10
- doc/
11
- lib/bundler/man
12
- pkg
13
- rdoc
14
- spec/reports
15
- test/tmp
16
- test/version_tmp
17
- tmp
data/.travis.yml DELETED
@@ -1,8 +0,0 @@
1
- script: "bundle exec rake spec"
2
- language: ruby
3
- bundler_args: --without development
4
- rvm:
5
- - 1.9.3
6
- - 2.0.0
7
- - 2.1.0
8
- - jruby-19mode
data/Gemfile DELETED
@@ -1,29 +0,0 @@
1
- source "https://rubygems.org"
2
-
3
- gemspec
4
-
5
- group :development do
6
- gem "fuubar"
7
- gem "yard"
8
- gem "guard-rspec"
9
- gem "guard-spork"
10
- gem "coolline"
11
-
12
- require "rbconfig"
13
-
14
- if RbConfig::CONFIG["target_os"] =~ /darwin/i
15
- gem "ruby_gntp", require: false
16
-
17
- elsif RbConfig::CONFIG["target_os"] =~ /linux/i
18
- gem "libnotify", require: false
19
-
20
- elsif RbConfig::CONFIG["target_os"] =~ /mswin|mingw/i
21
- gem "win32console", require: false
22
- end
23
- end
24
-
25
- group :test do
26
- gem "spork"
27
- gem "rake"
28
- gem "rspec"
29
- end
data/Guardfile DELETED
@@ -1,11 +0,0 @@
1
- guard 'spork', rspec_port: 8991 do
2
- watch('Gemfile')
3
- watch('spec/spec_helper.rb') { :rspec }
4
- end
5
-
6
- guard 'rspec', cli: "--color --drb --drb-port 8991 --format Fuubar", all_on_start: false, all_after_pass: false, notification: false do
7
- watch(%r{^spec/acceptance/.+_spec\.rb$})
8
- watch(%r{^spec/unit/.+_spec\.rb$})
9
- watch(%r{^lib/(.+)\.rb$}) { |m| "spec/unit/#{m[1]}_spec.rb" }
10
- watch('spec/spec_helper.rb') { "spec" }
11
- end
data/README.md DELETED
@@ -1,34 +0,0 @@
1
- # Semverse
2
- [![Gem Version](http://img.shields.io/gem/v/semverse.svg)][gem]
3
- [![Build Status](http://img.shields.io/travis/berkshelf/semverse.svg)][travis]
4
-
5
- [gem]: https://rubygems.org/gems/semverse
6
- [travis]: http://travis-ci.org/berkshelf/semverse
7
-
8
- An elegant library for representing and comparing SemVer versions and constraints
9
-
10
- ## Installation
11
-
12
- Add this line to your application's Gemfile:
13
-
14
- gem 'semverse'
15
-
16
- And then execute:
17
-
18
- $ bundle
19
-
20
- Or install it yourself as:
21
-
22
- $ gem install semverse
23
-
24
- ## Usage
25
-
26
- TODO: Write usage instructions here
27
-
28
- ## Contributing
29
-
30
- 1. Fork it ( http://github.com/berkshelf/semverse/fork )
31
- 2. Create your feature branch (`git checkout -b my-new-feature`)
32
- 3. Commit your changes (`git commit -am 'Add some feature'`)
33
- 4. Push to the branch (`git push origin my-new-feature`)
34
- 5. Create new Pull Request
data/Rakefile DELETED
@@ -1,6 +0,0 @@
1
- require "bundler/gem_tasks"
2
- require "rspec/core/rake_task"
3
-
4
- RSpec::Core::RakeTask.new(:spec)
5
-
6
- task :default => :spec
data/semverse.gemspec DELETED
@@ -1,24 +0,0 @@
1
- # coding: utf-8
2
- lib = File.expand_path('../lib', __FILE__)
3
- $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require 'semverse/gem_version'
5
-
6
- Gem::Specification.new do |spec|
7
- spec.name = "semverse"
8
- spec.version = Semverse::VERSION
9
- spec.authors = ["Jamie Winsor"]
10
- spec.email = ["jamie@vialstudios.com"]
11
- spec.summary = %q{An elegant library for representing and comparing SemVer versions and constraints}
12
- spec.description = spec.summary
13
- spec.homepage = "https://github.com/berkshelf/semverse"
14
- spec.license = "Apache 2.0"
15
-
16
- spec.files = `git ls-files -z`.split("\x0")
17
- spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
- spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
- spec.require_paths = ["lib"]
20
- spec.required_ruby_version = ">= 1.9.1"
21
-
22
- spec.add_development_dependency "bundler", "~> 1.5"
23
- spec.add_development_dependency "rake"
24
- end
data/spec/spec_helper.rb DELETED
@@ -1,25 +0,0 @@
1
- require 'rubygems'
2
- require 'bundler'
3
- require 'spork'
4
-
5
- Spork.prefork do
6
- require 'rspec'
7
-
8
- APP_ROOT = File.expand_path('../../', __FILE__)
9
-
10
- Dir[File.join(APP_ROOT, "spec/support/**/*.rb")].each {|f| require f}
11
-
12
- RSpec.configure do |config|
13
- config.mock_with :rspec
14
- config.treat_symbols_as_metadata_keys_with_true_values = true
15
- config.filter_run focus: true
16
- config.run_all_when_everything_filtered = true
17
-
18
- # Run specs in a random order
19
- config.order = :random
20
- end
21
- end
22
-
23
- Spork.each_run do
24
- require 'semverse'
25
- end