termline 0.2.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: 31c52f81fd0fe02b29f7a294cf7fae93e3cb008b2cdb1e34169f06fbf367d638
4
- data.tar.gz: 8a810a992c7be490f7eea90172bc480d0e078af072b633520dc8c1c75dce3392
3
+ metadata.gz: e46ef107e4a53ccd8aeddcd6ff33a0747c378455945e4876105bcb00f53b1339
4
+ data.tar.gz: 3cc3d602fce022b3eff07fe2fc71212d565a764fd17163403d8afd3d39784319
5
5
  SHA512:
6
- metadata.gz: 06ca46dd65fcf1a262568be376a160b9a0ea96d32f8db952d066fe0af71061ffd21342de906f79dfcc53c7f88837e56c1d75547e6b5754b6656b5dfaa4e6cb9c
7
- data.tar.gz: aa14be84ef383c11cdfea7571a73b0b2354d39a13d694ca170f03d280efed502f99267148f5e60ea69cc073caf910d1af5cf1e123b9045979e275c8a7c2b9bf2
6
+ metadata.gz: 4804e49bc1dd71fd7184935079a65280c10a19d7d5c01290df933d56180ddaf932f19cd4ff1415618e3357b900e86210b934f28f49f587372ab1a4a3440945a9
7
+ data.tar.gz: fbcd92152d4d8b9534e9102a6523a0bf0a63b8fc81472fb007309f59e4301f05d710fa5380dd42b5f870d7e25cb6f3e8d032d60bc3f3011e83e1d6535421195d
data/lib/termline/list.rb CHANGED
@@ -1,17 +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
-
5
- def self.bullet *items
6
- items.each { |item| puts(" #{Config::ICONS[:bullet]} #{ item }" )}
7
- end
8
-
9
- def self.check *items
10
- items.each { |item| puts(" #{Config::ICONS[:checkmark]} #{ item }" )}
11
- end
12
-
13
- def self.star *items
14
- items.each { |item| puts(" #{Config::ICONS[:star]} #{ item }" )}
35
+ class << self
36
+ def builder(items, icon:, color:)
37
+ items.each { |item| puts(" #{Style.colorize(Style.icon(icon), color)} #{ item }" )}
38
+ end
15
39
  end
16
40
  end
17
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
@@ -7,10 +38,9 @@ module Termline
7
38
  message,
8
39
  tag: nil,
9
40
  icon: nil,
10
- data: nil,
11
41
  color: :default,
12
42
  bgcolor: :default,
13
- timestamp: Time.now.strftime('%H:%M:%S:%L'))
43
+ timestamp: Time.now.strftime('%H:%M:%S:%L'), data:nil)
14
44
 
15
45
  parts = []
16
46
  parts << "[#{timestamp}]" if timestamp
@@ -19,7 +49,7 @@ module Termline
19
49
  parts << message
20
50
  parts << data_text(data, color) if data
21
51
 
22
- puts(parts.compact.map(&:to_s).reject(&:empty?).join(" ").strip)
52
+ parts.compact.map(&:to_s).reject(&:empty?).join(" ").strip
23
53
  end
24
54
 
25
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
@@ -21,6 +51,7 @@ module Termline
21
51
  white: '1;37',
22
52
  green: '32',
23
53
  black: '30',
54
+ gray: '90',
24
55
  blue: '36',
25
56
  red: '31'
26
57
  }.freeze
@@ -46,27 +77,29 @@ module Termline
46
77
  1
47
78
  end
48
79
 
49
- def self.icon icon
50
- ICONS[icon]
51
- end
80
+ class << self
81
+ def icon icon
82
+ ICONS[icon]
83
+ end
52
84
 
53
- # Concat color to text
54
- def self.colorize(text, colour = :default, bg_colour = :default)
55
- colour_code = COLORS[colour]
56
- bg_colour_code = BG_COLORS[bg_colour]
57
- return "\e[#{bg_colour_code};#{colour_code}m#{text}\e[0m".squeeze(';')
58
- 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
59
95
 
60
-
61
- def self.pretty(message, colour = :default, bg_colour = :default)
62
- width = 1
63
-
64
- unless bg_colour == :default
65
- width = WIDTH - message.length - 4
66
- 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)
67
102
  end
68
-
69
- return colorize("#{ message } #{"\ " * width}", colour, bg_colour)
70
103
  end
71
104
  end
72
105
  end
@@ -1,60 +1,90 @@
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
8
-
9
- if data.class.name == "ActiveRecord::Relation"
10
- data = data.to_a.map(&:serializable_hash)
11
- end
38
+ return if Gem.win_platform?
39
+ return unless data.size > 0
12
40
 
13
- # get the available characters in terminal width
14
- #terminal_width = `tput cols`.to_i
15
- terminal_width = Config::WIDTH
41
+ table_from_array = true if data.first.class == Array
42
+ header = false if table_from_array
16
43
 
17
- # get the number of columns to print base on the data hash
44
+ if data.class.name == "ActiveRecord::Relation"
45
+ data = data.to_a.map(&:serializable_hash)
46
+ end
18
47
 
19
- pp "--------------------------"
20
- pp "--------------------------"
21
- header = false if data.first.class == Array
22
- pp "--------------------------"
23
- pp "--------------------------"
48
+ # get the available characters in terminal width
49
+ #terminal_width = `tput cols`.to_i
50
+ terminal_width = Style::WIDTH
24
51
 
25
- cols = data.first.length + 1
52
+ # get the number of columns to print base on the data hash
53
+ cols = data.first.length + 1
26
54
 
27
- # get the available space for every column
28
- col_width = (terminal_width / cols) - 1
55
+ # get the available space for every column
56
+ col_width = (terminal_width / cols) - 1
29
57
 
30
- # validate that we have minimum space to render the table
31
- return if col_width <= 0
58
+ # validate that we have minimum space to render the table
59
+ return if col_width <= 0
32
60
 
33
- # separator for every column and row
34
- separator = ('| ' << ('- ' * (col_width / 2)))
61
+ # separator for every column and row
62
+ separator = ('| ' << ('- ' * (col_width / 2)))
35
63
 
36
- # add extra blank spaces to adjust the col_width only if col_width not a even number
37
- separator += (' ') if (col_width - separator.size).odd?
38
-
39
- # print data as table :)
40
- data.each_with_index do |row, index|
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?
41
66
 
42
67
  # only for table header
43
- if index == 0 && header
68
+ if header
44
69
 
45
70
  # print table titles
46
- puts '| ' << row.keys.map { |key| key.to_s.upcase.ljust(col_width) }.join('| ')
71
+ puts '| ' << data.first.keys.map { |key| key.to_s.upcase.ljust(col_width) }.join('| ')
72
+ end
47
73
 
48
- # print header separators, only for visible columns
49
- puts separator * (cols - 1)
74
+ # print header separators, only for visible columns
75
+ puts separator * (cols - 1)
50
76
 
51
- end
77
+ # print data as table :)
78
+ data.each_with_index do |row, index|
79
+
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
52
82
 
53
- # join hash values as a line and justify every value to print value
54
- # in its own column
55
- puts '| ' << row.values.map { |value| value.to_s.ljust(col_width) }.join('| ')
56
- #puts '| ' << row.map { |value| value.to_s.ljust(col_width) }.join('| ')
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
57
86
 
87
+ puts separator * (cols - 1) unless header
58
88
  end
59
89
  end
60
90
  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 = "0.2.0"
34
- BUILD = "1774211535"
33
+ VERSION = "1.1.0"
34
+ BUILD = "1774403591"
35
35
  end
data/lib/termline.rb CHANGED
@@ -35,73 +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:nil)
49
- messages.each { |message| Termline::Msg.builder(message, data:data) }
50
- end
51
-
52
- def self.info *messages, tag:'INFO:', icon: :info, data:nil
53
- messages.each { |message| Termline::Msg.builder(message, tag:tag, icon:icon, data:data, color: :blue) }
54
- end
55
-
56
- def self.success *messages, tag:'SUCCESS:', icon: :success, data:nil
57
- messages.each { |message| Termline::Msg.builder(message, tag:tag, icon:icon, data:data, color: :green) }
58
- end
59
-
60
- def self.warning *messages, tag:'WARNING:', icon: :warning, data:nil
61
- messages.each { |message| Termline::Msg.builder(message, tag:tag, icon:icon, data:data, color: :yellow) }
62
- end
47
+ def msg(*messages, **data)
48
+ messages.each { |message| puts(Termline::Msg.builder(message, data:data)) }
49
+ end
63
50
 
64
- def self.danger *messages, tag:'DANGER:', icon: :error, data:nil
65
- messages.each { |message| Termline::Msg.builder(message, tag:tag, icon:icon, data:data, color: :red) }
66
- 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
67
54
 
68
- def self.alert *messages
69
- messages.each { |message| Termline::Msg.alert(message) }
70
- 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
71
58
 
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
72
62
 
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
73
66
 
67
+ def alert(*messages)
68
+ messages.each { |message| puts(Termline::Msg.alert(message)) }
69
+ end
74
70
 
75
- def self.list *items
76
- Termline::List.bullet(items)
77
- end
78
71
 
79
- def self.list_check *items
80
- Termline::List.check(items)
81
- end
72
+ def list(*items, color: :default, icon: :debug)
73
+ Termline::List.builder(items, color:color, icon:icon)
74
+ end
82
75
 
83
- def self.list_star *items
84
- Termline::List.star(items)
85
- end
86
76
 
77
+ def table(data, header:true)
78
+ Termline::Table.builder(data, header:header)
79
+ end
87
80
 
88
- def self.table data, header:true
89
- Termline::Table.simple(data, header:header)
90
- end
91
-
92
- def self.br count=1
93
- Termline::Space.br(count)
94
- end
81
+ def br(count=1)
82
+ puts(Termline::Space.builder("\n", count))
83
+ end
95
84
 
96
- def self.line count=8
97
- Termline::Space.line(count)
98
- end
85
+ def line(count=8)
86
+ puts(Termline::Space.builder('-·- ', count))
87
+ end
99
88
 
100
- def self.color color
101
- Termline::Space.color(count)
102
- end
89
+ def color(color)
90
+ Termline::Space.color(count)
91
+ end
103
92
 
104
93
 
105
- def self.deprecation message
94
+ def deprecation message
95
+ end
106
96
  end
107
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: 0.2.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