versionaire 9.1.1 → 9.2.0

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: 95e35f5d3112af653667a69f1421b1c2ffeb9f0ee37081679e42e40b02613fce
4
- data.tar.gz: 604702a9d233a94faee6d8ecc20f19b7d17e8f1dda2972a6b72b46cda4f44acb
3
+ metadata.gz: d1e1e12933915ebaa8ce2769bac22f1ead28d07902b32bcdb4801f70b724b016
4
+ data.tar.gz: 4c454f8f399df43ebc649010c50d9ee95f321435c96468162ab21b9abd849abb
5
5
  SHA512:
6
- metadata.gz: 64a6327a293b8dd9989f000b1173541e83bb8855886c4da4213f2b7f70973c8d012ec58080c1ae6b675e4aa6033c5eacd6d2e23968a3ad9c66d58a32472aded0
7
- data.tar.gz: 4ef00d34ac1dacff42fa208970bf53b36ba27b0d849a4dcb11d57c98ea756fd7499f3c51c9a0c41316b3451d73b18aa7adc8a0393823a20f96674644f3dc7164
6
+ metadata.gz: facb53e495986112920ca938387be6448eb5bd6e6b94d1a8d5a5e3f3a9c34bbed72da9b6d2f0476b052796d61bedbbb1f27553c536792d2b72a9f81e961d4f70
7
+ data.tar.gz: 32ad27fbdd19b4c6d253009c025b9409ee29766f2eb0c7e158f5d2e231052b8efa661886a534c719cc0baef9b74758698831c81e49c1f7fd93d264ae7e3ffa33
checksums.yaml.gz.sig CHANGED
Binary file
data.tar.gz.sig CHANGED
Binary file
data/README.adoc CHANGED
@@ -257,6 +257,46 @@ version.down :patch, 3 # => "5.5.2"
257
257
  version.down :major, 6 # => Versionaire::Errors::NegativeNumber
258
258
  ----
259
259
 
260
+ === Extensions
261
+
262
+ This project supports libraries which might desire native `Version` types. Each extension _must be
263
+ explicitly required_ in order to be used since they are _optional_ by default. See below for
264
+ details.
265
+
266
+ ==== OptionParser
267
+
268
+ link:https://github.com/ruby/optparse[OptionParser] is one of Ruby's
269
+ link:https://stdgems.org[default gems] which can accept additional types not native to Ruby by
270
+ default. To extend `OptionParser` with the `Version` type, all you need to do is add these two lines
271
+ to your implementation:
272
+
273
+ . `require "versionaire/extensions/option_parser"` - This will load dependencies and register the
274
+ `Version` type with `OptionParser`.
275
+ . `instance.on "--tag VERSION", Versionaire::Version` - Specifying `Versionaire::Version` as the
276
+ second argument will ensure `OptionParser` properly casts command line input as a `Version` type.
277
+
278
+ Here's an example implementation that demonstrates full usage:
279
+
280
+ [source,ruby]
281
+ ----
282
+ require "versionaire/extensions/option_parser"
283
+
284
+ options = {}
285
+
286
+ parser = OptionParser.new do |instance|
287
+ instance.on "--tag VERSION", Versionaire::Version, "Casts to version." do |value|
288
+ options[:version] = value
289
+ end
290
+ end
291
+
292
+ parser.parse! %w[--tag 1.2.3]
293
+ puts options
294
+ ----
295
+
296
+ The above will ensure `--tag 1.2.3` is parsed as `{:version=>#<struct Versionaire::Version major=1,
297
+ minor=2, patch=3>}` within your `options` variable. Should `OptionParser` parse an invalid version,
298
+ you'll get a `OptionParser::InvalidArgument` instead.
299
+
260
300
  == Development
261
301
 
262
302
  To contribute, run:
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "optparse"
4
+ require "versionaire"
5
+
6
+ OptionParser.accept Versionaire::Version do |value|
7
+ Versionaire::Version value
8
+ rescue Versionaire::Errors::Base
9
+ raise OptionParser::InvalidArgument, value
10
+ end
@@ -5,7 +5,7 @@ module Versionaire
5
5
  module Identity
6
6
  NAME = "versionaire"
7
7
  LABEL = "Versionaire"
8
- VERSION = "9.1.1"
8
+ VERSION = "9.2.0"
9
9
  VERSION_LABEL = "#{LABEL} #{VERSION}"
10
10
  end
11
11
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: versionaire
3
3
  version: !ruby/object:Gem::Version
4
- version: 9.1.1
4
+ version: 9.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brooke Kuhlmann
@@ -28,7 +28,7 @@ cert_chain:
28
28
  lkHilIrX69jq8wMPpBhlaw2mRmeSL50Wv5u6xVBvOHhXFSP1crXM95vfLhLyRYod
29
29
  W2A=
30
30
  -----END CERTIFICATE-----
31
- date: 2021-04-18 00:00:00.000000000 Z
31
+ date: 2021-05-02 00:00:00.000000000 Z
32
32
  dependencies:
33
33
  - !ruby/object:Gem::Dependency
34
34
  name: refinements
@@ -61,6 +61,7 @@ files:
61
61
  - lib/versionaire/errors/cast.rb
62
62
  - lib/versionaire/errors/invalid_number.rb
63
63
  - lib/versionaire/errors/negative_number.rb
64
+ - lib/versionaire/extensions/option_parser.rb
64
65
  - lib/versionaire/function.rb
65
66
  - lib/versionaire/identity.rb
66
67
  - lib/versionaire/version.rb
metadata.gz.sig CHANGED
Binary file