shellopts 2.0.6 → 2.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/TODO +1 -0
- data/lib/shellopts/args.rb +12 -7
- data/lib/shellopts/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6e8933ca7084aea3e51858cd679eec2a6b34b2fc7ae9a55ccce131947ccc7375
|
4
|
+
data.tar.gz: 125309b75338e9205fb05c5c556fca54cbc1cc77ef890a4ca2d6992c69eff302
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 123b17ded3c4943267612959f3b8ab56a37249e38ea9c338c577ad254ebc1c7c9c305ca9a7a3ee2661d9474e905ddd193c5da8e7a5adc3e711c236349095a636
|
7
|
+
data.tar.gz: a3115c875274fccf6628d4c839e3eac36804157f7c56e90b599e8201c1bf8f1070b5b92b7e22cbe2c6615e20b81f4de8b81233227aaccdb873f1016e129d99ae
|
data/TODO
CHANGED
data/lib/shellopts/args.rb
CHANGED
@@ -2,18 +2,23 @@
|
|
2
2
|
module ShellOpts
|
3
3
|
# Specialization of Array for arguments lists. Args extends Array with a
|
4
4
|
# #extract and an #expect method to extract elements from the array. The
|
5
|
-
# methods raise a ShellOpts::
|
5
|
+
# methods raise a ShellOpts::Error exception in case of errors
|
6
6
|
#
|
7
7
|
class Args < Array
|
8
|
+
# :call-seq:
|
9
|
+
# extract(count, message = nil)
|
10
|
+
# extract(range, message = nil)
|
11
|
+
#
|
8
12
|
# Remove and return elements from beginning of the array
|
9
13
|
#
|
10
14
|
# If +count_or_range+ is a number, that number of elements will be
|
11
15
|
# returned. If the count is one, a simple value is returned instead of an
|
12
16
|
# array. If the count is negative, the elements will be removed from the
|
13
17
|
# end of the array. If +count_or_range+ is a range, the number of elements
|
14
|
-
# returned will be in that range.
|
18
|
+
# returned will be in that range. Note that the range can't contain
|
19
|
+
# negative numbers
|
15
20
|
#
|
16
|
-
# #extract raise a ShellOpts::
|
21
|
+
# #extract raise a ShellOpts::Error exception if there's is not enough
|
17
22
|
# elements in the array to satisfy the request
|
18
23
|
#
|
19
24
|
def extract(count_or_range, message = nil)
|
@@ -30,16 +35,16 @@ module ShellOpts
|
|
30
35
|
count.abs <= self.size or inoa(message)
|
31
36
|
start = count >= 0 ? 0 : size + count
|
32
37
|
r = slice!(start, count.abs)
|
33
|
-
r.size
|
38
|
+
r.size == 1 ? r.first : r
|
34
39
|
else
|
35
40
|
raise ArgumentError
|
36
41
|
end
|
37
42
|
end
|
38
43
|
|
39
44
|
# As #extract except it doesn't allow negative counts and that the array is
|
40
|
-
#
|
45
|
+
# expected to be emptied by the operation
|
41
46
|
#
|
42
|
-
# #expect raise a ShellOpts::
|
47
|
+
# #expect raise a ShellOpts::Error exception if the array is not emptied
|
43
48
|
# by the operation
|
44
49
|
#
|
45
50
|
def expect(count_or_range, message = nil)
|
@@ -55,7 +60,7 @@ module ShellOpts
|
|
55
60
|
|
56
61
|
private
|
57
62
|
def inoa(message = nil)
|
58
|
-
raise
|
63
|
+
raise ShellOpts::Error, message || "Illegal number of arguments"
|
59
64
|
end
|
60
65
|
end
|
61
66
|
end
|
data/lib/shellopts/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: shellopts
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Claus Rasmussen
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-03-
|
11
|
+
date: 2022-03-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: forward_to
|