sai 0.3.2 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +9 -1
- data/README.md +25 -4
- data/docs/USAGE.md +9 -16
- data/lib/sai/ansi.rb +40 -0
- data/lib/sai/conversion/rgb/color_space.rb +2 -2
- data/lib/sai/decorator/delegator.rb +79 -0
- data/lib/sai/decorator/named_colors.rb +38 -744
- data/lib/sai/decorator.rb +2 -3
- data/lib/sai/registry.rb +134 -0
- data/lib/sai.rb +28 -765
- data/sig/sai/ansi.rbs +21 -0
- data/sig/sai/decorator/delegator.rbs +95 -0
- data/sig/sai/decorator/named_colors.rbs +30 -1460
- data/sig/sai/decorator.rbs +2 -3
- data/sig/sai/{named_colors.rbs → registry.rbs} +31 -52
- data/sig/sai.rbs +14 -1519
- metadata +8 -8
- data/lib/sai/decorator/delegation.rb +0 -85
- data/lib/sai/named_colors.rb +0 -522
- data/sig/sai/decorator/delegation.rbs +0 -47
data/sig/sai/decorator.rbs
CHANGED
@@ -11,11 +11,10 @@ module Sai
|
|
11
11
|
# @note For each named color, two methods are dynamically generated:
|
12
12
|
# * color_name - Applies the color to the foreground
|
13
13
|
# * on_color_name - Applies the color to the backgroundAll color methods return {Decorator}
|
14
|
-
# @see Sai::NamedColors Sai::NamedColors for available color names
|
15
14
|
#
|
16
15
|
# @example Using a named color
|
17
|
-
# decorator.
|
18
|
-
# decorator.
|
16
|
+
# decorator.blue.decorate('Hello').to_s #=> "\e[38;2;0;0;238mHello\e[0m"
|
17
|
+
# decorator.on_blue.decorate('Hello').to_s #=> "\e[48;2;0;0;238mHello\e[0m"
|
19
18
|
class Decorator
|
20
19
|
include ColorManipulations
|
21
20
|
|
@@ -1,44 +1,13 @@
|
|
1
|
-
# Generated from lib/sai/
|
1
|
+
# Generated from lib/sai/registry.rb with RBS::Inline
|
2
2
|
|
3
3
|
module Sai
|
4
|
-
#
|
4
|
+
# The named color registry
|
5
5
|
#
|
6
6
|
# @author {https://aaronmallen.me Aaron Allen}
|
7
|
-
# @since 0.
|
7
|
+
# @since 0.4.0
|
8
8
|
#
|
9
9
|
# @api private
|
10
|
-
module
|
11
|
-
# Standard ANSI color names and their RGB values
|
12
|
-
#
|
13
|
-
# @author {https://aaronmallen.me Aaron Allen}
|
14
|
-
# @since 0.3.1
|
15
|
-
#
|
16
|
-
# @api private
|
17
|
-
#
|
18
|
-
# @return [Hash{Symbol => Array<Integer>}] the color names and RGB values
|
19
|
-
ANSI: untyped
|
20
|
-
|
21
|
-
# CSS color names and their RGB values
|
22
|
-
#
|
23
|
-
# @author {https://aaronmallen.me Aaron Allen}
|
24
|
-
# @since 0.3.1
|
25
|
-
#
|
26
|
-
# @api private
|
27
|
-
#
|
28
|
-
# @return [Hash{Symbol => Array<Integer>}] the color names and RGB values
|
29
|
-
CSS: Hash[Symbol, Array[Integer]]
|
30
|
-
|
31
|
-
# XTERM color names and their RGB values
|
32
|
-
#
|
33
|
-
# @author {https://aaronmallen.me Aaron Allen}
|
34
|
-
# @since 0.3.1
|
35
|
-
#
|
36
|
-
# @api private
|
37
|
-
#
|
38
|
-
# @return [Hash{Symbol => Array<Integer>}] the color names and RGB values
|
39
|
-
# rubocop:disable Naming/VariableNumber
|
40
|
-
XTERM: Hash[Symbol, Array[Integer]]
|
41
|
-
|
10
|
+
module Registry
|
42
11
|
# Look up an RGB value by color name
|
43
12
|
#
|
44
13
|
# @author {https://aaronmallen.me Aaron Allen}
|
@@ -65,7 +34,7 @@ module Sai
|
|
65
34
|
# Register a named color with an RGB or Hexadecimal value
|
66
35
|
#
|
67
36
|
# @author {https://aaronmallen.me Aaron Allen}
|
68
|
-
# @since 0.
|
37
|
+
# @since 0.4.0
|
69
38
|
#
|
70
39
|
# @api private
|
71
40
|
#
|
@@ -76,47 +45,57 @@ module Sai
|
|
76
45
|
# @rbs (String | Symbol name, Array[Integer] | String rgb_or_hex) -> void
|
77
46
|
def self.register: (String | Symbol name, Array[Integer] | String rgb_or_hex) -> void
|
78
47
|
|
79
|
-
#
|
48
|
+
# Subscribe to registry changes
|
80
49
|
#
|
81
50
|
# @author {https://aaronmallen.me Aaron Allen}
|
82
|
-
# @since 0.
|
51
|
+
# @since 0.4.0
|
83
52
|
#
|
84
53
|
# @api private
|
85
54
|
#
|
86
|
-
# @param
|
55
|
+
# @param subscriber [Object] the subscriber
|
87
56
|
#
|
88
57
|
# @return [void]
|
89
|
-
# @rbs (
|
90
|
-
|
58
|
+
# @rbs (Object subscriber) -> void
|
59
|
+
def self.subscribe: (Object subscriber) -> void
|
91
60
|
|
92
|
-
#
|
61
|
+
# Broadcast a color registration to all subscribers
|
93
62
|
#
|
94
63
|
# @author {https://aaronmallen.me Aaron Allen}
|
95
|
-
# @since 0.
|
64
|
+
# @since 0.4.0
|
96
65
|
#
|
97
66
|
# @api private
|
98
67
|
#
|
99
|
-
# @param
|
100
|
-
# @param rgb_or_hex [Array<Integer>, String] the RGB or Hexadecimal value of the color
|
68
|
+
# @param color_name [Symbol] the color name
|
101
69
|
#
|
102
70
|
# @return [void]
|
103
|
-
# @rbs (Symbol name
|
104
|
-
private def self.
|
71
|
+
# @rbs (Symbol name) -> void
|
72
|
+
private def self.broadcast_registration: (Symbol name) -> void
|
73
|
+
|
74
|
+
# The Sai named colors lookup
|
75
|
+
#
|
76
|
+
# @author {https://aaronmallen.me Aaron Allen}
|
77
|
+
# @since 0.4.0
|
78
|
+
#
|
79
|
+
# @api private
|
80
|
+
#
|
81
|
+
# @return [Hash{Symbol => Array<Integer>}] the named colors lookup
|
82
|
+
private def self.lookup: () -> untyped
|
105
83
|
|
106
|
-
# The
|
84
|
+
# The registry subscribers
|
107
85
|
#
|
108
86
|
# @author {https://aaronmallen.me Aaron Allen}
|
109
|
-
# @since 0.
|
87
|
+
# @since 0.4.0
|
110
88
|
#
|
111
89
|
# @api private
|
112
90
|
#
|
113
|
-
# @return [
|
114
|
-
|
91
|
+
# @return [Array<Class, Module, Object>] the subscribers
|
92
|
+
# @rbs () -> Array[Class | Module | Object]
|
93
|
+
private def self.subscribers: () -> Array[Class | Module | Object]
|
115
94
|
|
116
95
|
# A Mutex for thread safety
|
117
96
|
#
|
118
97
|
# @author {https://aaronmallen.me Aaron Allen}
|
119
|
-
# @since 0.
|
98
|
+
# @since 0.4.0
|
120
99
|
#
|
121
100
|
# @api private
|
122
101
|
#
|