color_puts 0.0.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: ce6017de43a93b4674922740d9a576f2250055fd
4
- data.tar.gz: 545fe5b927a1e900f89f9f544c44a1e851e79cdf
2
+ SHA256:
3
+ metadata.gz: 18105027d129f71a933697b6d6284de9b57d5a78ddb203dc0e531177d94a3308
4
+ data.tar.gz: efe7b8e3aeacb95dbfbdbdacc816db2b72f9b31214b74c65d13b3f8f54ac2084
5
5
  SHA512:
6
- metadata.gz: 1a1279e04c732a32fd0fb018de8cac5e99a0944a63bdc189a96caeeea28cd03e1ead746cd9ef649f9c6c56e66dd226515310cfa347a88a90a8e7588785a0f2e1
7
- data.tar.gz: 0207c4bba8ab2d4b8c1b384c9c97669f550c22aa76e98e157675a4d9aeed02276134851f1c061f60457a3598d83cd2d5a71287c84dc097a283afbb73aa5872cb
6
+ metadata.gz: 735297f86b0cb7049de23a6a1d22de2ed48dde7cd2671ff14cdd1a5435664bbfbbac7b700a6993e2df82652811b538a20aeccc5a914f9acfd0c4102ea139234c
7
+ data.tar.gz: 17041f37378e7a03b42cae4da5336018d704572d40aa0a138fd9bb10cad77ea529a05b1e6453cc1bcdaa3fe3a48561d60cc10b42aaf8102a24774292b3e428f1
data/.gitignore CHANGED
@@ -1,6 +1,5 @@
1
1
  /.bundle/
2
2
  /.yardoc
3
- /Gemfile.lock
4
3
  /_yardoc/
5
4
  /coverage/
6
5
  /doc/
data/.standard.yml ADDED
@@ -0,0 +1,7 @@
1
+ # For available configuration options, see:
2
+ # https://github.com/testdouble/standard
3
+ ruby_version: 3.2
4
+
5
+ AllCops:
6
+ Exclude:
7
+ - "bin/*"
data/Gemfile CHANGED
@@ -1,2 +1,7 @@
1
- source 'https://rubygems.org'
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+
2
5
  gemspec
6
+
7
+ gem "standard", require: false
data/Gemfile.lock ADDED
@@ -0,0 +1,59 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ color_puts (0.1.0)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ ast (2.4.2)
10
+ json (2.9.0)
11
+ language_server-protocol (3.17.0.3)
12
+ lint_roller (1.1.0)
13
+ parallel (1.26.3)
14
+ parser (3.3.6.0)
15
+ ast (~> 2.4.1)
16
+ racc
17
+ racc (1.8.1)
18
+ rainbow (3.1.1)
19
+ regexp_parser (2.9.3)
20
+ rubocop (1.68.0)
21
+ json (~> 2.3)
22
+ language_server-protocol (>= 3.17.0)
23
+ parallel (~> 1.10)
24
+ parser (>= 3.3.0.2)
25
+ rainbow (>= 2.2.2, < 4.0)
26
+ regexp_parser (>= 2.4, < 3.0)
27
+ rubocop-ast (>= 1.32.2, < 2.0)
28
+ ruby-progressbar (~> 1.7)
29
+ unicode-display_width (>= 2.4.0, < 3.0)
30
+ rubocop-ast (1.36.2)
31
+ parser (>= 3.3.1.0)
32
+ rubocop-performance (1.22.1)
33
+ rubocop (>= 1.48.1, < 2.0)
34
+ rubocop-ast (>= 1.31.1, < 2.0)
35
+ ruby-progressbar (1.13.0)
36
+ standard (1.42.1)
37
+ language_server-protocol (~> 3.17.0.2)
38
+ lint_roller (~> 1.0)
39
+ rubocop (~> 1.68.0)
40
+ standard-custom (~> 1.0.0)
41
+ standard-performance (~> 1.5)
42
+ standard-custom (1.0.2)
43
+ lint_roller (~> 1.0)
44
+ rubocop (~> 1.50)
45
+ standard-performance (1.5.0)
46
+ lint_roller (~> 1.1)
47
+ rubocop-performance (~> 1.22.0)
48
+ unicode-display_width (2.6.0)
49
+
50
+ PLATFORMS
51
+ arm64-darwin-23
52
+ ruby
53
+
54
+ DEPENDENCIES
55
+ color_puts!
56
+ standard
57
+
58
+ BUNDLED WITH
59
+ 2.5.23
data/LICENSE.md ADDED
@@ -0,0 +1,8 @@
1
+ The MIT License (MIT)
2
+ Copyright (c)
3
+
4
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
5
+
6
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
7
+
8
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md CHANGED
@@ -7,7 +7,7 @@ Color your output with inline color codes.
7
7
  Add this line to your application's Gemfile:
8
8
 
9
9
  ```ruby
10
- gem 'color_puts'
10
+ gem "color_puts"
11
11
  ```
12
12
 
13
13
  ## Usage
@@ -15,9 +15,9 @@ gem 'color_puts'
15
15
  Example:
16
16
 
17
17
  ```ruby
18
- include ColorPuts
18
+ include ColorPuts
19
19
 
20
- cputs "There was a %green{field} and %blue{sky}."
20
+ colorize "There was a %green{field} and %blue{sky}."
21
21
  ```
22
22
 
23
23
  ## Colors
@@ -25,26 +25,24 @@ Example:
25
25
  List of colors names:
26
26
 
27
27
  ```
28
- black
29
- dblue
30
- dgreen
31
- dcyan
32
- dred
33
- dpurple
34
- dgray
35
- brown
36
- gray
37
- blue
38
- green
39
- cyan
40
- red
41
- purple
42
- yellow
43
- white
28
+ black
29
+ dblue
30
+ dgreen
31
+ dcyan
32
+ dred
33
+ dpurple
34
+ dgray
35
+ brown
36
+ gray
37
+ blue
38
+ green
39
+ cyan
40
+ red
41
+ purple
42
+ yellow
43
+ white
44
44
  ```
45
45
 
46
-
47
46
  ## Contributing
48
47
 
49
48
  Contributions are welcome!
50
-
data/color_puts.gemspec CHANGED
@@ -1,20 +1,19 @@
1
- # coding: utf-8
2
- lib = File.expand_path('../lib', __FILE__)
1
+ lib = File.expand_path("../lib", __FILE__)
3
2
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require 'color_puts/version'
3
+ require "color_puts/version"
5
4
 
6
5
  Gem::Specification.new do |spec|
7
- spec.name = "color_puts"
8
- spec.version = ColorPuts::VERSION
9
- spec.authors = ["Ingemar"]
10
- spec.email = ["ingemar@xox.se"]
6
+ spec.name = "color_puts"
7
+ spec.version = ColorPuts::VERSION
8
+ spec.authors = ["Ingemar"]
9
+ spec.email = ["ingemar@xox.se"]
11
10
 
12
- spec.summary = %q{Color your output text}
13
- spec.description = %q{Color your output with inline color codes}
14
- spec.homepage = "https://github.com/ingemar/color_puts"
11
+ spec.summary = "Color your output text"
12
+ spec.description = "Color your output with inline color codes"
13
+ spec.homepage = "https://github.com/ingemar/color_puts"
14
+ spec.license = "MIT"
15
15
 
16
- spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
16
+ spec.required_ruby_version = ">= 3.2"
17
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
17
18
  spec.require_paths = ["lib"]
18
-
19
- spec.add_development_dependency "bundler", "~> 1.11"
20
19
  end
@@ -1,3 +1,3 @@
1
1
  module ColorPuts
2
- VERSION = "0.0.0"
2
+ VERSION = "0.2.0"
3
3
  end
data/lib/color_puts.rb CHANGED
@@ -1,43 +1,44 @@
1
- require "color_puts/version"
1
+ # frozen_string_literal: true
2
2
 
3
3
  module ColorPuts
4
4
  COLORS = {
5
- black: '0;30',
6
- dblue: '0;34',
7
- dgreen: '0;32',
8
- dcyan: '0;36',
9
- dred: '0;31',
10
- dpurple: '0;35',
11
- dgray: '1;30',
12
- brown: '0;33',
13
- gray: '0;37',
14
- blue: '1;34',
15
- green: '1;32',
16
- cyan: '1;36',
17
- red: '1;31',
18
- purple: '1;35',
19
- yellow: '1;33',
20
- white: '1;37'
21
- }
5
+ "black" => "0;30",
6
+ "dblue" => "0;34",
7
+ "dgreen" => "0;32",
8
+ "dcyan" => "0;36",
9
+ "dred" => "0;31",
10
+ "dpurple" => "0;35",
11
+ "dgray" => "1;30",
12
+ "brown" => "0;33",
13
+ "gray" => "0;37",
14
+ "blue" => "1;34",
15
+ "green" => "1;32",
16
+ "cyan" => "1;36",
17
+ "red" => "1;31",
18
+ "purple" => "1;35",
19
+ "yellow" => "1;33",
20
+ "white" => "1;37"
21
+ }.freeze
22
+
23
+ REGEXP = /%(#{COLORS.keys.join("|")})\{([^}]*)\}/
24
+ private_constant :REGEXP
25
+
26
+ TEMPLATE = "\e[%<color>sm%<text>s\e[0;39m"
27
+ private_constant :TEMPLATE
22
28
 
23
29
  # Example:
24
30
  #
25
- # cputs "There was a %green{field} and %blue{sky}."
31
+ # colorize("There was a %green{field} and %blue{sky}.")
26
32
  #
27
- def cputs(string = "")
28
- regexp = /%(\w+)\{[^}]*./
29
- text_regexp = /%\w+{(.*)}/
30
-
31
- string = string.dup
33
+ def colorize(string)
34
+ string
35
+ .dup
36
+ .gsub(REGEXP) do |match|
37
+ color, text = match.match(REGEXP).captures
32
38
 
33
- while m = string.match(regexp) do
34
- string.gsub!(m.to_s) do |s|
35
- color = ColorPuts::COLORS[m.captures.first.to_sym]
36
- text = s.match(text_regexp).captures.first
37
- "\e[#{color}m#{text}\e[0;39m"
39
+ TEMPLATE % {color: COLORS[color], text:}
38
40
  end
39
- end
40
-
41
- puts string
42
41
  end
42
+
43
+ def cputs(string = "") = puts colorize(string)
43
44
  end
metadata CHANGED
@@ -1,29 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: color_puts
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ingemar
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-02-22 00:00:00.000000000 Z
12
- dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: bundler
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - "~>"
18
- - !ruby/object:Gem::Version
19
- version: '1.11'
20
- type: :development
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - "~>"
25
- - !ruby/object:Gem::Version
26
- version: '1.11'
11
+ date: 2024-12-05 00:00:00.000000000 Z
12
+ dependencies: []
27
13
  description: Color your output with inline color codes
28
14
  email:
29
15
  - ingemar@xox.se
@@ -32,16 +18,19 @@ extensions: []
32
18
  extra_rdoc_files: []
33
19
  files:
34
20
  - ".gitignore"
21
+ - ".standard.yml"
35
22
  - Gemfile
23
+ - Gemfile.lock
24
+ - LICENSE.md
36
25
  - README.md
37
26
  - color_puts.gemspec
38
- - color_puts.gemspec.lock
39
27
  - lib/color_puts.rb
40
28
  - lib/color_puts/version.rb
41
29
  homepage: https://github.com/ingemar/color_puts
42
- licenses: []
30
+ licenses:
31
+ - MIT
43
32
  metadata: {}
44
- post_install_message:
33
+ post_install_message:
45
34
  rdoc_options: []
46
35
  require_paths:
47
36
  - lib
@@ -49,16 +38,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
49
38
  requirements:
50
39
  - - ">="
51
40
  - !ruby/object:Gem::Version
52
- version: '0'
41
+ version: '3.2'
53
42
  required_rubygems_version: !ruby/object:Gem::Requirement
54
43
  requirements:
55
44
  - - ">="
56
45
  - !ruby/object:Gem::Version
57
46
  version: '0'
58
47
  requirements: []
59
- rubyforge_project:
60
- rubygems_version: 2.4.6
61
- signing_key:
48
+ rubygems_version: 3.5.23
49
+ signing_key:
62
50
  specification_version: 4
63
51
  summary: Color your output text
64
52
  test_files: []
@@ -1,3 +0,0 @@
1
- PLATFORMS
2
-
3
- DEPENDENCIES