ectoplasm 1.2.3 → 1.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/ectoplasm.rb +239 -246
- metadata +12 -24
- data/.github/workflows/build.yml +0 -27
- data/.github/workflows/gem-push.yml +0 -44
- data/.gitignore +0 -3
- data/.rubocop.yml +0 -4522
- data/CHANGELOG.md +0 -22
- data/Gemfile +0 -9
- data/LICENSE.txt +0 -674
- data/README.md +0 -23
- data/Rakefile +0 -2
- data/bin/console +0 -14
- data/bin/setup +0 -8
- data/ectoplasm.gemspec +0 -29
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b1630a2531a6f313b0784aa55fd2fa28df0b6445719d307ec51db1c12f8bd4c2
|
4
|
+
data.tar.gz: a562e611642e7a54b116db6e1269b64fc6c5a674b7fbdad0ae9de0381cfb225b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ea685cded5068288055c2b83c7f0fbbea3e139aa455eff83dfaa2f1dbe2b23f2df77ea4e23cd6e3d6e5d6f26eddca0af066048ec067e8fcfff904d9f639f0c96
|
7
|
+
data.tar.gz: 15976b94b9fcce27ef02c2c40d8cc3a380b984f4550d6dc68909d59acc543672f4b071f0c9a553ac2e478d4208fa4b9ff80191b0f74a249d8b24ada84ee99b3e
|
data/lib/ectoplasm.rb
CHANGED
@@ -1,246 +1,239 @@
|
|
1
|
-
require 'ostruct'
|
2
|
-
|
3
|
-
module Ectoplasm
|
4
|
-
module Version
|
5
|
-
MAJOR = 1
|
6
|
-
MINOR =
|
7
|
-
TINY =
|
8
|
-
end
|
9
|
-
|
10
|
-
VERSION = [Version::MAJOR, Version::MINOR, Version::TINY].compact * '.'
|
11
|
-
|
12
|
-
DEFAULT_SECURE_KEYS = ['password', 'secret', 'token', 'secure', 'pass', 'cert', 'key']
|
13
|
-
|
14
|
-
class ::String
|
15
|
-
|
16
|
-
|
17
|
-
def
|
18
|
-
|
19
|
-
end
|
20
|
-
|
21
|
-
def
|
22
|
-
def
|
23
|
-
|
24
|
-
def
|
25
|
-
def
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
alias
|
31
|
-
alias
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
"\e[#{ansi_color}m#{self}\e[0m"
|
62
|
-
end
|
63
|
-
end
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
.
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
end
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
end
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
class ::
|
218
|
-
def
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
duration_str = "#{minutes}m #{duration_str}" if minutes
|
241
|
-
duration_str = "#{hours}h #{duration_str}" if hours
|
242
|
-
|
243
|
-
duration_str
|
244
|
-
end
|
245
|
-
end
|
246
|
-
end
|
1
|
+
require 'ostruct'
|
2
|
+
|
3
|
+
module Ectoplasm
|
4
|
+
module Version
|
5
|
+
MAJOR = 1
|
6
|
+
MINOR = 4
|
7
|
+
TINY = 0
|
8
|
+
end
|
9
|
+
|
10
|
+
VERSION = [Version::MAJOR, Version::MINOR, Version::TINY].compact * '.'
|
11
|
+
|
12
|
+
DEFAULT_SECURE_KEYS = ['password', 'secret', 'token', 'secure', 'pass', 'cert', 'key', 'auth']
|
13
|
+
|
14
|
+
class ::String
|
15
|
+
def white; self; end
|
16
|
+
def red; colored '31'; end
|
17
|
+
def green; colored '32'; end
|
18
|
+
def yellow; colored '33'; end
|
19
|
+
def blue; colored '34'; end
|
20
|
+
def magenta; colored '35'; end
|
21
|
+
def cyan; colored '36'; end
|
22
|
+
def grey; colored '90'; end
|
23
|
+
|
24
|
+
def bold; colored '1'; end
|
25
|
+
def underline; colored '4'; end
|
26
|
+
|
27
|
+
alias ok green
|
28
|
+
alias error red
|
29
|
+
alias warn yellow
|
30
|
+
alias info blue
|
31
|
+
alias dim grey
|
32
|
+
|
33
|
+
def indent amount, char: ' '
|
34
|
+
self.split("\n").map { |line| char * amount + line }.join "\n"
|
35
|
+
end
|
36
|
+
|
37
|
+
def length
|
38
|
+
m = /\e\[\d{2}m(.*)\e\[0m/.match self
|
39
|
+
|
40
|
+
return self.chars.count - 9 if m
|
41
|
+
|
42
|
+
self.chars.count
|
43
|
+
end
|
44
|
+
|
45
|
+
def frmt props, prefix_suffix=['<', '>']
|
46
|
+
str = self
|
47
|
+
|
48
|
+
props.keys.each do |key|
|
49
|
+
placeholder = prefix_suffix[0] + key.to_s + prefix_suffix[1]
|
50
|
+
str = str.gsub(placeholder, props[key])
|
51
|
+
end
|
52
|
+
|
53
|
+
str
|
54
|
+
end
|
55
|
+
|
56
|
+
private
|
57
|
+
|
58
|
+
def colored ansi_color
|
59
|
+
return self unless $stdout.tty?
|
60
|
+
|
61
|
+
"\e[#{ansi_color}m#{self}\e[0m"
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
class ::Object
|
66
|
+
def pretty(*)
|
67
|
+
self.to_s
|
68
|
+
end
|
69
|
+
|
70
|
+
def obfuscate! _secure_keys = nil
|
71
|
+
self
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
class ::TrueClass
|
76
|
+
def pretty(*)
|
77
|
+
'yes'.green
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
class ::FalseClass
|
82
|
+
def pretty(*)
|
83
|
+
'no'.yellow
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
class ::NilClass
|
88
|
+
def pretty(*)
|
89
|
+
'n/a'.grey
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
class ::Array
|
94
|
+
def pretty width: 25
|
95
|
+
return 'empty'.grey if self.empty?
|
96
|
+
return self.first.pretty if self.count == 1 and not self.first.is_a? Hash
|
97
|
+
|
98
|
+
list_length = self.map { |x| x.to_s.length }.reduce(:+)
|
99
|
+
return self.join ', ' if list_length && list_length < 30
|
100
|
+
|
101
|
+
self
|
102
|
+
.select { |x| x != nil && x != '' }
|
103
|
+
.map do |x|
|
104
|
+
' - ' + x.pretty(width: width-3).strip.gsub(/\n/, "\n ")
|
105
|
+
end
|
106
|
+
.join "\n"
|
107
|
+
end
|
108
|
+
|
109
|
+
def table header: nil, mappings: {}, with_index: false, limit: 50
|
110
|
+
header = self[0].keys if header == nil
|
111
|
+
heading = header.is_a?(Array) ? header : self[0].keys
|
112
|
+
|
113
|
+
table_data = self.slice(0, limit).map do |row|
|
114
|
+
heading.map do |key|
|
115
|
+
mappings.key?(key) ? mappings[key][row, row[key]] : row[key]
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
119
|
+
table_data.insert(0, heading) if header != false
|
120
|
+
|
121
|
+
data_sizes = table_data.map do |row|
|
122
|
+
row.map { |data| data.to_s.length }
|
123
|
+
end
|
124
|
+
|
125
|
+
column_sizes = data_sizes[0]
|
126
|
+
.zip(*data_sizes[1..-1])
|
127
|
+
.map { |row| row.max }
|
128
|
+
|
129
|
+
table = table_data.map { |row| column_sizes.zip row }
|
130
|
+
|
131
|
+
table_str = ''
|
132
|
+
table.each_with_index do |row, index|
|
133
|
+
if with_index
|
134
|
+
if index == 0
|
135
|
+
table_str += ' '
|
136
|
+
else
|
137
|
+
table_str += "[#{index}] "
|
138
|
+
end
|
139
|
+
end
|
140
|
+
|
141
|
+
row.each do |col_size, data|
|
142
|
+
table_str += (data.to_s + ' ' * (col_size - data.to_s.length)) + ' '
|
143
|
+
end
|
144
|
+
|
145
|
+
table_str += "\n"
|
146
|
+
end
|
147
|
+
table_str += '[...]' if self.count > limit
|
148
|
+
print table_str
|
149
|
+
end
|
150
|
+
|
151
|
+
def obfuscate! secure_keys = DEFAULT_SECURE_KEYS
|
152
|
+
self.map { |x| x.obfuscate!(secure_keys) }
|
153
|
+
end
|
154
|
+
end
|
155
|
+
|
156
|
+
class ::Hash
|
157
|
+
def pretty indent: 0, width: 25
|
158
|
+
s = ''
|
159
|
+
|
160
|
+
self
|
161
|
+
.select { |_, value| value != nil || value != '' }
|
162
|
+
.map do |key, value|
|
163
|
+
value = true if value == 'true'
|
164
|
+
value = false if value == 'false'
|
165
|
+
value = '********' if Regexp.new(DEFAULT_SECURE_KEYS.join '|') =~ key.to_s
|
166
|
+
|
167
|
+
if value.is_a? Hash
|
168
|
+
s += key.to_s.cyan.indent(indent) + "\n"
|
169
|
+
s += value.pretty(width: width-indent-2).indent(indent+2)
|
170
|
+
s += "\n"
|
171
|
+
next
|
172
|
+
end
|
173
|
+
|
174
|
+
s += ' ' * indent
|
175
|
+
|
176
|
+
if value.is_a? Array
|
177
|
+
list = value.pretty(width: width)
|
178
|
+
|
179
|
+
if list.split("\n").count > 1
|
180
|
+
s += key.to_s.cyan + "\n"
|
181
|
+
s += value.pretty(width: width).indent(indent)
|
182
|
+
s += "\n"
|
183
|
+
next
|
184
|
+
end
|
185
|
+
|
186
|
+
value = list
|
187
|
+
end
|
188
|
+
|
189
|
+
s += key.to_s.cyan
|
190
|
+
s += ' ' + '.' * (width-key.to_s.length-indent) if width-key.to_s.length > indent
|
191
|
+
s += ': '
|
192
|
+
s += value.pretty + "\n"
|
193
|
+
end
|
194
|
+
|
195
|
+
s
|
196
|
+
end
|
197
|
+
|
198
|
+
def obfuscate! secure_keys = DEFAULT_SECURE_KEYS
|
199
|
+
self.each do |k, v|
|
200
|
+
if v.is_a? Hash
|
201
|
+
v.obfuscate!(secure_keys)
|
202
|
+
elsif v.is_a? Array
|
203
|
+
v.each { |_| v.obfuscate!(secure_keys) }
|
204
|
+
elsif secure_keys.any? { |x| k.to_s.downcase.include? x.downcase }
|
205
|
+
self[k] = '*****'
|
206
|
+
end
|
207
|
+
end
|
208
|
+
end
|
209
|
+
end
|
210
|
+
|
211
|
+
class ::OpenStruct
|
212
|
+
def obfuscate! secure_keys = DEFAULT_SECURE_KEYS
|
213
|
+
OpenStruct.new(self.to_h.obfuscate! secure_keys)
|
214
|
+
end
|
215
|
+
end
|
216
|
+
|
217
|
+
class ::Float
|
218
|
+
def duration
|
219
|
+
seconds = self
|
220
|
+
|
221
|
+
if seconds > 60
|
222
|
+
seconds = seconds.to_i
|
223
|
+
minutes = seconds / 60
|
224
|
+
seconds = seconds % 60
|
225
|
+
end
|
226
|
+
|
227
|
+
if minutes && minutes > 60
|
228
|
+
hours = minutes / 60
|
229
|
+
minutes = minutes % 60
|
230
|
+
end
|
231
|
+
|
232
|
+
duration_str = "#{seconds}s"
|
233
|
+
duration_str = "#{minutes}m #{duration_str}" if minutes
|
234
|
+
duration_str = "#{hours}h #{duration_str}" if hours
|
235
|
+
|
236
|
+
duration_str
|
237
|
+
end
|
238
|
+
end
|
239
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ectoplasm
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Christian Neubauer
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-01-30 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Adds some extension methods to build in types to add prettier console
|
14
14
|
output
|
@@ -18,27 +18,15 @@ executables: []
|
|
18
18
|
extensions: []
|
19
19
|
extra_rdoc_files: []
|
20
20
|
files:
|
21
|
-
- ".github/workflows/build.yml"
|
22
|
-
- ".github/workflows/gem-push.yml"
|
23
|
-
- ".gitignore"
|
24
|
-
- ".rubocop.yml"
|
25
|
-
- CHANGELOG.md
|
26
|
-
- Gemfile
|
27
|
-
- LICENSE.txt
|
28
|
-
- README.md
|
29
|
-
- Rakefile
|
30
|
-
- bin/console
|
31
|
-
- bin/setup
|
32
|
-
- ectoplasm.gemspec
|
33
21
|
- lib/ectoplasm.rb
|
34
|
-
homepage: https://
|
22
|
+
homepage: https://github.com/cneubauer/ectoplasm
|
35
23
|
licenses:
|
36
|
-
-
|
24
|
+
- GPL-3.0-or-later
|
37
25
|
metadata:
|
38
|
-
homepage_uri: https://
|
39
|
-
source_code_uri: https://
|
40
|
-
changelog_uri: https://
|
41
|
-
post_install_message:
|
26
|
+
homepage_uri: https://github.com/cneubauer/ectoplasm
|
27
|
+
source_code_uri: https://github.com/cneubauer/ectoplasm
|
28
|
+
changelog_uri: https://github.com/cneubauer/ectoplasm/blob/main/CHANGELOG.md
|
29
|
+
post_install_message:
|
42
30
|
rdoc_options: []
|
43
31
|
require_paths:
|
44
32
|
- lib
|
@@ -46,15 +34,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
46
34
|
requirements:
|
47
35
|
- - ">="
|
48
36
|
- !ruby/object:Gem::Version
|
49
|
-
version:
|
37
|
+
version: 3.0.0
|
50
38
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
51
39
|
requirements:
|
52
40
|
- - ">="
|
53
41
|
- !ruby/object:Gem::Version
|
54
42
|
version: '0'
|
55
43
|
requirements: []
|
56
|
-
rubygems_version: 3.3.
|
57
|
-
signing_key:
|
44
|
+
rubygems_version: 3.3.26
|
45
|
+
signing_key:
|
58
46
|
specification_version: 4
|
59
47
|
summary: A helper library for console output
|
60
48
|
test_files: []
|
data/.github/workflows/build.yml
DELETED
@@ -1,27 +0,0 @@
|
|
1
|
-
name: Build
|
2
|
-
|
3
|
-
on:
|
4
|
-
push:
|
5
|
-
branches:
|
6
|
-
- develop
|
7
|
-
|
8
|
-
permissions:
|
9
|
-
contents: read
|
10
|
-
|
11
|
-
jobs:
|
12
|
-
build:
|
13
|
-
name: Test and Build
|
14
|
-
runs-on: ubuntu-latest
|
15
|
-
steps:
|
16
|
-
- uses: actions/checkout@v3
|
17
|
-
- name: Set up Ruby
|
18
|
-
uses: ruby/setup-ruby@v1
|
19
|
-
with:
|
20
|
-
ruby-version: '3.1'
|
21
|
-
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
|
22
|
-
- name: Style check
|
23
|
-
run: bundle exec rubocop
|
24
|
-
- name: Run tests
|
25
|
-
run: bundle exec rspec spec
|
26
|
-
- name: Build gem
|
27
|
-
run: bundle exec rake build
|
@@ -1,44 +0,0 @@
|
|
1
|
-
name: Ruby Gem
|
2
|
-
|
3
|
-
on:
|
4
|
-
push:
|
5
|
-
tags:
|
6
|
-
- 'v*.*.*'
|
7
|
-
|
8
|
-
jobs:
|
9
|
-
build:
|
10
|
-
name: Build and Publish
|
11
|
-
runs-on: ubuntu-latest
|
12
|
-
permissions:
|
13
|
-
contents: read
|
14
|
-
packages: write
|
15
|
-
|
16
|
-
steps:
|
17
|
-
- uses: actions/checkout@v3
|
18
|
-
- name: Set up Ruby
|
19
|
-
uses: actions/setup-ruby@v1
|
20
|
-
with:
|
21
|
-
ruby-version: '3.1'
|
22
|
-
|
23
|
-
- name: Publish to GPR
|
24
|
-
run: |
|
25
|
-
mkdir -p $HOME/.gem
|
26
|
-
touch $HOME/.gem/credentials
|
27
|
-
chmod 0600 $HOME/.gem/credentials
|
28
|
-
printf -- "---\n:github: ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials
|
29
|
-
gem build *.gemspec
|
30
|
-
gem push --KEY github --host https://rubygems.pkg.github.com/${OWNER} *.gem
|
31
|
-
env:
|
32
|
-
GEM_HOST_API_KEY: "Bearer ${{secrets.GITHUB_TOKEN}}"
|
33
|
-
OWNER: ${{ github.repository_owner }}
|
34
|
-
|
35
|
-
- name: Publish to RubyGems
|
36
|
-
run: |
|
37
|
-
mkdir -p $HOME/.gem
|
38
|
-
touch $HOME/.gem/credentials
|
39
|
-
chmod 0600 $HOME/.gem/credentials
|
40
|
-
printf -- "---\n:rubygems_api_key: ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials
|
41
|
-
gem build *.gemspec
|
42
|
-
gem push *.gem
|
43
|
-
env:
|
44
|
-
GEM_HOST_API_KEY: "${{secrets.RUBYGEMS_AUTH_TOKEN}}"
|
data/.gitignore
DELETED