colorato 1.0.0 → 1.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6a04ec628455d986e1a98d0046ee1b63b1f046c1bc6d7018ef5cf2524998e18e
4
- data.tar.gz: 947d85416c2d2f2a2d28645f97858788886a58b5c4088ac4b4bb55917ca781aa
3
+ metadata.gz: b28fd8267ee3efc81eeff84c4d0cb31904898b0c97f52277966e720f2e739ffd
4
+ data.tar.gz: 2d096f6c8970cebea52a1e30fba7bd4fab9d5d85741c1968caed17cc0941d060
5
5
  SHA512:
6
- metadata.gz: 261f7abe0f7bebe479efae920db1ccc976c547ea2e312e1406b7efa637d0273e1eb77483b6945e63b6c3204c61389c40ef7172db1f4ca6e1bc0d64be8889add1
7
- data.tar.gz: 968df424e0014f91f5cbe5fce37b51576790ecfd04453e6a88d168e2b096b8de9cbd617b765eef0cf76c0c96c5adf8c765794cad3364daa7c9db4f9b20f85764
6
+ metadata.gz: '08c68f4329d2d36927ccfe3d02805ef8f21bde89f0ddb70a71b935454f8b2fcbe6557098d3ded29b2e38664a9307849f5fd9978fe2227867fafa2792ff1c6d75'
7
+ data.tar.gz: 8cc6529dd0968df22087e816cc6a78b8b6ca4a6a109455b2401e7bf85273072b820b6979af0497aabb8c927b4298dd757a2bc2d4f3f5bb2f3c5f71535bbf210e
data/CHANGELOG.md CHANGED
@@ -2,6 +2,12 @@
2
2
  # colorato
3
3
 
4
4
 
5
+ ## 1.1.0 released 2025-01-16
6
+
7
+ * colorato.blue { 'blo' + 'ck' }
8
+ * Show the colours when `ruby lib/colorato.rb`
9
+
10
+
5
11
  ## 1.0.0 released 2023-01-03
6
12
 
7
13
  * Introduce `make colo.rb`
data/LICENSE.txt CHANGED
@@ -1,5 +1,5 @@
1
1
 
2
- Copyright (c) 2015-2023, John Mettraux, jmettraux+flor@gmail.com
2
+ Copyright (c) 2015-2025, John Mettraux, jmettraux+flor@gmail.com
3
3
 
4
4
  Permission is hereby granted, free of charge, to any person obtaining a copy
5
5
  of this software and associated documentation files (the "Software"), to deal
data/README.md CHANGED
@@ -14,8 +14,10 @@ NC = Colorato.nocolours
14
14
 
15
15
  C.blue # => "\e[34m"
16
16
  C.blue('car') # => "\e[34mcar\e[0;0m"
17
+ C.blue { 'car' } # => "\e[34mcar\e[0;0m"
17
18
 
18
19
  NC.blue('car') # => "car"
20
+ NC.blue { 'car' } # => "car"
19
21
  ```
20
22
 
21
23
  ### .decolour(string)
data/colorato.gemspec CHANGED
@@ -26,6 +26,7 @@ terminal colors extracted from flor
26
26
  'homepage_uri' => s.homepage,
27
27
  'source_code_uri' => s.homepage,
28
28
  #'wiki_uri' => s.homepage + '/wiki',
29
+ 'rubygems_mfa_required' => 'true',
29
30
  }
30
31
 
31
32
  #s.files = `git ls-files`.split("\n")
@@ -40,7 +41,8 @@ terminal colors extracted from flor
40
41
  #s.add_runtime_dependency 'raabro', '~> 1.4'
41
42
  #s.add_runtime_dependency 'et-orbi', '~> 1', '>= 1.2.7'
42
43
 
43
- s.add_development_dependency 'rspec', '~> 3.12'
44
+ #s.add_development_dependency 'rspec', '~> 3.12'
45
+ s.add_development_dependency 'probatio', '~> 1'
44
46
 
45
47
  s.require_path = 'lib'
46
48
  end
data/lib/colorato/core.rb CHANGED
@@ -12,6 +12,7 @@ module Colorato
12
12
  black 30 red 31 green 32 yellow 33 blue 34 magenta 35 cyan 36
13
13
  light_gray 37 dark_gray 90 light_red 91 light_green 92 light_yellow 93
14
14
  light_blue 94 light_magenta 95 light_cyan 96 white 97
15
+
15
16
  bg_default 49 bg_black 40 bg_red 41 bg_green 42 bg_yellow 43 bg_blue 44
16
17
  bg_magenta 45 bg_cyan 46 bg_light_gray 47 bg_dark_gray 100
17
18
  bg_light_red 101 bg_light_green 102 bg_light_yellow 103
@@ -35,16 +36,14 @@ module Colorato
35
36
  if v.match(/\A\d/) # Ruby 2.3 doesn't have String#match?
36
37
 
37
38
  ::Colorato::Colours.class_eval(%{
38
- def #{k}(s=nil)
39
- s ?
40
- "\e[#{v}m\#{s}\e[0;0m" :
39
+ def #{k}(s=nil, &block)
40
+ (x = (block && block.call) || s) ?
41
+ "\e[#{v}m\#{x}\e[0;0m" :
41
42
  "\e[#{v}m"
42
43
  end })
43
44
  ::Colorato::NoColours.class_eval(%{
44
- def #{k}(s=nil)
45
- s ?
46
- s :
47
- ''
45
+ def #{k}(s=nil, &block)
46
+ (x = (block && block.call) || s) ? x : ''
48
47
  end })
49
48
 
50
49
  else
@@ -70,6 +69,38 @@ module Colorato
70
69
  alias colors colours
71
70
  alias nocolors no_colours
72
71
  alias no_colors no_colours
72
+
73
+ def show_colours
74
+
75
+ cs = Colorato.colours.public_methods
76
+ .inject([]) { |a, n|
77
+ m = n.to_s.match(/^bg_(.+)$/)
78
+ a << m[1] if m
79
+ a }
80
+
81
+ #%w[ (default) bright dim ].each do |filter|
82
+
83
+ puts
84
+
85
+ fs = %w[ (def) bright dim ]
86
+
87
+ puts "%14s %-9s %-9s %-9s" % ([ '' ] + fs)
88
+ puts
89
+
90
+ cs.each do |n|
91
+ a = [ n ]
92
+ fs.each do |f|
93
+ f = Colorato.colours.send(f) rescue ''
94
+ fgc = f + Colorato.colours.send(n)
95
+ bgc = f + Colorato.colours.send("bg_#{n}")
96
+ a << (fgc + 'Text' + Colorato.colours.reset)
97
+ a << (bgc + ' ' + Colorato.colours.reset)
98
+ end
99
+ puts "%14s: %s %s %s %s %s %s" % a
100
+ end
101
+
102
+ puts
103
+ end
73
104
  end
74
105
  end
75
106
 
data/lib/colorato.rb CHANGED
@@ -3,9 +3,12 @@
3
3
 
4
4
  module Colorato
5
5
 
6
- VERSION = '1.0.0'
6
+ VERSION = '1.1.0'
7
7
  end
8
8
 
9
9
  require 'colorato/core'
10
10
  require 'colorato/more'
11
11
 
12
+
13
+ Colorato.show_colours if __FILE__ == $0
14
+
metadata CHANGED
@@ -1,29 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: colorato
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Mettraux
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-01-03 00:00:00.000000000 Z
11
+ date: 2025-01-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: rspec
14
+ name: probatio
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '3.12'
19
+ version: '1'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '3.12'
26
+ version: '1'
27
27
  description: terminal colors extracted from flor
28
28
  email:
29
29
  - jmettraux+flor@gmail.com
@@ -48,6 +48,7 @@ metadata:
48
48
  bug_tracker_uri: https://github.com/floraison/colorato/issues
49
49
  homepage_uri: https://github.com/floraison/colorato
50
50
  source_code_uri: https://github.com/floraison/colorato
51
+ rubygems_mfa_required: 'true'
51
52
  post_install_message:
52
53
  rdoc_options: []
53
54
  require_paths:
@@ -63,7 +64,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
63
64
  - !ruby/object:Gem::Version
64
65
  version: '0'
65
66
  requirements: []
66
- rubygems_version: 3.1.6
67
+ rubygems_version: 3.5.16
67
68
  signing_key:
68
69
  specification_version: 4
69
70
  summary: terminal colors for flor