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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 52971494b88f77b6b66a95e8409de7cbebcbf030588089c395424b7e86f5e372
4
- data.tar.gz: e00e482a0db690c2b7bd0861589a5179a67d7cec9b285ebcc1d2b5a7b6f73ff7
3
+ metadata.gz: 6e8933ca7084aea3e51858cd679eec2a6b34b2fc7ae9a55ccce131947ccc7375
4
+ data.tar.gz: 125309b75338e9205fb05c5c556fca54cbc1cc77ef890a4ca2d6992c69eff302
5
5
  SHA512:
6
- metadata.gz: 2206c1e56c4239472bf5b697854fc4d7ba06bd9dedfe4eb2f86c2e115f4ddd52f66e9b4f47cbba41b1b4eafb08b8666b2115df7f70d769465dcb3e4a344d322a
7
- data.tar.gz: f9bc90bdba87159a2821afb3c719ba4c4fbc7077601266d9e61c5f83273924bc23e9fa2208bf727855fc99b6acac09a97ec3dc58be179f649c9ed6dbb4fcc259
6
+ metadata.gz: 123b17ded3c4943267612959f3b8ab56a37249e38ea9c338c577ad254ebc1c7c9c305ca9a7a3ee2661d9474e905ddd193c5da8e7a5adc3e711c236349095a636
7
+ data.tar.gz: a3115c875274fccf6628d4c839e3eac36804157f7c56e90b599e8201c1bf8f1070b5b92b7e22cbe2c6615e20b81f4de8b81233227aaccdb873f1016e129d99ae
data/TODO CHANGED
@@ -1,4 +1,5 @@
1
1
 
2
+ o Add brackets to optional option arguments: '--all=FILE?' -> '--all[=FILE]'
2
3
  o Ignore all text after ' # ' (doesn't conflict with option flag)
3
4
  o Command aliases
4
5
  o Add user-defined setions
@@ -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::UserError exception in case of errors
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. The range can't contain negative numbers
18
+ # returned will be in that range. Note that the range can't contain
19
+ # negative numbers
15
20
  #
16
- # #extract raise a ShellOpts::UserError exception if there's is not enough
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 <= 0 ? nil : (r.size == 1 ? r.first : r)
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
- # expect to be emptied by the operation
45
+ # expected to be emptied by the operation
41
46
  #
42
- # #expect raise a ShellOpts::UserError exception if the array is not emptied
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 ArgumentError, message || "Illegal number of arguments"
63
+ raise ShellOpts::Error, message || "Illegal number of arguments"
59
64
  end
60
65
  end
61
66
  end
@@ -1,3 +1,3 @@
1
1
  module ShellOpts
2
- VERSION = "2.0.6"
2
+ VERSION = "2.0.7"
3
3
  end
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.6
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-01 00:00:00.000000000 Z
11
+ date: 2022-03-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: forward_to