shellopts 2.0.12 → 2.0.13

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: b2f378c7e7c04297221bfae81065ef06699e93b2dc4fda892b210ef4702c5836
4
- data.tar.gz: f5d83b09b371aebd7cc07e73905edffb2f9f834ba5e382894277310e984e7ecc
3
+ metadata.gz: 8dd7a731b489dbf650e15549d9768469ae9d6c47c6dba3ae79f4d956fea069ab
4
+ data.tar.gz: 4b71aff7ba350d4616a136580857a6acd840141ed0b7463034518dcf4ae4dada
5
5
  SHA512:
6
- metadata.gz: 6255a64a99ceefe0dc0a7a3195976d42b2db6b3a28d779cbeefbc9f36380e46a762939e2062ff9f32f4f78bd5bff8122606b5102d9d8473e86c0a742cd7db479
7
- data.tar.gz: b54f74a5d8fd251d1492667bd8e1340c1f17a3e96936f423efd61e82fe665294936c1edd1ac9ac4ab9df118450ccefafcda117f84ef4e0726d78159196e075cf
6
+ metadata.gz: bb5792606dd91f46b95fe786b509fd079697c87fd603c667e49740b365cafafa0cdc7b49a0a86c72cd014f9c2d88cdf74f096422e6099403042d8c34d35044b3
7
+ data.tar.gz: d7f2637649b474741b70dd9334e25107586fe52eb4e4f9a289453699f334488fed60322a676ad20fcab2f0c993785ccdef89be4397055028e75d79795766b972
@@ -45,12 +45,12 @@ module ShellOpts
45
45
 
46
46
  # These names can't be used as option or command names
47
47
  RESERVED_OPTION_NAMES = %w(
48
- is_a instance_eval instance_exec method_missing singleton_method_added
48
+ is_a to_h instance_eval instance_exec method_missing singleton_method_added
49
49
  singleton_method_removed singleton_method_undefined
50
50
  )
51
51
 
52
- # These methods can be overridden by an option or a command (the value is not used -
53
- # this is just for informational purposes)
52
+ # These methods can be overridden by an option or a command (this constant
53
+ # is not used - it is just for informational purposes)
54
54
  OVERRIDEABLE_METHOD_NAMES = %w(
55
55
  subcommand subcommand! supercommand!
56
56
  )
@@ -96,6 +96,19 @@ module ShellOpts
96
96
  end
97
97
  end
98
98
 
99
+ # Returns a hash of the given options if defined. Returns all options if no
100
+ # options are given
101
+ def to_h(*keys)
102
+ keys = ::Kernel::Array(keys).flatten
103
+ if keys.empty?
104
+ @__option_values__
105
+ else
106
+ keys.map { |key|
107
+ @__option_values__.key?(key) ? [key, @__option_values__[key]] : nil
108
+ }.compact.to_h
109
+ end
110
+ end
111
+
99
112
  # Subcommand identifier or nil if not present. #subcommand is often used in
100
113
  # case statement to branch out to code that handles the given subcommand:
101
114
  #
@@ -1,3 +1,3 @@
1
1
  module ShellOpts
2
- VERSION = "2.0.12"
2
+ VERSION = "2.0.13"
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.12
4
+ version: 2.0.13
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-15 00:00:00.000000000 Z
11
+ date: 2022-04-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: forward_to