rake-commander 0.3.6 → 0.4.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 81af760fc8b135dae5ced0487cb346032eb088df3596bef256e2fe0d97f6c09e
4
- data.tar.gz: af9ed108e3436eae5c705b43070066c2e208d816ef0b7f5dc497cf4f46e6f15a
3
+ metadata.gz: fced681b17be5244fd8cf23294e246e060d7d52daba92a11f84e396d3f0c2ec4
4
+ data.tar.gz: b7937192c15dab0e9acf907ee4d7dacc505de9724967b96064881a30be2c5f6e
5
5
  SHA512:
6
- metadata.gz: 42d7b3bdc73a577f5c149323a119e36c5dfa43ae0796548fe9f5f5acf9cc833f73f805c15dc14ddb132d6f932222b8f57258de81adec4320a46629f6c585e977
7
- data.tar.gz: 0bcb309f5284ca49bb3af8493313b78fd9f86c75facc1ba3d8aaf419560bfff6d488dc15b7d4420668bcb745463f79c5812a1f5f467e2c9f777840a3d1fdcd77
6
+ metadata.gz: 2c36cf00c0dc4afa116e548e7e643b39a7f64f38f64990c9b8f7c11b2dca340979de9f0b6a9d53c532fa041898182dcc4a1c634ba2eedf874515c4257091a999
7
+ data.tar.gz: cecf9b603645401cf14e38d4745be6d6619f505adf3cbf1f2f482f4901d220e45539b434bcf75d99d61e6bb460c22594d7eb52e3da15312ebcd85fd4c46d94fd
@@ -0,0 +1,4 @@
1
+ {
2
+ "MD013": false,
3
+ "MD024": false
4
+ }
data/.rubocop.yml CHANGED
@@ -1,80 +1,93 @@
1
1
  AllCops:
2
- TargetRubyVersion: 2.7.2
3
- Exclude:
4
- - 'config/routes.rb'
2
+ TargetRubyVersion: 3.2.2
3
+ NewCops: enable
5
4
 
6
- Naming/VariableNumber:
7
- EnforcedStyle: snake_case
8
- Naming/FileName:
9
- Enabled: false
10
-
11
- Metrics/LineLength:
12
- Enabled: false
13
- Metrics/BlockLength:
14
- ExcludedMethods: [context, describe]
15
- Max: 50
16
- Metrics/MethodLength:
17
- Max: 50
18
5
  Metrics/ClassLength:
19
- Max: 200
6
+ Max: 500
20
7
  Metrics/ModuleLength:
21
- Max: 200
8
+ Max: 300
9
+ Metrics/MethodLength:
10
+ Max: 50
22
11
  Metrics/AbcSize:
12
+ Max: 30
13
+ Metrics/ParameterLists:
14
+ Max: 5
15
+ CountKeywordArgs: false
16
+ Metrics/BlockLength:
17
+ CountAsOne: ['array', 'heredoc', 'method_call']
23
18
  Max: 50
24
19
  Metrics/CyclomaticComplexity:
25
- Max: 10
20
+ Max: 30
26
21
  Metrics/PerceivedComplexity:
27
- Max: 10
22
+ Max: 30
28
23
 
29
- ParameterLists:
30
- Max: 5
31
- CountKeywordArgs: false
32
-
33
- Style/Alias:
34
- EnforcedStyle: prefer_alias_method
35
- Style/StringLiterals:
24
+ Style/AccessorGrouping:
36
25
  Enabled: false
37
- Style/FrozenStringLiteralComment:
26
+ Style/ConditionalAssignment:
38
27
  Enabled: false
39
- Style/CommentedKeyword:
28
+ Style/BlockDelimiters:
29
+ BracesRequiredMethods: ['log']
30
+ AllowedPatterns: ['proc', 'new']
31
+ Style/ClassAndModuleChildren:
40
32
  Enabled: false
41
- Style/MultilineBlockChain:
33
+ Style/FrozenStringLiteralComment:
42
34
  Enabled: false
43
- Style/Documentation:
35
+ Style/StringLiterals:
44
36
  Enabled: false
45
37
  Style/StringLiteralsInInterpolation:
46
38
  Enabled: false
47
- Style/AndOr:
39
+ Style/Documentation:
48
40
  Enabled: false
49
- Style/SlicingWithRange:
41
+ Style/CommentedKeyword:
50
42
  Enabled: false
51
- Style/ClassAndModuleChildren:
43
+ Style/MultilineBlockChain:
52
44
  Enabled: false
53
- Style/OptionalBooleanParameter:
45
+ Style/AndOr:
46
+ Enabled: false
47
+ Style/Alias:
48
+ EnforcedStyle: prefer_alias_method
49
+ Style/FetchEnvVar:
54
50
  Enabled: false
51
+ Style/RegexpLiteral:
52
+ EnforcedStyle: mixed
53
+ AllowInnerSlashes: true
55
54
 
56
55
  Layout/HashAlignment:
57
56
  EnforcedColonStyle: table
57
+ EnforcedHashRocketStyle: table
58
+ Layout/LeadingCommentSpace:
59
+ Enabled: false
60
+ AllowGemfileRubyComment: true
61
+ Layout/ParameterAlignment:
62
+ Enabled: false
63
+ Layout/MultilineMethodDefinitionBraceLayout:
64
+ EnforcedStyle: symmetrical
65
+ Layout/LineLength:
66
+ Enabled: true
67
+ Layout/SpaceInsideHashLiteralBraces:
68
+ Enabled: false
69
+ Layout/SpaceInsideBlockBraces:
70
+ Enabled: false
71
+ Layout/SpaceAroundOperators:
72
+ Enabled: false
58
73
  Layout/ExtraSpacing:
59
74
  AllowForAlignment: true
75
+ AllowBeforeTrailingComments: true
60
76
  Layout/AccessModifierIndentation:
61
77
  EnforcedStyle: indent
62
78
  Layout/DotPosition:
63
79
  EnforcedStyle: trailing
64
80
  Layout/MultilineMethodCallIndentation:
65
81
  EnforcedStyle: indented
66
- Layout/SpaceInsideHashLiteralBraces:
67
- Enabled: false
68
- Layout/SpaceInsideBlockBraces:
69
- Enabled: false
70
- Layout/SpaceAroundOperators:
71
- Enabled: false
72
82
  Layout/FirstHashElementIndentation:
73
83
  Enabled: false
74
84
  Layout/EmptyLineAfterGuardClause:
75
85
  Enabled: false
76
- Layout/LeadingCommentSpace:
77
- Enabled: false
78
86
 
79
- Lint/AssignmentInCondition:
87
+ Naming/VariableNumber:
88
+ EnforcedStyle: snake_case
89
+ CheckSymbols: false
90
+ Naming/MethodParameterName:
91
+ AllowedNames: ['x', 'y', 'i', 'j', 'id', 'io', 'to']
92
+ Naming/RescuedExceptionsVariableName:
80
93
  Enabled: false
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 3.2.2
data/CHANGELOG.md CHANGED
@@ -1,175 +1,209 @@
1
1
  # Change Log
2
+
2
3
  All notable changes to this project will be documented in this file.
3
4
 
4
5
  ## TO DO
5
- - Think if [`binstubs`](https://github.com/rbenv/rbenv/wiki/Understanding-binstubs) would offer a neater patch right on `Rake::Application#init`
6
- - `option_reopen` -> upsert should be optional (add `upsert: false` as default an raise missing option if not found)
7
- - The error on missing short pops up where it's not clear the short was missed in the option_reopen call.
8
- - Option results
9
- - Include the symbol name keys (configurable). Note that dash will be replaced by underscore.
10
- - Type Coercions
11
- - Add a way to define/redefine a set and use them.
12
- - Add more supported type_coercions as native to the gem (i.e. `Symbol`)
13
- - Add support [for `ActiveRecord::Enum`](https://apidock.com/rails/ActiveRecord/Enum)
14
- - Option definitions
15
- - Order: `where: [:tail, :top]` and `[after, before]: :option_name`
16
- - Configuration: allow to define option override behaviour and whether it should trigger an exception
17
- - Error handlers
18
- - See if it would be possible to parse all the valid options so we get all the valid results before some error is raised. Although this can be achieved with `OptionParser#order!`, it destroys switches; which would require to give it two parsing shots whenever there is an error.
19
- - It should be ensured that the parsed options results object is remains the same.
20
- - Think about options that modify other options. Technically this should be hold only at behaviour level
21
- - This would allow to make the order of the options irrelevant when it comes to modify error handling behaviour via options themselves.
22
- - Rake task parameters (see: https://stackoverflow.com/a/825832/4352306 & https://stackoverflow.com/a/825832/4352306)
23
- - Add `enhance` functionality (when a task is invoked it runs before it; declared with `task` as well)
24
- - Add `no_short` option (which should give the result of that option with the option name key)
25
- - Add `on_option` handler at instance level, so within a `task` definition, we can decide certain things, such as if the functionality should be active when the `self.class` does not have that option.
26
- * This is specially useful to be able to extend through inheritance chain, where we extend `task` (rather than redefining it), but we don't want options we removed (with `option_remove`) to throw unexpected results.
27
- * Example: `on_option(:t, defined: true) {|option| do-stuff}` <- block to be called only if the option is defined in the class (alternative: `defined: :only`)
28
- * Example: `on_option(:t, defined: false) {|option| do-stuff}` <- block to be called regardless the option exists (alternative: `defined: :ignore`)
29
- * Example: `on_options(:t, :s, present: true) {|options| do-stuff}` <- block to be called only when the option `:t` and `:s` are both present in the parsed `options` result.
30
- - Once this has been done, think about it being a hash-alike object with methods for the option names (i.e. `options.debug?`)
31
-
32
-
33
- ## [0.3.7] - 2023-05-xx
6
+
7
+ - Think if [`binstubs`](https://github.com/rbenv/rbenv/wiki/Understanding-binstubs) would offer a neater patch right on `Rake::Application#init`
8
+ - `option_reopen` -> upsert should be optional (add `upsert: false` as default an raise missing option if not found)
9
+ - The error on missing short pops up where it's not clear the short was missed in the option_reopen call.
10
+ - Option results
11
+ - Include the symbol name keys (configurable). Note that dash will be replaced by underscore.
12
+ - Type Coercions
13
+ - Add a way to define/redefine a set and use them.
14
+ - Add more supported type_coercions as native to the gem (i.e. `Symbol`)
15
+ - Add support [for `ActiveRecord::Enum`](https://apidock.com/rails/ActiveRecord/Enum)
16
+ - Option definitions
17
+ - Order: `where: [:tail, :top]` and `[after, before]: :option_name`
18
+ - Configuration: allow to define option override behaviour and whether it should trigger an exception
19
+ - Error handlers
20
+ - See if it would be possible to parse all the valid options so we get all the valid results before some error is raised. Although this can be achieved with `OptionParser#order!`, it destroys switches; which would require to give it two parsing shots whenever there is an error.
21
+ - It should be ensured that the parsed options results object is remains the same.
22
+ - Think about options that modify other options. Technically this should be hold only at behaviour level
23
+ - This would allow to make the order of the options irrelevant when it comes to modify error handling behaviour via options themselves.
24
+ - Rake task parameters (see: <https://stackoverflow.com/a/825832/4352306> & <https://stackoverflow.com/a/825832/4352306>)
25
+ - Add `enhance` functionality (when a task is invoked it runs before it; declared with `task` as well)
26
+ - Add `no_short` option (which should give the result of that option with the option name key)
27
+ - Add `on_option` handler at instance level, so within a `task` definition, we can decide certain things, such as if the functionality should be active when the `self.class` does not have that option.
28
+ - This is specially useful to be able to extend through inheritance chain, where we extend `task` (rather than redefining it), but we don't want options we removed (with `option_remove`) to throw unexpected results.
29
+ - Example: `on_option(:t, defined: true) {|option| do-stuff}` <- block to be called only if the option is defined in the class (alternative: `defined: :only`)
30
+ - Example: `on_option(:t, defined: false) {|option| do-stuff}` <- block to be called regardless the option exists (alternative: `defined: :ignore`)
31
+ - Example: `on_options(:t, :s, present: true) {|options| do-stuff}` <- block to be called only when the option `:t` and `:s` are both present in the parsed `options` result.
32
+ - Once this has been done, think about it being a hash-alike object with methods for the option names (i.e. `options.debug?`)
33
+
34
+ ## [0.4.1] - 2025-02-xx
34
35
 
35
36
  ### Added
37
+
38
+ - Predefined values cohertion (i.e. `Enum`)
39
+
36
40
  ### Fixed
41
+
42
+ - Description: break lines should be respected.
43
+
37
44
  ### Changed
38
45
 
46
+ - Allow multiple `desc` declarations to be aligned with `OptsParser` behaviour.
47
+
48
+ ## [0.4.0] - 2023-08-01
49
+
50
+ ### Changed
51
+
52
+ - require `ruby 3`
53
+
39
54
  ## [0.3.6] - 2023-05-15
40
55
 
41
56
  ### Fixed
42
- - `RakeCommander::Options` inheritance of options in `options_hash` was NOT doing a `dup`
57
+
58
+ - `RakeCommander::Options` inheritance of options in `options_hash` was NOT doing a `dup`
43
59
 
44
60
  ### Changed
45
- - `RakeCommander::Options#options_hash` made public method
61
+
62
+ - `RakeCommander::Options#options_hash` made public method
46
63
 
47
64
  ## [0.3.5] - 2023-05-08
48
65
 
49
66
  ### Fixed
50
- - `RakeCommander::Options#option_reopen` using name to reopen should not redefine if passed as Symbol.
67
+
68
+ - `RakeCommander::Options#option_reopen` using name to reopen should not redefine if passed as Symbol.
51
69
 
52
70
  ## [0.3.4] - 2023-05-08
53
71
 
54
72
  ### Fixed
55
- - `RakeCommand::Option#name` boolean form (`[no-]`) should not be part of the name.
73
+
74
+ - `RakeCommand::Option#name` boolean form (`[no-]`) should not be part of the name.
56
75
 
57
76
  ### Changed
58
- - Slight refactor to the patch
77
+
78
+ - Slight refactor to the patch
59
79
 
60
80
  ## [0.3.3] - 2023-05-01
61
81
 
62
82
  ### Changed
63
- - Replaced the patching method, so the `Rake` application doesn't need re-launch.
83
+
84
+ - Replaced the patching method, so the `Rake` application doesn't need re-launch.
64
85
 
65
86
  ## [0.2.12] - 2023-05-01
66
87
 
67
88
  ### Fixed
68
- - `RakeCommander::Option#type_coercion` wasn't correctly captured.
69
89
 
90
+ - `RakeCommander::Option#type_coercion` wasn't correctly captured.
70
91
 
71
92
  ## [0.2.11] - 2023-05-01
72
93
 
73
94
  ### Fixed
74
- - When `RakeCommander::Option#type_coercion` is `FalseClass`, it should reverse the result.
95
+
96
+ - When `RakeCommander::Option#type_coercion` is `FalseClass`, it should reverse the result.
75
97
 
76
98
  ## [0.2.10] - 2023-05-01
77
99
 
78
100
  ### Fixed
79
- - `RakeCommander::Options` clean `options_hash` inheritance.
80
101
 
102
+ - `RakeCommander::Options` clean `options_hash` inheritance.
81
103
 
82
104
  ## [0.2.7] - 2023-05-01
83
105
 
84
106
  ### Fixed
85
- - `RakeCommander::Option#desc` when fetching from other, should not fetch array but single value.
107
+
108
+ - `RakeCommander::Option#desc` when fetching from other, should not fetch array but single value.
86
109
 
87
110
  ## [0.2.6] - 2023-05-01
88
111
 
89
112
  ### Changed
90
- - `RakeCommander::Option` configure_other should only apply when the instance vars are not defined.
113
+
114
+ - `RakeCommander::Option` configure_other should only apply when the instance vars are not defined.
91
115
 
92
116
  ## [0.2.5] - 2023-05-01
93
117
 
94
118
  ### Changed
95
- - `RakeCommander::Base::ClassInheritable#inherited_class_value` now expects a reference to the subclass
119
+
120
+ - `RakeCommander::Base::ClassInheritable#inherited_class_value` now expects a reference to the subclass
96
121
 
97
122
  ## [0.2.4] - 2023-04-30
98
123
 
99
124
  ### Added
100
- - `RakeCommander::Options`
101
- - `::option_get` retrieves an option by name or short, may it exist.
102
- - `::option?` to check if an opion exists.
125
+
126
+ - `RakeCommander::Options`
127
+ - `::option_get` retrieves an option by name or short, may it exist.
128
+ - `::option?` to check if an opion exists.
103
129
 
104
130
  ## [0.2.3] - 2023-04-29
105
131
 
106
132
  ### Added
107
- - Include Symbol option names in the parsed option results.
133
+
134
+ - Include Symbol option names in the parsed option results.
108
135
 
109
136
  ## [0.2.2] - 2023-04-29
110
137
 
111
138
  ### Fixed
112
- - Typo in `RakeCommander::Base::ClassAutoLoader`
139
+
140
+ - Typo in `RakeCommander::Base::ClassAutoLoader`
113
141
 
114
142
  ## [0.2.1] - 2023-04-29
115
143
 
116
144
  ### Fixed
117
- - `RakeCommander::Option` type coercion was not being inherited
118
- - Typo on `coertion`: writes `coercion`
119
145
 
146
+ - `RakeCommander::Option` type coercion was not being inherited
147
+ - Typo on `coertion`: writes `coercion`
120
148
 
121
149
  ## [0.2.0] - 2023-04-28
122
150
 
123
151
  ### Added
124
- - Better support for `RakeCommander::Options::Set`
125
- - `RakeCommander::Options::options_use` accepts it as a parameter.
126
- - Added `override` parameter to specify if this should override clashed option names.
127
- - `RakeCommander::Options::class_resolver` to define the `RakeCommander::Option` class.
128
- - Serves the purpose to ease class extension through inheritance.
129
- - Ability to reopen options without changing the order.
130
- - `RakeCommander::Options::option_reopen` which upserts (adds if not existing).
131
- - New parameter `reopen` to `RakeCommander::Options::option` (redirects to the above method).
132
- - Automatic option shortcuts (`implicit_shorts`) show in help and only when applicable.
133
- - These are added automatically by `OptionParser`
134
- - `OptionParser` leftovers trigger an error by default.
135
- - This behaviour can be disabled or modified via callback/block by using `RakeCommander::Options:Error::error_on_leftovers`.
136
- - Description auto **multi-line**
137
- - Currently based on `RakeCommander::Options::Description::DESC_MAX_LENGTH`
138
- - `RakeCommander::Options#remove_option`
139
- - `RakeCommander::Options::Error::Base` and children can be raised using different methods (see `RakeCommander::Options::Error` for examples).
140
- - The **task** `name` that raised the error is included in the message.
141
- - `RakeCommander::Options::Error::Handling` which provides **configurability** around actions on specific option errors with a default to a general options parsing error.
152
+
153
+ - Better support for `RakeCommander::Options::Set`
154
+ - `RakeCommander::Options::options_use` accepts it as a parameter.
155
+ - Added `override` parameter to specify if this should override clashed option names.
156
+ - `RakeCommander::Options::class_resolver` to define the `RakeCommander::Option` class.
157
+ - Serves the purpose to ease class extension through inheritance.
158
+ - Ability to reopen options without changing the order.
159
+ - `RakeCommander::Options::option_reopen` which upserts (adds if not existing).
160
+ - New parameter `reopen` to `RakeCommander::Options::option` (redirects to the above method).
161
+ - Automatic option shortcuts (`implicit_shorts`) show in help and only when applicable.
162
+ - These are added automatically by `OptionParser`
163
+ - `OptionParser` leftovers trigger an error by default.
164
+ - This behaviour can be disabled or modified via callback/block by using `RakeCommander::Options:Error::error_on_leftovers`.
165
+ - Description auto **multi-line**
166
+ - Currently based on `RakeCommander::Options::Description::DESC_MAX_LENGTH`
167
+ - `RakeCommander::Options#remove_option`
168
+ - `RakeCommander::Options::Error::Base` and children can be raised using different methods (see `RakeCommander::Options::Error` for examples).
169
+ - The **task** `name` that raised the error is included in the message.
170
+ - `RakeCommander::Options::Error::Handling` which provides **configurability** around actions on specific option errors with a default to a general options parsing error.
142
171
 
143
172
  ### Fixed
144
- - `RakeCommander::Base::ClassAutoLoader`
145
- - Register excluded child classes (singleton classes) into their own property,
146
- rather than in the `autoloaded_children` (they are not autoloaded).
147
- - Missing `rake` dependency in gemspec file.
148
- - Boolean switch detection (pre-parse arguments) and parsing
149
- - It adds support for boolean option names such as `--[no-]verbose`
150
- - Error messaging. There were missing cases, specially with implicit short options.
151
- - `RakeCommander::Options`
152
- - `#option_reopen` fixed
153
- - **Inheritance fixed**
173
+
174
+ - `RakeCommander::Base::ClassAutoLoader`
175
+ - Register excluded child classes (singleton classes) into their own property,
176
+ rather than in the `autoloaded_children` (they are not autoloaded).
177
+ - Missing `rake` dependency in gemspec file.
178
+ - Boolean switch detection (pre-parse arguments) and parsing
179
+ - It adds support for boolean option names such as `--[no-]verbose`
180
+ - Error messaging. There were missing cases, specially with implicit short options.
181
+ - `RakeCommander::Options`
182
+ - `#option_reopen` fixed
183
+ - **Inheritance fixed**
154
184
 
155
185
  ### Changed
156
- - Development: examples invokation via `Rake`
157
- - Refactored `RakeCommander::Options` to acquire functionality through extension.
158
- - `attr_inheritable` and `inheritable_class_var` are the new names of previous methods
159
- - Behaviour has been changed, so you define if it should `dup` the variables, and you can pass a `block` to do the `dup` yourself. They won **NOT** `freeze` anymore, as we are mostly working at class level.
186
+
187
+ - Development: examples invokation via `Rake`
188
+ - Refactored `RakeCommander::Options` to acquire functionality through extension.
189
+ - `attr_inheritable` and `inheritable_class_var` are the new names of previous methods
190
+ - Behaviour has been changed, so you define if it should `dup` the variables, and you can pass a `block` to do the `dup` yourself. They won **NOT** `freeze` anymore, as we are mostly working at class level.
160
191
 
161
192
  ## [0.1.4] - 2023-04-20
162
193
 
163
194
  ### Fixed
164
- - `rubocop` offenders
165
- - Added implicity `exit(0)` when wrapping the `task` block
195
+
196
+ - `rubocop` offenders
197
+ - Added implicity `exit(0)` when wrapping the `task` block
166
198
 
167
199
  ## [0.1.3] - 2023-04-20
168
200
 
169
201
  ### Fixed
170
- - Reference to repo and gem
202
+
203
+ - Reference to repo and gem
171
204
 
172
205
  ## [0.1.2] - 2023-04-19
173
206
 
174
207
  ### Added
175
- - First commit
208
+
209
+ - First commit
data/README.md CHANGED
@@ -32,6 +32,10 @@ Or install it yourself as:
32
32
 
33
33
  $ gem install rake-commander
34
34
 
35
+ ## Changelog
36
+
37
+ See {file:CHANGELOG.md} for a list of changes.
38
+
35
39
  ## Usage
36
40
 
37
41
  See [**the `examples`**](https://github.com/rellampec/rake-commander/tree/main/examples).
@@ -8,11 +8,13 @@ class RakeCommander::Custom::BasicExample < RakeCommander
8
8
  option '-w', :show_time, TrueClass, desc: 'Displays the local time'
9
9
  option :z, '--timezone', TrueClass, default: false, required: true
10
10
  option :o, '--hello NAME', String, desc: 'It greets.'
11
- option '-s', '--say [SOMETHING]', "It says 'something'", default: %q(I don't know what to "say"...)
11
+ option '-s', '--say [SOMETHING]', "It says 'something'", 'But it comes with default',
12
+ default: %q(I don't know what to "say"...)
12
13
  option :d, '--folder NAME', default: '.', desc: 'Source local folder', required: true
13
14
  option '-e', :'--enviro ENV', 'The target environment to run this task', required: true
14
15
  option :v, :debug, TrueClass, 'Shows the parsed options'
15
16
  option :V, '[no-]verbose', 'Verbosity', TrueClass
17
+ option :l, '--colour COLOUR', "Choose a colour", type: %i[red yellow green blue]
16
18
  #option :f, :folder, required: false, reopen: true
17
19
 
18
20
  def task(*_args)
@@ -10,8 +10,9 @@ class RakeCommander::Custom::ChainerPlus < RakeCommander::Custom::Chainer
10
10
  # Update option description
11
11
  option_reopen :chain, desc: "Calls: '< rake|raked > #{TARGET_TASK} task'"
12
12
  # Extend with new options
13
- option :e, '--exit-on-error', TrueClass, \
14
- desc: "Whether #{TARGET_TASK} should just exit on 'missing argument' error (or raise an exception)"
13
+ option \
14
+ :e, '--exit-on-error', TrueClass,
15
+ desc: "Whether #{TARGET_TASK} should just exit on 'missing argument' error (or raise an exception)"
15
16
  option :o, '--hello NAME', String, desc: 'It greets.'
16
17
 
17
18
  # Make it default to `exit 1` when there are errors
@@ -50,17 +50,20 @@ class RakeCommander
50
50
  # @return [Boolean] determines if a given namespace is entitled for autoloading
51
51
  def autoload_class?(constant)
52
52
  constants = constant.to_s.split("::").compact
53
- autoload = true
53
+ autoload = true
54
+
54
55
  unless autoloaded_namespaces(:include).empty?
55
56
  autoload = autoloaded_namespaces(:include).any? do |ns|
56
57
  ns.to_s.split("::").compact.zip(constants).all? {|(r, c)| r == c}
57
58
  end
58
59
  end
60
+
59
61
  unless autoloaded_namespaces(:ignore).empty?
60
62
  autoload &&= autoloaded_namespaces(:ignore).none? do |ns|
61
63
  ns.to_s.split("::").compact.zip(constants).all? {|(r, c)| r == c}
62
64
  end
63
65
  end
66
+
64
67
  autoload
65
68
  end
66
69
 
@@ -90,8 +93,10 @@ class RakeCommander
90
93
  # Children classes of `autoloader_class` that have not been created an instance of.
91
94
  def unloaded_children
92
95
  return [] unless autoloaded_class
96
+
93
97
  new_detected = new_classes
94
98
  known_class!(*new_detected)
99
+
95
100
  descendants(parent_class: autoloaded_class, scope: new_detected).select do |child_class|
96
101
  !autoloaded_children.include?(child_class) && \
97
102
  !excluded_children.include?(child_class) && \
@@ -105,9 +110,12 @@ class RakeCommander
105
110
  # @return [Boolean] `true` if there were children loaded, `false` otherwise.
106
111
  def autoload_children(object = nil)
107
112
  return false if !autoloaded_class || @loading_children
113
+
108
114
  pending_children = unloaded_children
109
115
  return false if pending_children.empty?
116
+
110
117
  @loading_children = true
118
+
111
119
  pending_children.each do |klass|
112
120
  exclude = false
113
121
  child = object ? klass.new(object) : klass.new
@@ -119,6 +127,7 @@ class RakeCommander
119
127
  ensure
120
128
  autoloaded_children.push(klass) unless exclude
121
129
  end
130
+
122
131
  @loading_children = false
123
132
  true
124
133
  end
@@ -11,6 +11,7 @@ class RakeCommander
11
11
  # just return @message
12
12
  def to_s
13
13
  return @message if @message
14
+
14
15
  unclassed(super)
15
16
  end
16
17
 
@@ -18,6 +19,7 @@ class RakeCommander
18
19
  # just return @message
19
20
  def message
20
21
  return @message if @message
22
+
21
23
  to_message(unclassed(super))
22
24
  end
23
25
 
@@ -30,9 +32,7 @@ class RakeCommander
30
32
  case value
31
33
  when StandardError
32
34
  to_message(value.message)
33
- when String
34
- value
35
- when NilClass
35
+ when String, NilClass
36
36
  value
37
37
  else
38
38
  raise ArgumentError, "Expecting String, StandardError or NilClass. Given: #{value.class}"
@@ -10,7 +10,8 @@ class RakeCommander
10
10
  module Base
11
11
  class << self
12
12
  def included(base)
13
- super(base)
13
+ super
14
+
14
15
  base.extend RakeCommander::Base::ClassAutoLoader
15
16
  base.autoloads_children_of RakeCommander
16
17