ex_aequo 0.1.2 → 0.1.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8b6cd6a07b2a9d435aeadf493afb7c3efb927697e24ba774e524d2c05d0345dc
4
- data.tar.gz: 6d7ad31a36ccd40db1673cf2bb9e50303cb23300a1f0455fcdae85cb217c21ed
3
+ metadata.gz: '0499472f115bf5da195d99bdd428ba149cdfdd9aaafa9fcc3142bed9666912c8'
4
+ data.tar.gz: c5f216790f1eff9d99e779c6e2ca1560f02add2714e7e49286467bdf0a49d34a
5
5
  SHA512:
6
- metadata.gz: 1d58560196e7c7a9ba5ab95eacced6545843a35e12c0b5cea22e43cdeb3e2d416012e4328f625d482dfdcce77b18d83320b22ac0224764555220e8fc750bd026
7
- data.tar.gz: 1f4ca9354ac79edd8cb66690bb2b89986bd2a1411393862be7baefbfcd8dbfc62d349dad1f7f4cf4d7146636bc54049295ab0cbacd044bd52ca81c3160619b91
6
+ metadata.gz: e37bb04b1113d2f9dd82736382d3616bccd46e279be3a588bbdb113a34a6788d289d4baf4e2d7c4eaed2340cd4db3b2ea0e4950c278ad6f3435ce6530b7e1e21
7
+ data.tar.gz: 498f891d7209f9942a121db3d0ee7ae63f7e07399d4a0503ae2880acbf24df4795cdfdd1a75f4f2273a61268db251cf1f565aeb62fcfd6ee4435ddfdf19c6e15
@@ -9,10 +9,10 @@ module ExAequo
9
9
 
10
10
  def ansi256(color, bold: false, dim: false, italic: false, underline: false)
11
11
  case color
12
- in 1..256
12
+ in 0..255
13
13
  "\e[38;5;#{color}#{postfix_modifiers(bold:, dim:, italic:, underline:)}m"
14
14
  else
15
- raise IllegalColor, "#{color.inspect} is not a color number between 1 and 256"
15
+ raise IllegalColor, "#{color.inspect} is not a color number between 0 and 255"
16
16
  end
17
17
  end
18
18
  end
@@ -9,6 +9,7 @@ module ExAequo
9
9
  ansi: nil,
10
10
  ansi256: nil,
11
11
  rgb: nil,
12
+ web: nil
12
13
  }.freeze
13
14
 
14
15
  StyleKeywords = {
@@ -42,7 +43,7 @@ module ExAequo
42
43
 
43
44
  def _check_rgb_args!(kwds)
44
45
  unless kwds.values_at(*ColorMethodKeywords.keys).compact.size == 1
45
- raise ArgumentError, 'need to specify exactly one of the following keyword arguments: :ansi, :ansi256, :rgb'
46
+ raise ArgumentError, 'need to specify exactly one of the following keyword arguments: :ansi, :ansi256, :rgb, :web'
46
47
  end
47
48
 
48
49
  if kwds[:rgb] && Access.any_key?(kwds, :bold, :dim)
@@ -54,9 +55,11 @@ module ExAequo
54
55
  end
55
56
 
56
57
  def _color_code(**kwds)
57
- kwds => {ansi:, ansi256:, rgb:, italic:, underline:}
58
+ kwds => {ansi:, ansi256:, rgb:, web:, italic:, underline:}
58
59
  if rgb
59
60
  ExAequo::Color.rgb(*Array(rgb), italic:, underline:)
61
+ elsif web
62
+ ExAequo::Color.rgb(*ExAequo::Color::Web.to_rgb(web), italic:, underline:)
60
63
  elsif ansi
61
64
  ExAequo::Color.ansi(ansi, **kwds.slice(*StyleKeywords.keys))
62
65
  else
@@ -0,0 +1,165 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ExAequo
4
+ module Color
5
+ module Web
6
+ extend self
7
+
8
+ WebColorNames = {
9
+ 'aliceblue' => [240, 248, 255],
10
+ 'antiquewhite' => [250, 235, 215],
11
+ 'aqua' => [0, 255, 255],
12
+ 'aquamarine' => [127, 255, 212],
13
+ 'azure' => [240, 255, 255],
14
+ 'beige' => [245, 245, 220],
15
+ 'bisque' => [255, 228, 196],
16
+ 'black' => [0, 0, 0],
17
+ 'blanchedalmond' => [255, 235, 205],
18
+ 'blue' => [0, 0, 255],
19
+ 'blueviolet' => [138, 43, 226],
20
+ 'brown' => [165, 42, 42],
21
+ 'burlywood' => [222, 184, 135],
22
+ 'cadetblue' => [95, 158, 160],
23
+ 'chartreuse' => [127, 255, 0],
24
+ 'chocolate' => [210, 105, 30],
25
+ 'coral' => [255, 127, 80],
26
+ 'cornflowerblue' => [100, 149, 237],
27
+ 'cornsilk' => [255, 248, 220],
28
+ 'crimson' => [220, 20, 60],
29
+ 'cyan' => [0, 255, 255],
30
+ 'darkblue' => [0, 0, 139],
31
+ 'darkcyan' => [0, 139, 139],
32
+ 'darkgoldenrod' => [184, 134, 11],
33
+ 'darkgray' => [169, 169, 169],
34
+ 'darkgreen' => [0, 100, 0],
35
+ 'darkgrey' => [169, 169, 169],
36
+ 'darkkhaki' => [189, 183, 107],
37
+ 'darkmagenta' => [139, 0, 139],
38
+ 'darkolivegreen' => [85, 107, 47],
39
+ 'darkorange' => [255, 140, 0],
40
+ 'darkorchid' => [153, 50, 204],
41
+ 'darkred' => [139, 0, 0],
42
+ 'darksalmon' => [233, 150, 122],
43
+ 'darkseagreen' => [143, 188, 143],
44
+ 'darkslateblue' => [72, 61, 139],
45
+ 'darkslategray' => [47, 79, 79],
46
+ 'darkslategrey' => [47, 79, 79],
47
+ 'darkturquoise' => [0, 206, 209],
48
+ 'darkviolet' => [148, 0, 211],
49
+ 'deeppink' => [255, 20, 147],
50
+ 'deepskyblue' => [0, 191, 255],
51
+ 'dimgray' => [105, 105, 105],
52
+ 'dimgrey' => [105, 105, 105],
53
+ 'dodgerblue' => [30, 144, 255],
54
+ 'firebrick' => [178, 34, 34],
55
+ 'floralwhite' => [255, 250, 240],
56
+ 'forestgreen' => [34, 139, 34],
57
+ 'fuchsia' => [255, 0, 255],
58
+ 'gainsboro' => [220, 220, 220],
59
+ 'ghostwhite' => [248, 248, 255],
60
+ 'gold' => [255, 215, 0],
61
+ 'goldenrod' => [218, 165, 32],
62
+ 'gray' => [128, 128, 128],
63
+ 'green' => [0, 128, 0],
64
+ 'greenyellow' => [173, 255, 47],
65
+ 'grey' => [128, 128, 128],
66
+ 'honeydew' => [240, 255, 240],
67
+ 'hotpink' => [255, 105, 180],
68
+ 'indianred' => [205, 92, 92],
69
+ 'indigo' => [75, 0, 130],
70
+ 'ivory' => [255, 255, 240],
71
+ 'khaki' => [240, 230, 140],
72
+ 'lavender' => [230, 230, 250],
73
+ 'lavenderblush' => [255, 240, 245],
74
+ 'lawngreen' => [124, 252, 0],
75
+ 'lemonchiffon' => [255, 250, 205],
76
+ 'lightblue' => [173, 216, 230],
77
+ 'lightcoral' => [240, 128, 128],
78
+ 'lightcyan' => [224, 255, 255],
79
+ 'lightgoldenrodyellow' => [250, 250, 210],
80
+ 'lightgray' => [211, 211, 211],
81
+ 'lightgreen' => [144, 238, 144],
82
+ 'lightgrey' => [211, 211, 211],
83
+ 'lightpink' => [255, 182, 193],
84
+ 'lightsalmon' => [255, 160, 122],
85
+ 'lightseagreen' => [32, 178, 170],
86
+ 'lightskyblue' => [135, 206, 250],
87
+ 'lightslategray' => [119, 136, 153],
88
+ 'lightslategrey' => [119, 136, 153],
89
+ 'lightsteelblue' => [176, 196, 222],
90
+ 'lightyellow' => [255, 255, 224],
91
+ 'lime' => [0, 255, 0],
92
+ 'limegreen' => [50, 205, 50],
93
+ 'linen' => [250, 240, 230],
94
+ 'magenta' => [255, 0, 255],
95
+ 'maroon' => [128, 0, 0],
96
+ 'mediumaquamarine' => [102, 205, 170],
97
+ 'mediumblue' => [0, 0, 205],
98
+ 'mediumorchid' => [186, 85, 211],
99
+ 'mediumpurple' => [147, 112, 219],
100
+ 'mediumseagreen' => [60, 179, 113],
101
+ 'mediumslateblue' => [123, 104, 238],
102
+ 'mediumspringgreen' => [0, 250, 154],
103
+ 'mediumturquoise' => [72, 209, 204],
104
+ 'mediumvioletred' => [199, 21, 133],
105
+ 'midnightblue' => [25, 25, 112],
106
+ 'mintcream' => [245, 255, 250],
107
+ 'mistyrose' => [255, 228, 225],
108
+ 'moccasin' => [255, 228, 181],
109
+ 'navajowhite' => [255, 222, 173],
110
+ 'navy' => [0, 0, 128],
111
+ 'oldlace' => [253, 245, 230],
112
+ 'olive' => [128, 128, 0],
113
+ 'olivedrab' => [107, 142, 35],
114
+ 'orange' => [255, 165, 0],
115
+ 'orangered' => [255, 69, 0],
116
+ 'orchid' => [218, 112, 214],
117
+ 'palegoldenrod' => [238, 232, 170],
118
+ 'palegreen' => [152, 251, 152],
119
+ 'paleturquoise' => [175, 238, 238],
120
+ 'palevioletred' => [219, 112, 147],
121
+ 'papayawhip' => [255, 239, 213],
122
+ 'peachpuff' => [255, 218, 185],
123
+ 'peru' => [205, 133, 63],
124
+ 'pink' => [255, 192, 203],
125
+ 'plum' => [221, 160, 221],
126
+ 'powderblue' => [176, 224, 230],
127
+ 'purple' => [128, 0, 128],
128
+ 'red' => [255, 0, 0],
129
+ 'rosybrown' => [188, 143, 143],
130
+ 'royalblue' => [65, 105, 225],
131
+ 'saddlebrown' => [139, 69, 19],
132
+ 'salmon' => [250, 128, 114],
133
+ 'sandybrown' => [244, 164, 96],
134
+ 'seagreen' => [46, 139, 87],
135
+ 'seashell' => [255, 245, 238],
136
+ 'sienna' => [160, 82, 45],
137
+ 'silver' => [192, 192, 192],
138
+ 'skyblue' => [135, 206, 235],
139
+ 'slateblue' => [106, 90, 205],
140
+ 'slategray' => [112, 128, 144],
141
+ 'slategrey' => [112, 128, 144],
142
+ 'snow' => [255, 250, 250],
143
+ 'springgreen' => [0, 255, 127],
144
+ 'steelblue' => [70, 130, 180],
145
+ 'tan' => [210, 180, 140],
146
+ 'teal' => [0, 128, 128],
147
+ 'thistle' => [216, 191, 216],
148
+ 'tomato' => [255, 99, 71],
149
+ 'transparent' => [0, 0, 0],
150
+ 'turquoise' => [64, 224, 208],
151
+ 'violet' => [238, 130, 238],
152
+ 'wheat' => [245, 222, 179],
153
+ 'white' => [255, 255, 255],
154
+ 'whitesmoke' => [245, 245, 245],
155
+ 'yellow' => [255, 255, 0],
156
+ 'yellowgreen' => [154, 205, 50],
157
+ 'rebeccapurple' => [102, 51, 153]
158
+ }.freeze
159
+ def to_rgb(color)
160
+ WebColorNames.fetch(color.to_s.downcase) { raise ArgumentError, "unsupported web color: #{color}" }
161
+ end
162
+ end
163
+ end
164
+ end
165
+ # SPDX-License-Identifier: Apache-2.0
@@ -6,6 +6,7 @@ require_relative 'kernel/fn'
6
6
  require_relative 'color/ansi'
7
7
  require_relative 'color/ansi256'
8
8
  require_relative 'color/rgb'
9
+ require_relative 'color/web'
9
10
 
10
11
  require_relative 'color/colorizer'
11
12
 
@@ -0,0 +1,29 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'color/colorizer'
4
+ module ExAequo
5
+ module Colors
6
+ extend self
7
+
8
+ def ansi(text, ansi, **kwds)
9
+ ExAequo::Color::Colorizer.colorize(text, ansi:, **kwds)
10
+ end
11
+
12
+ def ansi256(text, ansi256, **kwds)
13
+ ExAequo::Color::Colorizer.colorize(text, ansi256:, **kwds)
14
+ end
15
+
16
+ def rgb(text, *args, **kwds)
17
+ if args.size == 1
18
+ ExAequo::Color::Colorizer.colorize(text, rgb: args.first, **kwds)
19
+ else
20
+ ExAequo::Color::Colorizer.colorize(text, rgb: args, **kwds)
21
+ end
22
+ end
23
+
24
+ def method_missing(name, text, **kwds)
25
+ ExAequo::Color::Colorizer.colorize(text, web: name, **kwds)
26
+ end
27
+ end
28
+ end
29
+ # SPDX-License-Identifier: Apache-2.0
@@ -2,7 +2,7 @@
2
2
 
3
3
  module ExAequo
4
4
  module Version
5
- VERSION = '0.1.2'
5
+ VERSION = '0.1.4'
6
6
  end
7
7
  end
8
8
  # SPDX-License-Identifier: Apache-2.0
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ex_aequo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Robert Dober
@@ -27,6 +27,8 @@ files:
27
27
  - lib/ex_aequo/color/colorizer.rb
28
28
  - lib/ex_aequo/color/modifiers.rb
29
29
  - lib/ex_aequo/color/rgb.rb
30
+ - lib/ex_aequo/color/web.rb
31
+ - lib/ex_aequo/colors.rb
30
32
  - lib/ex_aequo/kernel.rb
31
33
  - lib/ex_aequo/kernel/access.rb
32
34
  - lib/ex_aequo/kernel/fn.rb