optimist 3.1.0 → 3.2.1

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.
@@ -1,7 +1,7 @@
1
- require 'test_helper'
1
+ require_relative '../test_helper'
2
2
 
3
3
  module Optimist
4
- class VersionNeededTest < ::MiniTest::Test
4
+ class VersionNeededTest < ::Minitest::Test
5
5
  def test_class
6
6
  assert_kind_of Exception, vn("message")
7
7
  end
@@ -1,6 +1,6 @@
1
- require 'test_helper'
1
+ require_relative 'test_helper'
2
2
 
3
- class OptimistTest < MiniTest::Test
3
+ class OptimistTest < Minitest::Test
4
4
  def setup
5
5
  Optimist.send(:instance_variable_set, "@last_parser", nil)
6
6
  end
@@ -39,7 +39,8 @@ class OptimistTest < MiniTest::Test
39
39
  end
40
40
 
41
41
  def test_die_without_options_ever_run
42
- assert_raises(ArgumentError) { Optimist.die 'hello' }
42
+ err_regex = /Optimist::die can only be called after Optimist::options/
43
+ assert_raises_errmatch(ArgumentError, err_regex) { Optimist.die 'hello' }
43
44
  end
44
45
 
45
46
  def test_die
@@ -70,7 +71,8 @@ class OptimistTest < MiniTest::Test
70
71
  end
71
72
 
72
73
  def test_educate_without_options_ever_run
73
- assert_raises(ArgumentError) { Optimist.educate }
74
+ err_regex = /Optimist::educate can only be called after Optimist::options/
75
+ assert_raises_errmatch(ArgumentError, err_regex) { Optimist.educate }
74
76
  end
75
77
 
76
78
  def test_educate
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Minitest::Assertions
2
4
  def assert_parses_correctly(parser, commandline, expected_opts,
3
5
  expected_leftovers)
@@ -9,7 +11,7 @@ module Minitest::Assertions
9
11
  def assert_stderr(str = nil, msg = nil)
10
12
  msg = "#{msg}.\n" if msg
11
13
 
12
- old_stderr, $stderr = $stderr, StringIO.new('')
14
+ old_stderr, $stderr = $stderr, StringIO.new
13
15
  yield
14
16
  assert_match str, $stderr.string, msg if str
15
17
  ensure
@@ -19,7 +21,7 @@ module Minitest::Assertions
19
21
  def assert_stdout(str = nil, msg = nil)
20
22
  msg = "#{msg}.\n" if msg
21
23
 
22
- old_stdout, $stdout = $stdout, StringIO.new('')
24
+ old_stdout, $stdout = $stdout, StringIO.new
23
25
  yield
24
26
  assert_match str, $stdout.string, msg if str
25
27
  ensure
@@ -42,5 +44,10 @@ module Minitest::Assertions
42
44
  end
43
45
  flunk "#{msg}#{mu_pp(exp)} SystemExit expected but nothing was raised."
44
46
  end
45
- end
46
47
 
48
+ # wrapper around common assertion checking pattern
49
+ def assert_raises_errmatch(err_klass, err_regexp, &b)
50
+ err = assert_raises(err_klass, &b)
51
+ assert_match(err_regexp, err.message)
52
+ end
53
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: optimist
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.1.0
4
+ version: 3.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - William Morgan
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2023-07-24 00:00:00.000000000 Z
13
+ date: 2025-03-19 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: chronic
@@ -32,28 +32,28 @@ dependencies:
32
32
  requirements:
33
33
  - - ">="
34
34
  - !ruby/object:Gem::Version
35
- version: '0'
35
+ version: 1.5.3
36
36
  type: :development
37
37
  prerelease: false
38
38
  version_requirements: !ruby/object:Gem::Requirement
39
39
  requirements:
40
40
  - - ">="
41
41
  - !ruby/object:Gem::Version
42
- version: '0'
42
+ version: 1.5.3
43
43
  - !ruby/object:Gem::Dependency
44
44
  name: minitest
45
45
  requirement: !ruby/object:Gem::Requirement
46
46
  requirements:
47
47
  - - "~>"
48
48
  - !ruby/object:Gem::Version
49
- version: 5.4.3
49
+ version: '5.25'
50
50
  type: :development
51
51
  prerelease: false
52
52
  version_requirements: !ruby/object:Gem::Requirement
53
53
  requirements:
54
54
  - - "~>"
55
55
  - !ruby/object:Gem::Version
56
- version: 5.4.3
56
+ version: '5.25'
57
57
  - !ruby/object:Gem::Dependency
58
58
  name: rake
59
59
  requirement: !ruby/object:Gem::Requirement
@@ -89,17 +89,32 @@ files:
89
89
  - CHANGELOG.md
90
90
  - FAQ.txt
91
91
  - Gemfile
92
- - History.txt
93
92
  - LICENSE.txt
94
93
  - README.md
95
94
  - Rakefile
95
+ - examples/a_basic_example.rb
96
+ - examples/alt_names.rb
97
+ - examples/banners1.rb
98
+ - examples/banners2.rb
99
+ - examples/banners3.rb
100
+ - examples/boolean.rb
101
+ - examples/constraints.rb
102
+ - examples/didyoumean.rb
103
+ - examples/medium_example.rb
104
+ - examples/partialmatch.rb
105
+ - examples/permitted.rb
106
+ - examples/types_custom.rb
96
107
  - lib/optimist.rb
97
108
  - optimist.gemspec
109
+ - renovate.json
110
+ - test/optimist/alt_names_test.rb
98
111
  - test/optimist/command_line_error_test.rb
99
112
  - test/optimist/help_needed_test.rb
113
+ - test/optimist/parser_constraint_test.rb
100
114
  - test/optimist/parser_educate_test.rb
101
115
  - test/optimist/parser_opt_test.rb
102
116
  - test/optimist/parser_parse_test.rb
117
+ - test/optimist/parser_permitted_test.rb
103
118
  - test/optimist/parser_test.rb
104
119
  - test/optimist/version_needed_test.rb
105
120
  - test/optimist_test.rb
@@ -109,7 +124,7 @@ homepage: http://manageiq.github.io/optimist/
109
124
  licenses:
110
125
  - MIT
111
126
  metadata:
112
- changelog_uri: https://github.com/ManageIQ/optimist/blob/master/History.txt
127
+ changelog_uri: https://github.com/ManageIQ/optimist/blob/master/CHANGELOG.md
113
128
  source_code_uri: https://github.com/ManageIQ/optimist/
114
129
  bug_tracker_uri: https://github.com/ManageIQ/optimist/issues
115
130
  post_install_message:
@@ -127,17 +142,20 @@ required_rubygems_version: !ruby/object:Gem::Requirement
127
142
  - !ruby/object:Gem::Version
128
143
  version: '0'
129
144
  requirements: []
130
- rubygems_version: 3.2.33
145
+ rubygems_version: 3.5.22
131
146
  signing_key:
132
147
  specification_version: 4
133
148
  summary: Optimist is a commandline option parser for Ruby that just gets out of your
134
149
  way.
135
150
  test_files:
151
+ - test/optimist/alt_names_test.rb
136
152
  - test/optimist/command_line_error_test.rb
137
153
  - test/optimist/help_needed_test.rb
154
+ - test/optimist/parser_constraint_test.rb
138
155
  - test/optimist/parser_educate_test.rb
139
156
  - test/optimist/parser_opt_test.rb
140
157
  - test/optimist/parser_parse_test.rb
158
+ - test/optimist/parser_permitted_test.rb
141
159
  - test/optimist/parser_test.rb
142
160
  - test/optimist/version_needed_test.rb
143
161
  - test/optimist_test.rb
data/History.txt DELETED
@@ -1,175 +0,0 @@
1
- == [3.0.1] / 2020-04-20
2
-
3
- * Add a LICENSE.txt file to the released package
4
- * Test fixes (thanks @aried3r, @neontapir, @npras)
5
-
6
- == [3.0.0] / 2018-08-24
7
-
8
- * The gem has been officially renamed to optimist
9
-
10
- == [2.1.3] / 2018-07-05
11
-
12
- * Refactor each option type into subclasses of Option. Define a registry for the registration of each option. This makes the code more modular and facilitates extension by allowing additional Option subclasses. (thanks @clxy)
13
- * Fixed implementation of ignore_invalid_options. (thanks @metcalf)
14
- * Various warning cleanup for ruby 2.1, 2.3, etc. (thanks @nanobowers)
15
- * Optimist.die can now accept an error code.
16
- * fixed default (thanks @nanobowers)
17
- * Change from ruby license to MIT license in the code.
18
-
19
- == [2.1.2] / 2015-03-10
20
- * loosen mime-types requirements (for better ruby 1.8.7 support)
21
- * use io/console gem instead of curses (for better jruby support)
22
- * fix parsing bug when chronic gem is not available
23
- * allow default array to be empty if a type is specified
24
- * better specified license and better spec coverage
25
-
26
- == [2.1.1] / 2015-01-03
27
- * Remove curses as a hard dependency. It is optional. This can leverage the gem if it is present.
28
- * Fix ruby -w warnings
29
-
30
- == 2.1.0 / 2015-01-02
31
- * Integer parser now supports underscore separator.
32
- * Add Parser#usage and Parser#synopsis commands for creating a standard banner
33
- message. Using Parser#banner directly will override both of those.
34
- * Add Parser#ignore_invalid_options to prevent erroring on unknown options.
35
- * Allow flags to act as switches if they have defaults set and no value is
36
- passed on the commandline
37
- * Parser#opt learned to accept a block or a :callback option which it will call
38
- after parsing the option.
39
- * Add Optimist::educate which displays the help message and dies.
40
- * Reformat help message to be more GNUish.
41
- * Fix command name in help message when script has no extension.
42
- * Fix handling of newlines inside descriptions
43
- * Documentation and other fixes.
44
-
45
- == 2.0 / 2012-08-11
46
- * Change flag logic: --no-X will always be false, and --X will always be true,
47
- regardless of default.
48
- * For flags that default to true, display --no-X instead of --X in the help
49
- menu. Accept both versions on the commandline.
50
- * Fix a spurious warning
51
- * Update Rakefile to 1.9
52
- * Minor documentation fixes
53
-
54
- == 1.16.2 / 2010-04-06
55
- * Bugfix in Optimist::options. Thanks to Brian C. Thomas for pointing it out.
56
-
57
- == 1.16.1 / 2010-04-05
58
- * Bugfix in Optimist::die method introduced in last release.
59
-
60
- == 1.16 / 2010-04-01
61
- * Add Optimist::with_standard_exception_handling method for easing the use of Parser directly.
62
- * Handle scientific notation in float arguments, thanks to Will Fitzgerald.
63
- * Drop hoe dependency.
64
-
65
- == 1.15 / 2009-09-30
66
- * Don't raise an exception when out of short arguments (thanks to Rafael
67
- Sevilla for pointing out how dumb this behavior was).
68
-
69
- == 1.14 / 2009-06-19
70
- * Make :multi arguments default to [], not nil, when not set on the commandline.
71
- * Minor commenting and error message improvements
72
-
73
- == 1.13 / 2009-03-16
74
- * Fix parsing of "--longarg=<value with spaces>".
75
-
76
- == 1.12 / 2009-01-30
77
- * Fix some unit test failures in the last release. Should be more careful.
78
- * Make default short options only be assigned *after* all user-specified
79
- short options. Now there's a little less juggling to do when you just
80
- want to specify a few short options.
81
-
82
- == 1.11 / 2009-01-29
83
- * Set <opt>_given keys in the results hash for options that were specified
84
- on the commandline.
85
-
86
- == 1.10.2 / 2008-10-23
87
- * No longer try `stty size` for screen size detection. Just use curses, and
88
- screen users will have to deal with the screen clearing.
89
-
90
- == 1.10.1 / 2008-10-22
91
- * Options hash now responds to method calls as well as standard hash lookup.
92
- * Default values for multi-occurrence parameters now autoboxed.
93
- * The relationship between multi-value, multi-occurrence, and default values
94
- improved and explained.
95
- * Documentation improvements.
96
-
97
- == 1.10 / 2008-10-21
98
- * Added :io type for parameters that point to IO streams (filenames, URIs, etc).
99
- * For screen size detection, first try `stty size` before loading Curses.
100
- * Improved documentation.
101
-
102
- == 1.9 / 2008-08-20
103
- * Added 'stop_on_unknown' command to stop parsing on any unknown argument.
104
- This is useful for handling sub-commands when you don't know the entire
105
- set of commands up front. (E.g. if the initial arguments can change it.)
106
- * Added a :multi option for parameters, signifying that they can be specified
107
- multiple times.
108
- * Added :ints, :strings, :doubles, and :floats option types, which can take
109
- multiple arguments.
110
-
111
- == 1.8.2 / 2008-06-25
112
- * Bugfix for #conflicts and #depends error messages
113
-
114
- == 1.8.1 / 2008-06-24
115
- * Bugfix for short option autocreation
116
- * More aggressive documentation
117
-
118
- == 1.8 / 2008-06-16
119
- * Sub-command support via Parser#stop_on
120
-
121
- == 1.7.2 / 2008-01-16
122
- * Ruby 1.9-ify. Apparently this means replacing :'s with ;'s.
123
-
124
- == 1.7.1 / 2008-01-07
125
- * Documentation improvements
126
-
127
- == 1.7 / 2007-06-17
128
- * Fix incorrect error message for multiple missing required arguments
129
- (thanks to Neill Zero)
130
-
131
- == 1.6 / 2007-04-01
132
- * Don't attempt curses screen-width magic unless running on a terminal.
133
-
134
- == 1.5 / 2007-03-31
135
- * --help and --version do the right thing even if the rest of the
136
- command line is incorrect.
137
- * Added #conflicts and #depends to model dependencies and exclusivity
138
- between arguments.
139
- * Minor bugfixes.
140
-
141
- == 1.4 / 2007-03-26
142
- * Disable short options with :short => :none.
143
- * Minor bugfixes and error message improvements.
144
-
145
- == 1.3 / 2007-01-31
146
- * Wrap at (screen width - 1) instead of screen width.
147
- * User can override --help and --version.
148
- * Bugfix in handling of -v and -h.
149
- * More tests to confirm the above.
150
-
151
- == 1.2 / 2007-01-31
152
- * Minor documentation tweaks.
153
- * Removed hoe dependency.
154
-
155
- == 1.1 / 2007-01-30
156
- * Optimist::options now passes any arguments as block arguments. Since
157
- instance variables are not properly captured by the block, this
158
- makes it slightly less noisy to pass them in as local variables.
159
- (A real-life use for _why's cloaker!)
160
- * Help display now preserves original argument order.
161
- * Optimist::die now also has a single string form in case death is not
162
- due to a single argument.
163
- * Parser#text now an alias for Parser#banner, and can be called
164
- multiple times, with the output being placed in the right position
165
- in the help text.
166
- * Slightly more indicative formatting for parameterized arguments.
167
-
168
- == 1.0 / 2007-01-29
169
- * Initial release.
170
-
171
- [3.0.1]: https://github.com/ManageIQ/optimist/compare/v3.0.0...v3.0.1
172
- [3.0.0]: https://github.com/ManageIQ/optimist/compare/v2.1.3...v3.0.0
173
- [2.1.3]: https://github.com/ManageIQ/optimist/compare/v2.1.2...v2.1.3
174
- [2.1.2]: https://github.com/ManageIQ/optimist/compare/v2.1.1...v2.1.2
175
- [2.1.1]: https://github.com/ManageIQ/optimist/compare/v2.1.0...v2.1.1