tins 1.20.0 → 1.20.1

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: 6ef6d2f0b36fcd36a9e2d04a93734e2344f34b3e7fbb7cf338e5d96c4a956b2f
4
- data.tar.gz: 336a0db38796155a2561e55ac4c631730c179f1246045b1161cdd5a32e197c6a
3
+ metadata.gz: b45beecb1aa668a60dbba0fd3de82977bfba124e7c61cb197436677efe5c289a
4
+ data.tar.gz: 1a68ac6e0e0f8d90b5006a0dd0e2f366df2cbf771e1ac515590120399bfb693f
5
5
  SHA512:
6
- metadata.gz: 53f6a410165371cb96139274549b0dff25f33c538aca7e71adf62e36b2c7bd94bef7c4f321de7321faea9eb220deceac8479a0a1c02fe96a438c92691d22f215
7
- data.tar.gz: 67c04f5f1c9804b574ef4af508cf2ae814da283a9bed1714413274d4ca91b8fe10f798672ec58813362f50bb13c3c4cf8aab9ad2726fae66def4a6048f33f8cf
6
+ metadata.gz: eae6d13e3a93317e9210df3cfcb23da8bb3853bc50aaa85ee776047d078f3bfa3526e6b82618907238217d2ed6102e02e55af0b2220cae400dc8352c87695ac2
7
+ data.tar.gz: 763fb5a20cc33b498a0e3ec62f09884804bf23b2c1d43a75585d934861f98d82f552a975bd68a9c10f1b4af57c5ed7b8d499dad8b6abdab287f4b5e27ba0db73
data/README.md CHANGED
@@ -13,6 +13,8 @@ Non yet.
13
13
  ## Changes
14
14
 
15
15
 
16
+ * 2018-11-14 Release 1.20.1
17
+ - Add disabling boolean options in Tins::GO#go method.
16
18
  * 2018-11-14 Release 1.20.0
17
19
  - Support default arguments in Tins::GO#go method.
18
20
  * 2018-11-07 Release 1.19.0
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.20.0
1
+ 1.20.1
@@ -20,7 +20,8 @@ module Tins
20
20
  # Parses the argument array _args_, according to the pattern _s_, to
21
21
  # retrieve the single character command line options from it. If _s_ is
22
22
  # 'xy:' an option '-x' without an option argument is searched, and an
23
- # option '-y foo' with an option argument ('foo').
23
+ # option '-y foo' with an option argument ('foo'). To disable the '-x'
24
+ # option, pass '~x'.
24
25
  #
25
26
  # The _defaults_ argument specifies default values for the options.
26
27
  #
@@ -29,7 +30,7 @@ module Tins
29
30
  def go(s, args = ARGV, defaults: {})
30
31
  d = defaults || {}
31
32
  b, v = s.scan(/(.)(:?)/).inject([ {}, {} ]) { |t, (o, a)|
32
- a = a == ':'
33
+ a = a == ?:
33
34
  t[a ? 1 : 0][o] = a ? nil : false
34
35
  t
35
36
  }
@@ -85,6 +86,7 @@ module Tins
85
86
  end
86
87
  end && break
87
88
  end
89
+ r.reject! { |a| /\A~(?<p>.)/ =~ a and (b[p] = false) or true }
88
90
  args.replace r
89
91
  b.merge(v)
90
92
  end
@@ -1,6 +1,6 @@
1
1
  module Tins
2
2
  # Tins version
3
- VERSION = '1.20.0'
3
+ VERSION = '1.20.1'
4
4
  VERSION_ARRAY = VERSION.split('.').map(&:to_i) # :nodoc:
5
5
  VERSION_MAJOR = VERSION_ARRAY[0] # :nodoc:
6
6
  VERSION_MINOR = VERSION_ARRAY[1] # :nodoc:
@@ -63,6 +63,9 @@ module Tins
63
63
  r = go('bv:', args = %w[ -v bar ], defaults: { ?b => true, ?v => 'foo' })
64
64
  assert_equal({ ?b => 1, 'v' => 'bar' }, r)
65
65
  assert_equal [], args
66
+ r = go('bv:', args = %w[ ~b -v bar ], defaults: { ?b => true, ?v => 'foo' })
67
+ assert_equal({ ?b => false, 'v' => 'bar' }, r)
68
+ assert_equal [], args
66
69
  r = go('bv:', args = %w[ -b -v bar ], defaults: { ?b => 22, ?v => 'foo' })
67
70
  assert_equal({ ?b => 23, 'v' => 'bar' }, r)
68
71
  assert_equal [], args
@@ -1,9 +1,9 @@
1
1
  # -*- encoding: utf-8 -*-
2
- # stub: tins 1.20.0 ruby lib
2
+ # stub: tins 1.20.1 ruby lib
3
3
 
4
4
  Gem::Specification.new do |s|
5
5
  s.name = "tins".freeze
6
- s.version = "1.20.0"
6
+ s.version = "1.20.1"
7
7
 
8
8
  s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
9
9
  s.require_paths = ["lib".freeze]
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tins
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.20.0
4
+ version: 1.20.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Florian Frank