termline 0.1.0 → 0.2.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: e8a666432b2c154e47a5a7eab4bf5000b82f757505ae7dc8d3e666f6d5e3348e
4
- data.tar.gz: 474673368a2be027c630918b5e063c65d0439adf222ec541b1ecfd546c9475c1
3
+ metadata.gz: 31c52f81fd0fe02b29f7a294cf7fae93e3cb008b2cdb1e34169f06fbf367d638
4
+ data.tar.gz: 8a810a992c7be490f7eea90172bc480d0e078af072b633520dc8c1c75dce3392
5
5
  SHA512:
6
- metadata.gz: 5498fedb4fc8b12a28da46e142a188ff0251667704e3df0b02143932ebc14f95afb91df155715a5e93208fc59fd149cf301450428e6a84c2783e69845fe77bc8
7
- data.tar.gz: 8365ae2a44b6857315d9d3006d4362747094a71c8375bb32745d1a70523354bd1173d06e8fcce30779c6264c4f4503a8be356cb46749f7d3de71752bc26211bd
6
+ metadata.gz: 06ca46dd65fcf1a262568be376a160b9a0ea96d32f8db952d066fe0af71061ffd21342de906f79dfcc53c7f88837e56c1d75547e6b5754b6656b5dfaa4e6cb9c
7
+ data.tar.gz: aa14be84ef383c11cdfea7571a73b0b2354d39a13d694ca170f03d280efed502f99267148f5e60ea69cc073caf910d1af5cf1e123b9045979e275c8a7c2b9bf2
data/lib/termline/msg.rb CHANGED
@@ -1,32 +1,47 @@
1
1
 
2
2
  module Termline
3
3
  module Msg
4
- def self.msg messages
5
- puts(message)
6
- end
4
+ class << self
7
5
 
8
- def self.builder message, tag: 'MSG', color: :default
9
- puts(Config.pretty("#{tag} #{ message }", color))
10
- end
11
-
12
- def self.info message
13
- builder(message, tag:'INFO:', color: :blue)
14
- end
6
+ def builder(
7
+ message,
8
+ tag: nil,
9
+ icon: nil,
10
+ data: nil,
11
+ color: :default,
12
+ bgcolor: :default,
13
+ timestamp: Time.now.strftime('%H:%M:%S:%L'))
15
14
 
16
- def self.success message
17
- builder(message, tag:'SUCCESS:', color: :green)
18
- end
15
+ parts = []
16
+ parts << "[#{timestamp}]" if timestamp
17
+ parts << Style.colorize(Style.icon(icon), color) if icon
18
+ parts << Style.colorize(tag, color) if tag
19
+ parts << message
20
+ parts << data_text(data, color) if data
19
21
 
20
- def self.warning messages
21
- messages.each { |message| puts(Config.pretty("WARNING: #{ message }", :yellow)) }
22
- end
22
+ puts(parts.compact.map(&:to_s).reject(&:empty?).join(" ").strip)
23
+ end
23
24
 
24
- def self.danger messages
25
- messages.each { |message| puts(Config.pretty("ERROR: #{ message }", :red)) }
26
- end
25
+ def alert message
26
+ puts("\e[5m#{message}\e[0m")
27
+ puts("\e[5m#{Style.colorize(message,:red)}\e[0m")
28
+ end
29
+
30
+ private
31
+
32
+ def format_value(value)
33
+ case value
34
+ when String
35
+ value.include?(" ") ? value.inspect : value
36
+ else
37
+ value.inspect
38
+ end
39
+ end
27
40
 
28
- def self.alert messages
29
- messages.each { |message| puts("\e[5m#{message}\e[0m") }
41
+ def data_text(data, color)
42
+ return nil if data.nil? || data.empty?
43
+ data.map { |key, value| "#{key}#{Style.colorize('=>', color)}#{format_value(value)}" }.join(" ")
44
+ end
30
45
  end
31
46
  end
32
47
  end
@@ -1,11 +1,15 @@
1
1
 
2
2
 
3
3
  module Termline
4
- module Config
4
+ module Style
5
5
 
6
+ # Available icons
6
7
  ICONS = {
7
- checkmark: "",
8
- bullet: "",
8
+ warning: "",
9
+ success: "",
10
+ debug: "•",
11
+ error: "✖",
12
+ info: "ℹ",
9
13
  star: "★"
10
14
  }.freeze
11
15
 
@@ -35,7 +39,6 @@ module Termline
35
39
 
36
40
  # calculate the console width
37
41
  # tputcols is not available on windows
38
- #WIDTH = `tput cols`.to_i rescue WIDTH = 1;
39
42
  WIDTH = begin
40
43
  term = ENV['TERM']
41
44
  term ? `tput cols`.to_i : 1
@@ -43,6 +46,11 @@ module Termline
43
46
  1
44
47
  end
45
48
 
49
+ def self.icon icon
50
+ ICONS[icon]
51
+ end
52
+
53
+ # Concat color to text
46
54
  def self.colorize(text, colour = :default, bg_colour = :default)
47
55
  colour_code = COLORS[colour]
48
56
  bg_colour_code = BG_COLORS[bg_colour]
@@ -58,7 +66,7 @@ module Termline
58
66
  width = 1 if width.negative?
59
67
  end
60
68
 
61
- return colorize("\ \ #{ message } #{"\ " * width}", colour, bg_colour)
69
+ return colorize("#{ message } #{"\ " * width}", colour, bg_colour)
62
70
  end
63
71
  end
64
72
  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.1.0"
34
- BUILD = "1774159419"
33
+ VERSION = "0.2.0"
34
+ BUILD = "1774211535"
35
35
  end
data/lib/termline.rb CHANGED
@@ -1,6 +1,8 @@
1
1
  =begin
2
2
 
3
- Copyright (c) 2022, Lesli Technologies, S. A.
3
+ Lesli
4
+
5
+ Copyright (c) 2026, Lesli Technologies, S. A.
4
6
 
5
7
  This program is free software: you can redistribute it and/or modify
6
8
  it under the terms of the GNU General Public License as published by
@@ -13,68 +15,61 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
15
  GNU General Public License for more details.
14
16
 
15
17
  You should have received a copy of the GNU General Public License
16
- along with this program. If not, see <http://www.gnu.org/licenses/>.
18
+ along with this program. If not, see http://www.gnu.org/licenses/.
17
19
 
18
- Lesli Ruby Messages - Message utilities for the Ruby console
20
+ Lesli · Ruby on Rails SaaS Development Framework.
19
21
 
20
- Powered by https://www.lesli.tech
22
+ Made with ♥ by LesliTech
21
23
  Building a better future, one line of code at a time.
22
24
 
23
- @contact <hello@lesli.tech>
24
- @website <https://www.lesli.tech>
25
+ @contact hello@lesli.tech
26
+ @website https://www.lesli.tech
25
27
  @license GPLv3 http://www.gnu.org/licenses/gpl-3.0.en.html
26
- @author The Lesli Development Team
27
28
 
28
- // · ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~
29
+ // · ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~
29
30
  // ·
30
31
  =end
31
32
 
32
- require "termline/config"
33
- require "termline/table"
34
- require "termline/space"
35
- require "termline/list"
36
- require "termline/msg"
37
- require "termline/banner"
33
+ require_relative "termline/style"
34
+ require_relative "termline/table"
35
+ require_relative "termline/space"
36
+ require_relative "termline/list"
37
+ require_relative "termline/msg"
38
+ require_relative "termline/banner"
38
39
 
39
40
 
40
41
  # ·
41
42
  module Termline
42
43
 
43
44
  def self.m *messages
44
- messages.each { |message| Termline::Msg.msg(message) }
45
+ messages.each { |message| puts(message) }
45
46
  end
46
47
 
47
- def self.msg (*messages)
48
- messages.each { |message| Termline::Msg.builder(message) }
48
+ def self.msg (*messages, data:nil)
49
+ messages.each { |message| Termline::Msg.builder(message, data:data) }
49
50
  end
50
51
 
51
- def self.info *messages
52
- messages.each { |message| Termline::Msg.info(message) }
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) }
53
54
  end
54
55
 
55
- def self.success *messages
56
- messages.each { |message| Termline::Msg.success(message) }
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) }
57
58
  end
58
59
 
59
- def self.warning *messages
60
- Termline::Msg.warning(messages)
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) }
61
62
  end
62
63
 
63
- def self.danger *messages
64
- Termline::Msg.danger(messages)
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) }
65
66
  end
66
67
 
67
68
  def self.alert *messages
68
- Termline::Msg.alert(messages)
69
+ messages.each { |message| Termline::Msg.alert(message) }
69
70
  end
70
71
 
71
- def self.warn *messages
72
- warning(messages)
73
- end
74
72
 
75
- def self.error *messages
76
- Termline::Msg.danger(messages)
77
- end
78
73
 
79
74
 
80
75
  def self.list *items
data/readme.md CHANGED
@@ -1,145 +1,76 @@
1
- <p align="center">
2
- <a href="https://www.lesli.dev" target="_blank">
3
- <img alt="Lesli Ruby Message logo" width="200px" src="./docs/l2-logo.svg" />
4
- </a>
5
- </p>
6
- <h3 align="center">Message utilities for the Ruby console</h3>
1
+ <div align="center" class="documentation-header">
2
+ <img width="100" alt="LesliTesting logo" src="./docs/images/termline-logo.svg" />
3
+ <h3 align="center">Human-friendly terminal logs for the Lesli Platform</h3>
4
+ </div>
7
5
 
8
- Version 0.5.2
6
+ <br />
7
+ <hr/>
8
+ <br />
9
9
 
10
- ## Installation
11
10
 
12
- Install the gem and add to the application's Gemfile by executing:
11
+ ### Quick start
13
12
 
14
- $ bundle add l2
15
-
16
- If bundler is not being used to manage dependencies, install the gem by executing:
17
-
18
- $ gem install l2
19
-
20
- Rails apps
21
-
22
- $ gem "L2", "~> 0.4.0"
23
-
24
- ## Usage
25
-
26
-
27
- **Simple message:**
28
-
29
- ```ruby
30
- L2.m("hola")
31
- L2.m("hola", "hello", "hallo", 1, [2], {"a":"b"})
32
- ```
33
-
34
-
35
- **Simple message with dividing line:**
36
-
37
- ```ruby
38
- L2.msg("hola")
39
- L2.msg("hola", "hello", "hallo", 1, [2], {"a":"b"})
40
- ```
41
-
42
-
43
- **Informative message:**
44
-
45
- ```ruby
46
- L2.info("hola")
47
- L2.info("hola", "hello", "hallo", 1, [2], {"a":"b"})
48
- ```
49
-
50
-
51
- **Sucessful message:**
52
-
53
- ```ruby
54
- L2.success("hola")
55
- L2.success("hola", "hello", "hallo", 1, [2], {"a":"b"})
56
- ```
57
-
58
-
59
- **Simple message:**
60
-
61
- ```ruby
62
- L2.warning("hola")
63
- L2.warning("hola", "hello", "hallo", 1, [2], {"a":"b"})
64
- ```
65
-
66
-
67
- **Error message:**
68
-
69
- ```ruby
70
- L2.danger("hola")
71
- L2.danger("hola", "hello", "hallo", 1, [2], {"a":"b"})
72
- ```
73
-
74
-
75
- **Error with flashing message:**
76
-
77
- ```ruby
78
- L2.fatal("hola")
79
- L2.fatal("hola", "hello", "hallo", 1, [2], {"a":"b"})
80
- ```
81
-
82
-
83
- **Flashing message:**
84
-
85
- ```ruby
86
- L2.alert("hola")
87
- L2.alert("hola", "hello", "hallo", 1, [2], {"a":"b"})
88
- ```
89
-
90
-
91
- **Useful to give instructions in deprecated methods or code:**
92
-
93
- ```ruby
94
- L2.deprecation("hola")
13
+ ```shell
14
+ # Add LesliAdmin engine gem
15
+ bundle add termline
95
16
  ```
96
17
 
97
-
98
- **Print a simple list:**
99
-
18
+ ### Usage
100
19
  ```ruby
101
- L2.list("hola", "hello", "hallo", 1, [2], {"a":"b"})
20
+ 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"})
102
27
  ```
103
28
 
29
+ **Result:**
104
30
 
105
- **Show data as table:**
31
+ <img alt="LesliTesting logo" src="./docs/images/screenshot.png" />
106
32
 
107
- ```ruby
108
- L2.table([
109
- { español: "hola", english: "hello", deutsch: "hallo" },
110
- { español: "hola", english: "hello", deutsch: "hallo" },
111
- { español: "hola", english: "hello", deutsch: "hallo" }
112
- ])
113
- ```
114
33
 
34
+ ### Documentation
35
+ * [website](https://www.lesli.dev/)
36
+ * [documentation](https://www.lesli.dev/gems/termline/)
115
37
 
116
- **Display a cow message:**
117
-
118
- ```ruby
119
- L2.cow("Hello little cow!")
120
- ```
121
38
 
39
+ ### Connect with Lesli
122
40
 
123
- ### Development
124
- ------
41
+ * [X: @LesliTech](https://x.com/LesliTech)
42
+ * [Email: hello@lesli.tech](hello@lesli.tech)
43
+ * [Website: https://www.lesli.tech](https://www.lesli.tech)
125
44
 
126
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
127
45
 
128
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
46
+ ### License
47
+ -------
48
+ Copyright (c) 2026, Lesli Technologies, S. A.
129
49
 
130
- ### Contributing
131
- ------
50
+ This program is free software: you can redistribute it and/or modify
51
+ it under the terms of the GNU General Public License as published by
52
+ the Free Software Foundation, either version 3 of the License, or
53
+ (at your option) any later version.
132
54
 
133
- Bug reports and pull requests are welcome on GitHub at https://github.com/LesliTech/l2.
55
+ This program is distributed in the hope that it will be useful,
56
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
57
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
58
+ GNU General Public License for more details.
134
59
 
60
+ You should have received a copy of the GNU General Public License
61
+ along with this program. If not, see http://www.gnu.org/licenses/.
135
62
 
136
- ### License
137
- ------
63
+ <br />
64
+ <hr />
65
+ <br />
66
+ <br />
138
67
 
139
- Software developed in [Guatemala](http://visitguatemala.com/) distributed under the *General Public License v 3.0* you can read the full license [here](http://www.gnu.org/licenses/gpl-3.0.html)
68
+ <div align="center" class="has-text-centered">
69
+ <img width="200" alt="Lesli logo" src="https://cdn.lesli.tech/lesli/brand/app-logo.svg" />
70
+ <h3 align="center" class="mt-0">
71
+ The Open-Source SaaS Development Framework for Ruby on Rails.
72
+ </h3>
73
+ </div>
140
74
 
141
- <p align="center">
142
- <a href="https://www.lesli.tech" target="_blank">
143
- <img alt="LesliTech logo" width="150" src="https://cdn.lesli.tech/leslitech/brand/leslitech-logo.svg" />
144
- </a>
145
- </p>
75
+ <br />
76
+ <br />
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.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - The Lesli Development Team
@@ -19,10 +19,10 @@ extra_rdoc_files: []
19
19
  files:
20
20
  - lib/termline.rb
21
21
  - lib/termline/banner.rb
22
- - lib/termline/config.rb
23
22
  - lib/termline/list.rb
24
23
  - lib/termline/msg.rb
25
24
  - lib/termline/space.rb
25
+ - lib/termline/style.rb
26
26
  - lib/termline/table.rb
27
27
  - lib/termline/version.rb
28
28
  - readme.md