yorha 1.9.4
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 +7 -0
- data/CHANGELOG.md +58 -0
- data/LICENSE.txt +21 -0
- data/README.md +65 -0
- data/exe/yorha +19 -0
- data/lib/yorha/access_point.rb +280 -0
- data/lib/yorha/banner.rb +87 -0
- data/lib/yorha/black_box.rb +187 -0
- data/lib/yorha/chips.rb +317 -0
- data/lib/yorha/cli.rb +280 -0
- data/lib/yorha/config.rb +208 -0
- data/lib/yorha/core_ext.rb +61 -0
- data/lib/yorha/errors.rb +77 -0
- data/lib/yorha/machine.rb +108 -0
- data/lib/yorha/palette.rb +86 -0
- data/lib/yorha/pod.rb +200 -0
- data/lib/yorha/quotes.rb +71 -0
- data/lib/yorha/render.rb +94 -0
- data/lib/yorha/terminal.rb +192 -0
- data/lib/yorha/version.rb +11 -0
- data/lib/yorha/widgets.rb +384 -0
- data/lib/yorha.rb +139 -0
- metadata +69 -0
data/lib/yorha.rb
ADDED
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# Main public entrypoint for the YoRHa gem.
|
|
4
|
+
#
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
# ---------------------------------------------------------------------
|
|
8
|
+
# Step 1: the three files every program needs.
|
|
9
|
+
# ---------------------------------------------------------------------
|
|
10
|
+
|
|
11
|
+
# Defines Yorha::VERSION, returned by Yorha.version.
|
|
12
|
+
require_relative "yorha/version"
|
|
13
|
+
|
|
14
|
+
# Defines Yorha::Error and every subclass the gem raises on purpose.
|
|
15
|
+
require_relative "yorha/errors"
|
|
16
|
+
|
|
17
|
+
# Defines Yorha::Config, the settings object behind Yorha.config.
|
|
18
|
+
require_relative "yorha/config"
|
|
19
|
+
|
|
20
|
+
require_relative "yorha/quotes"
|
|
21
|
+
require_relative "yorha/widgets"
|
|
22
|
+
|
|
23
|
+
# ---------------------------------------------------------------------
|
|
24
|
+
# Step 2: the top-level API.
|
|
25
|
+
# ---------------------------------------------------------------------
|
|
26
|
+
|
|
27
|
+
module Yorha
|
|
28
|
+
class << self
|
|
29
|
+
# Returns the gem's current semantic version.
|
|
30
|
+
# @return [String] version defined by Yorha::VERSION
|
|
31
|
+
# @api public
|
|
32
|
+
def version
|
|
33
|
+
VERSION
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
# Returns the current process-wide frozen configuration.
|
|
37
|
+
|
|
38
|
+
def config
|
|
39
|
+
@config ||= Config.default
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
# Applies changes through a mutable draft, then publishes a snapshot.
|
|
43
|
+
|
|
44
|
+
def configure
|
|
45
|
+
unless block_given?
|
|
46
|
+
raise ArgumentError, "A configuration block is required"
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
draft = config.dup
|
|
50
|
+
|
|
51
|
+
yield draft
|
|
52
|
+
|
|
53
|
+
@config = draft.snapshot
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
# Replaces the current settings with a fresh default snapshot.
|
|
57
|
+
#
|
|
58
|
+
|
|
59
|
+
def reset_config!
|
|
60
|
+
@config = Config.default
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
# Installs a feature (a "chip") in the default chip registry.
|
|
64
|
+
#
|
|
65
|
+
|
|
66
|
+
def install_chip(name, cost:, description: nil, &on_install)
|
|
67
|
+
Chips.install(name, cost: cost, description: description, &on_install)
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
# Checks whether the default registry contains a feature.
|
|
71
|
+
#
|
|
72
|
+
# Shortcut for Yorha::Chips.installed?.
|
|
73
|
+
|
|
74
|
+
def chip_installed?(name)
|
|
75
|
+
Chips.installed?(name)
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
def remove_chip(name)
|
|
80
|
+
Chips.remove(name)
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
def black_box(unit: nil, io: nil, frames: 6, &block)
|
|
85
|
+
raise ArgumentError, "a block is required" unless block
|
|
86
|
+
|
|
87
|
+
begin
|
|
88
|
+
block.call
|
|
89
|
+
rescue StandardError => exception
|
|
90
|
+
stream = io || config.err
|
|
91
|
+
|
|
92
|
+
begin
|
|
93
|
+
stream.write(BlackBox.report(exception, unit: unit, io: stream, frames: frames))
|
|
94
|
+
rescue StandardError, ScriptError
|
|
95
|
+
stream.write(exception.full_message)
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
raise
|
|
99
|
+
end
|
|
100
|
+
end
|
|
101
|
+
end
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
# ---------------------------------------------------------------------
|
|
105
|
+
# Step 3: components, registered in layer order and loaded on first use.
|
|
106
|
+
|
|
107
|
+
# ---------------------------------------------------------------------
|
|
108
|
+
|
|
109
|
+
module Yorha
|
|
110
|
+
# Absolute path of the folder that holds the component files. Using
|
|
111
|
+
# absolute paths means Ruby opens each file directly and never has
|
|
112
|
+
# to search its load path for it.
|
|
113
|
+
components = File.join(__dir__, "yorha")
|
|
114
|
+
|
|
115
|
+
# Foundation: what the output stream can display, and how to colour it.
|
|
116
|
+
autoload :Terminal, "#{components}/terminal"
|
|
117
|
+
autoload :Palette, "#{components}/palette"
|
|
118
|
+
autoload :Render, "#{components}/render"
|
|
119
|
+
|
|
120
|
+
# Presentation: output built on Render. Nothing is drawn until a
|
|
121
|
+
# method is called.
|
|
122
|
+
autoload :Widgets, "#{components}/widgets"
|
|
123
|
+
autoload :Banner, "#{components}/banner"
|
|
124
|
+
autoload :Machine, "#{components}/machine"
|
|
125
|
+
|
|
126
|
+
# Systems: chips, the Pod logger, crash reports, and saved records.
|
|
127
|
+
# black_box.rb defines both BlackBox and CrashHandler, so both names
|
|
128
|
+
# point at it. Loading it does not install the crash handler; that
|
|
129
|
+
# needs Yorha::CrashHandler.install.
|
|
130
|
+
autoload :Chips, "#{components}/chips"
|
|
131
|
+
autoload :Pod, "#{components}/pod"
|
|
132
|
+
autoload :BlackBox, "#{components}/black_box"
|
|
133
|
+
autoload :CrashHandler, "#{components}/black_box"
|
|
134
|
+
autoload :AccessPoint, "#{components}/access_point"
|
|
135
|
+
|
|
136
|
+
# Integration: the command dispatcher used by the yorha executable.
|
|
137
|
+
# Loading it defines Yorha::CLI and runs no command.
|
|
138
|
+
autoload :CLI, "#{components}/cli"
|
|
139
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: yorha
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 1.9.4
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- AstralCloud_SZA
|
|
8
|
+
bindir: exe
|
|
9
|
+
cert_chain: []
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
11
|
+
dependencies: []
|
|
12
|
+
description: |-
|
|
13
|
+
An unofficial fan-made Ruby toolkit providing terminal palettes,
|
|
14
|
+
renderers, banners, widgets, and themed command-line tools.
|
|
15
|
+
email:
|
|
16
|
+
- NRV_EVA95@protonmail.com
|
|
17
|
+
executables:
|
|
18
|
+
- yorha
|
|
19
|
+
extensions: []
|
|
20
|
+
extra_rdoc_files: []
|
|
21
|
+
files:
|
|
22
|
+
- CHANGELOG.md
|
|
23
|
+
- LICENSE.txt
|
|
24
|
+
- README.md
|
|
25
|
+
- exe/yorha
|
|
26
|
+
- lib/yorha.rb
|
|
27
|
+
- lib/yorha/access_point.rb
|
|
28
|
+
- lib/yorha/banner.rb
|
|
29
|
+
- lib/yorha/black_box.rb
|
|
30
|
+
- lib/yorha/chips.rb
|
|
31
|
+
- lib/yorha/cli.rb
|
|
32
|
+
- lib/yorha/config.rb
|
|
33
|
+
- lib/yorha/core_ext.rb
|
|
34
|
+
- lib/yorha/errors.rb
|
|
35
|
+
- lib/yorha/machine.rb
|
|
36
|
+
- lib/yorha/palette.rb
|
|
37
|
+
- lib/yorha/pod.rb
|
|
38
|
+
- lib/yorha/quotes.rb
|
|
39
|
+
- lib/yorha/render.rb
|
|
40
|
+
- lib/yorha/terminal.rb
|
|
41
|
+
- lib/yorha/version.rb
|
|
42
|
+
- lib/yorha/widgets.rb
|
|
43
|
+
homepage: https://github.com/AstralCloud-SZA/YorHa_GemBundle
|
|
44
|
+
licenses:
|
|
45
|
+
- MIT
|
|
46
|
+
metadata:
|
|
47
|
+
source_code_uri: https://github.com/AstralCloud-SZA/YorHa_GemBundle/tree/master/yorha
|
|
48
|
+
changelog_uri: https://github.com/AstralCloud-SZA/YorHa_GemBundle/blob/master/yorha/CHANGELOG.md
|
|
49
|
+
bug_tracker_uri: https://github.com/AstralCloud-SZA/YorHa_GemBundle/issues
|
|
50
|
+
allowed_push_host: https://rubygems.org
|
|
51
|
+
rubygems_mfa_required: 'true'
|
|
52
|
+
rdoc_options: []
|
|
53
|
+
require_paths:
|
|
54
|
+
- lib
|
|
55
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
56
|
+
requirements:
|
|
57
|
+
- - ">="
|
|
58
|
+
- !ruby/object:Gem::Version
|
|
59
|
+
version: '3.3'
|
|
60
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
61
|
+
requirements:
|
|
62
|
+
- - ">="
|
|
63
|
+
- !ruby/object:Gem::Version
|
|
64
|
+
version: '0'
|
|
65
|
+
requirements: []
|
|
66
|
+
rubygems_version: 3.6.9
|
|
67
|
+
specification_version: 4
|
|
68
|
+
summary: 'A NieR: Automata-inspired visual and utility toolkit for Ruby.'
|
|
69
|
+
test_files: []
|