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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 3c1ff413759b7e9f9c43b33d7e638d0fd938259a007994b7f1f1e96f6d24f717
4
+ data.tar.gz: a8f1a1ac68633fc9e76dda633c8886cbca78c6f88dacee5ee18b4c3c55d042ba
5
+ SHA512:
6
+ metadata.gz: 3c868723e9c67bc76945f4abdecd33c25c08d68293cfd40ed1c480d7f652118dbf71c536b503b5779d81f1e94148c8f543c90efec13ec412c9920219a4e93b40
7
+ data.tar.gz: ee06d1f54d67263e85ea9a1a31ede71eda7f7c7c65f25d5bc3477f7887f4df68671e5cd809878cd9e719b8116ad3f67034f8268ac2bd90429fe5aa17315b8279
data/CHANGELOG.md ADDED
@@ -0,0 +1,58 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project are documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ ## [Unreleased]
9
+
10
+ ## [1.9.4] - 2026-12-04
11
+
12
+ First release published through RubyGems Trusted Publishing. Versions 1.8.3
13
+ through 1.9.3 were tagged or prepared but never published, so their changes
14
+ ship here.
15
+
16
+ ### Added
17
+
18
+ - `Yorha::Widgets.table`: bordered tables with header support, padding for
19
+ ragged rows, and column widths measured in terminal columns.
20
+ - `Yorha::Banner.boot` and a `boot` route in the command line interface.
21
+ - Quotes data module and specs.
22
+ - GitHub Actions CI matrix: Ruby 3.3, 3.4, and 4.0 on Ubuntu and Windows.
23
+ - Release workflow using RubyGems Trusted Publishing, with no stored API key.
24
+ It checks that the tag is on `master`, that the tag matches the gem version,
25
+ and that this changelog has an entry for the version before it publishes.
26
+ - Rewritten README covering installation, configuration, widgets, the command
27
+ line, colour and Unicode detection, development, and releasing.
28
+ - This changelog.
29
+
30
+ ### Changed
31
+
32
+ - Workflows moved to the repository root, branch set to `master`, and the
33
+ gem's working directory set to `yorha`.
34
+ - Release workflow renamed to `release.yml`.
35
+ - Gemspec `source_code_uri` and `changelog_uri` now point at the `master`
36
+ branch and the `yorha` folder, and a `bug_tracker_uri` was added.
37
+
38
+ ### Fixed
39
+
40
+ - Display width no longer counts spaces as wide characters. The wide-character
41
+ pattern was written as a multi-line extended regular expression, and Ruby
42
+ treats whitespace inside a bracket class as literal, so boxes and tables
43
+ came out too narrow whenever a row contained spaces.
44
+ - `Gemfile.lock` now lists the `x86_64-linux` platform, so frozen installs
45
+ succeed on Linux runners.
46
+ - The release workflow now runs from the `yorha` directory, so it can find
47
+ `lib/yorha/version.rb`.
48
+ - The progress bar spec escaped the glyph before scanning, which matched the
49
+ wrong text when the ASCII glyph was `#`.
50
+
51
+ ## [1.8.2]
52
+
53
+ Tagged on an earlier commit, before the workflows were moved. No release notes
54
+ were recorded for this version.
55
+
56
+ [Unreleased]: https://github.com/AstralCloud-SZA/YorHa_GemBundle/compare/v1.9.4...HEAD
57
+ [1.9.4]: https://github.com/AstralCloud-SZA/YorHa_GemBundle/compare/v1.8.2...v1.9.4
58
+ [1.8.2]: https://github.com/AstralCloud-SZA/YorHa_GemBundle/releases/tag/v1.8.2
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 AstralCloud_SZA
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,65 @@
1
+ # YoRHa
2
+
3
+ An unofficial fan-made NieR: Automata-inspired visual and utility toolkit
4
+ for Ruby applications.
5
+
6
+ ## Project status
7
+
8
+ YoRHa is currently in early development. The first milestone focuses on the
9
+ terminal visual foundation:
10
+
11
+ - Terminal capability detection
12
+ - Semantic color palettes
13
+ - ANSI rendering
14
+ - Unicode and ASCII glyphs
15
+ - Themed widgets
16
+ - Boot banners
17
+
18
+ ## Requirements
19
+
20
+ - Ruby 3.3 or newer
21
+ - Bundler
22
+
23
+ The project is currently being developed with Ruby 3.4.9.
24
+
25
+ ## Development setup
26
+
27
+ Install the development dependencies:
28
+
29
+ ```shell
30
+ bundle install
31
+ ```
32
+
33
+ Run the test suite:
34
+
35
+ ```shell
36
+ bundle exec rspec
37
+ ```
38
+
39
+ Run the default Rake task:
40
+
41
+ ```shell
42
+ bundle exec rake
43
+ ```
44
+
45
+ Build the gem locally:
46
+
47
+ ```shell
48
+ bundle exec rake build
49
+ ```
50
+
51
+ ## Basic usage
52
+
53
+ ```ruby
54
+ require "yorha"
55
+
56
+ puts Yorha.version
57
+ ```
58
+
59
+ ## Disclaimer
60
+
61
+ This is an unofficial fan-made project. It is not associated with or endorsed
62
+ by Square Enix.
63
+
64
+ The source code and original visual implementation in this repository are
65
+ released under the MIT License.
data/exe/yorha ADDED
@@ -0,0 +1,19 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ # Command-line launcher for the YoRHa gem.
5
+
6
+
7
+ lib = File.expand_path("../lib", __dir__)
8
+ $LOAD_PATH.unshift(lib) if File.directory?(lib) && !$LOAD_PATH.include?(lib)
9
+
10
+ require "yorha"
11
+ require "yorha/cli"
12
+
13
+ begin
14
+ exit(Yorha::CLI.new.run(ARGV))
15
+ rescue Interrupt
16
+ exit(130)
17
+ rescue Errno::EPIPE
18
+ exit(0)
19
+ end
@@ -0,0 +1,280 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Named-record persistence (Systems layer).
4
+ #
5
+ # Design document reference: section 5.9, Yorha::AccessPoint.
6
+ #
7
+ # Responsibility:
8
+ # Tiny named-record persistence for scripts and dev tools: save,
9
+ # load, list, and delete small state records under a project.
10
+ #
11
+ # This file does not:
12
+ # - Touch disk before AccessPoint.connect is called (principle P2).
13
+ # - Load YAML through anything but Psych.safe_load.
14
+ # - Print flavour lines on non-TTY streams, or when quiet: true.
15
+ #
16
+ # Storage layout: one file per record (.yorha/access_point/name.yml)
17
+ # rather than one blob, so saves never rewrite the world and git
18
+ # diffs stay sane. Marshal is opt-in and only for trusted input.
19
+
20
+ require_relative "errors"
21
+ require_relative "version"
22
+
23
+ module Yorha
24
+ class AccessPoint
25
+ # Immutable summary of one stored record.
26
+ #
27
+ # @api public
28
+ Record = Data.define(:name, :saved_at, :yorha_version)
29
+
30
+ # Default storage directory relative to the working directory.
31
+ DEFAULT_PATH = "./.yorha/access_point"
32
+
33
+ # Supported serialisation formats.
34
+ FORMATS = %i[yaml marshal].freeze
35
+
36
+ @current = nil
37
+
38
+ private_class_method :new
39
+
40
+ class << self
41
+ # Opens the access point at a path, creating the directory.
42
+ #
43
+ # This is the explicit entry point (principle P2): nothing
44
+ # touches disk until it is called.
45
+ #
46
+ # @param path [String] storage directory
47
+ # @param format [Symbol] :yaml (default, safe) or :marshal
48
+ # (trusted input only)
49
+ # @param quiet [Boolean] suppress flavour lines even on a TTY
50
+ # @return [AccessPoint] the connected instance
51
+ # @raise [ArgumentError] for an unsupported format
52
+ # @api public
53
+ def connect(path = DEFAULT_PATH, format: :yaml, quiet: false)
54
+ unless FORMATS.include?(format)
55
+ raise ArgumentError, "format must be one of #{FORMATS.join(', ')}"
56
+ end
57
+
58
+ require "fileutils"
59
+ FileUtils.mkdir_p(path)
60
+
61
+ @current = new(path: path, format: format, quiet: quiet)
62
+ @current.flavour("ACCESS POINT ESTABLISHED")
63
+
64
+ @current
65
+ end
66
+
67
+ # Returns the connected instance.
68
+ #
69
+ # @return [AccessPoint]
70
+ # @raise [NotConnectedError] before connect is called
71
+ # @api public
72
+ def current
73
+ raise NotConnectedError, "AccessPoint.connect was not called" if @current.nil?
74
+
75
+ @current
76
+ end
77
+
78
+ # Reports whether an access point is connected.
79
+ #
80
+ # @return [Boolean]
81
+ # @api public
82
+ def connected?
83
+ !@current.nil?
84
+ end
85
+
86
+ # Clears the current connection. Intended for specs.
87
+ #
88
+ # @return [AccessPoint, nil] the previous instance
89
+ # @api public
90
+ def disconnect
91
+ previous = @current
92
+ @current = nil
93
+ previous
94
+ end
95
+ end
96
+
97
+ # Creates an instance; prefer {AccessPoint.connect}.
98
+ #
99
+ # @param path [String] storage directory
100
+ # @param format [Symbol] :yaml or :marshal
101
+ # @param quiet [Boolean] suppress flavour lines
102
+ # @api private
103
+ def initialize(path:, format:, quiet:)
104
+ @path = path
105
+ @format = format
106
+ @ext = format == :yaml ? ".yml" : ".marshal"
107
+ @io = Yorha.config.io
108
+ @quiet = quiet
109
+ end
110
+
111
+ # Saves a record under a name.
112
+ #
113
+ # @param name [String, Symbol] record identifier
114
+ # @param data [Object] payload; a Hash with Symbol keys and Time
115
+ # values round-trips through YAML
116
+ # @return [Record]
117
+ # @raise [ArgumentError] for an invalid name
118
+ # @raise [CorruptRecordError] never on save; write errors raise
119
+ # the underlying Errno exception untouched
120
+ # @api public
121
+ def save(name, data)
122
+ key = normalize_name(name)
123
+
124
+ wrapper = {
125
+ name: key,
126
+ saved_at: Time.now.utc,
127
+ yorha_version: Yorha::VERSION,
128
+ data: data
129
+ }
130
+
131
+ write_wrapper(key, wrapper)
132
+ flavour("RECORDING #{key}")
133
+
134
+ record_from(wrapper)
135
+ end
136
+
137
+ # Loads a record's payload.
138
+ #
139
+ # @param name [String, Symbol] record identifier
140
+ # @return [Object, nil] the saved payload, or nil when absent
141
+ # @raise [CorruptRecordError] when the stored file is unreadable
142
+ # @api public
143
+ def load(name)
144
+ key = normalize_name(name)
145
+ file = file_for(key)
146
+
147
+ return nil unless File.exist?(file)
148
+
149
+ wrapper = read_wrapper(file)
150
+ flavour("RETRIEVING #{key}")
151
+
152
+ wrapper[:data]
153
+ end
154
+
155
+ # Deletes a record.
156
+ #
157
+ # @param name [String, Symbol] record identifier
158
+ # @return [Record, nil] the removed record, or nil when absent
159
+ # @raise [CorruptRecordError] when the stored file is unreadable
160
+ # @api public
161
+ def delete(name)
162
+ key = normalize_name(name)
163
+ file = file_for(key)
164
+
165
+ return nil unless File.exist?(file)
166
+
167
+ wrapper = read_wrapper(file)
168
+ File.delete(file)
169
+
170
+ record_from(wrapper)
171
+ end
172
+
173
+ # Lists every stored record, sorted by name.
174
+ #
175
+ # @return [Array<Record>]
176
+ # @raise [CorruptRecordError] when any stored file is unreadable
177
+ # @api public
178
+ def records
179
+ Dir[File.join(@path, "*#{@ext}")].sort.map do |file|
180
+ record_from(read_wrapper(file))
181
+ end
182
+ end
183
+
184
+ # Writes a flavour line to the TTY, when not silenced.
185
+ #
186
+ # Flavour lines are decoration, so they are skipped entirely on
187
+ # non-TTY streams; piped output stays clean.
188
+ #
189
+ # @param text [String]
190
+ # @return [void]
191
+ # @api private
192
+ def flavour(text)
193
+ return if @quiet
194
+ return unless @io.respond_to?(:tty?) && @io.tty?
195
+
196
+ @io.write("#{Yorha::Render.paint(text, :muted, io: @io)}\n")
197
+ end
198
+
199
+ private
200
+
201
+ # Validates and normalises a record name.
202
+ #
203
+ # Names reject path separators and traversal fragments so a
204
+ # record name can never escape the storage directory.
205
+ #
206
+ # @param name [String, Symbol]
207
+ # @return [Symbol]
208
+ # @raise [ArgumentError] for an invalid name
209
+ def normalize_name(name)
210
+ unless name.is_a?(String) || name.is_a?(Symbol)
211
+ raise ArgumentError, "record name must be a String or Symbol"
212
+ end
213
+
214
+ text = name.to_s.strip
215
+
216
+ if text.empty? || text.match?(%r{[/\\]}) || text.include?("..")
217
+ raise ArgumentError, "invalid record name #{name.inspect}"
218
+ end
219
+
220
+ text.to_sym
221
+ end
222
+
223
+ # @param key [Symbol] record name
224
+ # @return [String] path to the record's file
225
+ def file_for(key)
226
+ File.join(@path, "#{key}#{@ext}")
227
+ end
228
+
229
+ # Serialises a wrapper to disk.
230
+ #
231
+ # @param key [Symbol] record name
232
+ # @param wrapper [Hash]
233
+ # @return [void]
234
+ def write_wrapper(key, wrapper)
235
+ file = file_for(key)
236
+
237
+ if @format == :yaml
238
+ require "yaml"
239
+ File.write(file, Psych.dump(wrapper))
240
+ else
241
+ File.binwrite(file, Marshal.dump(wrapper))
242
+ end
243
+ end
244
+
245
+ # Parses a stored wrapper.
246
+ #
247
+ # YAML always loads through Psych.safe_load with Symbol and Time
248
+ # permitted. Marshal is only for input you trust, because
249
+ # Marshal.load can execute code in crafted files.
250
+ #
251
+ # @param file [String] path to read
252
+ # @return [Hash{Symbol => Object}]
253
+ # @raise [CorruptRecordError] when parsing fails
254
+ def read_wrapper(file)
255
+ if @format == :yaml
256
+ require "yaml"
257
+ parsed = Psych.safe_load(File.read(file), permitted_classes: [Symbol, Time])
258
+ else
259
+ parsed = Marshal.load(File.binread(file))
260
+ end
261
+
262
+ unless parsed.is_a?(Hash) && parsed.key?(:data) &&
263
+ parsed.key?(:name) && parsed.key?(:saved_at)
264
+ raise CorruptRecordError, "#{file} is not a YoRHa record"
265
+ end
266
+
267
+ parsed
268
+ rescue ArgumentError, TypeError, Psych::SyntaxError
269
+ raise CorruptRecordError, "#{file} could not be parsed"
270
+ end
271
+
272
+ # Builds a Record summary from a wrapper.
273
+ #
274
+ # @param wrapper [Hash{Symbol => Object}]
275
+ # @return [Record]
276
+ def record_from(wrapper)
277
+ Record.new(name: wrapper[:name], saved_at: wrapper[:saved_at], yorha_version: wrapper[:yorha_version])
278
+ end
279
+ end
280
+ end
@@ -0,0 +1,87 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Bunker boot sequence (Presentation layer).
4
+ #
5
+ # Design document reference: section 5.5, Yorha::Banner.
6
+ #
7
+ # Responsibility:
8
+ # Print the themed boot sequence, one line at a time on an
9
+ # interactive terminal, instantly everywhere else.
10
+ #
11
+ # This file does not:
12
+ # - Sleep on non-TTY streams; delay is forced to zero there.
13
+ # - Emit Japanese text unless Terminal reports Unicode support.
14
+
15
+ require_relative "terminal"
16
+ require_relative "render"
17
+
18
+ module Yorha
19
+ module Banner
20
+ # Boot sequence steps. Original fan-homage wording (principle P7).
21
+ SEQUENCE = [
22
+ "LOADING - SYSTEM CHECK",
23
+ "LOADING - MEMORY UNIT",
24
+ "LOADING - REGION DATA",
25
+ "LOADING - COMBAT DATA"
26
+ ].freeze
27
+
28
+ # Closing line, selected by Unicode capability.
29
+ FINAL_UNICODE = "人類に栄光あれ"
30
+ FINAL_ASCII = "GLORY TO MANKIND"
31
+
32
+ class << self
33
+ # Prints the boot sequence.
34
+ #
35
+ # On a TTY the lines appear with `delay` seconds between them.
36
+ # On any non-TTY stream every line is written instantly, so
37
+ # pipes and CI logs never sleep.
38
+ #
39
+ # @param unit [String, nil] unit name; defaults to config
40
+ # @param io [#write, nil] output stream; defaults to config
41
+ # @param delay [Numeric] seconds between lines on a TTY
42
+ # @return [String] the full text written
43
+ # @api public
44
+ def boot(unit: nil, io: nil, delay: 0.04)
45
+ stream = io || Yorha.config.io
46
+ unit_name = unit || Yorha.config.unit
47
+
48
+ animated =
49
+ delay.positive? &&
50
+ stream.respond_to?(:tty?) &&
51
+ stream.tty?
52
+
53
+ lines = [Yorha::Render.paint("YoRHa SYSTEM BOOT", :muted, io: stream)]
54
+ SEQUENCE.each do |step|
55
+ lines << Yorha::Render.paint(step, :fg, io: stream)
56
+ end
57
+
58
+ lines << Yorha::Render.paint("UNIT: #{unit_name}", :fg, io: stream)
59
+ lines << Yorha::Render.paint(
60
+ "CONNECTION TO BUNKER ESTABLISHED", :success, io: stream
61
+ )
62
+ lines << Yorha::Render.paint(closing_line(stream), :accent, io: stream)
63
+
64
+ lines.each_with_index do |line, index|
65
+ stream.write("#{line}\n")
66
+ stream.flush if stream.respond_to?(:flush)
67
+
68
+ if animated && index < lines.length - 1
69
+ sleep(delay)
70
+ end
71
+ end
72
+
73
+ "#{lines.join("\n")}\n"
74
+ end
75
+
76
+ private
77
+
78
+ # Picks the closing line for this stream.
79
+ #
80
+ # @param stream [#write]
81
+ # @return [String]
82
+ def closing_line(stream)
83
+ Yorha::Terminal.unicode?(stream) ? FINAL_UNICODE : FINAL_ASCII
84
+ end
85
+ end
86
+ end
87
+ end