L2 0.5.2 → 0.6.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 +4 -4
- data/lib/L2.rb +32 -167
- metadata +5 -19
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b264818a3f5af77f0ca579737bf36aa09205a685a9b05dfc18ed753c9c1344c7
|
4
|
+
data.tar.gz: 75f7caa168b4a6e224780ddf1d2da6400a24fbd7aacc9de586e9c8aa7f77406c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b063d07d782e5f08754ec0fe99dea119434924ecbc6f047537f606ec15c4691d2e3f483de936d2623e32e44e02fce6772a86427b4fefbd0d66cb201df6c62c88
|
7
|
+
data.tar.gz: '055648ed84a8db941adb87aca18e670ce6b4b17f4cb5b9eca67d803c385a48fbc0ad6730b724186594878a139e38decddf9b09d158255f324f69de33e41dabe6'
|
data/lib/L2.rb
CHANGED
@@ -29,220 +29,85 @@ Building a better future, one line of code at a time.
|
|
29
29
|
// ·
|
30
30
|
=end
|
31
31
|
|
32
|
-
require "ruby_cowsay"
|
33
32
|
|
34
|
-
|
33
|
+
require "l2/Msg"
|
34
|
+
require "l2/List"
|
35
|
+
require "l2/Table"
|
36
|
+
require "l2/Space"
|
35
37
|
|
36
|
-
# standard color palette for texts
|
37
|
-
COLORS = {
|
38
|
-
default: '38',
|
39
|
-
yellow: '1;33',
|
40
|
-
white: '1;37',
|
41
|
-
green: '32',
|
42
|
-
black: '30',
|
43
|
-
blue: '34',
|
44
|
-
red: '31'
|
45
|
-
}.freeze
|
46
|
-
|
47
|
-
# standard color palette for backgrounds
|
48
|
-
BG_COLORS = {
|
49
|
-
default: '0',
|
50
|
-
yellow: '103',
|
51
|
-
white: '107',
|
52
|
-
green: '42',
|
53
|
-
black: '40',
|
54
|
-
blue: '44',
|
55
|
-
red: '41'
|
56
|
-
}.freeze
|
57
|
-
|
58
|
-
|
59
|
-
# calculate the console width
|
60
|
-
# tputcols is not available on windows
|
61
|
-
WIDTH = `tput cols`.to_i rescue 1;
|
62
38
|
|
39
|
+
# ·
|
40
|
+
module L2
|
63
41
|
|
64
42
|
def self.m *messages
|
65
|
-
|
43
|
+
L2::Msg.simple(messages)
|
66
44
|
end
|
67
45
|
|
68
|
-
|
69
46
|
def self.msg *messages
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
separator_blank
|
47
|
+
self.br
|
48
|
+
L2::Msg.simple(messages)
|
49
|
+
self.line
|
74
50
|
end
|
75
51
|
|
76
|
-
|
77
52
|
def self.info *messages
|
78
|
-
|
79
|
-
messages.each { |message| puts(pretty("INFO: #{ message }", :white, :blue)) }
|
80
|
-
puts(separator_pretty(:blue))
|
53
|
+
L2::Msg.info(messages)
|
81
54
|
end
|
82
55
|
|
83
|
-
|
84
56
|
def self.success *messages
|
85
|
-
|
86
|
-
messages.each { |message| puts(pretty("SUCCESS: #{ message }", :black, :green)) }
|
87
|
-
puts(separator_pretty(:green))
|
57
|
+
L2::Msg.success(messages)
|
88
58
|
end
|
89
59
|
|
90
|
-
|
91
60
|
def self.warning *messages
|
92
|
-
|
93
|
-
messages.each { |message| puts(pretty("WARNING: #{ message }", :black, :yellow)) }
|
94
|
-
puts(separator_pretty(:yellow))
|
61
|
+
L2::Msg.warning(messages)
|
95
62
|
end
|
96
63
|
|
97
|
-
|
98
64
|
def self.danger *messages
|
99
|
-
|
100
|
-
messages.each { |message| puts(pretty("ERROR: #{ message }", :yellow, :red)) }
|
101
|
-
puts(pretty("PATH: #{ caller[0] }", :yellow, :red))
|
102
|
-
puts(separator_pretty(:red))
|
65
|
+
L2::Msg.danger(messages)
|
103
66
|
end
|
104
67
|
|
105
|
-
|
106
|
-
def self.fatal *messages
|
107
|
-
puts(separator_pretty(:red))
|
108
|
-
messages.each { |message| puts("\e[5m#{pretty(message, :white, :red)}\e[0m") }
|
109
|
-
puts(pretty("PATH: #{ caller[0] }", :white, :red))
|
110
|
-
puts(separator_pretty(:red))
|
111
|
-
end
|
112
|
-
|
113
|
-
|
114
68
|
def self.alert *messages
|
115
|
-
|
69
|
+
L2::Msg.alert(messages)
|
116
70
|
end
|
117
71
|
|
118
|
-
|
119
|
-
|
120
|
-
puts(separator_pretty(:red))
|
121
|
-
puts(pretty("DEPRECATED METHOD: #{ caller[0] }, #{ message }", :white, :red))
|
122
|
-
puts(separator_pretty(:red))
|
72
|
+
def self.warn *messages
|
73
|
+
warning(messages)
|
123
74
|
end
|
124
75
|
|
125
|
-
|
126
|
-
|
127
|
-
messages.each { |message| puts(" - #{ message }" )}
|
128
|
-
separator_blank
|
76
|
+
def self.error *messages
|
77
|
+
L2::Msg.danger(messages)
|
129
78
|
end
|
130
79
|
|
131
80
|
|
132
|
-
def self.
|
133
|
-
|
134
|
-
return if Gem.win_platform?
|
135
|
-
return unless data.size > 0
|
136
|
-
|
137
|
-
if data.class.name == "ActiveRecord::Relation"
|
138
|
-
data = data.to_a.map(&:serializable_hash)
|
139
|
-
end
|
140
|
-
|
141
|
-
# get the available characters in terminal width
|
142
|
-
terminal_width = `tput cols`.to_i
|
143
|
-
|
144
|
-
# get the number of columns to print base on the data hash
|
145
|
-
cols = data.first.keys.count + 1
|
146
|
-
|
147
|
-
# get the available space for every column
|
148
|
-
col_width = (terminal_width / cols) - 1
|
149
|
-
|
150
|
-
# validate that we have minimum space to render the table
|
151
|
-
return if col_width <= 0
|
152
|
-
|
153
|
-
# separator for every column and row
|
154
|
-
separator = ('| ' << ('- ' * (col_width / 2)))
|
155
|
-
|
156
|
-
# add extra blank spaces to adjust the col_width only if col_width not a even number
|
157
|
-
separator += (' ') if (col_width - separator.size).odd?
|
158
|
-
|
159
|
-
# print data as table :)
|
160
|
-
data.each_with_index do |row, index|
|
161
|
-
|
162
|
-
# only for table header
|
163
|
-
if index == 0
|
164
|
-
|
165
|
-
# print table titles
|
166
|
-
puts '| ' << row.keys.map { |key| key.to_s.upcase.ljust(col_width) }.join('| ')
|
167
|
-
|
168
|
-
# print header separators, only for visible columns
|
169
|
-
puts separator * (cols - 1)
|
170
|
-
|
171
|
-
end
|
172
|
-
|
173
|
-
# join hash values as a line and justify every value to print value
|
174
|
-
# in its own column
|
175
|
-
puts '| ' << row.values.map { |value| value.to_s.ljust(col_width) }.join('| ')
|
176
|
-
|
177
|
-
end
|
178
|
-
|
81
|
+
def self.list *items
|
82
|
+
L2::List.bullet(items)
|
179
83
|
end
|
180
84
|
|
181
|
-
def self.
|
182
|
-
|
183
|
-
# ids of the prettiest cows in the library
|
184
|
-
pretty_cows = [46,33,32,31,29,27,21,10,5]
|
185
|
-
|
186
|
-
# get a random cow id
|
187
|
-
random_cows = rand(0..(pretty_cows.size - 1))
|
188
|
-
|
189
|
-
br()
|
190
|
-
|
191
|
-
# show simple text message
|
192
|
-
puts Cow.new({ :cow => Cow.cows[pretty_cows[random_cows]] }).say(message)
|
85
|
+
def self.list_check *items
|
86
|
+
L2::List.check(items)
|
193
87
|
end
|
194
88
|
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
def self.warn *messages
|
200
|
-
warning(messages)
|
89
|
+
def self.list_star *items
|
90
|
+
L2::List.star(items)
|
201
91
|
end
|
202
92
|
|
203
93
|
|
204
|
-
def self.
|
205
|
-
|
94
|
+
def self.table data
|
95
|
+
L2::Table.simple(data)
|
206
96
|
end
|
207
97
|
|
208
98
|
def self.br count=1
|
209
|
-
|
99
|
+
L2::Space.br(count)
|
210
100
|
end
|
211
101
|
|
212
102
|
def self.line count=8
|
213
|
-
|
214
|
-
end
|
215
|
-
|
216
|
-
private
|
217
|
-
|
218
|
-
def self.separator_blank count=1
|
219
|
-
puts("\n" * count);
|
220
|
-
end
|
221
|
-
|
222
|
-
|
223
|
-
def self.separator_line count=8
|
224
|
-
puts('-·- ' * count)
|
225
|
-
end
|
226
|
-
|
227
|
-
|
228
|
-
def self.separator_pretty(bg_colour = :default)
|
229
|
-
pretty("", :black, bg_colour)
|
103
|
+
L2::Space.line(count)
|
230
104
|
end
|
231
105
|
|
232
|
-
|
233
|
-
|
234
|
-
colour_code = COLORS[colour]
|
235
|
-
bg_colour_code = BG_COLORS[bg_colour]
|
236
|
-
return "\e[#{bg_colour_code};#{colour_code}m#{text}\e[0m".squeeze(';')
|
106
|
+
def self.color color
|
107
|
+
L2::Space.color(count)
|
237
108
|
end
|
238
|
-
|
239
109
|
|
240
|
-
def self.pretty(message, colour = :default, bg_colour = :default)
|
241
110
|
|
242
|
-
|
243
|
-
width = 1 if width.negative?
|
244
|
-
|
245
|
-
return colorize("\ \ #{ message } #{"\ " * width}", colour, bg_colour)
|
111
|
+
def self.deprecation message
|
246
112
|
end
|
247
|
-
|
248
113
|
end
|
metadata
CHANGED
@@ -1,29 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: L2
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- The Lesli Development Team
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
12
|
-
dependencies:
|
13
|
-
- !ruby/object:Gem::Dependency
|
14
|
-
name: ruby_cowsay
|
15
|
-
requirement: !ruby/object:Gem::Requirement
|
16
|
-
requirements:
|
17
|
-
- - "~>"
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: 0.1.3
|
20
|
-
type: :runtime
|
21
|
-
prerelease: false
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
23
|
-
requirements:
|
24
|
-
- - "~>"
|
25
|
-
- !ruby/object:Gem::Version
|
26
|
-
version: 0.1.3
|
11
|
+
date: 2024-06-09 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
27
13
|
description:
|
28
14
|
email:
|
29
15
|
- hello@lesli.tech
|
@@ -39,7 +25,7 @@ metadata:
|
|
39
25
|
homepage_uri: https://github.com/LesliTech/L2
|
40
26
|
source_code_uri: https://github.com/LesliTech/L2
|
41
27
|
bug_tracker_uri: https://github.com/LesliTech/L2/issues
|
42
|
-
changelog_uri: https://github.com/LesliTech/L2/releases/tag/v0.
|
28
|
+
changelog_uri: https://github.com/LesliTech/L2/releases/tag/v0.6.0
|
43
29
|
post_install_message:
|
44
30
|
rdoc_options: []
|
45
31
|
require_paths:
|
@@ -55,7 +41,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
55
41
|
- !ruby/object:Gem::Version
|
56
42
|
version: '0'
|
57
43
|
requirements: []
|
58
|
-
rubygems_version: 3.
|
44
|
+
rubygems_version: 3.3.7
|
59
45
|
signing_key:
|
60
46
|
specification_version: 4
|
61
47
|
summary: Message utilities for the Ruby console.
|