everyday-cli-utils 1.2.0 → 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6aaaed2712c0b90ca6ed889e79e62365f22212d8
|
4
|
+
data.tar.gz: 5a599eaf22c830354c9b23ccc50ac574d44e2d31
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5c6fd0fa669e955f0070ea5332c1cc80c78a0d6d7d6dab07d1a0890fa4a996343aea11ad58d815b6eb23e751281824c8cdfe2c981aa2656614589042669d08c7
|
7
|
+
data.tar.gz: cd14ebdc8c59db60787338915eaf61f62b45b1ae0022c2cb0654b32b953edf756a64e9bd729fbea3fb25422458b0220c51024e4adbc6ea568498026abddf38fd
|
@@ -119,6 +119,13 @@ module EverydayCliUtils
|
|
119
119
|
}.gsub(regex2) { |_| format($1, color_profile_string($2.to_sym)) }
|
120
120
|
end
|
121
121
|
|
122
|
+
def self::remove_format(text)
|
123
|
+
colors = 'bk|rd|gr|yw|bl|pu|cy|wh|no'
|
124
|
+
regex = /\{(.+?)\}\((bd)?(ul)?(?:f(#{colors}))?(?:b(#{colors}))?\)/
|
125
|
+
regex2 = /\{(.+?)\}\(:(.+?)\)/
|
126
|
+
text.gsub(regex, '\1').gsub(regex2, '\1') {}
|
127
|
+
end
|
128
|
+
|
122
129
|
def self.mycenter(str, len, char = ' ')
|
123
130
|
tlen = str.gsub(%r{\e\[.*?m}, '').length
|
124
131
|
return str if tlen >= len
|
@@ -76,6 +76,20 @@ describe EverydayCliUtils::Format do
|
|
76
76
|
str.format_all.should eq expected
|
77
77
|
end
|
78
78
|
|
79
|
+
it 'allows removing shorthand for formatting in-string' do
|
80
|
+
str = 'abc {def}(bdulfywbgr) ghi {jkl}(ulfyw) mno'
|
81
|
+
expected = 'abc def ghi jkl mno'
|
82
|
+
str.remove_format.should eq expected
|
83
|
+
end
|
84
|
+
|
85
|
+
it 'allows removing color profile shorthand for formatting in-string' do
|
86
|
+
EverydayCliUtils::Format.color_profile(:p1, bold: true, underline: true, fgcolor: :yellow, bgcolor: :green)
|
87
|
+
EverydayCliUtils::Format.color_profile(:p2, underline: true, fgcolor: :yellow)
|
88
|
+
str = 'abc {def}(:p1) ghi {jkl}(:p2) mno'
|
89
|
+
expected = 'abc def ghi jkl mno'
|
90
|
+
str.remove_format.should eq expected
|
91
|
+
end
|
92
|
+
|
79
93
|
it 'allows centering a formatted string' do
|
80
94
|
str = 'abc'
|
81
95
|
str2 = str.center(10)
|