kolorit 0.1.3 → 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: ef040c50bebe6a3d79fcaee8de83f9bd97233b9e432d6a232db7137beff88643
4
- data.tar.gz: c262eabd58497efbfa76e72d918c1b2a6445c2a7dec772a0cbd67c97722d5b86
3
+ metadata.gz: 219b95536dadf60c775fc7346daf11c5e5d2150bc634f9effb2c2008b6b83fd6
4
+ data.tar.gz: bd0c07c902a020d41f8df17952b6df00330954ffce38809a2b34faec46cf7c47
5
5
  SHA512:
6
- metadata.gz: 0dac1ce53413bc676b2d03a0d3be3b8b27129ab02f2137dca9112e9ded142d184c320912b7560fd59b377564d3edcf95131ae3b6e372e6b001a3f2b493d45806
7
- data.tar.gz: 63cd157d5400ac32f2eeca5e0b7af678175f5f3e94dc464175b8269ed1ecde08d9632ec52e5023e89e2096005dad35b05c6a62a92baf2d2455445595d5758443
6
+ metadata.gz: 5842b9370bedb89d2daf73ef8018f144271cd3851a164a8157dcc3388541b9773312c24782a113670d9a2b6ec1cd88f14d82b4cb25197dda0b46c77dbf50b914
7
+ data.tar.gz: fbda9da5af368ec58ee28bd1bb6927d93655f793c3f184eafb6123b19e8d0e62b320fc4fce7617f2bc9e9803720963d36346e9262d8b902bbc3cce8f2e022836
data/lib/kolorit/linux.rb CHANGED
@@ -1,51 +1,37 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Kolorit
4
+ ##
5
+ # Color codes for linux systems.
6
+ # Allow use of color methods when included in **String** class.
7
+ # @see Kolorit
8
+ #
4
9
  module Linux
5
- def black = colorize(30)
6
-
7
- def red = colorize(31)
8
-
9
- def green = colorize(32)
10
-
11
- def yellow = colorize(33)
12
-
13
- def blue = colorize(34)
14
-
15
- def pink = colorize(35)
16
-
17
- def cyan = colorize(36)
18
-
19
- def gray = colorize(37)
20
-
21
- def bold = colorize(1)
22
-
23
- def italic = colorize(3)
24
-
25
- def underline = colorize(4)
26
-
27
- def blink = colorize(5)
28
-
10
+ def red = colorize(31)
11
+ def green = colorize(32)
12
+ def yellow = colorize(33)
13
+ def blue = colorize(34)
14
+ def pink = colorize(35)
15
+ def cyan = colorize(36)
16
+ def gray = colorize(37)
17
+
18
+ def bold = colorize(1)
19
+ def italic = colorize(3)
20
+ def underline = colorize(4)
21
+ def blink = colorize(5)
29
22
  def reverse_color = colorize(7)
30
23
 
31
24
  private
32
25
 
33
- ##
34
- # colorize string based on color_code
35
- #
36
26
  def colorize(color_code)
37
- # check if we change color or type
38
27
  type = case color_code
39
- # for type-change
40
28
  when 1 then 22 # bold
41
29
  when 3 then 23 # italic
42
30
  when 4 then 24 # underline
43
31
  when 5 then 25 # blink
44
32
  when 7 then 27 # reverse_color
45
- # for color change
46
33
  else 0
47
34
  end
48
- # create colorized string
49
35
  "\e[#{color_code}m#{self}\e[#{type}m"
50
36
  end
51
37
  end
@@ -2,5 +2,5 @@
2
2
 
3
3
  module Kolorit
4
4
  # gem version
5
- VERSION = '0.1.3'
5
+ VERSION = '0.1.4'
6
6
  end
data/lib/kolorit.rb CHANGED
@@ -2,18 +2,31 @@
2
2
 
3
3
  require_relative 'kolorit/version'
4
4
 
5
+ ##
6
+ # Handle modules with color codes and methods to colorize string.
7
+ # Right module is included depending on user OS.
8
+ #
9
+ # @example Colorize string
10
+ # 'I am mr Red String'.red
11
+ # 'I am mr Green String'.green
12
+ # 'I am bold (fat) mis Pink String'.pink.bold
13
+ #
14
+ # @example Available colors
15
+ # red, green, yellow, blue, pink, cyan, gray
16
+ #
17
+ # @example Available types
18
+ # bold, italic, underline, blink, reverse_color
19
+ #
5
20
  module Kolorit
6
21
  end
7
22
 
23
+ klass = String
24
+
8
25
  if ENV['OS'] == 'Windows_NT'
26
+ # working on windows color codes
9
27
  # require_relative 'kolorit/windows'
10
- class String
11
- # working on windows color codes
12
- # include Kolorit::Windows unless RUBY_PLATFORM =~ /cygwin/
13
- end
28
+ # klass.include Kolorit::Windows unless RUBY_PLATFORM =~ /cygwin/
14
29
  else
15
30
  require_relative 'kolorit/linux'
16
- class String
17
- include Kolorit::Linux
18
- end
31
+ klass.include(Kolorit::Linux)
19
32
  end
metadata CHANGED
@@ -1,18 +1,18 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kolorit
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - alx3dev
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-01-25 00:00:00.000000000 Z
11
+ date: 2022-01-26 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: |
14
14
  Print your terminal output in different colors. Early development stage,
15
- for now only Linux and Mac. MIT license.'
15
+ for now only Linux and Mac. MIT license.
16
16
  email:
17
17
  - alx3dev@gmail.com
18
18
  executables: []
@@ -30,7 +30,8 @@ metadata:
30
30
  homepage_uri: https://www.github.com/alx3dev/kolorit
31
31
  source_code_uri: https://www.github.com/alx3dev/kolorit
32
32
  changelog_uri: https://www.github.com/alx3dev/kolorit/CHANGELOG.md
33
- documentation_uri: https://rubydoc.info/gems/kolorit
33
+ documentation_uri: https://rubydoc.info/gems/kolorit/0.1.4
34
+ license_uri: https://www.github.com/alx3dev/kolorit/LICENSE
34
35
  post_install_message:
35
36
  rdoc_options: []
36
37
  require_paths:
@@ -49,7 +50,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
49
50
  - !ruby/object:Gem::Version
50
51
  version: '0'
51
52
  requirements: []
52
- rubygems_version: 3.2.32
53
+ rubygems_version: 3.3.6
53
54
  signing_key:
54
55
  specification_version: 4
55
56
  summary: Colorize terminal output. Linux-Mac only, Windows CLI coming soon.