termline 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: 9ffa74e98e74cd4e79135aab3703a664301edad3c1a68789547876b5ed523a25
4
- data.tar.gz: e194b805ec6fee33f52cde37d15af6005bd27d0c876fabe6978a7f585e584e0d
3
+ metadata.gz: e46ef107e4a53ccd8aeddcd6ff33a0747c378455945e4876105bcb00f53b1339
4
+ data.tar.gz: 3cc3d602fce022b3eff07fe2fc71212d565a764fd17163403d8afd3d39784319
5
5
  SHA512:
6
- metadata.gz: 8336beddc055905e84ad0cd98c77192d890990daac52cdfeb3f861c33b7cee177f85db496b293e5fd74dfcf934bb0e81a3314e583afeaee65cec58df389dea19
7
- data.tar.gz: 91ab1b950cb4585c8fe257c92b12e06bc27b4b81ec191684f7b5865a0dc4feebdfcfd120f44cd75dad410b875a7322e06aaafff509db99f8bb927adb11ec54af
6
+ metadata.gz: 4804e49bc1dd71fd7184935079a65280c10a19d7d5c01290df933d56180ddaf932f19cd4ff1415618e3357b900e86210b934f28f49f587372ab1a4a3440945a9
7
+ data.tar.gz: fbcd92152d4d8b9534e9102a6523a0bf0a63b8fc81472fb007309f59e4301f05d710fa5380dd42b5f870d7e25cb6f3e8d032d60bc3f3011e83e1d6535421195d
data/lib/termline/list.rb CHANGED
@@ -1,8 +1,41 @@
1
+ =begin
2
+
3
+ Lesli
4
+
5
+ Copyright (c) 2026, Lesli Technologies, S. A.
6
+
7
+ This program is free software: you can redistribute it and/or modify
8
+ it under the terms of the GNU General Public License as published by
9
+ the Free Software Foundation, either version 3 of the License, or
10
+ (at your option) any later version.
11
+
12
+ This program is distributed in the hope that it will be useful,
13
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
+ GNU General Public License for more details.
16
+
17
+ You should have received a copy of the GNU General Public License
18
+ along with this program. If not, see http://www.gnu.org/licenses/.
19
+
20
+ Lesli · Ruby on Rails SaaS Development Framework.
21
+
22
+ Made with ♥ by LesliTech
23
+ Building a better future, one line of code at a time.
24
+
25
+ @contact hello@lesli.tech
26
+ @website https://www.lesli.tech
27
+ @license GPLv3 http://www.gnu.org/licenses/gpl-3.0.en.html
28
+
29
+ // · ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~
30
+ // ·
31
+ =end
1
32
 
2
33
  module Termline
3
34
  module List
4
- def self.builder(items, icon:, color:)
5
- items.each { |item| puts(" #{Style.colorize(Style.icon(icon), color)} #{ item }" )}
35
+ class << self
36
+ def builder(items, icon:, color:)
37
+ items.each { |item| puts(" #{Style.colorize(Style.icon(icon), color)} #{ item }" )}
38
+ end
6
39
  end
7
40
  end
8
41
  end
data/lib/termline/msg.rb CHANGED
@@ -1,3 +1,34 @@
1
+ =begin
2
+
3
+ Lesli
4
+
5
+ Copyright (c) 2026, Lesli Technologies, S. A.
6
+
7
+ This program is free software: you can redistribute it and/or modify
8
+ it under the terms of the GNU General Public License as published by
9
+ the Free Software Foundation, either version 3 of the License, or
10
+ (at your option) any later version.
11
+
12
+ This program is distributed in the hope that it will be useful,
13
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
+ GNU General Public License for more details.
16
+
17
+ You should have received a copy of the GNU General Public License
18
+ along with this program. If not, see http://www.gnu.org/licenses/.
19
+
20
+ Lesli · Ruby on Rails SaaS Development Framework.
21
+
22
+ Made with ♥ by LesliTech
23
+ Building a better future, one line of code at a time.
24
+
25
+ @contact hello@lesli.tech
26
+ @website https://www.lesli.tech
27
+ @license GPLv3 http://www.gnu.org/licenses/gpl-3.0.en.html
28
+
29
+ // · ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~
30
+ // ·
31
+ =end
1
32
 
2
33
  module Termline
3
34
  module Msg
@@ -18,7 +49,7 @@ module Termline
18
49
  parts << message
19
50
  parts << data_text(data, color) if data
20
51
 
21
- puts(parts.compact.map(&:to_s).reject(&:empty?).join(" ").strip)
52
+ parts.compact.map(&:to_s).reject(&:empty?).join(" ").strip
22
53
  end
23
54
 
24
55
  def alert message
@@ -1,17 +1,52 @@
1
+ =begin
2
+
3
+ Lesli
4
+
5
+ Copyright (c) 2026, Lesli Technologies, S. A.
6
+
7
+ This program is free software: you can redistribute it and/or modify
8
+ it under the terms of the GNU General Public License as published by
9
+ the Free Software Foundation, either version 3 of the License, or
10
+ (at your option) any later version.
11
+
12
+ This program is distributed in the hope that it will be useful,
13
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
+ GNU General Public License for more details.
16
+
17
+ You should have received a copy of the GNU General Public License
18
+ along with this program. If not, see http://www.gnu.org/licenses/.
19
+
20
+ Lesli · Ruby on Rails SaaS Development Framework.
21
+
22
+ Made with ♥ by LesliTech
23
+ Building a better future, one line of code at a time.
24
+
25
+ @contact hello@lesli.tech
26
+ @website https://www.lesli.tech
27
+ @license GPLv3 http://www.gnu.org/licenses/gpl-3.0.en.html
28
+
29
+ // · ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~
30
+ // ·
31
+ =end
1
32
 
2
33
  module Termline
3
34
  module Space
35
+ class << self
36
+ def builder(character, count)
37
+ character * count
38
+ end
39
+ def br count=1
40
+ puts("\n" * count);
41
+ end
42
+
43
+ def line count=8
44
+ puts('-·- ' * count)
45
+ end
4
46
 
5
- def self.br count=1
6
- puts("\n" * count);
7
- end
8
-
9
- def self.line count=8
10
- puts('-·- ' * count)
11
- end
12
-
13
- def self.color color
14
- Config.pretty("", :black, color)
47
+ def color color
48
+ Config.pretty("", :black, color)
49
+ end
15
50
  end
16
51
  end
17
52
  end
@@ -1,4 +1,34 @@
1
+ =begin
1
2
 
3
+ Lesli
4
+
5
+ Copyright (c) 2026, Lesli Technologies, S. A.
6
+
7
+ This program is free software: you can redistribute it and/or modify
8
+ it under the terms of the GNU General Public License as published by
9
+ the Free Software Foundation, either version 3 of the License, or
10
+ (at your option) any later version.
11
+
12
+ This program is distributed in the hope that it will be useful,
13
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
+ GNU General Public License for more details.
16
+
17
+ You should have received a copy of the GNU General Public License
18
+ along with this program. If not, see http://www.gnu.org/licenses/.
19
+
20
+ Lesli · Ruby on Rails SaaS Development Framework.
21
+
22
+ Made with ♥ by LesliTech
23
+ Building a better future, one line of code at a time.
24
+
25
+ @contact hello@lesli.tech
26
+ @website https://www.lesli.tech
27
+ @license GPLv3 http://www.gnu.org/licenses/gpl-3.0.en.html
28
+
29
+ // · ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~
30
+ // ·
31
+ =end
2
32
 
3
33
  module Termline
4
34
  module Style
@@ -47,27 +77,29 @@ module Termline
47
77
  1
48
78
  end
49
79
 
50
- def self.icon icon
51
- ICONS[icon]
52
- end
80
+ class << self
81
+ def icon icon
82
+ ICONS[icon]
83
+ end
53
84
 
54
- # Concat color to text
55
- def self.colorize(text, colour = :default, bg_colour = :default)
56
- colour_code = COLORS[colour]
57
- bg_colour_code = BG_COLORS[bg_colour]
58
- return "\e[#{bg_colour_code};#{colour_code}m#{text}\e[0m".squeeze(';')
59
- end
85
+ # Concat color to text
86
+ def colorize(text, colour = :default, bg_colour = :default)
87
+ colour_code = COLORS[colour]
88
+ bg_colour_code = BG_COLORS[bg_colour]
89
+ return "\e[#{bg_colour_code};#{colour_code}m#{text}\e[0m".squeeze(';')
90
+ end
91
+
92
+ # Format text
93
+ def pretty(message, colour = :default, bg_colour = :default)
94
+ width = 1
60
95
 
61
-
62
- def self.pretty(message, colour = :default, bg_colour = :default)
63
- width = 1
64
-
65
- unless bg_colour == :default
66
- width = WIDTH - message.length - 4
67
- width = 1 if width.negative?
96
+ unless bg_colour == :default
97
+ width = WIDTH - message.length - 4
98
+ width = 1 if width.negative?
99
+ end
100
+
101
+ return colorize("#{ message } #{"\ " * width}", colour, bg_colour)
68
102
  end
69
-
70
- return colorize("#{ message } #{"\ " * width}", colour, bg_colour)
71
103
  end
72
104
  end
73
105
  end
@@ -1,58 +1,91 @@
1
+ =begin
2
+
3
+ Lesli
4
+
5
+ Copyright (c) 2026, Lesli Technologies, S. A.
6
+
7
+ This program is free software: you can redistribute it and/or modify
8
+ it under the terms of the GNU General Public License as published by
9
+ the Free Software Foundation, either version 3 of the License, or
10
+ (at your option) any later version.
11
+
12
+ This program is distributed in the hope that it will be useful,
13
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
+ GNU General Public License for more details.
16
+
17
+ You should have received a copy of the GNU General Public License
18
+ along with this program. If not, see http://www.gnu.org/licenses/.
19
+
20
+ Lesli · Ruby on Rails SaaS Development Framework.
21
+
22
+ Made with ♥ by LesliTech
23
+ Building a better future, one line of code at a time.
24
+
25
+ @contact hello@lesli.tech
26
+ @website https://www.lesli.tech
27
+ @license GPLv3 http://www.gnu.org/licenses/gpl-3.0.en.html
28
+
29
+ // · ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~
30
+ // ·
31
+ =end
1
32
 
2
33
  module Termline
3
34
  module Table
4
- def self.simple data, header:true
35
+ class << self
36
+ def builder data, header:true
5
37
 
6
- return if Gem.win_platform?
7
- return unless data.size > 0
38
+ return if Gem.win_platform?
39
+ return unless data.size > 0
8
40
 
9
- table_from_array = true if data.first.class == Array
10
- header = false if table_from_array
41
+ table_from_array = true if data.first.class == Array
42
+ header = false if table_from_array
11
43
 
12
- if data.class.name == "ActiveRecord::Relation"
13
- data = data.to_a.map(&:serializable_hash)
14
- end
44
+ if data.class.name == "ActiveRecord::Relation"
45
+ data = data.to_a.map(&:serializable_hash)
46
+ end
15
47
 
16
- # get the available characters in terminal width
17
- #terminal_width = `tput cols`.to_i
18
- terminal_width = Style::WIDTH
48
+ # get the available characters in terminal width
49
+ #terminal_width = `tput cols`.to_i
50
+ terminal_width = Style::WIDTH
19
51
 
20
- # get the number of columns to print base on the data hash
21
- cols = data.first.length + 1
52
+ # get the number of columns to print base on the data hash
53
+ cols = data.first.length + 1
22
54
 
23
- # get the available space for every column
24
- col_width = (terminal_width / cols) - 1
55
+ # get the available space for every column
56
+ col_width = (terminal_width / cols) - 1
25
57
 
26
- # validate that we have minimum space to render the table
27
- return if col_width <= 0
58
+ # validate that we have minimum space to render the table
59
+ return if col_width <= 0
28
60
 
29
- # separator for every column and row
30
- separator = ('| ' << ('- ' * (col_width / 2)))
61
+ # separator for every column and row
62
+ separator = ('| ' << ('- ' * (col_width / 2)))
31
63
 
32
- # add extra blank spaces to adjust the col_width only if col_width not a even number
33
- separator += (' ') if (col_width - separator.size).odd?
64
+ # add extra blank spaces to adjust the col_width only if col_width not a even number
65
+ separator += (' ') if (col_width - separator.size).odd?
34
66
 
35
- # only for table header
36
- if header
67
+ # only for table header
68
+ if header
37
69
 
38
- # print table titles
39
- puts '| ' << data.first.keys.map { |key| key.to_s.upcase.ljust(col_width) }.join('| ')
40
- end
70
+ # print table titles
71
+ puts '| ' << data.first.keys.map { |key| key.to_s.upcase.ljust(col_width) }.join('| ')
72
+ end
41
73
 
42
- # print header separators, only for visible columns
43
- puts separator * (cols - 1)
74
+ # print header separators, only for visible columns
75
+ puts separator * (cols - 1)
44
76
 
45
- # print data as table :)
46
- data.each_with_index do |row, index|
77
+ # print data as table :)
78
+ data.each_with_index do |row, index|
47
79
 
48
- # join hash values as a line and justify every value to print value in its own column
49
- puts '| ' << row.values.map { |value| value.to_s.ljust(col_width) }.join('| ') unless table_from_array
80
+ # join hash values as a line and justify every value to print value in its own column
81
+ puts '| ' << row.values.map { |value| value.to_s.ljust(col_width) }.join('| ') unless table_from_array
50
82
 
51
- # print simple value from the array data
52
- puts '| ' << row.map { |value| value.to_s.ljust(col_width) }.join('| ') if table_from_array
53
- end
83
+ # print simple value from the array data
84
+ puts '| ' << row.map { |value| value.to_s.ljust(col_width) }.join('| ') if table_from_array
85
+ end
54
86
 
55
- puts separator * (cols - 1) unless header
87
+ puts separator * (cols - 1) unless header
88
+ end
56
89
  end
57
90
  end
58
91
  end
@@ -30,6 +30,6 @@ Building a better future, one line of code at a time.
30
30
  =end
31
31
 
32
32
  module Termline
33
- VERSION = "1.0.0"
34
- BUILD = "1774219112"
33
+ VERSION = "1.1.0"
34
+ BUILD = "1774403591"
35
35
  end
data/lib/termline.rb CHANGED
@@ -35,63 +35,63 @@ require_relative "termline/table"
35
35
  require_relative "termline/space"
36
36
  require_relative "termline/list"
37
37
  require_relative "termline/msg"
38
- require_relative "termline/banner"
39
38
 
40
39
 
41
40
  # ·
42
41
  module Termline
42
+ class << self
43
+ def m(*messages)
44
+ messages.each { |message| puts(message) }
45
+ end
43
46
 
44
- def self.m *messages
45
- messages.each { |message| puts(message) }
46
- end
47
-
48
- def self.msg (*messages, **data)
49
- messages.each { |message| Termline::Msg.builder(message, data:data) }
50
- end
47
+ def msg(*messages, **data)
48
+ messages.each { |message| puts(Termline::Msg.builder(message, data:data)) }
49
+ end
51
50
 
52
- def self.info *messages, tag:'INFO:', icon: :info, **data
53
- messages.each { |message| Termline::Msg.builder(message, tag:tag, icon:icon, data:data, color: :blue) }
54
- end
51
+ def info(*messages, tag:'INFO:', icon: :info, **data)
52
+ messages.each { |message| puts(Termline::Msg.builder(message, tag:tag, icon:icon, data:data, color: :blue)) }
53
+ end
55
54
 
56
- def self.success *messages, tag:'SUCCESS:', icon: :success, **data
57
- messages.each { |message| Termline::Msg.builder(message, tag:tag, icon:icon, data:data, color: :green) }
58
- end
55
+ def success(*messages, tag:'SUCCESS:', icon: :success, **data)
56
+ messages.each { |message| puts(Termline::Msg.builder(message, tag:tag, icon:icon, data:data, color: :green)) }
57
+ end
59
58
 
60
- def self.warning *messages, tag:'WARNING:', icon: :warning, **data
61
- messages.each { |message| Termline::Msg.builder(message, tag:tag, icon:icon, data:data, color: :yellow) }
62
- end
59
+ def warning(*messages, tag:'WARNING:', icon: :warning, **data)
60
+ messages.each { |message| puts(Termline::Msg.builder(message, tag:tag, icon:icon, data:data, color: :yellow)) }
61
+ end
63
62
 
64
- def self.danger *messages, tag:'DANGER:', icon: :error, **data
65
- messages.each { |message| Termline::Msg.builder(message, tag:tag, icon:icon, data:data, color: :red) }
66
- end
63
+ def danger(*messages, tag:'DANGER:', icon: :error, **data)
64
+ messages.each { |message| puts(Termline::Msg.builder(message, tag:tag, icon:icon, data:data, color: :red)) }
65
+ end
67
66
 
68
- def self.alert *messages
69
- messages.each { |message| Termline::Msg.alert(message) }
70
- end
67
+ def alert(*messages)
68
+ messages.each { |message| puts(Termline::Msg.alert(message)) }
69
+ end
71
70
 
72
71
 
73
- def self.list *items, color: :default, icon: :debug
74
- Termline::List.builder(items, color:color, icon:icon)
75
- end
72
+ def list(*items, color: :default, icon: :debug)
73
+ Termline::List.builder(items, color:color, icon:icon)
74
+ end
76
75
 
77
76
 
78
- def self.table data, header:true
79
- Termline::Table.simple(data, header:header)
80
- end
77
+ def table(data, header:true)
78
+ Termline::Table.builder(data, header:header)
79
+ end
81
80
 
82
- def self.br count=1
83
- Termline::Space.br(count)
84
- end
81
+ def br(count=1)
82
+ puts(Termline::Space.builder("\n", count))
83
+ end
85
84
 
86
- def self.line count=8
87
- Termline::Space.line(count)
88
- end
85
+ def line(count=8)
86
+ puts(Termline::Space.builder('-·- ', count))
87
+ end
89
88
 
90
- def self.color color
91
- Termline::Space.color(count)
92
- end
89
+ def color(color)
90
+ Termline::Space.color(count)
91
+ end
93
92
 
94
93
 
95
- def self.deprecation message
94
+ def deprecation message
95
+ end
96
96
  end
97
97
  end
data/readme.md CHANGED
@@ -17,13 +17,18 @@ bundle add termline
17
17
 
18
18
  ### Usage
19
19
  ```ruby
20
+ Termline.msg "Hello world"
21
+ Termline.info "Server started"
22
+ Termline.success "All tests passed"
23
+ Termline.warning "Low disk space"
24
+ Termline.danger "Something failed"
25
+
20
26
  Termline.br
21
- Termline.m("Simple message")
22
- Termline.msg("Message with data:", data:{ name: "Luis", last_name: "Donis", title: "Software developer"})
23
- Termline.info("Message with data:", data:{ name: "Luis", last_name: "Donis", title: "Software developer"})
24
- Termline.success("Message with data:", data:{ name: "Luis", last_name: "Donis", title: "Software developer"})
25
- Termline.warning("Message with data:", data:{ name: "Luis", last_name: "Donis", title: "Software developer"})
26
- Termline.danger("Message with data:", data:{ name: "Luis", last_name: "Donis", title: "Software developer"})
27
+
28
+ Termline.table([
29
+ { name: "Luis", role: "Admin", status: "Active" },
30
+ { name: "Ana", role: "Developer", status: "Pending" }
31
+ ])
27
32
  ```
28
33
 
29
34
  **Result:**
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: termline
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
  - The Lesli Development Team
@@ -18,7 +18,6 @@ extensions: []
18
18
  extra_rdoc_files: []
19
19
  files:
20
20
  - lib/termline.rb
21
- - lib/termline/banner.rb
22
21
  - lib/termline/list.rb
23
22
  - lib/termline/msg.rb
24
23
  - lib/termline/space.rb
@@ -1,50 +0,0 @@
1
-
2
- module Termline
3
- module Banner
4
- def self.title title
5
- width = WIDTH - title.length - 4
6
- self.line(WIDTH/8)
7
- puts title.rjust(width / 2)
8
- self.line(WIDTH/8)
9
- end
10
-
11
- def self.infob *messages
12
- puts(separator_pretty(:blue))
13
- messages.each { |message| puts(pretty("INFO: #{ message }", :white, :blue)) }
14
- puts(separator_pretty(:blue))
15
- end
16
-
17
- def self.successb *messages
18
- puts(separator_pretty(:green))
19
- messages.each { |message| puts(pretty("SUCCESS: #{ message }", :black, :green)) }
20
- puts(separator_pretty(:green))
21
- end
22
-
23
- def self.warningb *messages
24
- puts(separator_pretty(:yellow))
25
- messages.each { |message| puts(pretty("WARNING: #{ message }", :black, :yellow)) }
26
- puts(separator_pretty(:yellow))
27
- end
28
-
29
- def self.dangerb *messages
30
- puts(separator_pretty(:red))
31
- messages.each { |message| puts(pretty("ERROR: #{ message }", :yellow, :red)) }
32
- puts(pretty("PATH: #{ caller[0] }", :yellow, :red))
33
- puts(separator_pretty(:red))
34
- end
35
-
36
- def self.fatal *messages
37
- puts(separator_pretty(:red))
38
- messages.each { |message| puts("\e[5m#{pretty(message, :white, :red)}\e[0m") }
39
- puts(pretty("PATH: #{ caller[0] }", :white, :red))
40
- puts(separator_pretty(:red))
41
- end
42
-
43
-
44
- def self.deprecation message
45
- puts(separator_pretty(:red))
46
- puts(pretty("DEPRECATED METHOD: #{ caller[0] }, #{ message }", :white, :red))
47
- puts(separator_pretty(:red))
48
- end
49
- end
50
- end