toys-core 0.9.1 → 0.9.2

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.
@@ -47,7 +47,7 @@ module Toys
47
47
  module Gems
48
48
  include Mixin
49
49
 
50
- on_include do |opts = {}|
50
+ on_include do |**opts|
51
51
  @__gems_opts = opts
52
52
 
53
53
  ## @private
@@ -56,7 +56,7 @@ module Toys
56
56
  #
57
57
  KEY = ::Object.new.freeze
58
58
 
59
- on_initialize do |opts = {}|
59
+ on_initialize do |**opts|
60
60
  require "toys/utils/terminal"
61
61
  self[KEY] = Utils::Terminal.new(**opts)
62
62
  end
@@ -960,11 +960,12 @@ module Toys
960
960
  #
961
961
  # @param proc [Proc] The initializer block
962
962
  # @param args [Object...] Arguments to pass to the initializer
963
+ # @param kwargs [keywords] Keyword arguments to pass to the initializer
963
964
  # @return [self]
964
965
  #
965
- def add_initializer(proc, *args)
966
+ def add_initializer(proc, *args, **kwargs)
966
967
  check_definition_state
967
- @initializers << [proc, args]
968
+ @initializers << [proc, args, kwargs]
968
969
  self
969
970
  end
970
971
 
@@ -1090,8 +1091,8 @@ module Toys
1090
1091
  # @private
1091
1092
  #
1092
1093
  def run_initializers(context)
1093
- @initializers.each do |func, args|
1094
- context.instance_exec(*args, &func)
1094
+ @initializers.each do |func, args, kwargs|
1095
+ context.instance_exec(*args, **kwargs, &func)
1095
1096
  end
1096
1097
  end
1097
1098
 
@@ -140,19 +140,19 @@ module Toys
140
140
  # @param block [Proc] A block that is called if a key is not found. It is
141
141
  # passed the unknown key, and expected to return a default value
142
142
  # (which can be nil).
143
- # @param opts [Hash] Initial default options.
143
+ # @param opts [keywords] Initial default options.
144
144
  #
145
- def initialize(opts = {}, &block)
145
+ def initialize(**opts, &block)
146
146
  @default_opts = Opts.new(&block).add(opts)
147
147
  end
148
148
 
149
149
  ##
150
150
  # Set default options
151
151
  #
152
- # @param opts [Hash] New default options to set
152
+ # @param opts [keywords] New default options to set
153
153
  # @return [self]
154
154
  #
155
- def configure_defaults(opts = {})
155
+ def configure_defaults(**opts)
156
156
  @default_opts.add(opts)
157
157
  self
158
158
  end
@@ -165,7 +165,7 @@ module Toys
165
165
  # provided, a {Toys::Utils::Exec::Controller} will be yielded to it.
166
166
  #
167
167
  # @param cmd [String,Array<String>] The command to execute.
168
- # @param opts [Hash] The command options. See the section on
168
+ # @param opts [keywords] The command options. See the section on
169
169
  # configuration options in the {Toys::Utils::Exec} module docs.
170
170
  # @yieldparam controller [Toys::Utils::Exec::Controller] A controller
171
171
  # for the subprocess streams.
@@ -175,7 +175,7 @@ module Toys
175
175
  # @return [Toys::Utils::Exec::Result] The result, if the process ran in
176
176
  # the foreground.
177
177
  #
178
- def exec(cmd, opts = {}, &block)
178
+ def exec(cmd, **opts, &block)
179
179
  exec_opts = Opts.new(@default_opts).add(opts)
180
180
  spawn_cmd =
181
181
  if cmd.is_a?(::Array)
@@ -198,7 +198,7 @@ module Toys
198
198
  # provided, a {Toys::Utils::Exec::Controller} will be yielded to it.
199
199
  #
200
200
  # @param args [String,Array<String>] The arguments to ruby.
201
- # @param opts [Hash] The command options. See the section on
201
+ # @param opts [keywords] The command options. See the section on
202
202
  # configuration options in the {Toys::Utils::Exec} module docs.
203
203
  # @yieldparam controller [Toys::Utils::Exec::Controller] A controller
204
204
  # for the subprocess streams.
@@ -208,10 +208,11 @@ module Toys
208
208
  # @return [Toys::Utils::Exec::Result] The result, if the process ran in
209
209
  # the foreground.
210
210
  #
211
- def exec_ruby(args, opts = {}, &block)
211
+ def exec_ruby(args, **opts, &block)
212
212
  cmd = args.is_a?(::Array) ? [::RbConfig.ruby] + args : "#{::RbConfig.ruby} #{args}"
213
213
  log_cmd = args.is_a?(::Array) ? ["ruby"] + args : "ruby #{args}"
214
- exec(cmd, {argv0: "ruby", log_cmd: log_cmd}.merge(opts), &block)
214
+ opts = {argv0: "ruby", log_cmd: log_cmd}.merge(opts)
215
+ exec(cmd, **opts, &block)
215
216
  end
216
217
  alias ruby exec_ruby
217
218
 
@@ -222,7 +223,7 @@ module Toys
222
223
  # provided, a {Toys::Utils::Exec::Controller} will be yielded to it.
223
224
  #
224
225
  # @param func [Proc] The proc to call.
225
- # @param opts [Hash] The command options. See the section on
226
+ # @param opts [keywords] The command options. See the section on
226
227
  # configuration options in the {Toys::Utils::Exec} module docs.
227
228
  # @yieldparam controller [Toys::Utils::Exec::Controller] A controller
228
229
  # for the subprocess streams.
@@ -232,7 +233,7 @@ module Toys
232
233
  # @return [Toys::Utils::Exec::Result] The result, if the process ran in
233
234
  # the foreground.
234
235
  #
235
- def exec_proc(func, opts = {}, &block)
236
+ def exec_proc(func, **opts, &block)
236
237
  exec_opts = Opts.new(@default_opts).add(opts)
237
238
  executor = Executor.new(exec_opts, func, block)
238
239
  executor.execute
@@ -249,15 +250,16 @@ module Toys
249
250
  # yielded to it.
250
251
  #
251
252
  # @param cmd [String,Array<String>] The command to execute.
252
- # @param opts [Hash] The command options. See the section on
253
+ # @param opts [keywords] The command options. See the section on
253
254
  # configuration options in the {Toys::Utils::Exec} module docs.
254
255
  # @yieldparam controller [Toys::Utils::Exec::Controller] A controller
255
256
  # for the subprocess streams.
256
257
  #
257
258
  # @return [String] What was written to standard out.
258
259
  #
259
- def capture(cmd, opts = {}, &block)
260
- exec(cmd, opts.merge(out: :capture, background: false), &block).captured_out
260
+ def capture(cmd, **opts, &block)
261
+ opts = opts.merge(out: :capture, background: false)
262
+ exec(cmd, **opts, &block).captured_out
261
263
  end
262
264
 
263
265
  ##
@@ -270,15 +272,16 @@ module Toys
270
272
  # yielded to it.
271
273
  #
272
274
  # @param args [String,Array<String>] The arguments to ruby.
273
- # @param opts [Hash] The command options. See the section on
275
+ # @param opts [keywords] The command options. See the section on
274
276
  # configuration options in the {Toys::Utils::Exec} module docs.
275
277
  # @yieldparam controller [Toys::Utils::Exec::Controller] A controller
276
278
  # for the subprocess streams.
277
279
  #
278
280
  # @return [String] What was written to standard out.
279
281
  #
280
- def capture_ruby(args, opts = {}, &block)
281
- ruby(args, opts.merge(out: :capture, background: false), &block).captured_out
282
+ def capture_ruby(args, **opts, &block)
283
+ opts = opts.merge(out: :capture, background: false)
284
+ ruby(args, **opts, &block).captured_out
282
285
  end
283
286
 
284
287
  ##
@@ -291,15 +294,16 @@ module Toys
291
294
  # yielded to it.
292
295
  #
293
296
  # @param func [Proc] The proc to call.
294
- # @param opts [Hash] The command options. See the section on
297
+ # @param opts [keywords] The command options. See the section on
295
298
  # configuration options in the {Toys::Utils::Exec} module docs.
296
299
  # @yieldparam controller [Toys::Utils::Exec::Controller] A controller
297
300
  # for the subprocess streams.
298
301
  #
299
302
  # @return [String] What was written to standard out.
300
303
  #
301
- def capture_proc(func, opts = {}, &block)
302
- exec_proc(func, opts.merge(out: :capture, background: false), &block).captured_out
304
+ def capture_proc(func, **opts, &block)
305
+ opts = opts.merge(out: :capture, background: false)
306
+ exec_proc(func, **opts, &block).captured_out
303
307
  end
304
308
 
305
309
  ##
@@ -310,15 +314,16 @@ module Toys
310
314
  # yielded to it.
311
315
  #
312
316
  # @param cmd [String] The shell command to execute.
313
- # @param opts [Hash] The command options. See the section on
317
+ # @param opts [keywords] The command options. See the section on
314
318
  # configuration options in the {Toys::Utils::Exec} module docs.
315
319
  # @yieldparam controller [Toys::Utils::Exec::Controller] A controller
316
320
  # for the subprocess streams.
317
321
  #
318
322
  # @return [Integer] The exit code
319
323
  #
320
- def sh(cmd, opts = {}, &block)
321
- exec(cmd, opts.merge(background: false), &block).exit_code
324
+ def sh(cmd, **opts, &block)
325
+ opts = opts.merge(background: false)
326
+ exec(cmd, **opts, &block).exit_code
322
327
  end
323
328
 
324
329
  ##
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: toys-core
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.1
4
+ version: 0.9.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Azuma
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-12-23 00:00:00.000000000 Z
11
+ date: 2020-01-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: highline
@@ -72,14 +72,14 @@ dependencies:
72
72
  requirements:
73
73
  - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: '6.2'
75
+ version: 6.1.2
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
- version: '6.2'
82
+ version: 6.1.2
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: redcarpet
85
85
  requirement: !ruby/object:Gem::Requirement
@@ -114,14 +114,14 @@ dependencies:
114
114
  requirements:
115
115
  - - "~>"
116
116
  - !ruby/object:Gem::Version
117
- version: 0.9.20
117
+ version: 0.9.22
118
118
  type: :development
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
121
121
  requirements:
122
122
  - - "~>"
123
123
  - !ruby/object:Gem::Version
124
- version: 0.9.20
124
+ version: 0.9.22
125
125
  description: Toys-Core is the command line tool framework underlying Toys. It can
126
126
  be used to create command line executables using the Toys DSL and classes.
127
127
  email:
@@ -182,7 +182,7 @@ metadata:
182
182
  changelog_uri: https://github.com/dazuma/toys/blob/master/toys-core/CHANGELOG.md
183
183
  source_code_uri: https://github.com/dazuma/toys
184
184
  bug_tracker_uri: https://github.com/dazuma/toys/issues
185
- documentation_uri: https://dazuma.github.io/toys/gems/toys-core/v0.9.1
185
+ documentation_uri: https://dazuma.github.io/toys/gems/toys-core/v0.9.2
186
186
  post_install_message:
187
187
  rdoc_options: []
188
188
  require_paths:
@@ -198,7 +198,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
198
198
  - !ruby/object:Gem::Version
199
199
  version: '0'
200
200
  requirements: []
201
- rubygems_version: 3.0.3
201
+ rubygems_version: 3.1.2
202
202
  signing_key:
203
203
  specification_version: 4
204
204
  summary: Framework for creating command line executables