boreal 0.1.0

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: d5546aed483aa7a5dbee66b8e8acf78047fc38e7d0f435260935531361b9232a
4
+ data.tar.gz: 8ee439a58d722f3c63db99b3ee19abdb92395924f11be5b7a5859935be3e1c9d
5
+ SHA512:
6
+ metadata.gz: a95e738c9dd6129520217fea2d58082ce7e8ff228dd296fcdf831111617013f8ea1b1b5e4e4085e2e76f5ca626e32df677298c7ec29f0b153910b9c2150ace73
7
+ data.tar.gz: 2eed82022fe83149f534081d22fbb5b158e2cb5f453aad7c57cafb975a152f9d138474ffd7884cd6d7960dc979d3dfd143f045790e24d8e2be300bcc67c38589
data/Gemfile ADDED
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ source 'https://rubygems.org'
4
+
5
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,170 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to the Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by the Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy thereof.
109
+
110
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
111
+ any Contribution intentionally submitted for inclusion in the Work
112
+ by You to the Licensor shall be under the terms and conditions of
113
+ this License, without any additional terms or conditions.
114
+ Notwithstanding the above, nothing herein shall supersede or modify
115
+ the terms of any separate license agreement you may have executed
116
+ with Licensor regarding such Contributions.
117
+
118
+ 6. Trademarks. This License does not grant permission to use the trade
119
+ names, trademarks, service marks, or product names of the Licensor,
120
+ except as required for reasonable and customary use in describing the
121
+ origin of the Work and reproducing the content of the NOTICE file.
122
+
123
+ 7. Disclaimer of Warranty. Unless required by applicable law or
124
+ agreed to in writing, Licensor provides the Work (and each
125
+ Contributor provides its Contributions) on an "AS IS" BASIS,
126
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
127
+ implied, including, without limitation, any warranties or conditions
128
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
129
+ PARTICULAR PURPOSE. You are solely responsible for determining the
130
+ appropriateness of using or redistributing the Work and assume any
131
+ risks associated with Your exercise of permissions under this License.
132
+
133
+ 8. Limitation of Liability. In no event and under no legal theory,
134
+ whether in tort (including negligence), contract, or otherwise,
135
+ unless required by applicable law (such as deliberate and grossly
136
+ negligent acts) or agreed to in writing, shall any Contributor be
137
+ liable to You for damages, including any direct, indirect, special,
138
+ incidental, or consequential damages of any character arising as a
139
+ result of this License or out of the use or inability to use the
140
+ Work (including but not limited to damages for loss of goodwill,
141
+ work stoppage, computer failure or malfunction, or any and all
142
+ other commercial damages or losses), even if such Contributor
143
+ has been advised of the possibility of such damages.
144
+
145
+ 9. Accepting Warranty or Additional Liability. While redistributing
146
+ the Work or Derivative Works thereof, You may choose to offer,
147
+ and charge a fee for, acceptance of support, warranty, indemnity,
148
+ or other liability obligations and/or rights consistent with this
149
+ License. However, in accepting such obligations, You may act only
150
+ on Your own behalf and on Your sole responsibility, not on behalf
151
+ of any other Contributor, and only if You agree to indemnify,
152
+ defend, and hold each Contributor harmless for any liability
153
+ incurred by, or claims asserted against, such Contributor by reason
154
+ of your accepting any such warranty or additional liability.
155
+
156
+ END OF TERMS AND CONDITIONS
157
+
158
+ Copyright 2025 The Pleme Authors
159
+
160
+ Licensed under the Apache License, Version 2.0 (the "License");
161
+ you may not use this file except in compliance with the License.
162
+ You may obtain a copy of the License at
163
+
164
+ http://www.apache.org/licenses/LICENSE-2.0
165
+
166
+ Unless required by applicable law or agreed to in writing, software
167
+ distributed under the License is distributed on an "AS IS" BASIS,
168
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
169
+ See the License for the specific language governing permissions and
170
+ limitations under the License.
data/Rakefile ADDED
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'rspec/core/rake_task'
4
+
5
+ RSpec::Core::RakeTask.new(:spec)
6
+
7
+ task default: :spec
data/boreal.gemspec ADDED
@@ -0,0 +1,37 @@
1
+ # frozen_string_literal: true
2
+
3
+ lib = File.expand_path('lib', __dir__)
4
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
+ require 'boreal/version'
6
+
7
+ Gem::Specification.new do |spec|
8
+ spec.name = 'boreal'
9
+ spec.version = Boreal::VERSION
10
+ spec.authors = ['Luis Zayas']
11
+ spec.email = ['drzthslnt@gmail.com']
12
+ spec.summary = 'Nord-themed CLI look-and-feel for Ruby'
13
+ spec.description = 'True 24-bit Nord palette theming for CLI tools. Wraps TTY components (box, table, spinner, progress) with unified Nord styling via the Paint gem.'
14
+ spec.homepage = 'https://github.com/pleme-io/boreal'
15
+ spec.license = 'Apache-2.0'
16
+ spec.require_paths = ['lib']
17
+ spec.required_ruby_version = '>= 3.3.0'
18
+
19
+ spec.files = Dir['lib/**/*.rb'] + %w[boreal.gemspec Gemfile LICENSE Rakefile]
20
+
21
+ # Core — true 24-bit color
22
+ spec.add_dependency 'paint', '~> 2.3'
23
+
24
+ # TTY components (the gem's value is pre-themed wrappers)
25
+ spec.add_dependency 'tty-box', '~> 0.7'
26
+ spec.add_dependency 'tty-table', '~> 0.12'
27
+ spec.add_dependency 'tty-spinner', '~> 0.9'
28
+ spec.add_dependency 'tty-progressbar', '~> 0.18'
29
+
30
+ # Compat layer (TTY internals use Pastel for style: hashes)
31
+ spec.add_dependency 'pastel', '~> 0.8'
32
+
33
+ spec.add_development_dependency 'rake', '~> 13.0'
34
+ spec.add_development_dependency 'rspec', '~> 3.12'
35
+
36
+ spec.metadata['rubygems_mfa_required'] = 'true'
37
+ end
@@ -0,0 +1,83 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'pastel'
4
+
5
+ module Boreal
6
+ # Compatibility bridge between Boreal roles and Pastel symbols.
7
+ #
8
+ # Two purposes:
9
+ # 1. Map Boreal semantic roles to the closest Pastel symbol for TTY gems
10
+ # that accept symbol-based `style:` hashes (TTY::Box, TTY::Logger).
11
+ # 2. Map raw Pastel symbols (`:bright_cyan`, `:green`) to Nord hex values
12
+ # for callers migrating incrementally.
13
+ module Compat
14
+ # Boreal role → closest Pastel symbol (for TTY style: hashes)
15
+ PASTEL_MAP = {
16
+ success: :green,
17
+ error: :red,
18
+ warning: :yellow,
19
+ info: :blue,
20
+ debug: :bright_black,
21
+ create: :green,
22
+ update: :yellow,
23
+ delete: :red,
24
+ replace: :magenta,
25
+ import: :blue,
26
+ refresh: :cyan,
27
+ primary: :cyan,
28
+ secondary: :blue,
29
+ muted: :bright_black,
30
+ text: :white,
31
+ bright: :bright_white,
32
+ border: :cyan,
33
+ separator: :bright_black,
34
+ added: :green,
35
+ removed: :red,
36
+ changed: :yellow,
37
+ pending: :cyan
38
+ }.freeze
39
+
40
+ # Pastel symbol → Nord hex (for incremental migration)
41
+ HEX_MAP = {
42
+ green: Palette::GREEN,
43
+ bright_green: Palette::GREEN,
44
+ red: Palette::RED,
45
+ bright_red: Palette::RED,
46
+ yellow: Palette::YELLOW,
47
+ bright_yellow: Palette::YELLOW,
48
+ blue: Palette::FROST2,
49
+ bright_blue: Palette::FROST2,
50
+ cyan: Palette::FROST1,
51
+ bright_cyan: Palette::FROST1,
52
+ magenta: Palette::PURPLE,
53
+ bright_magenta: Palette::PURPLE,
54
+ white: Palette::SNOW0,
55
+ bright_white: Palette::SNOW2,
56
+ black: Palette::NIGHT0,
57
+ bright_black: Palette::NIGHT3
58
+ }.freeze
59
+
60
+ class << self
61
+ # Return the Pastel symbol for a Boreal role.
62
+ def pastel_sym(role)
63
+ PASTEL_MAP.fetch(role) { raise ArgumentError, "No Pastel mapping for role: #{role}" }
64
+ end
65
+
66
+ # Return the Nord hex for a Pastel symbol, or nil if unknown.
67
+ def hex_for(pastel_sym)
68
+ HEX_MAP[pastel_sym]
69
+ end
70
+
71
+ # Build a Pastel-compatible color hash for TTY::Box `style: { border: { color: } }`.
72
+ def border_style(role = :border)
73
+ { color: pastel_sym(role) }
74
+ end
75
+
76
+ # Return a shared Pastel instance for TTY internals that require one.
77
+ # Consumers should prefer Boreal.paint over this.
78
+ def pastel
79
+ @pastel ||= Pastel.new
80
+ end
81
+ end
82
+ end
83
+ end
@@ -0,0 +1,53 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'tty-box'
4
+
5
+ module Boreal
6
+ module Components
7
+ # ASCII art framing with Nord-themed borders and colors.
8
+ class Banner
9
+ include Base
10
+
11
+ # Render framed ASCII art with Nord border characters.
12
+ def art(content, width: 70, align: :center)
13
+ TTY::Box.frame(
14
+ content,
15
+ width: width,
16
+ align: align,
17
+ border: :thick,
18
+ style: { border: border_chars(:primary) }
19
+ )
20
+ end
21
+
22
+ # Compact command header line.
23
+ def header(title, subtitle: nil)
24
+ line = paint(title, :primary)
25
+ line += " #{paint(subtitle, :muted)}" if subtitle
26
+ separator = paint('─' * 50, :muted)
27
+ "#{line}\n#{separator}"
28
+ end
29
+
30
+ # Full-width section divider.
31
+ def divider(width: 60, role: :primary)
32
+ paint('━' * width, role)
33
+ end
34
+
35
+ # Success banner with dividers.
36
+ def success_banner(message, width: 60)
37
+ d = divider(width: width, role: :success)
38
+ text = bold("#{icon(:success)} #{message}", :success)
39
+ "\n#{d}\n#{text}\n#{d}\n"
40
+ end
41
+
42
+ class << self
43
+ def instance
44
+ @instance ||= new
45
+ end
46
+
47
+ %i[art header divider success_banner].each do |method|
48
+ define_method(method) { |*args, **kwargs| instance.send(method, *args, **kwargs) }
49
+ end
50
+ end
51
+ end
52
+ end
53
+ end
@@ -0,0 +1,36 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Boreal
4
+ module Components
5
+ # Shared behavior for all themed components.
6
+ module Base
7
+ private
8
+
9
+ def paint(text, role_or_hex)
10
+ Renderer.paint(text, role_or_hex)
11
+ end
12
+
13
+ def bold(text, role_or_hex = nil)
14
+ Renderer.bold(text, role_or_hex)
15
+ end
16
+
17
+ def icon(role)
18
+ Renderer.icon(role)
19
+ end
20
+
21
+ def border_chars(role = :border)
22
+ hex = role.is_a?(Symbol) ? Theme.hex(role) : role
23
+ {
24
+ top: Paint['─', hex],
25
+ bottom: Paint['─', hex],
26
+ left: Paint['│', hex],
27
+ right: Paint['│', hex],
28
+ top_left: Paint['╭', hex],
29
+ top_right: Paint['╮', hex],
30
+ bottom_left: Paint['╰', hex],
31
+ bottom_right: Paint['╯', hex]
32
+ }
33
+ end
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,68 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'tty-box'
4
+
5
+ module Boreal
6
+ module Components
7
+ # TTY::Box wrapper with Nord-themed borders and convenience methods.
8
+ class Box
9
+ include Base
10
+
11
+ # Render a framed box with painted Nord border characters.
12
+ def frame(content, width: 60, align: :left, role: :border, border: :light, title: nil, padding: 1)
13
+ options = {
14
+ width: width,
15
+ align: align,
16
+ border: border,
17
+ padding: padding,
18
+ style: { border: border_chars(role) }
19
+ }
20
+ options[:title] = { top_left: title } if title
21
+
22
+ TTY::Box.frame(content.to_s.strip, **options)
23
+ end
24
+
25
+ # Pre-themed status boxes
26
+ def success(title, details = nil)
27
+ content = "#{paint('✅', :success)} #{paint(title, :success)}"
28
+ content += "\n#{paint(details, :muted)}" if details
29
+ frame(content, role: :success, width: [title.to_s.length + 16, 60].max)
30
+ end
31
+
32
+ def error(title, details = nil, suggestions: [])
33
+ content = "#{paint('❌', :error)} #{paint(title, :error)}"
34
+ content += "\n\n#{paint(details, :text)}" if details
35
+
36
+ if suggestions.any?
37
+ content += "\n\n#{bold('💡 Suggestions:', :warning)}"
38
+ suggestions.each { |s| content += "\n #{paint('•', :warning)} #{paint(s, :text)}" }
39
+ end
40
+
41
+ frame(content, role: :error, width: 70, border: :thick)
42
+ end
43
+
44
+ def warning(title, details = nil)
45
+ content = "#{paint('⚠️', :warning)} #{paint(title, :warning)}"
46
+ content += "\n#{paint(details, :text)}" if details
47
+ frame(content, role: :warning, width: [title.to_s.length + 16, 60].max)
48
+ end
49
+
50
+ def info(title, items = {})
51
+ content = "#{paint("ℹ️ #{title}", :primary)}\n\n"
52
+ items.each { |k, v| content += "#{bold(k.to_s.ljust(15), :bright)}: #{paint(v, :text)}\n" }
53
+ frame(content, role: :primary, width: 70)
54
+ end
55
+
56
+ # Class-level convenience
57
+ class << self
58
+ def instance
59
+ @instance ||= new
60
+ end
61
+
62
+ %i[frame success error warning info].each do |method|
63
+ define_method(method) { |*args, **kwargs| instance.send(method, *args, **kwargs) }
64
+ end
65
+ end
66
+ end
67
+ end
68
+ end
@@ -0,0 +1,64 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Boreal
4
+ module Components
5
+ # Structured log output with Nord role colors.
6
+ class Logger
7
+ include Base
8
+
9
+ # Log styles compatible with TTY::Logger (uses Pastel symbols).
10
+ LOG_STYLES = {
11
+ info: { symbol: 'ℹ', label: 'info', color: Compat::PASTEL_MAP[:info], levelpad: 1 },
12
+ success: { symbol: '✓', label: 'success', color: Compat::PASTEL_MAP[:success], levelpad: 0 },
13
+ error: { symbol: '✗', label: 'error', color: Compat::PASTEL_MAP[:error], levelpad: 1 },
14
+ warn: { symbol: '⚠', label: 'warning', color: Compat::PASTEL_MAP[:warning], levelpad: 0 },
15
+ debug: { symbol: '•', label: 'debug', color: Compat::PASTEL_MAP[:debug], levelpad: 1 }
16
+ }.freeze
17
+
18
+ # Action styles for resource operations.
19
+ ACTION_STYLES = {
20
+ create: { symbol: '◉', role: :create },
21
+ update: { symbol: '◎', role: :update },
22
+ delete: { symbol: '◯', role: :delete },
23
+ replace: { symbol: '⧗', role: :replace },
24
+ import: { symbol: '⬇', role: :import },
25
+ refresh: { symbol: '↻', role: :refresh },
26
+ default: { symbol: '●', role: :text }
27
+ }.freeze
28
+
29
+ STATUS_INDICATORS = {
30
+ success: ' ✓',
31
+ error: ' ✗',
32
+ warning: ' ⚠',
33
+ pending: ' ⧖'
34
+ }.freeze
35
+
36
+ TEMPLATE_ICONS = {
37
+ compiling: '⚙️',
38
+ compiled: '✅',
39
+ failed: '❌',
40
+ validating: '🔍',
41
+ validated: '✅',
42
+ default: '📄'
43
+ }.freeze
44
+
45
+ class << self
46
+ def log_styles
47
+ LOG_STYLES
48
+ end
49
+
50
+ def action_styles
51
+ ACTION_STYLES
52
+ end
53
+
54
+ def status_indicators
55
+ STATUS_INDICATORS
56
+ end
57
+
58
+ def template_icons
59
+ TEMPLATE_ICONS
60
+ end
61
+ end
62
+ end
63
+ end
64
+ end
@@ -0,0 +1,60 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'tty-progressbar'
4
+
5
+ module Boreal
6
+ module Components
7
+ # TTY::ProgressBar wrapper with Nord-themed bar characters.
8
+ class Progress
9
+ include Base
10
+
11
+ def single(title, total:)
12
+ bar = create_bar(title, total)
13
+ begin
14
+ yield(bar)
15
+ ensure
16
+ bar.finish
17
+ end
18
+ end
19
+
20
+ def multi(title, &block)
21
+ TTY::ProgressBar::Multi.new(title, &block)
22
+ end
23
+
24
+ def transfer(title, total_bytes:)
25
+ TTY::ProgressBar.new(
26
+ "#{title} [:bar] :percent :current_byte/:total_byte :rate/s :eta",
27
+ total: total_bytes,
28
+ bar_format: :block,
29
+ clear: true,
30
+ width: 30
31
+ )
32
+ end
33
+
34
+ class << self
35
+ def instance
36
+ @instance ||= new
37
+ end
38
+
39
+ %i[single multi transfer].each do |method|
40
+ define_method(method) { |*args, **kwargs, &block| instance.send(method, *args, **kwargs, &block) }
41
+ end
42
+ end
43
+
44
+ private
45
+
46
+ def create_bar(title, total)
47
+ TTY::ProgressBar.new(
48
+ "#{title} [:bar] :percent :current/:total :elapsed",
49
+ total: total,
50
+ bar_format: :block,
51
+ clear: true,
52
+ width: 30,
53
+ complete: paint('█', :success),
54
+ incomplete: paint('░', :muted),
55
+ head: paint('█', :update)
56
+ )
57
+ end
58
+ end
59
+ end
60
+ end
@@ -0,0 +1,82 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'tty-spinner'
4
+
5
+ module Boreal
6
+ module Components
7
+ # TTY::Spinner wrapper with Nord-themed marks and colors.
8
+ class Spinner
9
+ include Base
10
+
11
+ def initialize(message = nil, format: :dots, clear: false, interval: 10)
12
+ spinner_format = "[:spinner] #{paint(message, :text)}"
13
+
14
+ @spinner = TTY::Spinner.new(
15
+ spinner_format,
16
+ format: format,
17
+ hide_cursor: true,
18
+ success_mark: paint('✅', :success),
19
+ error_mark: paint('❌', :error),
20
+ clear: clear,
21
+ interval: interval
22
+ )
23
+ @start_time = nil
24
+ end
25
+
26
+ def start
27
+ @start_time = Time.now
28
+ @spinner.start
29
+ end
30
+
31
+ def stop
32
+ @spinner.stop
33
+ end
34
+
35
+ def success(message = nil)
36
+ formatted = if message && @start_time
37
+ duration = Time.now - @start_time
38
+ "#{paint(message, :success)} #{paint("(#{format_duration(duration)})", :muted)}"
39
+ else
40
+ message
41
+ end
42
+ @spinner.success(formatted)
43
+ end
44
+
45
+ def error(message = nil)
46
+ @spinner.error(message ? paint(message, :error) : nil)
47
+ end
48
+
49
+ def warning(message = nil)
50
+ @spinner.success("⚠️ #{message ? paint(message, :warning) : nil}")
51
+ end
52
+
53
+ def update(message)
54
+ @spinner.update(title: "[:spinner] #{paint(message, :text)}")
55
+ end
56
+
57
+ def spin
58
+ start
59
+ result = yield
60
+ success
61
+ result
62
+ rescue StandardError => e
63
+ error(e.message)
64
+ raise
65
+ ensure
66
+ stop
67
+ end
68
+
69
+ private
70
+
71
+ def format_duration(seconds)
72
+ case seconds
73
+ when 0...1 then "#{(seconds * 1000).round}ms"
74
+ when 1...60 then "#{seconds.round(1)}s"
75
+ else
76
+ minutes, remaining = seconds.divmod(60)
77
+ "#{minutes.floor}m #{remaining.round}s"
78
+ end
79
+ end
80
+ end
81
+ end
82
+ end
@@ -0,0 +1,67 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'tty-table'
4
+
5
+ module Boreal
6
+ module Components
7
+ # TTY::Table wrapper with Nord-themed borders and header colors.
8
+ class Table
9
+ include Base
10
+
11
+ BORDER_CHARS = %w[─ ─ │ │ ┌ ┐ └ ┘ ┬ ─ ├ ┤ ┼ ┴].freeze
12
+ BORDER_SYMS = %i[top bottom left right top_left top_right bottom_left bottom_right
13
+ top_mid mid mid_left mid_right mid_mid bottom_mid].freeze
14
+
15
+ def initialize(headers = nil, rows = [], **options)
16
+ @headers = headers
17
+ @rows = rows
18
+ @options = default_options.merge(options)
19
+ end
20
+
21
+ def render
22
+ colored_headers = @headers&.map { |h| bold(h, :bright) }
23
+ table = TTY::Table.new(colored_headers, @rows)
24
+ table.render(:unicode, **@options)
25
+ end
26
+
27
+ def add_row(row)
28
+ @rows << row
29
+ end
30
+
31
+ def to_s
32
+ render
33
+ end
34
+
35
+ class << self
36
+ def render_table(headers:, rows:)
37
+ new(headers, rows).render
38
+ end
39
+
40
+ def simple(headers, rows, title: nil)
41
+ result = render_table(headers: headers, rows: rows)
42
+ if title
43
+ title_line = Renderer.paint(title, :primary)
44
+ separator = Renderer.paint('─' * title.length, :primary)
45
+ result = "#{title_line}\n#{separator}\n#{result}"
46
+ end
47
+ result
48
+ end
49
+ end
50
+
51
+ private
52
+
53
+ def default_options
54
+ painted_border = BORDER_SYMS.zip(
55
+ BORDER_CHARS.map { |c| paint(c, :border) }
56
+ ).to_h
57
+
58
+ {
59
+ padding: [0, 1],
60
+ resize: true,
61
+ multiline: true,
62
+ style: { border: painted_border }
63
+ }
64
+ end
65
+ end
66
+ end
67
+ end
@@ -0,0 +1,39 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Boreal
4
+ # The canonical Nord 16-color palette.
5
+ # Source: arcticicestudio/nord — https://www.nordtheme.com
6
+ module Palette
7
+ # Polar Night — dark backgrounds and surfaces
8
+ NIGHT0 = '#2E3440'
9
+ NIGHT1 = '#3B4252'
10
+ NIGHT2 = '#434C5E'
11
+ NIGHT3 = '#4C566A'
12
+
13
+ # Snow Storm — light text and foregrounds
14
+ SNOW0 = '#D8DEE9'
15
+ SNOW1 = '#E5E9F0'
16
+ SNOW2 = '#ECEFF4'
17
+
18
+ # Frost — blue accents
19
+ FROST0 = '#8FBCBB'
20
+ FROST1 = '#88C0D0'
21
+ FROST2 = '#81A1C1'
22
+ FROST3 = '#5E81AC'
23
+
24
+ # Aurora — status and action colors
25
+ RED = '#BF616A'
26
+ ORANGE = '#D08770'
27
+ YELLOW = '#EBCB8B'
28
+ GREEN = '#A3BE8C'
29
+ PURPLE = '#B48EAD'
30
+
31
+ # All colors as a frozen hash for iteration
32
+ ALL = {
33
+ night0: NIGHT0, night1: NIGHT1, night2: NIGHT2, night3: NIGHT3,
34
+ snow0: SNOW0, snow1: SNOW1, snow2: SNOW2,
35
+ frost0: FROST0, frost1: FROST1, frost2: FROST2, frost3: FROST3,
36
+ red: RED, orange: ORANGE, yellow: YELLOW, green: GREEN, purple: PURPLE
37
+ }.freeze
38
+ end
39
+ end
@@ -0,0 +1,79 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'paint'
4
+
5
+ module Boreal
6
+ # Paint-based true-color text rendering engine.
7
+ # Replaces Pastel for all user-visible text coloring.
8
+ module Renderer
9
+ module_function
10
+
11
+ # Paint text using a semantic role or raw hex color.
12
+ #
13
+ # Boreal::Renderer.paint("ok", :success) # => green bold
14
+ # Boreal::Renderer.paint("ok", '#88C0D0') # => raw hex
15
+ def paint(text, role_or_hex)
16
+ return text.to_s unless Terminal.color_enabled?
17
+
18
+ if role_or_hex.is_a?(Symbol)
19
+ paint_role(text, role_or_hex)
20
+ else
21
+ Paint[text.to_s, role_or_hex]
22
+ end
23
+ end
24
+
25
+ # Paint with explicit hex color.
26
+ def hex(text, hex_color)
27
+ return text.to_s unless Terminal.color_enabled?
28
+
29
+ Paint[text.to_s, hex_color]
30
+ end
31
+
32
+ # Paint with bold + role color (ignores role's default styles).
33
+ def bold(text, role_or_hex = nil)
34
+ return text.to_s unless Terminal.color_enabled?
35
+
36
+ if role_or_hex
37
+ color = role_or_hex.is_a?(Symbol) ? Theme.hex(role_or_hex) : role_or_hex
38
+ Paint[text.to_s, color, :bold]
39
+ else
40
+ Paint[text.to_s, :bold]
41
+ end
42
+ end
43
+
44
+ # Return the icon string for a role.
45
+ def icon(role)
46
+ Theme.icon(role) || ''
47
+ end
48
+
49
+ # Render "icon text" in the role's color.
50
+ def status(role, text)
51
+ ic = icon(role)
52
+ prefix = ic.empty? ? '' : "#{ic} "
53
+ paint("#{prefix}#{text}", role)
54
+ end
55
+
56
+ # Decorate text with a Pastel-compatible symbol (for TTY internals).
57
+ # Falls back to Paint hex when possible.
58
+ def decorate(text, color_sym)
59
+ return text.to_s unless Terminal.color_enabled?
60
+
61
+ if Theme::ROLES.key?(color_sym)
62
+ paint(text, color_sym)
63
+ else
64
+ # Pastel symbol — use Compat mapping
65
+ mapped_hex = Compat.hex_for(color_sym)
66
+ mapped_hex ? Paint[text.to_s, mapped_hex] : Paint[text.to_s, color_sym]
67
+ end
68
+ end
69
+
70
+ # --- private helpers ---
71
+
72
+ def paint_role(text, role)
73
+ r = Theme.role(role)
74
+ args = [text.to_s, r.hex, *r.styles]
75
+ Paint[*args]
76
+ end
77
+ private_class_method :paint_role
78
+ end
79
+ end
@@ -0,0 +1,34 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Boreal
4
+ # TTY capability detection: true color, NO_COLOR, CI environments.
5
+ module Terminal
6
+ module_function
7
+
8
+ def true_color?
9
+ return false if no_color?
10
+
11
+ colorterm = ENV['COLORTERM'].to_s.downcase
12
+ return true if colorterm == 'truecolor' || colorterm == '24bit'
13
+
14
+ term = ENV['TERM'].to_s
15
+ return true if term.include?('24bit') || term.include?('truecolor')
16
+
17
+ # Most modern terminals support true color even without advertising it
18
+ term_program = ENV['TERM_PROGRAM'].to_s
19
+ %w[iTerm.app WezTerm Hyper vscode kitty alacritty ghostty].any? { |t| term_program.include?(t) }
20
+ end
21
+
22
+ def no_color?
23
+ ENV.key?('NO_COLOR')
24
+ end
25
+
26
+ def ci?
27
+ ENV.key?('CI') || ENV.key?('GITHUB_ACTIONS') || ENV.key?('GITLAB_CI')
28
+ end
29
+
30
+ def color_enabled?
31
+ !no_color?
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,74 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Boreal
4
+ # Semantic role → palette mappings with optional styles and icons.
5
+ # Maps ecosystem conventions (starship, fzf, neovim, terraform) to Nord colors.
6
+ module Theme
7
+ Role = Data.define(:hex, :styles, :icon)
8
+
9
+ ROLES = {
10
+ # Status
11
+ success: Role.new(hex: Palette::GREEN, styles: [:bold], icon: '✓'),
12
+ error: Role.new(hex: Palette::RED, styles: [:bold], icon: '✗'),
13
+ warning: Role.new(hex: Palette::ORANGE, styles: [], icon: '⚠'),
14
+ info: Role.new(hex: Palette::FROST2, styles: [], icon: 'ℹ'),
15
+ debug: Role.new(hex: Palette::NIGHT3, styles: [], icon: '•'),
16
+
17
+ # Actions (terraform-style)
18
+ create: Role.new(hex: Palette::GREEN, styles: [:bold], icon: '+'),
19
+ update: Role.new(hex: Palette::YELLOW, styles: [], icon: '~'),
20
+ delete: Role.new(hex: Palette::RED, styles: [:bold], icon: '-'),
21
+ replace: Role.new(hex: Palette::PURPLE, styles: [], icon: '±'),
22
+ import: Role.new(hex: Palette::FROST2, styles: [], icon: '⬇'),
23
+ refresh: Role.new(hex: Palette::FROST1, styles: [], icon: '↻'),
24
+
25
+ # Emphasis
26
+ primary: Role.new(hex: Palette::FROST1, styles: [:bold], icon: nil),
27
+ secondary: Role.new(hex: Palette::FROST3, styles: [], icon: nil),
28
+ muted: Role.new(hex: Palette::NIGHT3, styles: [], icon: nil),
29
+ text: Role.new(hex: Palette::SNOW0, styles: [], icon: nil),
30
+ bright: Role.new(hex: Palette::SNOW2, styles: [], icon: nil),
31
+
32
+ # Structural
33
+ border: Role.new(hex: Palette::FROST1, styles: [], icon: nil),
34
+ separator: Role.new(hex: Palette::NIGHT3, styles: [], icon: nil),
35
+
36
+ # Diff
37
+ added: Role.new(hex: Palette::GREEN, styles: [], icon: '+'),
38
+ removed: Role.new(hex: Palette::RED, styles: [], icon: '-'),
39
+ changed: Role.new(hex: Palette::YELLOW, styles: [], icon: '~'),
40
+
41
+ # Pending
42
+ pending: Role.new(hex: Palette::FROST1, styles: [], icon: '⧖')
43
+ }.freeze
44
+
45
+ # Extended icons for domain-specific contexts (templates, resources, etc.)
46
+ ICONS = {
47
+ success: '✓', error: '✗', warning: '⚠', info: 'ℹ', pending: '⧖',
48
+ create: '+', update: '~', delete: '-', replace: '±', import: '⬇', refresh: '↻',
49
+ template: '📄', resource: '🏗️', provider: '☁️', backend: '🔧', namespace: '🏷️',
50
+ workspace: '📁', config: '⚙️', summary: '📊', plan: '📋', output: '📤',
51
+ state: '📈', diff: '🔄', security: '🔒', network: '🌐', database: '🗄️',
52
+ compute: '💻', storage: '💾', compiling: '⚙️', compiled: '✅', failed: '❌',
53
+ validating: '🔍', validated: '✅', applying: '🚀', destroying: '💥', initializing: '🔧'
54
+ }.freeze
55
+
56
+ class << self
57
+ def role(name)
58
+ ROLES.fetch(name) { raise ArgumentError, "Unknown role: #{name}" }
59
+ end
60
+
61
+ def hex(name)
62
+ role(name).hex
63
+ end
64
+
65
+ def icon(name)
66
+ ICONS[name] || ROLES.dig(name, :icon)
67
+ end
68
+
69
+ def styles(name)
70
+ role(name).styles
71
+ end
72
+ end
73
+ end
74
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Boreal
4
+ VERSION = '0.1.0'
5
+ end
data/lib/boreal.rb ADDED
@@ -0,0 +1,51 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'boreal/version'
4
+ require_relative 'boreal/palette'
5
+ require_relative 'boreal/theme'
6
+ require_relative 'boreal/terminal'
7
+ require_relative 'boreal/renderer'
8
+ require_relative 'boreal/compat'
9
+ require_relative 'boreal/components/base'
10
+ require_relative 'boreal/components/box'
11
+ require_relative 'boreal/components/table'
12
+ require_relative 'boreal/components/spinner'
13
+ require_relative 'boreal/components/progress'
14
+ require_relative 'boreal/components/banner'
15
+ require_relative 'boreal/components/logger'
16
+
17
+ module Boreal
18
+ class << self
19
+ # Paint text using a semantic role or raw hex color.
20
+ # Boreal.paint("ok", :success) # => green bold via Paint
21
+ # Boreal.paint("ok", '#88C0D0') # => raw hex
22
+ def paint(text, role_or_hex)
23
+ Renderer.paint(text, role_or_hex)
24
+ end
25
+
26
+ # Paint with explicit hex color.
27
+ def hex(text, hex_color)
28
+ Renderer.hex(text, hex_color)
29
+ end
30
+
31
+ # Paint with bold + role color.
32
+ def bold(text, role_or_hex = nil)
33
+ Renderer.bold(text, role_or_hex)
34
+ end
35
+
36
+ # Return the icon string for a role.
37
+ def icon(role)
38
+ Renderer.icon(role)
39
+ end
40
+
41
+ # Render "icon text" in the role's color.
42
+ def status(role, text)
43
+ Renderer.status(role, text)
44
+ end
45
+
46
+ # Decorate text using a Pastel-compatible symbol name.
47
+ def decorate(text, color_sym)
48
+ Renderer.decorate(text, color_sym)
49
+ end
50
+ end
51
+ end
metadata ADDED
@@ -0,0 +1,172 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: boreal
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Luis Zayas
8
+ bindir: bin
9
+ cert_chain: []
10
+ date: 2026-02-23 00:00:00.000000000 Z
11
+ dependencies:
12
+ - !ruby/object:Gem::Dependency
13
+ name: paint
14
+ requirement: !ruby/object:Gem::Requirement
15
+ requirements:
16
+ - - "~>"
17
+ - !ruby/object:Gem::Version
18
+ version: '2.3'
19
+ type: :runtime
20
+ prerelease: false
21
+ version_requirements: !ruby/object:Gem::Requirement
22
+ requirements:
23
+ - - "~>"
24
+ - !ruby/object:Gem::Version
25
+ version: '2.3'
26
+ - !ruby/object:Gem::Dependency
27
+ name: tty-box
28
+ requirement: !ruby/object:Gem::Requirement
29
+ requirements:
30
+ - - "~>"
31
+ - !ruby/object:Gem::Version
32
+ version: '0.7'
33
+ type: :runtime
34
+ prerelease: false
35
+ version_requirements: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - "~>"
38
+ - !ruby/object:Gem::Version
39
+ version: '0.7'
40
+ - !ruby/object:Gem::Dependency
41
+ name: tty-table
42
+ requirement: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - "~>"
45
+ - !ruby/object:Gem::Version
46
+ version: '0.12'
47
+ type: :runtime
48
+ prerelease: false
49
+ version_requirements: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - "~>"
52
+ - !ruby/object:Gem::Version
53
+ version: '0.12'
54
+ - !ruby/object:Gem::Dependency
55
+ name: tty-spinner
56
+ requirement: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - "~>"
59
+ - !ruby/object:Gem::Version
60
+ version: '0.9'
61
+ type: :runtime
62
+ prerelease: false
63
+ version_requirements: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - "~>"
66
+ - !ruby/object:Gem::Version
67
+ version: '0.9'
68
+ - !ruby/object:Gem::Dependency
69
+ name: tty-progressbar
70
+ requirement: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - "~>"
73
+ - !ruby/object:Gem::Version
74
+ version: '0.18'
75
+ type: :runtime
76
+ prerelease: false
77
+ version_requirements: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - "~>"
80
+ - !ruby/object:Gem::Version
81
+ version: '0.18'
82
+ - !ruby/object:Gem::Dependency
83
+ name: pastel
84
+ requirement: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - "~>"
87
+ - !ruby/object:Gem::Version
88
+ version: '0.8'
89
+ type: :runtime
90
+ prerelease: false
91
+ version_requirements: !ruby/object:Gem::Requirement
92
+ requirements:
93
+ - - "~>"
94
+ - !ruby/object:Gem::Version
95
+ version: '0.8'
96
+ - !ruby/object:Gem::Dependency
97
+ name: rake
98
+ requirement: !ruby/object:Gem::Requirement
99
+ requirements:
100
+ - - "~>"
101
+ - !ruby/object:Gem::Version
102
+ version: '13.0'
103
+ type: :development
104
+ prerelease: false
105
+ version_requirements: !ruby/object:Gem::Requirement
106
+ requirements:
107
+ - - "~>"
108
+ - !ruby/object:Gem::Version
109
+ version: '13.0'
110
+ - !ruby/object:Gem::Dependency
111
+ name: rspec
112
+ requirement: !ruby/object:Gem::Requirement
113
+ requirements:
114
+ - - "~>"
115
+ - !ruby/object:Gem::Version
116
+ version: '3.12'
117
+ type: :development
118
+ prerelease: false
119
+ version_requirements: !ruby/object:Gem::Requirement
120
+ requirements:
121
+ - - "~>"
122
+ - !ruby/object:Gem::Version
123
+ version: '3.12'
124
+ description: True 24-bit Nord palette theming for CLI tools. Wraps TTY components
125
+ (box, table, spinner, progress) with unified Nord styling via the Paint gem.
126
+ email:
127
+ - drzthslnt@gmail.com
128
+ executables: []
129
+ extensions: []
130
+ extra_rdoc_files: []
131
+ files:
132
+ - Gemfile
133
+ - LICENSE
134
+ - Rakefile
135
+ - boreal.gemspec
136
+ - lib/boreal.rb
137
+ - lib/boreal/compat.rb
138
+ - lib/boreal/components/banner.rb
139
+ - lib/boreal/components/base.rb
140
+ - lib/boreal/components/box.rb
141
+ - lib/boreal/components/logger.rb
142
+ - lib/boreal/components/progress.rb
143
+ - lib/boreal/components/spinner.rb
144
+ - lib/boreal/components/table.rb
145
+ - lib/boreal/palette.rb
146
+ - lib/boreal/renderer.rb
147
+ - lib/boreal/terminal.rb
148
+ - lib/boreal/theme.rb
149
+ - lib/boreal/version.rb
150
+ homepage: https://github.com/pleme-io/boreal
151
+ licenses:
152
+ - Apache-2.0
153
+ metadata:
154
+ rubygems_mfa_required: 'true'
155
+ rdoc_options: []
156
+ require_paths:
157
+ - lib
158
+ required_ruby_version: !ruby/object:Gem::Requirement
159
+ requirements:
160
+ - - ">="
161
+ - !ruby/object:Gem::Version
162
+ version: 3.3.0
163
+ required_rubygems_version: !ruby/object:Gem::Requirement
164
+ requirements:
165
+ - - ">="
166
+ - !ruby/object:Gem::Version
167
+ version: '0'
168
+ requirements: []
169
+ rubygems_version: 3.6.6
170
+ specification_version: 4
171
+ summary: Nord-themed CLI look-and-feel for Ruby
172
+ test_files: []