toys-core 0.15.0 → 0.15.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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +8 -0
- data/lib/toys/cli.rb +1 -4
- data/lib/toys/core.rb +1 -1
- data/lib/toys/loader.rb +2 -3
- data/lib/toys/module_lookup.rb +1 -2
- data/lib/toys/settings.rb +8 -10
- data/lib/toys/standard_middleware/show_help.rb +4 -2
- data/lib/toys/standard_mixins/exec.rb +2 -0
- data/lib/toys/standard_mixins/fileutils.rb +1 -2
- data/lib/toys/standard_mixins/gems.rb +4 -2
- data/lib/toys/standard_mixins/highline.rb +1 -1
- data/lib/toys/standard_mixins/xdg.rb +0 -2
- data/lib/toys/tool_definition.rb +1 -3
- data/lib/toys/utils/completion_engine.rb +1 -2
- data/lib/toys/utils/exec.rb +3 -4
- data/lib/toys/utils/gems.rb +1 -1
- data/lib/toys/utils/git_cache.rb +6 -7
- data/lib/toys/utils/help_text.rb +2 -0
- data/lib/toys/utils/pager.rb +4 -3
- data/lib/toys/utils/standard_ui.rb +2 -1
- data/lib/toys/utils/terminal.rb +1 -3
- data/lib/toys/utils/xdg.rb +2 -2
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 840dff30d3a85e5af4cdbbdaa77498491efe89e473608e4e130e75d9a49a249c
|
4
|
+
data.tar.gz: 3ea3662f0fbf2b8a28063435ef0f4b28300e9b8b4664ab4a1c7d5dd5b6a8e77f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9368f93ffc0cea245a55c5961e56523bf94426996f100cf260080625e5ae91d5bef2773c06bcb029924ed9753987b5e864f2cdfb1b8df52d40483da9503b88c0
|
7
|
+
data.tar.gz: 14d7d4eb508528c401a33fb4a40fc385485e5697b345ac353faa2e42470852f70ed1b8e3bb6c20043b29c562742aad83e96bce40817eef1ee050f910534558f0
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,13 @@
|
|
1
1
|
# Release History
|
2
2
|
|
3
|
+
### v0.15.2 / 2023-10-17
|
4
|
+
|
5
|
+
* (No significant changes)
|
6
|
+
|
7
|
+
### v0.15.1 / 2023-10-15
|
8
|
+
|
9
|
+
* FIXED: Clean up some internal requires, which may improve performance with built-in gems.
|
10
|
+
|
3
11
|
### v0.15.0 / 2023-10-12
|
4
12
|
|
5
13
|
Toys-Core 0.15.0 is a major release that overhauls error and signal handling, cleans up some warts around entrypoint and method definition, and fixes a few long-standing issues.
|
data/lib/toys/cli.rb
CHANGED
@@ -1,9 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require "rbconfig"
|
4
|
-
require "logger"
|
5
|
-
require "toys/completion"
|
6
|
-
|
7
3
|
module Toys
|
8
4
|
##
|
9
5
|
# A Toys-based CLI.
|
@@ -566,6 +562,7 @@ module Toys
|
|
566
562
|
# @return [Proc]
|
567
563
|
#
|
568
564
|
def default_logger_factory
|
565
|
+
require "logger"
|
569
566
|
proc do
|
570
567
|
logger = ::Logger.new($stderr)
|
571
568
|
logger.level = ::Logger::WARN
|
data/lib/toys/core.rb
CHANGED
data/lib/toys/loader.rb
CHANGED
@@ -1,7 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require "monitor"
|
4
|
-
|
5
3
|
module Toys
|
6
4
|
##
|
7
5
|
# The Loader service loads tools from configuration files, and finds the
|
@@ -55,6 +53,7 @@ module Toys
|
|
55
53
|
if index_file_name && ::File.extname(index_file_name) != ".rb"
|
56
54
|
raise ::ArgumentError, "Illegal index file name #{index_file_name.inspect}"
|
57
55
|
end
|
56
|
+
require "monitor"
|
58
57
|
@mutex = ::Monitor.new
|
59
58
|
@mixin_lookup = mixin_lookup || ModuleLookup.new
|
60
59
|
@template_lookup = template_lookup || ModuleLookup.new
|
@@ -477,7 +476,7 @@ module Toys
|
|
477
476
|
end
|
478
477
|
end
|
479
478
|
|
480
|
-
@git_cache_mutex = ::
|
479
|
+
@git_cache_mutex = ::Mutex.new
|
481
480
|
@default_git_cache = nil
|
482
481
|
|
483
482
|
##
|
data/lib/toys/module_lookup.rb
CHANGED
@@ -1,7 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require "monitor"
|
4
|
-
|
5
3
|
module Toys
|
6
4
|
##
|
7
5
|
# A helper module that provides methods to do module lookups. This is
|
@@ -56,6 +54,7 @@ module Toys
|
|
56
54
|
# Create an empty ModuleLookup
|
57
55
|
#
|
58
56
|
def initialize
|
57
|
+
require "monitor"
|
59
58
|
@mutex = ::Monitor.new
|
60
59
|
@paths = []
|
61
60
|
@paths_locked = false
|
data/lib/toys/settings.rb
CHANGED
@@ -1,7 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require "date"
|
4
|
-
|
5
3
|
module Toys
|
6
4
|
##
|
7
5
|
# A settings class defines the structure of application settings, i.e. the
|
@@ -488,7 +486,7 @@ module Toys
|
|
488
486
|
def convert(val, klass)
|
489
487
|
return val if val.is_a?(klass)
|
490
488
|
begin
|
491
|
-
CONVERTERS[klass].call(val)
|
489
|
+
CONVERTERS[klass.name].call(val)
|
492
490
|
rescue ::StandardError
|
493
491
|
ILLEGAL_VALUE
|
494
492
|
end
|
@@ -564,13 +562,13 @@ module Toys
|
|
564
562
|
# @private
|
565
563
|
#
|
566
564
|
CONVERTERS = {
|
567
|
-
|
568
|
-
|
569
|
-
|
570
|
-
|
571
|
-
|
572
|
-
|
573
|
-
|
565
|
+
"Date" => date_converter,
|
566
|
+
"DateTime" => datetime_converter,
|
567
|
+
"Float" => float_converter,
|
568
|
+
"Integer" => integer_converter,
|
569
|
+
"Regexp" => regexp_converter,
|
570
|
+
"Symbol" => symbol_converter,
|
571
|
+
"Time" => time_converter,
|
574
572
|
}.freeze
|
575
573
|
end
|
576
574
|
|
@@ -248,8 +248,10 @@ module Toys
|
|
248
248
|
private
|
249
249
|
|
250
250
|
def terminal
|
251
|
-
|
252
|
-
|
251
|
+
@terminal ||= begin
|
252
|
+
require "toys/utils/terminal"
|
253
|
+
Utils::Terminal.new(output: @stream, styled: @styled_output)
|
254
|
+
end
|
253
255
|
end
|
254
256
|
|
255
257
|
def show_usage(context)
|
@@ -65,9 +65,11 @@ module Toys
|
|
65
65
|
# @private
|
66
66
|
#
|
67
67
|
def self.gems
|
68
|
-
require "toys/utils/gems"
|
69
68
|
# rubocop:disable Naming/MemoizedInstanceVariableName
|
70
|
-
@__gems ||=
|
69
|
+
@__gems ||= begin
|
70
|
+
require "toys/utils/gems"
|
71
|
+
Utils::Gems.new(**@__gems_opts)
|
72
|
+
end
|
71
73
|
# rubocop:enable Naming/MemoizedInstanceVariableName
|
72
74
|
end
|
73
75
|
|
@@ -131,7 +131,7 @@ module Toys
|
|
131
131
|
|
132
132
|
on_initialize do |*args|
|
133
133
|
require "toys/utils/gems"
|
134
|
-
Toys::Utils::Gems.activate("highline", "~> 2.0")
|
134
|
+
::Toys::Utils::Gems.activate("highline", "~> 2.0")
|
135
135
|
require "highline"
|
136
136
|
self[KEY] = ::HighLine.new(*args)
|
137
137
|
self[KEY].use_color = $stdout.tty?
|
data/lib/toys/tool_definition.rb
CHANGED
@@ -1,7 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require "set"
|
4
|
-
|
5
3
|
module Toys
|
6
4
|
##
|
7
5
|
# A ToolDefinition describes a single command that can be invoked using Toys.
|
@@ -284,7 +282,7 @@ module Toys
|
|
284
282
|
##
|
285
283
|
# Settings for this tool
|
286
284
|
#
|
287
|
-
# @return [Toys::
|
285
|
+
# @return [Toys::ToolDefinition::Settings]
|
288
286
|
#
|
289
287
|
attr_reader :settings
|
290
288
|
|
data/lib/toys/utils/exec.rb
CHANGED
@@ -1,9 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require "rbconfig"
|
4
|
-
require "logger"
|
5
|
-
require "shellwords"
|
6
|
-
|
7
3
|
module Toys
|
8
4
|
module Utils
|
9
5
|
##
|
@@ -266,6 +262,9 @@ module Toys
|
|
266
262
|
# for a description of the options.
|
267
263
|
#
|
268
264
|
def initialize(**opts, &block)
|
265
|
+
require "rbconfig"
|
266
|
+
require "logger"
|
267
|
+
require "stringio"
|
269
268
|
@default_opts = Opts.new(&block).add(opts)
|
270
269
|
end
|
271
270
|
|
data/lib/toys/utils/gems.rb
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require "monitor"
|
4
|
-
require "rubygems"
|
5
4
|
|
6
5
|
module Toys
|
7
6
|
module Utils
|
@@ -123,6 +122,7 @@ module Toys
|
|
123
122
|
output: nil,
|
124
123
|
suppress_confirm: nil,
|
125
124
|
default_confirm: nil)
|
125
|
+
require "rubygems"
|
126
126
|
@default_confirm = default_confirm || default_confirm.nil? ? true : false
|
127
127
|
@on_missing = on_missing ||
|
128
128
|
if suppress_confirm
|
data/lib/toys/utils/git_cache.rb
CHANGED
@@ -1,12 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require "digest"
|
4
|
-
require "fileutils"
|
5
|
-
require "json"
|
6
|
-
require "toys/compat"
|
7
|
-
require "toys/utils/exec"
|
8
|
-
require "toys/utils/xdg"
|
9
|
-
|
10
3
|
module Toys
|
11
4
|
module Utils
|
12
5
|
##
|
@@ -288,6 +281,11 @@ module Toys
|
|
288
281
|
# a specific directory in the user's XDG cache.
|
289
282
|
#
|
290
283
|
def initialize(cache_dir: nil)
|
284
|
+
require "digest"
|
285
|
+
require "fileutils"
|
286
|
+
require "json"
|
287
|
+
require "toys/compat"
|
288
|
+
require "toys/utils/exec"
|
291
289
|
@cache_dir = ::File.expand_path(cache_dir || default_cache_dir)
|
292
290
|
@exec = Utils::Exec.new(out: :capture, err: :capture)
|
293
291
|
end
|
@@ -485,6 +483,7 @@ module Toys
|
|
485
483
|
end
|
486
484
|
|
487
485
|
def default_cache_dir
|
486
|
+
require "toys/utils/xdg"
|
488
487
|
::File.join(XDG.new.cache_home, "toys", "git")
|
489
488
|
end
|
490
489
|
|
data/lib/toys/utils/help_text.rb
CHANGED
@@ -351,6 +351,7 @@ module Toys
|
|
351
351
|
def initialize(tool, executable_name, delegates, subtools, search_term,
|
352
352
|
show_source_path, separate_sources, indent, indent2, wrap_width, styled)
|
353
353
|
require "toys/utils/terminal"
|
354
|
+
require "stringio"
|
354
355
|
@tool = tool
|
355
356
|
@executable_name = executable_name
|
356
357
|
@delegates = delegates
|
@@ -667,6 +668,7 @@ module Toys
|
|
667
668
|
def initialize(tool, subtools, recursive, search_term, separate_sources,
|
668
669
|
indent, wrap_width, styled)
|
669
670
|
require "toys/utils/terminal"
|
671
|
+
require "stringio"
|
670
672
|
@tool = tool
|
671
673
|
@subtools = subtools
|
672
674
|
@recursive = recursive
|
data/lib/toys/utils/pager.rb
CHANGED
@@ -1,7 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require "toys/utils/exec"
|
4
|
-
|
5
3
|
module Toys
|
6
4
|
module Utils
|
7
5
|
##
|
@@ -150,7 +148,10 @@ module Toys
|
|
150
148
|
# @private
|
151
149
|
#
|
152
150
|
def default_exec_service
|
153
|
-
@default_exec_service ||=
|
151
|
+
@default_exec_service ||= begin
|
152
|
+
require "toys/utils/exec"
|
153
|
+
Utils::Exec.new
|
154
|
+
end
|
154
155
|
end
|
155
156
|
end
|
156
157
|
end
|
@@ -28,8 +28,9 @@ module Toys
|
|
28
28
|
# terminal output. Default is `$stderr`.
|
29
29
|
#
|
30
30
|
def initialize(output: nil)
|
31
|
-
|
31
|
+
require "logger"
|
32
32
|
require "toys/utils/terminal"
|
33
|
+
@terminal = output || $stderr
|
33
34
|
@terminal = Terminal.new(output: @terminal) unless @terminal.is_a?(Terminal)
|
34
35
|
@log_header_severity_styles = {
|
35
36
|
"FATAL" => [:bright_magenta, :bold, :underline],
|
data/lib/toys/utils/terminal.rb
CHANGED
@@ -1,8 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require "stringio"
|
4
|
-
require "monitor"
|
5
|
-
|
6
3
|
begin
|
7
4
|
require "io/console"
|
8
5
|
rescue ::LoadError
|
@@ -116,6 +113,7 @@ module Toys
|
|
116
113
|
# setting is inferred from whether the output has a tty.
|
117
114
|
#
|
118
115
|
def initialize(input: $stdin, output: $stdout, styled: nil)
|
116
|
+
require "monitor"
|
119
117
|
@input = input
|
120
118
|
@output = output
|
121
119
|
@styled =
|
data/lib/toys/utils/xdg.rb
CHANGED
@@ -1,7 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require "toys/compat"
|
4
|
-
|
5
3
|
module Toys
|
6
4
|
module Utils
|
7
5
|
##
|
@@ -50,6 +48,8 @@ module Toys
|
|
50
48
|
# you can omit this argument, as it will default to `::ENV`.
|
51
49
|
#
|
52
50
|
def initialize(env: ::ENV)
|
51
|
+
require "fileutils"
|
52
|
+
require "toys/compat"
|
53
53
|
@env = env
|
54
54
|
end
|
55
55
|
|
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.15.
|
4
|
+
version: 0.15.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: 2023-10-
|
11
|
+
date: 2023-10-17 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Toys-Core is the command line tool framework underlying Toys. It can
|
14
14
|
be used to create command line executables using the Toys DSL and classes.
|
@@ -79,10 +79,10 @@ homepage: https://github.com/dazuma/toys
|
|
79
79
|
licenses:
|
80
80
|
- MIT
|
81
81
|
metadata:
|
82
|
-
changelog_uri: https://dazuma.github.io/toys/gems/toys-core/v0.15.
|
82
|
+
changelog_uri: https://dazuma.github.io/toys/gems/toys-core/v0.15.2/file.CHANGELOG.html
|
83
83
|
source_code_uri: https://github.com/dazuma/toys/tree/main/toys-core
|
84
84
|
bug_tracker_uri: https://github.com/dazuma/toys/issues
|
85
|
-
documentation_uri: https://dazuma.github.io/toys/gems/toys-core/v0.15.
|
85
|
+
documentation_uri: https://dazuma.github.io/toys/gems/toys-core/v0.15.2
|
86
86
|
post_install_message:
|
87
87
|
rdoc_options: []
|
88
88
|
require_paths:
|