rake-commander 0.2.2 → 0.2.3

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: fd67a354c71f5013039c3cef58f8070aed34cad128c3b753eee699f7ed7c70e2
4
- data.tar.gz: f5b46e640c4395493906f80b1263b3b96636d1b60bc3880ba03d75b6abb3dd84
3
+ metadata.gz: bcd5bb7ca707d1e8e6cf543712c447cbd63061e7bbe8cfdc6e3c0c0755c338e5
4
+ data.tar.gz: 7b02270fbe937b0b50b6e8c4b1001005ba377c69f7a799ce97823fea42356893
5
5
  SHA512:
6
- metadata.gz: d16c7a9e9dcb95466463fcc3eddab2181314d4884613d6b23003e179b881be9e6eb15d72be783e76add51b3f26cf0e9082a6e4a8115c04f9d8054086d704869b
7
- data.tar.gz: 8c89aef16e4087fc5894f2033a21b09638599420a96ad6d474118e2a26ba76983e024e08ac4cec28fd811bbf7c4797bff08db6f76887b8da9fd237e5b6a36650
6
+ metadata.gz: 00d05400483297153797a08d02c32fb5bde4510a829cdb158121324d1d034d62dafa3560c2a56daa6893b6bc35ee9a46a832493e2b37403a34eb949f10082fc4
7
+ data.tar.gz: 01c09729261196848948383dfeb356c1463086f858e4365bcfb20a043e98e521284fe45b20cf8f39ef0ab139a37fa26ce381e433974fad48c860d6ea9c377476
data/CHANGELOG.md CHANGED
@@ -2,6 +2,8 @@
2
2
  All notable changes to this project will be documented in this file.
3
3
 
4
4
  ## TO DO
5
+ - `option_reopen` -> upsert should be optional (add `upsert: false` as default an raise missing option if not found)
6
+ - The error on missing short pops up where it's not clear the short was missed in the option_reopen call.
5
7
  - Option results
6
8
  - Include the symbol name keys (configurable). Note that dash will be replaced by underscore.
7
9
  - Type Coercions
@@ -30,12 +32,20 @@ All notable changes to this project will be documented in this file.
30
32
  - Option to globally enable/disable the 2nd patch?
31
33
  * That would make this gem completely useless.
32
34
 
33
- ## [0.2.2] - 2023-04-xx
35
+ ## [0.2.4] - 2023-04-xx
34
36
 
35
37
  ### Added
36
38
  ### Fixed
37
39
  ### Changed
38
40
 
41
+ ## [0.2.3] - 2023-04-29
42
+
43
+ ### Added
44
+ - Include Symbol option names in the parsed option results.
45
+
46
+ ### Fixed
47
+ ### Changed
48
+
39
49
  ## [0.2.2] - 2023-04-29
40
50
 
41
51
  ### Fixed
@@ -24,6 +24,7 @@ class RakeCommander::Custom::Chainer < RakeCommander
24
24
  option '-m', 'method [METHOD]', default: 'system', desc: str_desc
25
25
 
26
26
  def task(*_args)
27
+ print_options if options[:b]
27
28
  if options[:c]
28
29
  cmd = "#{subcommand_base} -- #{subcommand_arguments.join(' ')}"
29
30
  puts "Calling --> '#{cmd}'"
@@ -51,6 +52,11 @@ class RakeCommander::Custom::Chainer < RakeCommander
51
52
 
52
53
  private
53
54
 
55
+ def print_options
56
+ puts "These are the options received:"
57
+ pp options
58
+ end
59
+
54
60
  def puts(str)
55
61
  return super unless options[:b]
56
62
  super "#{app_id} #{str} #{thread_id}"
@@ -8,6 +8,7 @@ class RakeCommander::Custom::Chained < RakeCommander::Custom::Chainer
8
8
 
9
9
  def task(*_args)
10
10
  puts "Called !!"
11
+ print_options if options[:b]
11
12
  puts options[:s] if options[:s]
12
13
  end
13
14
  end
@@ -148,7 +148,7 @@ class RakeCommander
148
148
 
149
149
  # Called on parse runtime
150
150
  def option_block(&middleware)
151
- block_extra_args = [default, short, name]
151
+ block_extra_args = [default, short, name, self]
152
152
  proc do |value|
153
153
  args = block_extra_args.dup.unshift(value)
154
154
  original_block&.call(*args)
@@ -24,6 +24,12 @@ class RakeCommander
24
24
  # It **re-opens** the method and adds a middleware to gather and return
25
25
  # the results of the parsing (including the `leftovers`)
26
26
  # @note this extends the method parameters and changes the returned value.
27
+ # @yield [value, default, short, name, option] do somethin with parsed `value` for `option`
28
+ # @yieldparam value [] the resulting parsed value
29
+ # @yieldparam default [] the default value of the option
30
+ # @yieldparam short [Symbol] the symbol short of the option
31
+ # @yieldparam name [Symbol] the symbol name of the option
32
+ # @yieldparam option [RakeCommander::Option] the option that is being parsed
27
33
  # @param leftovers [Array<String>] see RakeCommander::Options#parse_options`
28
34
  # @param results [Hash] with `short` option as `key` and final value as `value`.
29
35
  # @see `RakeCommander::Options#parse_options`
@@ -66,9 +72,9 @@ class RakeCommander
66
72
  # @return [Proc] the results collector that wraps the middleware.
67
73
  def results_collector(results, &middleware)
68
74
  results = result_defaults(results)
69
- proc do |value, default, short, name|
70
- middleware&.call(value, default, short, name)
71
- results[short] = value.nil?? default : value
75
+ proc do |value, default, short, name, opt|
76
+ middleware&.call(value, default, short, name, opt)
77
+ results[name] = results[short] = value.nil?? default : value
72
78
  end
73
79
  end
74
80
 
@@ -79,7 +85,7 @@ class RakeCommander
79
85
  (options_with_defaults && opt.default?) \
80
86
  || (opt.required? && opt.default?)
81
87
  end.each do |opt|
82
- res_def[opt.short] = opt.default
88
+ res_def[opt.name] = res_def[opt.short] = opt.default
83
89
  end
84
90
  end
85
91
  end
@@ -1,3 +1,3 @@
1
1
  class RakeCommander
2
- VERSION = '0.2.2'.freeze
2
+ VERSION = '0.2.3'.freeze
3
3
  end
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.2
4
+ version: 0.2.3
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-28 00:00:00.000000000 Z
11
+ date: 2023-04-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler