sai 0.3.2 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -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.azure.decorate('Hello') #=> "\e[38;2;0;127;255mHello\e[0m"
18
- # decorator.on_azure.decorate('Hello') #=> "\e[48;2;0;127;255mHello\e[0m"
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/named_colors.rb with RBS::Inline
1
+ # Generated from lib/sai/registry.rb with RBS::Inline
2
2
 
3
3
  module Sai
4
- # A collection of named colors and their RGB values
4
+ # The named color registry
5
5
  #
6
6
  # @author {https://aaronmallen.me Aaron Allen}
7
- # @since 0.3.1
7
+ # @since 0.4.0
8
8
  #
9
9
  # @api private
10
- module NamedColors
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.3.2
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
- # Install the color methods onto {Sai} and {Sai::Decorator}
48
+ # Subscribe to registry changes
80
49
  #
81
50
  # @author {https://aaronmallen.me Aaron Allen}
82
- # @since 0.3.2
51
+ # @since 0.4.0
83
52
  #
84
53
  # @api private
85
54
  #
86
- # @param name [Symbol] the name of the color to install
55
+ # @param subscriber [Object] the subscriber
87
56
  #
88
57
  # @return [void]
89
- # @rbs (Symbol name) -> void
90
- private def self.install_color: (Symbol name) -> void
58
+ # @rbs (Object subscriber) -> void
59
+ def self.subscribe: (Object subscriber) -> void
91
60
 
92
- # Provision a color for the registry
61
+ # Broadcast a color registration to all subscribers
93
62
  #
94
63
  # @author {https://aaronmallen.me Aaron Allen}
95
- # @since 0.3.2
64
+ # @since 0.4.0
96
65
  #
97
66
  # @api private
98
67
  #
99
- # @param name [Symbol] the name of the color to register
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, Array[Integer] | String rgb_or_hex) -> void
104
- private def self.provision_color: (Symbol name, Array[Integer] | String rgb_or_hex) -> void
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 Sai named colors registry
84
+ # The registry subscribers
107
85
  #
108
86
  # @author {https://aaronmallen.me Aaron Allen}
109
- # @since 0.3.2
87
+ # @since 0.4.0
110
88
  #
111
89
  # @api private
112
90
  #
113
- # @return [Hash{Symbol => Array<Integer>}] the named colors registry
114
- private def self.registry: () -> untyped
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.3.2
98
+ # @since 0.4.0
120
99
  #
121
100
  # @api private
122
101
  #