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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fcf2b7517a237c398d900d9635fcb1cd95b00afff0df2e1e87253274ce038109
4
- data.tar.gz: 291eb95c1deaeae4056f553f43dae8af016e89269c6c3f3d8e7e1872ce73c777
3
+ metadata.gz: 840dff30d3a85e5af4cdbbdaa77498491efe89e473608e4e130e75d9a49a249c
4
+ data.tar.gz: 3ea3662f0fbf2b8a28063435ef0f4b28300e9b8b4664ab4a1c7d5dd5b6a8e77f
5
5
  SHA512:
6
- metadata.gz: 82c2f97733439d9af71c3636a01b972c5ac890160fd67a7b6cd5959efd3f30d4eeac8fc72b01e93c179d02f21cfbb60e4e21d5978633e79ce07972719ade80a6
7
- data.tar.gz: 696580a980190abc08686545f0ed44d8b145508aa3fc8094fbacb941125df312a0848819ce608515a481753edeb4c0924b5b8c5af872c2c81f08db605394b18c
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
@@ -9,7 +9,7 @@ module Toys
9
9
  # Current version of Toys core.
10
10
  # @return [String]
11
11
  #
12
- VERSION = "0.15.0"
12
+ VERSION = "0.15.2"
13
13
  end
14
14
 
15
15
  ##
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 = ::Monitor.new
479
+ @git_cache_mutex = ::Mutex.new
481
480
  @default_git_cache = nil
482
481
 
483
482
  ##
@@ -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
- ::Date => date_converter,
568
- ::DateTime => datetime_converter,
569
- ::Float => float_converter,
570
- ::Integer => integer_converter,
571
- ::Regexp => regexp_converter,
572
- ::Symbol => symbol_converter,
573
- ::Time => time_converter,
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
- require "toys/utils/terminal"
252
- @terminal ||= Utils::Terminal.new(output: @stream, styled: @styled_output)
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)
@@ -830,6 +830,8 @@ module Toys
830
830
  end
831
831
 
832
832
  on_initialize do |**opts|
833
+ require "rbconfig"
834
+ require "shellwords"
833
835
  require "toys/utils/exec"
834
836
  context = self
835
837
  opts = Exec._setup_exec_opts(opts, context)
@@ -1,7 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "fileutils"
4
-
5
3
  module Toys
6
4
  module StandardMixins
7
5
  ##
@@ -20,6 +18,7 @@ module Toys
20
18
  # @private
21
19
  #
22
20
  def self.included(mod)
21
+ require "fileutils"
23
22
  mod.include(::FileUtils)
24
23
  end
25
24
  end
@@ -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 ||= Utils::Gems.new(**@__gems_opts)
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?
@@ -1,7 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "fileutils"
4
-
5
3
  module Toys
6
4
  module StandardMixins
7
5
  ##
@@ -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::Tool::Settings]
285
+ # @return [Toys::ToolDefinition::Settings]
288
286
  #
289
287
  attr_reader :settings
290
288
 
@@ -1,7 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "shellwords"
4
-
5
3
  module Toys
6
4
  module Utils
7
5
  ##
@@ -21,6 +19,7 @@ module Toys
21
19
  # @param cli [Toys::CLI] The CLI.
22
20
  #
23
21
  def initialize(cli)
22
+ require "shellwords"
24
23
  @cli = cli
25
24
  end
26
25
 
@@ -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
 
@@ -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
@@ -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
 
@@ -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
@@ -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 ||= Exec.new
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
- @terminal = output || $stderr
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],
@@ -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 =
@@ -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.0
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-13 00:00:00.000000000 Z
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.0/file.CHANGELOG.html
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.0
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: