options_by_example 3.1.0 → 3.2.0

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: f90dee5b19415bddb809efe80e4fc2c6f39daf7b82259a0c247caa789d21ff23
4
- data.tar.gz: b74ece7699aee6f785e9a2fa5149f2a2ee6f2c7f5a4365a429e958d676e9aaf1
3
+ metadata.gz: b5533bd626a90e56af73f7fe32cbd2c0a79630da399242c98abce184ac084dd9
4
+ data.tar.gz: 4583a92414c1e10544ffb42b4e45da0d1c0eac1adc1d38748bd31e24e791337e
5
5
  SHA512:
6
- metadata.gz: c4e235ad68624c57e3efe1915a31c006128351f6c870fa5aefa8f6b2856ec0bab33c24107c1d99b308d9b5fa54cabdff901d3669413e4021c839d7778ecb9cb7
7
- data.tar.gz: a5c7213462bc16e1b88411b92c28c9be5b71cf9838bcad217316586b28318398441e1cc69acf56e223812c7c0fb51dcf381403158a35283f58ea2b0ce6f777bc
6
+ metadata.gz: cd7df1507d066462d1031d71dc054fa886764dddca9fe17b4d6f7310f9e17f75673a6a6709e6ef1636d863dd35a537918d9e6838a04981cd947174d402569480
7
+ data.tar.gz: 9f11d4fdae24faefc1069435683e65c648635568d54d19e3e8197040b721db3630be4aa779781403d26b5c2e04dd23b3b6bcc0e3bef11d405855ac07e89a0630
data/README.md CHANGED
@@ -30,15 +30,15 @@ require 'options_by_example'
30
30
 
31
31
  Options = OptionsByExample.read(DATA).parse(ARGV)
32
32
 
33
- puts Options.include_secure?
34
- puts Options.include_verbose?
35
- puts Options.include_retries?
36
- puts Options.include_timeout?
37
- puts Options.argument_retries
38
- puts Options.argument_timeout
39
- puts Options.argument_mode
40
- puts Options.argument_host
41
- puts Options.argument_port
33
+ puts Options.include? :secure
34
+ puts Options.include? :verbose
35
+ puts Options.include? :retries
36
+ puts Options.include? :timeout
37
+ puts Options.get :retries
38
+ puts Options.get :timeout
39
+ puts Options.get :mode
40
+ puts Options.get :host
41
+ puts Options.get :port
42
42
 
43
43
 
44
44
  __END__
@@ -50,8 +50,8 @@ Usage: connect [options] [mode] host port
50
50
  Options:
51
51
  -s, --secure Establish a secure connection (SSL/TSL)
52
52
  -v, --verbose Enable verbose output for detailed information
53
- -r, --retries NUM Specify the number of connection retries (default 3)
54
- -t, --timeout NUM Set the connection timeout in seconds (default 10)
53
+ -r, --retries NUM Number of connection retries (default 3)
54
+ -t, --timeout NUM Set connection timeout in seconds
55
55
 
56
56
  Arguments:
57
57
  [mode] Optional connection mode (active or passive)
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class OptionsByExample
4
- VERSION = '3.1.0'
4
+ VERSION = '3.2.0'
5
5
  end
6
6
 
7
7
 
@@ -11,6 +11,12 @@ __END__
11
11
  # Minor version bump when backward-compatible changes or enhancements
12
12
  # Patch version bump when backward-compatible bug fixes, security updates etc
13
13
 
14
+ 3.2.0
15
+
16
+ - New method #get returns argument value or nil
17
+ - New method #fetch returns argument value or raises error
18
+ - Changed internal method #parse_without_exit to private
19
+
14
20
  3.1.0
15
21
 
16
22
  - Support dash in argument and option names
@@ -8,6 +8,7 @@ class OptionsByExample
8
8
 
9
9
  attr_reader :arguments
10
10
  attr_reader :options
11
+ attr_reader :usage_message
11
12
 
12
13
  def self.read(data)
13
14
  return new data.read
@@ -61,19 +62,12 @@ class OptionsByExample
61
62
  exit 1
62
63
  end
63
64
 
64
- def parse_without_exit(argv)
65
- parser = Parser.new(
66
- @argument_names_required,
67
- @argument_names_optional,
68
- @default_values,
69
- @option_names,
70
- )
71
-
72
- parser.parse argv
73
- @arguments = parser.arguments
74
- @options = parser.options
65
+ def fetch(*args, &block)
66
+ @arguments.fetch(*args, &block)
67
+ end
75
68
 
76
- return self
69
+ def get(name)
70
+ @arguments[name]
77
71
  end
78
72
 
79
73
  def if_present(name)
@@ -89,6 +83,21 @@ class OptionsByExample
89
83
 
90
84
  private
91
85
 
86
+ def parse_without_exit(argv)
87
+ parser = Parser.new(
88
+ @argument_names_required,
89
+ @argument_names_optional,
90
+ @default_values,
91
+ @option_names,
92
+ )
93
+
94
+ parser.parse argv
95
+ @arguments = parser.arguments
96
+ @options = parser.options
97
+
98
+ return self
99
+ end
100
+
92
101
  def initialize_argument_accessors
93
102
  [
94
103
  *@argument_names_required,
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: options_by_example
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.1.0
4
+ version: 3.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adrian Kuhn
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-05-25 00:00:00.000000000 Z
11
+ date: 2023-06-17 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description:
14
14
  email: