sai 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.yardopts +11 -0
- data/CHANGELOG.md +18 -0
- data/LICENSE +21 -0
- data/README.md +275 -0
- data/lib/sai/ansi.rb +94 -0
- data/lib/sai/conversion/color_sequence.rb +167 -0
- data/lib/sai/conversion/rgb.rb +322 -0
- data/lib/sai/decorator.rb +856 -0
- data/lib/sai/support.rb +115 -0
- data/lib/sai/terminal/capabilities.rb +121 -0
- data/lib/sai/terminal/color_mode.rb +63 -0
- data/lib/sai.rb +185 -0
- data/sig/sai/ansi.rbs +51 -0
- data/sig/sai/conversion/color_sequence.rbs +114 -0
- data/sig/sai/conversion/rgb.rbs +243 -0
- data/sig/sai/decorator.rbs +246 -0
- data/sig/sai/support.rbs +108 -0
- data/sig/sai/terminal/capabilities.rbs +81 -0
- data/sig/sai/terminal/color_mode.rbs +63 -0
- data/sig/sai.rbs +207 -0
- metadata +67 -0
@@ -0,0 +1,63 @@
|
|
1
|
+
# Generated from lib/sai/terminal/color_mode.rb with RBS::Inline
|
2
|
+
|
3
|
+
module Sai
|
4
|
+
module Terminal
|
5
|
+
# Represents different color support levels for terminal interfaces
|
6
|
+
#
|
7
|
+
# @author {https://aaronmallen.me Aaron Allen}
|
8
|
+
# @since unreleased
|
9
|
+
#
|
10
|
+
# @api private
|
11
|
+
module ColorMode
|
12
|
+
# The terminal does not support color output
|
13
|
+
#
|
14
|
+
# @author {https://aaronmallen.me Aaron Allen}
|
15
|
+
# @since unreleased
|
16
|
+
#
|
17
|
+
# @api private
|
18
|
+
#
|
19
|
+
# @return [Integer] the color mode
|
20
|
+
NO_COLOR: Integer
|
21
|
+
|
22
|
+
# The terminal supports 8 colors (3-bit)
|
23
|
+
#
|
24
|
+
# @author {https://aaronmallen.me Aaron Allen}
|
25
|
+
# @since unreleased
|
26
|
+
#
|
27
|
+
# @api private
|
28
|
+
#
|
29
|
+
# @return [Integer] the color mode
|
30
|
+
BASIC: Integer
|
31
|
+
|
32
|
+
# The terminal supports 16 colors (4-bit)
|
33
|
+
#
|
34
|
+
# @author {https://aaronmallen.me Aaron Allen}
|
35
|
+
# @since unreleased
|
36
|
+
#
|
37
|
+
# @api private
|
38
|
+
#
|
39
|
+
# @return [Integer] the color mode
|
40
|
+
ANSI: Integer
|
41
|
+
|
42
|
+
# The terminal supports 256 colors (8-bit)
|
43
|
+
#
|
44
|
+
# @author {https://aaronmallen.me Aaron Allen}
|
45
|
+
# @since unreleased
|
46
|
+
#
|
47
|
+
# @api private
|
48
|
+
#
|
49
|
+
# @return [Integer] the color mode
|
50
|
+
BIT8: Integer
|
51
|
+
|
52
|
+
# The terminal supports 16 million colors (24-bit)
|
53
|
+
#
|
54
|
+
# @author {https://aaronmallen.me Aaron Allen}
|
55
|
+
# @since unreleased
|
56
|
+
#
|
57
|
+
# @api private
|
58
|
+
#
|
59
|
+
# @return [Integer] the color mode
|
60
|
+
TRUE_COLOR: Integer
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
data/sig/sai.rbs
ADDED
@@ -0,0 +1,207 @@
|
|
1
|
+
# Generated from lib/sai.rb with RBS::Inline
|
2
|
+
|
3
|
+
# An elegant color management system for crafting sophisticated CLI applications
|
4
|
+
#
|
5
|
+
# Sai (彩) - meaning 'coloring' or 'paint' in Japanese - is a powerful and intuitive system for managing color output in
|
6
|
+
# command-line applications. Drawing inspiration from traditional Japanese artistic techniques, Sai brings vibrancy and
|
7
|
+
# harmony to terminal interfaces through its sophisticated color management
|
8
|
+
#
|
9
|
+
# Sai empowers developers to create beautiful, colorful CLI applications that maintain visual consistency across
|
10
|
+
# different terminal capabilities. Like its artistic namesake, it combines simplicity and sophistication to bring rich,
|
11
|
+
# adaptive color to your terminal interfaces
|
12
|
+
#
|
13
|
+
# When included in a class or module, Sai provides the following instance methods:
|
14
|
+
# * {#decorator} - Returns a new instance of {Decorator} for method chaining
|
15
|
+
# * {#terminal_color_support} - Returns the color support capabilities of the current terminal
|
16
|
+
#
|
17
|
+
# The Sai module itself responds to all the same methods as {Decorator}, excluding methods used for applying
|
18
|
+
# decorations (apply, call, decorate, encode). These methods are directly delegated to a new {Decorator} instance
|
19
|
+
#
|
20
|
+
# @author {https://aaronmallen.me Aaron Allen}
|
21
|
+
# @since unreleased
|
22
|
+
#
|
23
|
+
# @api public
|
24
|
+
#
|
25
|
+
# @example Using Sai as a module
|
26
|
+
# class MyClass
|
27
|
+
# include Sai
|
28
|
+
# end
|
29
|
+
#
|
30
|
+
# my_class = MyClass.new
|
31
|
+
# my_class.decorator.red.on_blue.bold.decorate('Hello, World!')
|
32
|
+
# #=> "\e[38;2;205;0;0m\e[48;2;0;0;238m\e[1mHello, World!\e[0m"
|
33
|
+
#
|
34
|
+
# my_class.terminal_color_support.true_color? # => true
|
35
|
+
#
|
36
|
+
# @example Using Sai directly
|
37
|
+
# Sai.red.on_blue.bold.decorate('Hello, World!')
|
38
|
+
# #=> "\e[38;2;205;0;0m\e[48;2;0;0;238m\e[1mHello, World!\e[0m"
|
39
|
+
#
|
40
|
+
# Sai.support.true_color? # => true
|
41
|
+
module Sai
|
42
|
+
def black: () -> self
|
43
|
+
|
44
|
+
def blink: () -> self
|
45
|
+
|
46
|
+
def blue: () -> self
|
47
|
+
|
48
|
+
def bold: () -> self
|
49
|
+
|
50
|
+
def bright_black: () -> self
|
51
|
+
|
52
|
+
def bright_blue: () -> self
|
53
|
+
|
54
|
+
def bright_cyan: () -> self
|
55
|
+
|
56
|
+
def bright_green: () -> self
|
57
|
+
|
58
|
+
def bright_magenta: () -> self
|
59
|
+
|
60
|
+
def bright_red: () -> self
|
61
|
+
|
62
|
+
def bright_white: () -> self
|
63
|
+
|
64
|
+
def bright_yellow: () -> self
|
65
|
+
|
66
|
+
def conceal: () -> self
|
67
|
+
|
68
|
+
def cyan: () -> self
|
69
|
+
|
70
|
+
def dim: () -> self
|
71
|
+
|
72
|
+
def green: () -> self
|
73
|
+
|
74
|
+
def italic: () -> self
|
75
|
+
|
76
|
+
def magenta: () -> self
|
77
|
+
|
78
|
+
def no_blink: () -> self
|
79
|
+
|
80
|
+
def no_conceal: () -> self
|
81
|
+
|
82
|
+
def no_italic: () -> self
|
83
|
+
|
84
|
+
def no_reverse: () -> self
|
85
|
+
|
86
|
+
def no_strike: () -> self
|
87
|
+
|
88
|
+
def no_underline: () -> self
|
89
|
+
|
90
|
+
def normal_intensity: () -> self
|
91
|
+
|
92
|
+
def on_black: () -> self
|
93
|
+
|
94
|
+
def on_blue: () -> self
|
95
|
+
|
96
|
+
def on_bright_black: () -> self
|
97
|
+
|
98
|
+
def on_bright_blue: () -> self
|
99
|
+
|
100
|
+
def on_bright_cyan: () -> self
|
101
|
+
|
102
|
+
def on_bright_green: () -> self
|
103
|
+
|
104
|
+
def on_bright_magenta: () -> self
|
105
|
+
|
106
|
+
def on_bright_red: () -> self
|
107
|
+
|
108
|
+
def on_bright_white: () -> self
|
109
|
+
|
110
|
+
def on_bright_yellow: () -> self
|
111
|
+
|
112
|
+
def on_cyan: () -> self
|
113
|
+
|
114
|
+
def on_green: () -> self
|
115
|
+
|
116
|
+
def on_magenta: () -> self
|
117
|
+
|
118
|
+
def on_red: () -> self
|
119
|
+
|
120
|
+
def on_white: () -> self
|
121
|
+
|
122
|
+
def on_yellow: () -> self
|
123
|
+
|
124
|
+
def rapid_blink: () -> self
|
125
|
+
|
126
|
+
def red: () -> self
|
127
|
+
|
128
|
+
def reverse: () -> self
|
129
|
+
|
130
|
+
def strike: () -> self
|
131
|
+
|
132
|
+
def underline: () -> self
|
133
|
+
|
134
|
+
def white: () -> self
|
135
|
+
|
136
|
+
def yellow: () -> self
|
137
|
+
|
138
|
+
# The supported color modes for the terminal
|
139
|
+
#
|
140
|
+
# @author {https://aaronmallen.me Aaron Allen}
|
141
|
+
# @since unreleased
|
142
|
+
#
|
143
|
+
# @api public
|
144
|
+
#
|
145
|
+
# @example Check the color support of the terminal
|
146
|
+
# Sai.support.ansi? # => true
|
147
|
+
# Sai.support.basic? # => true
|
148
|
+
# Sai.support.bit8? # => true
|
149
|
+
# Sai.support.no_color? # => false
|
150
|
+
# Sai.support.true_color? # => true
|
151
|
+
#
|
152
|
+
# @return [Support] the color support
|
153
|
+
# @rbs () -> Support
|
154
|
+
def self.support: () -> Support
|
155
|
+
|
156
|
+
# Detect the color capabilities of the terminal
|
157
|
+
#
|
158
|
+
# @author {https://aaronmallen.me Aaron Allen}
|
159
|
+
# @since unreleased
|
160
|
+
#
|
161
|
+
# @api private
|
162
|
+
#
|
163
|
+
# @return [Integer] the color mode
|
164
|
+
# @rbs () -> Integer
|
165
|
+
private def self.color_mode: () -> Integer
|
166
|
+
|
167
|
+
# A helper method to initialize an instance of {Decorator}
|
168
|
+
#
|
169
|
+
# @author {https://aaronmallen.me Aaron Allen}
|
170
|
+
# @since unreleased
|
171
|
+
#
|
172
|
+
# @api public
|
173
|
+
#
|
174
|
+
# @example Initialize a new instance of {Decorator}
|
175
|
+
# class MyClass
|
176
|
+
# include Sai
|
177
|
+
# end
|
178
|
+
#
|
179
|
+
# MyClass.new.decorator.blue.on_red.bold.decorate('Hello, world!')
|
180
|
+
# #=> "\e[38;5;21m\e[48;5;160m\e[1mHello, world!\e[0m"
|
181
|
+
#
|
182
|
+
# @return [Decorator] the Decorator instance
|
183
|
+
# @rbs () -> Decorator
|
184
|
+
def decorator: () -> Decorator
|
185
|
+
|
186
|
+
# The supported color modes for the terminal
|
187
|
+
#
|
188
|
+
# @author {https://aaronmallen.me Aaron Allen}
|
189
|
+
# @since unreleased
|
190
|
+
#
|
191
|
+
# @api public
|
192
|
+
#
|
193
|
+
# @example Check the color support of the terminal
|
194
|
+
# class MyClass
|
195
|
+
# include Sai
|
196
|
+
# end
|
197
|
+
#
|
198
|
+
# MyClass.new.terminal_color_support.ansi? # => true
|
199
|
+
# MyClass.new.terminal_color_support.basic? # => true
|
200
|
+
# MyClass.new.terminal_color_support.bit8? # => true
|
201
|
+
# MyClass.new.terminal_color_support.no_color? # => false
|
202
|
+
# MyClass.new.terminal_color_support.true_color? # => true
|
203
|
+
#
|
204
|
+
# @return [Support] the color support
|
205
|
+
# @rbs () -> Support
|
206
|
+
def terminal_color_support: () -> Support
|
207
|
+
end
|
metadata
ADDED
@@ -0,0 +1,67 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: sai
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Aaron Allen
|
8
|
+
bindir: bin
|
9
|
+
cert_chain: []
|
10
|
+
date: 2025-01-19 00:00:00.000000000 Z
|
11
|
+
dependencies: []
|
12
|
+
description: |-
|
13
|
+
Sai (彩) - meaning 'coloring' or 'paint' in Japanese - is a powerful and intuitive system for managing color output in command-line applications. Drawing inspiration from traditional Japanese artistic techniques, Sai brings vibrancy and harmony to terminal interfaces through its sophisticated color management.
|
14
|
+
Sai empowers developers to create beautiful, colorful CLI applications that maintain visual consistency across different terminal capabilities. Like its artistic namesake, it combines simplicity and sophistication to bring rich, adaptive color to your terminal interfaces.
|
15
|
+
email:
|
16
|
+
- hello@aaronmallen.me
|
17
|
+
executables: []
|
18
|
+
extensions: []
|
19
|
+
extra_rdoc_files: []
|
20
|
+
files:
|
21
|
+
- ".yardopts"
|
22
|
+
- CHANGELOG.md
|
23
|
+
- LICENSE
|
24
|
+
- README.md
|
25
|
+
- lib/sai.rb
|
26
|
+
- lib/sai/ansi.rb
|
27
|
+
- lib/sai/conversion/color_sequence.rb
|
28
|
+
- lib/sai/conversion/rgb.rb
|
29
|
+
- lib/sai/decorator.rb
|
30
|
+
- lib/sai/support.rb
|
31
|
+
- lib/sai/terminal/capabilities.rb
|
32
|
+
- lib/sai/terminal/color_mode.rb
|
33
|
+
- sig/sai.rbs
|
34
|
+
- sig/sai/ansi.rbs
|
35
|
+
- sig/sai/conversion/color_sequence.rbs
|
36
|
+
- sig/sai/conversion/rgb.rbs
|
37
|
+
- sig/sai/decorator.rbs
|
38
|
+
- sig/sai/support.rbs
|
39
|
+
- sig/sai/terminal/capabilities.rbs
|
40
|
+
- sig/sai/terminal/color_mode.rbs
|
41
|
+
homepage: https://github.com/aaronmallen/sai
|
42
|
+
licenses:
|
43
|
+
- MIT
|
44
|
+
metadata:
|
45
|
+
bug_tracker_uri: https://github.com/aaronmallen/sai/issues
|
46
|
+
changelog_uri: https://github.com/aaronmallen/sai/releases/tag/0.1.0
|
47
|
+
homepage_uri: https://github.com/aaronmallen/sai
|
48
|
+
rubygems_mfa_required: 'true'
|
49
|
+
source_code_uri: https://github.com/aaronmallen/sai/tree/0.1.0
|
50
|
+
rdoc_options: []
|
51
|
+
require_paths:
|
52
|
+
- lib
|
53
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
54
|
+
requirements:
|
55
|
+
- - ">="
|
56
|
+
- !ruby/object:Gem::Version
|
57
|
+
version: '3.1'
|
58
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
59
|
+
requirements:
|
60
|
+
- - ">="
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: '0'
|
63
|
+
requirements: []
|
64
|
+
rubygems_version: 3.6.2
|
65
|
+
specification_version: 4
|
66
|
+
summary: An elegant color management system for crafting sophisticated CLI applications
|
67
|
+
test_files: []
|