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 +4 -4
- data/README.md +2 -0
- data/VERSION +1 -1
- data/lib/tins/go.rb +4 -2
- data/lib/tins/version.rb +1 -1
- data/tests/go_test.rb +3 -0
- data/tins.gemspec +2 -2
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b45beecb1aa668a60dbba0fd3de82977bfba124e7c61cb197436677efe5c289a
|
4
|
+
data.tar.gz: 1a68ac6e0e0f8d90b5006a0dd0e2f366df2cbf771e1ac515590120399bfb693f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: eae6d13e3a93317e9210df3cfcb23da8bb3853bc50aaa85ee776047d078f3bfa3526e6b82618907238217d2ed6102e02e55af0b2220cae400dc8352c87695ac2
|
7
|
+
data.tar.gz: 763fb5a20cc33b498a0e3ec62f09884804bf23b2c1d43a75585d934861f98d82f552a975bd68a9c10f1b4af57c5ed7b8d499dad8b6abdab287f4b5e27ba0db73
|
data/README.md
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.20.
|
1
|
+
1.20.1
|
data/lib/tins/go.rb
CHANGED
@@ -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
|
data/lib/tins/version.rb
CHANGED
data/tests/go_test.rb
CHANGED
@@ -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
|
data/tins.gemspec
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
|
-
# stub: tins 1.20.
|
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.
|
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]
|