toys-core 0.14.4 → 0.14.6
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/core.rb +1 -1
- data/lib/toys/standard_mixins/git_cache.rb +8 -8
- data/lib/toys/standard_mixins/pager.rb +9 -6
- data/lib/toys/utils/git_cache.rb +6 -6
- data/lib/toys/utils/pager.rb +24 -4
- 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: 4a49ffadd96ca26cf194b2c779f91704490fe6f345e5eb306638f61215e15920
|
4
|
+
data.tar.gz: 79bfe7f58285f0881a16383ffb0ba5f6fcad79b6001e4efd2effea178d1cedd7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d3d8bc7d78af759121c749b06454b585404c2093342a7476655e8ff3ac1f5e7d52fc729402e5669b42e75820babdd7f997f36a53d462276f2c26da5eff83fd5c
|
7
|
+
data.tar.gz: f04c5b0fdcbeb344f6733611bf134230586fc35a3fe73ffddeaba4aa602c1ff86726b2f1cd832e2a00dfbded1b30a59eaa5851c75df06e908b126682da627a81
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,13 @@
|
|
1
1
|
# Release History
|
2
2
|
|
3
|
+
### v0.14.6 / 2023-06-29
|
4
|
+
|
5
|
+
* FIXED: Fixed a GitCache exception when loading a repository containing a broken symlink
|
6
|
+
|
7
|
+
### v0.14.5 / 2023-03-20
|
8
|
+
|
9
|
+
* FIXED: Rescue broken pipe errors by default when running a pager
|
10
|
+
|
3
11
|
### v0.14.4 / 2023-01-23
|
4
12
|
|
5
13
|
* FIXED: Fixed missing require when "toys/utils/xdg" or "toys/utils/git_cache" is required without the rest of toys-core
|
data/lib/toys/core.rb
CHANGED
@@ -8,16 +8,16 @@ module Toys
|
|
8
8
|
# This mixin provides an instance of {Toys::Utils::GitCache}, providing
|
9
9
|
# cached access to files from a remote git repo.
|
10
10
|
#
|
11
|
-
#
|
11
|
+
# @example
|
12
12
|
#
|
13
|
-
#
|
13
|
+
# include :git_cache
|
14
14
|
#
|
15
|
-
#
|
16
|
-
#
|
17
|
-
#
|
18
|
-
#
|
19
|
-
#
|
20
|
-
#
|
15
|
+
# def run
|
16
|
+
# # Pull and cache the HEAD commit from the Toys repo.
|
17
|
+
# dir = git_cache.get("https://github.com/dazuma/toys.git")
|
18
|
+
# # Display the contents of the readme file.
|
19
|
+
# puts File.read(File.join(dir, "README.md"))
|
20
|
+
# end
|
21
21
|
#
|
22
22
|
module GitCache
|
23
23
|
include Mixin
|
@@ -8,6 +8,10 @@ module Toys
|
|
8
8
|
# This mixin provides an instance of {Toys::Utils::Pager}, which invokes
|
9
9
|
# an external pager for output.
|
10
10
|
#
|
11
|
+
# You can also pass additional keyword arguments to the `include` directive
|
12
|
+
# to configure the pager object. These will be passed on to
|
13
|
+
# {Toys::Utils::Pager#initialize}.
|
14
|
+
#
|
11
15
|
# @example
|
12
16
|
#
|
13
17
|
# include :pager
|
@@ -44,13 +48,12 @@ module Toys
|
|
44
48
|
self[KEY].start(&block)
|
45
49
|
end
|
46
50
|
|
47
|
-
on_initialize do
|
51
|
+
on_initialize do |**opts|
|
48
52
|
require "toys/utils/pager"
|
49
|
-
exec_service
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
self[KEY] = Utils::Pager.new(exec_service: exec_service)
|
53
|
+
if !opts.key?(:exec_service) && defined?(::Toys::StandardMixins::Exec)
|
54
|
+
opts[:exec_service] = self[::Toys::StandardMixins::Exec::KEY]
|
55
|
+
end
|
56
|
+
self[KEY] = Utils::Pager.new(**opts)
|
54
57
|
end
|
55
58
|
end
|
56
59
|
end
|
data/lib/toys/utils/git_cache.rb
CHANGED
@@ -402,7 +402,7 @@ module Toys
|
|
402
402
|
Array(remotes).map do |remote|
|
403
403
|
dir = repo_base_dir_for(remote)
|
404
404
|
if ::File.directory?(dir)
|
405
|
-
::FileUtils.chmod_R("u+w", dir)
|
405
|
+
::FileUtils.chmod_R("u+w", dir, force: true)
|
406
406
|
::FileUtils.rm_rf(dir)
|
407
407
|
remote
|
408
408
|
end
|
@@ -568,9 +568,9 @@ module Toys
|
|
568
568
|
source_path = ::File.join(dir, sha)
|
569
569
|
unless repo_lock.source_exists?(sha, path)
|
570
570
|
::FileUtils.mkdir_p(source_path)
|
571
|
-
::FileUtils.chmod_R("u+w", source_path)
|
571
|
+
::FileUtils.chmod_R("u+w", source_path, force: true)
|
572
572
|
copy_from_repo(repo_path, source_path, sha, path)
|
573
|
-
::FileUtils.chmod_R("a-w", source_path)
|
573
|
+
::FileUtils.chmod_R("a-w", source_path, force: true)
|
574
574
|
end
|
575
575
|
repo_lock.access_source!(sha, path)
|
576
576
|
path == "." ? source_path : ::File.join(source_path, path)
|
@@ -579,7 +579,7 @@ module Toys
|
|
579
579
|
def copy_files(dir, sha, path, repo_lock, into)
|
580
580
|
repo_path = ::File.join(dir, REPO_DIR_NAME)
|
581
581
|
::FileUtils.mkdir_p(into)
|
582
|
-
::FileUtils.chmod_R("u+w", into)
|
582
|
+
::FileUtils.chmod_R("u+w", into, force: true)
|
583
583
|
Compat.dir_children(into).each { |child| ::FileUtils.rm_rf(::File.join(into, child)) }
|
584
584
|
result = copy_from_repo(repo_path, into, sha, path)
|
585
585
|
repo_lock.access_repo!
|
@@ -594,7 +594,7 @@ module Toys
|
|
594
594
|
to_path = ::File.join(into, entry)
|
595
595
|
unless ::File.exist?(to_path)
|
596
596
|
from_path = ::File.join(repo_dir, entry)
|
597
|
-
::FileUtils.
|
597
|
+
::FileUtils.copy_entry(from_path, to_path)
|
598
598
|
end
|
599
599
|
end
|
600
600
|
into
|
@@ -603,7 +603,7 @@ module Toys
|
|
603
603
|
unless ::File.exist?(to_path)
|
604
604
|
from_path = ::File.join(repo_dir, path)
|
605
605
|
::FileUtils.mkdir_p(::File.dirname(to_path))
|
606
|
-
::FileUtils.
|
606
|
+
::FileUtils.copy_entry(from_path, to_path)
|
607
607
|
end
|
608
608
|
to_path
|
609
609
|
end
|
data/lib/toys/utils/pager.rb
CHANGED
@@ -34,12 +34,18 @@ module Toys
|
|
34
34
|
# executing commands, or `nil` (the default) to use a default.
|
35
35
|
# @param fallback_io [IO] An IO-like object to write to if the pager is
|
36
36
|
# disabled. Defaults to `$stdout`.
|
37
|
+
# @param rescue_broken_pipes [boolean] If `true` (the default), broken
|
38
|
+
# pipes are silently rescued. This prevents the exception from
|
39
|
+
# propagating out if the pager is interrupted. Set this parameter to
|
40
|
+
# `false` to disable this behavior.
|
37
41
|
#
|
38
|
-
def initialize(command: true, exec_service: nil, fallback_io: nil
|
42
|
+
def initialize(command: true, exec_service: nil, fallback_io: nil,
|
43
|
+
rescue_broken_pipes: true)
|
39
44
|
@command = command == true ? Pager.default_command : command
|
40
45
|
@command ||= nil
|
41
46
|
@exec_service = exec_service || Pager.default_exec_service
|
42
47
|
@fallback_io = fallback_io || $stdout
|
48
|
+
@rescue_broken_pipes = rescue_broken_pipes
|
43
49
|
end
|
44
50
|
|
45
51
|
##
|
@@ -60,7 +66,11 @@ module Toys
|
|
60
66
|
def start
|
61
67
|
if @command
|
62
68
|
result = @exec_service.exec(@command, in: :controller) do |controller|
|
63
|
-
|
69
|
+
begin
|
70
|
+
yield controller.in if controller.pid
|
71
|
+
rescue ::Errno::EPIPE => e
|
72
|
+
raise e unless @rescue_broken_pipes
|
73
|
+
end
|
64
74
|
end
|
65
75
|
return result.exit_code unless result.failed?
|
66
76
|
end
|
@@ -100,6 +110,10 @@ module Toys
|
|
100
110
|
# executing commands, or `nil` (the default) to use a default.
|
101
111
|
# @param fallback_io [IO] An IO-like object to write to if the pager is
|
102
112
|
# disabled. Defaults to `$stdout`.
|
113
|
+
# @param rescue_broken_pipes [boolean] If `true` (the default), broken
|
114
|
+
# pipes are silently rescued. This prevents the exception from
|
115
|
+
# propagating out if the pager is interrupted. Set this parameter to
|
116
|
+
# `false` to disable this behavior.
|
103
117
|
# @return [Integer] The exit code of the pager process.
|
104
118
|
#
|
105
119
|
# @example
|
@@ -107,8 +121,14 @@ module Toys
|
|
107
121
|
# Toys::Utils::Pager.start do |io|
|
108
122
|
# io.puts "A long string\n"
|
109
123
|
# end
|
110
|
-
|
111
|
-
|
124
|
+
#
|
125
|
+
def start(command: true,
|
126
|
+
exec_service: nil,
|
127
|
+
fallback_io: nil,
|
128
|
+
rescue_broken_pipes: true,
|
129
|
+
&block)
|
130
|
+
pager = new(command: command, exec_service: exec_service, fallback_io: fallback_io,
|
131
|
+
rescue_broken_pipes: rescue_broken_pipes)
|
112
132
|
pager.start(&block)
|
113
133
|
end
|
114
134
|
|
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.14.
|
4
|
+
version: 0.14.6
|
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-
|
11
|
+
date: 2023-06-29 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.
|
@@ -78,10 +78,10 @@ homepage: https://github.com/dazuma/toys
|
|
78
78
|
licenses:
|
79
79
|
- MIT
|
80
80
|
metadata:
|
81
|
-
changelog_uri: https://dazuma.github.io/toys/gems/toys-core/v0.14.
|
81
|
+
changelog_uri: https://dazuma.github.io/toys/gems/toys-core/v0.14.6/file.CHANGELOG.html
|
82
82
|
source_code_uri: https://github.com/dazuma/toys/tree/main/toys-core
|
83
83
|
bug_tracker_uri: https://github.com/dazuma/toys/issues
|
84
|
-
documentation_uri: https://dazuma.github.io/toys/gems/toys-core/v0.14.
|
84
|
+
documentation_uri: https://dazuma.github.io/toys/gems/toys-core/v0.14.6
|
85
85
|
post_install_message:
|
86
86
|
rdoc_options: []
|
87
87
|
require_paths:
|