rbtext 0.3.0 → 0.3.2

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
2
  SHA256:
3
- metadata.gz: aeaa3d4a31eb6b39b6351a8ebeb376210ad717d62d9bf00490fc588cd27356f4
4
- data.tar.gz: f201309c0bc1818511cbaa2e3435a6f27ac1a4446dcc73a3d5b2689aaae62102
3
+ metadata.gz: 25c59524b5af0b4acca39400131e5b938e80089937f67fd655a3251cc76d9911
4
+ data.tar.gz: a8d5abe5d2eb15ef94954d496a2c249cd7888cfa4a1e13604c5b6ada108b1cc5
5
5
  SHA512:
6
- metadata.gz: 7efedf2c0528c5624716c58adbdbfaa6d6e709cf5f03e955d3320a326861330cc1465b863cb1084a4879a4a8d7ed812356c862c092cfe5506244d05e9471c154
7
- data.tar.gz: 86ffbe26056a8de1437fa2ecd20c0b9cdb4ca04de03e82d868e8bf016965edded9aa08733cd3d33555cb9335448987dd539f6f7d10b1e83f994e897e636c4ddb
6
+ metadata.gz: 392a2a3e4edc646db3470d43cc2689b02cb61d3b3f1280c16baef95c61195fa75509e406d90bfc9362332e145a1f5ce810ee0598b91d6e203b748949f4e865fd
7
+ data.tar.gz: 43c39fb22e69d869886cf69625c8b385c4b1547b48d3b9c3c5138555af8b23abccc089bb18bd40e48e31b37a605d11499a6781b60c2da4a67472ffcbf915218f
data/bin/ftext CHANGED
@@ -1,11 +1,11 @@
1
- #!/usr/bin/ruby
1
+ #!/usr/bin/env ruby
2
2
  require_relative '../lib/rbtext.rb'
3
3
 
4
4
  params = (ARGV[1..ARGV.length-1]).to_a
5
5
 
6
- if $stdin.tty? && ARGV[0]
6
+ if STDIN.tty? && ARGV[0]
7
7
  txt = ARGV[0].to_s
8
- elsif $stdin.tty?
8
+ elsif STDIN.tty?
9
9
  return
10
10
  else
11
11
  if ARGV[0]
data/lib/rbtext/colors.rb CHANGED
@@ -1,13 +1,6 @@
1
1
  module RBText
2
2
  module Colors
3
- @@methods = [
4
- :fg_color_codes,
5
- :bg_color_codes,
6
- :color,
7
- :num_color
8
- ]
9
-
10
- def fg_color_codes
3
+ def self.fg_color_codes
11
4
  {
12
5
  black: "30",
13
6
  red: "31",
@@ -29,7 +22,7 @@ module RBText
29
22
  }
30
23
  end
31
24
 
32
- def bg_color_codes
25
+ def self.bg_color_codes
33
26
  bg_color_codes = {}
34
27
 
35
28
  for c in self.fg_color_codes.keys do
@@ -39,7 +32,7 @@ module RBText
39
32
  return bg_color_codes
40
33
  end
41
34
 
42
- def color(color, type: :fg, mode: :str)
35
+ def self.color(color, type: :fg, mode: :str)
43
36
  return "\033[39m\033[49m" if type == :all && color == :reset
44
37
 
45
38
  if type == :fg
@@ -54,21 +47,11 @@ module RBText
54
47
  print "\033[#{color_code}m" if mode == :set
55
48
  end
56
49
 
57
- def num_color(num, type: :fg, mode: :str)
50
+ def self.num_color(num, type: :fg, mode: :str)
58
51
  return "\033[#{type == :fg ? "38" : "48"};5;#{num}m" if mode == :str
59
52
  print "\033[#{type == :fg ? "38" : "48"};5;#{num}m" if mode == :set
60
53
  end
61
-
62
- @@methods.each do |method|
63
- module_function method
64
- end
65
- end
66
-
67
- module C
68
- include RBText::Colors
69
-
70
- @@methods.each do |method|
71
- module_function method
72
- end
73
54
  end
74
55
  end
56
+
57
+ RBText::C = RBText::Colors
data/lib/rbtext/cursor.rb CHANGED
@@ -1,34 +1,22 @@
1
1
  module RBText
2
2
  module Cursor
3
- @@methods = [
4
- :up,
5
- :down,
6
- :left,
7
- :right,
8
- :beginning_of_line,
9
- :go_to_pos,
10
- :pos,
11
- :show,
12
- :hide
13
- ]
14
-
15
- def up(num=1)
3
+ def self.up(num=1)
16
4
  print "\033[#{num.to_i}A"
17
5
  end
18
6
 
19
- def down(num=1)
7
+ def self.down(num=1)
20
8
  print "\033[#{num.to_i}B"
21
9
  end
22
10
 
23
- def left(num=1)
11
+ def self.left(num=1)
24
12
  print "\033[#{num.to_i}D"
25
13
  end
26
14
 
27
- def right(num=1)
15
+ def self.right(num=1)
28
16
  print "\033[#{num.to_i}C"
29
17
  end
30
18
 
31
- def go_to_pos(x, y=nil)
19
+ def self.go_to_pos(x, y=nil)
32
20
  if x.class == Array && !y
33
21
  y = x[1]
34
22
  x = x[0]
@@ -38,7 +26,7 @@ module RBText
38
26
  print "\033[#{y};#{x}f"
39
27
  end
40
28
 
41
- def pos
29
+ def self.pos
42
30
  res = ''
43
31
  $stdin.raw do |stdin|
44
32
  $stdout << "\e[6n"
@@ -51,27 +39,18 @@ module RBText
51
39
  return [Integer(m[:column]), Integer(m[:row])]
52
40
  end
53
41
 
54
- def beginning_of_line
42
+ def self.beginning_of_line
55
43
  print "\r"
56
44
  end
57
45
 
58
- def show
46
+ def self.show
59
47
  print "\033[?25h"
60
48
  end
61
49
 
62
- def hide
50
+ def self.hide
63
51
  print "\033[?25l"
64
52
  end
65
-
66
- @@methods.each do |method|
67
- module_function method
68
- end
69
- end
70
-
71
- module Cr
72
- include RBText::Cursor
73
- @@methods.each do |method|
74
- module_function method
75
- end
76
53
  end
77
54
  end
55
+
56
+ RBText::Cr = RBText::Cursor
@@ -1,16 +1,6 @@
1
1
  module RBText
2
2
  module Formatting
3
- @@methods = [
4
- :reset,
5
- :bold,
6
- :faint,
7
- :italic,
8
- :underline,
9
- :blinking,
10
- :strikethrough
11
- ]
12
-
13
- def reset(f_opt = nil, mode: :str)
3
+ def self.reset(f_opt = nil, mode: :str)
14
4
  if f_opt
15
5
  r="\033[#{
16
6
  f_opt =~ /^\033\[(1|2)m$/ ? "\033[22m" : "\033[2#{f_opt.gsub(/[^0-9]/, "")}m"
@@ -22,52 +12,42 @@ module RBText
22
12
  print r if mode == :set
23
13
  end
24
14
 
25
- def bold(mode: :str)
15
+ def self.bold(mode: :str)
26
16
  r="\033[1m"
27
17
  return r if mode == :str
28
18
  print r if mode == :set
29
19
  end
30
20
 
31
- def faint(mode: :str)
21
+ def self.faint(mode: :str)
32
22
  r="\033[2m"
33
23
  return r if mode == :str
34
24
  print r if mode == :set
35
25
  end
36
26
 
37
- def italic(mode: :str)
27
+ def self.italic(mode: :str)
38
28
  r="\033[3m"
39
29
  return r if mode == :str
40
30
  print r if mode == :set
41
31
  end
42
32
 
43
- def underline(mode: :str)
33
+ def self.underline(mode: :str)
44
34
  r="\033[4m"
45
35
  return r if mode == :str
46
36
  print r if mode == :set
47
37
  end
48
38
 
49
- def blinking(mode: :str)
39
+ def self.blinking(mode: :str)
50
40
  r="\033[5m"
51
41
  return r if mode == :str
52
42
  print r if mode == :set
53
43
  end
54
44
 
55
- def strikethrough(mode: :str)
45
+ def self.strikethrough(mode: :str)
56
46
  r="\033[9m"
57
47
  return r if mode == :str
58
48
  print r if mode == :set
59
49
  end
60
-
61
- module_function
62
- @@methods.each do |method|
63
- module_function method
64
- end
65
- end
66
-
67
- module F
68
- include RBText::Formatting
69
- @@methods.each do |method|
70
- module_function method
71
- end
72
50
  end
73
51
  end
52
+
53
+ RBText::F = RBText::Formatting
data/lib/rbtext/screen.rb CHANGED
@@ -1,47 +1,29 @@
1
1
  module RBText
2
2
  module Screen
3
- @@methods = [
4
- :clear,
5
- :clear_line,
6
- :size,
7
- :height,
8
- :width,
9
- :bell
10
- ]
11
-
12
- def clear
3
+ def self.clear
13
4
  print "\033[2J"
14
5
  end
15
6
 
16
- def clear_line
7
+ def self.clear_line
17
8
  print "\033[2K"
18
9
  end
19
10
 
20
- def size
11
+ def self.size
21
12
  IO.console.winsize
22
13
  end
23
14
 
24
- def height
15
+ def self.height
25
16
  self.size[0]
26
17
  end
27
18
 
28
- def width
19
+ def self.width
29
20
  self.size[1]
30
21
  end
31
22
 
32
- def bell
23
+ def self.bell
33
24
  print "\a"
34
25
  end
35
-
36
- @@methods.each do |method|
37
- module_function method
38
- end
39
- end
40
-
41
- module S
42
- include RBText::Screen
43
- @@methods.each do |method|
44
- module_function method
45
- end
46
26
  end
47
27
  end
28
+
29
+ RBText::S = RBText::Screen
data/lib/rbtext.rb CHANGED
@@ -8,14 +8,12 @@ require "io/console"
8
8
  module RBText
9
9
  @ver_1 = 0
10
10
  @ver_2 = 3
11
- @ver_3 = 0
11
+ @ver_3 = 2
12
12
  @ver_4 = ""
13
13
 
14
- def version
14
+ def self.version
15
15
  "#{@ver_1}.#{@ver_2}.#{@ver_3}#{".#{@ver_4}" if @ver_4.length > 1}"
16
16
  end
17
-
18
- module_function :version
19
17
  end
20
18
 
21
19
  module R
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rbtext
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matthias Lee
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-04-01 00:00:00.000000000 Z
11
+ date: 2022-10-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: io-console