rake-commander 0.2.0 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +14 -3
- data/README.md +10 -9
- data/lib/rake-commander/base/class_auto_loader.rb +1 -1
- data/lib/rake-commander/option.rb +6 -5
- data/lib/rake-commander/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fd67a354c71f5013039c3cef58f8070aed34cad128c3b753eee699f7ed7c70e2
|
4
|
+
data.tar.gz: f5b46e640c4395493906f80b1263b3b96636d1b60bc3880ba03d75b6abb3dd84
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d16c7a9e9dcb95466463fcc3eddab2181314d4884613d6b23003e179b881be9e6eb15d72be783e76add51b3f26cf0e9082a6e4a8115c04f9d8054086d704869b
|
7
|
+
data.tar.gz: 8c89aef16e4087fc5894f2033a21b09638599420a96ad6d474118e2a26ba76983e024e08ac4cec28fd811bbf7c4797bff08db6f76887b8da9fd237e5b6a36650
|
data/CHANGELOG.md
CHANGED
@@ -4,9 +4,9 @@ All notable changes to this project will be documented in this file.
|
|
4
4
|
## TO DO
|
5
5
|
- Option results
|
6
6
|
- Include the symbol name keys (configurable). Note that dash will be replaced by underscore.
|
7
|
-
- Type
|
7
|
+
- Type Coercions
|
8
8
|
- Add a way to define/redefine a set and use them.
|
9
|
-
- Add more supported
|
9
|
+
- Add more supported type_coercions as native to the gem (i.e. `Symbol`)
|
10
10
|
- Add support [for `ActiveRecord::Enum`](https://apidock.com/rails/ActiveRecord/Enum)
|
11
11
|
- Option definitions
|
12
12
|
- Order: `where: [:tail, :top]` and `[after, before]: :option_name`
|
@@ -30,12 +30,23 @@ All notable changes to this project will be documented in this file.
|
|
30
30
|
- Option to globally enable/disable the 2nd patch?
|
31
31
|
* That would make this gem completely useless.
|
32
32
|
|
33
|
-
## [0.2.
|
33
|
+
## [0.2.2] - 2023-04-xx
|
34
34
|
|
35
35
|
### Added
|
36
36
|
### Fixed
|
37
37
|
### Changed
|
38
38
|
|
39
|
+
## [0.2.2] - 2023-04-29
|
40
|
+
|
41
|
+
### Fixed
|
42
|
+
- Typo in `RakeCommander::Base::ClassAutoLoader`
|
43
|
+
|
44
|
+
## [0.2.1] - 2023-04-29
|
45
|
+
|
46
|
+
### Fixed
|
47
|
+
- `RakeCommander::Option` type coercion was not being inherited
|
48
|
+
- Typo on `coertion`: writes `coercion`
|
49
|
+
|
39
50
|
|
40
51
|
## [0.2.0] - 2023-04-28
|
41
52
|
|
data/README.md
CHANGED
@@ -9,12 +9,12 @@ Rake commander is a way to declare **rake tasks** with re-usable classes. It enh
|
|
9
9
|
Although the `OptionParser` ruby native class is used for parsing the options, the declaration of options, additionally to the ones of `OptionParser` comes with some **opinionated improvements** and amendments:
|
10
10
|
|
11
11
|
1. It is possible to declare options as `required`
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
12
|
+
* This is additional to required option arguments.
|
13
|
+
* Options are inheritable (they get a custom `deep_dup`)
|
14
|
+
1. An option can have a `default` value.
|
15
|
+
* Which can optionally be automatically used when the option accepts or requires an argument.
|
16
|
+
1. Options parsing raises specific option errors. For a given task/class, each error type can have its own handler or preferred action.
|
17
|
+
* Defined error handling is inheritable and can be redefined.
|
18
18
|
|
19
19
|
## Installation
|
20
20
|
|
@@ -74,10 +74,11 @@ rspec logging and results
|
|
74
74
|
It supports most of options syntax of the native `OptionParser` but for a couple of exceptions perhaps:
|
75
75
|
1. It does **NOT** support definitions or parsing of shortcuts with **embedded argument** (i.e. `-nNAME`).
|
76
76
|
2. It does **NOT** support definitions that include equal sign (i.e. `name=NAME`, `n=NAME`)
|
77
|
+
3. Currently, declaring a short and a name for the option is compulsory.
|
77
78
|
|
78
|
-
An argument should be explicitly declared in the `name` part:
|
79
|
+
An argument of an option should be explicitly declared in the `name` part:
|
79
80
|
|
80
|
-
```
|
81
|
+
```ruby
|
81
82
|
option :n, '--name NAME'
|
82
83
|
```
|
83
84
|
|
@@ -89,7 +90,7 @@ Although it is planned to extend the syntax, the current version shares the opti
|
|
89
90
|
rake [rake-options] task1 task2 -- [shared-task-options]
|
90
91
|
```
|
91
92
|
|
92
|
-
The double dash ` -- ` delimiter allows to modify the `ARGV` parsing behaviour of `rake`, giving room for **opinionated enhanced syntax**. Anything that comes before the double dash is
|
93
|
+
The double dash ` -- ` delimiter allows to modify the `ARGV` parsing behaviour of `rake`, giving room for **opinionated enhanced syntax**. Anything that comes before the double dash is fed to standard `rake`, and anything after `--` are parsed as option tasks via `rake commander`.
|
93
94
|
|
94
95
|
```
|
95
96
|
<rake part> -- [tasks options part]
|
@@ -41,7 +41,7 @@ class RakeCommander
|
|
41
41
|
autoloaded_namespaces(type).tap do |target|
|
42
42
|
next if namespaces.empty?
|
43
43
|
other_type = type == :include ? :ignore : :include
|
44
|
-
namespaces.each {|nm_sp|
|
44
|
+
namespaces.each {|nm_sp| autoloaded_namespaces(other_type).delete(nm_sp)}
|
45
45
|
target.concat(namespaces)
|
46
46
|
end
|
47
47
|
end
|
@@ -16,7 +16,7 @@ class RakeCommander
|
|
16
16
|
@default = kargs[:default] if kargs.key?(:default)
|
17
17
|
@desc = kargs[:desc] if kargs.key?(:desc)
|
18
18
|
@required = kargs[:required] if kargs.key?(:required)
|
19
|
-
@
|
19
|
+
@type_coercion = kargs[:type] if kargs.key?(:type)
|
20
20
|
@other_args = args
|
21
21
|
@original_block = block
|
22
22
|
configure_other
|
@@ -91,8 +91,8 @@ class RakeCommander
|
|
91
91
|
end
|
92
92
|
|
93
93
|
# @return [Class, NilClass]
|
94
|
-
def
|
95
|
-
@
|
94
|
+
def type_coercion
|
95
|
+
@type_coercion || (default? && default.class)
|
96
96
|
end
|
97
97
|
|
98
98
|
# @return [Boolean]
|
@@ -130,6 +130,7 @@ class RakeCommander
|
|
130
130
|
kargs.merge!(name: name_full.dup.freeze) if name_full
|
131
131
|
kargs.merge!(desc: desc.dup) if desc
|
132
132
|
kargs.merge!(default: default.dup) if default?
|
133
|
+
kargs.merge!(type: @type_coercion) if @type_coercion.is_a?(Class)
|
133
134
|
kargs.merge!(required: required?)
|
134
135
|
end
|
135
136
|
end
|
@@ -139,7 +140,7 @@ class RakeCommander
|
|
139
140
|
configure_other
|
140
141
|
args = [short_hyphen, name_hyphen]
|
141
142
|
args.push(*switch_desc(implicit_short: implicit_short))
|
142
|
-
args <<
|
143
|
+
args << type_coercion if type_coercion
|
143
144
|
args
|
144
145
|
end
|
145
146
|
|
@@ -228,7 +229,7 @@ class RakeCommander
|
|
228
229
|
# It consumes `other_args`, to prevent direct overrides to be overriden by it.
|
229
230
|
def configure_other
|
230
231
|
if type = other_args.find {|arg| arg.is_a?(Class)}
|
231
|
-
@
|
232
|
+
@type_coercion = type
|
232
233
|
other_args.delete(type)
|
233
234
|
end
|
234
235
|
if value = other_args.find {|arg| arg.is_a?(String)}
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rake-commander
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Oscar Segura Samper
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-04-
|
11
|
+
date: 2023-04-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|