L2 0.5.3 → 0.6.1

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