muflax 0.2.4 → 0.2.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +2 -2
- data/Gemfile.lock +1 -1
- data/lib/muflax/string.rb +28 -0
- data/muflax.gemspec +1 -1
- data.tar.gz.sig +0 -0
- metadata +1 -1
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c3c658af855414bea8ca9b03391eef441f7a3706
|
4
|
+
data.tar.gz: 7c45ee303680f6c7bffe588ff345ddecd04dc1cc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0bfa5c9b931ddd083e37e42c7908cdda757c8bf62b8e4c202d374dffb38ec1de66e58cde98520f2d3f43add24461fbca60a020ffc4ae0f67e98b99580911ef4c
|
7
|
+
data.tar.gz: 5d4af076c5f8c31569c1a0c9392cf9a37365b0e8b660e484ade2901b4ce0afd258926388ffa7afacdbbb4a43851cbdc7a0adfc471169e20f3b2dacafabac5ca9
|
checksums.yaml.gz.sig
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
�
|
2
|
-
|
1
|
+
=����G,����*ta`f����V�Rc�BY�,���p:n)���c>��Vt|���f��)�����6��L�e��M)�����4O*�p�U��v�6�#>����\�o��"�m��G�]��g��]�*v{�捚˂!xvS�l� �m32�1d9�b�
|
2
|
+
c��w���4��2)a��5}ٱ���z��&����Yد�ᡣ�� r�'�!�hS�x$q�� cK����&>)�9��.5)�z8t�s�|���
|
data/Gemfile.lock
CHANGED
data/lib/muflax/string.rb
CHANGED
@@ -18,4 +18,32 @@ class String
|
|
18
18
|
def whackuum str=/\s+/
|
19
19
|
self.split(str).map(&:strip)
|
20
20
|
end
|
21
|
+
|
22
|
+
ANSIColorRegexp = Regexp.new(/(?: \e \[ \d+ (?: ;\d+)* m )+/x)
|
23
|
+
|
24
|
+
def truncate length, omission: "..."
|
25
|
+
return self if self.length <= length
|
26
|
+
|
27
|
+
ss = StringScanner.new(self)
|
28
|
+
out = ss.scan(ANSIColorRegexp) || ""
|
29
|
+
cut_length = length - omission.str_length
|
30
|
+
used = 0
|
31
|
+
cut_at = 0
|
32
|
+
|
33
|
+
while used < length and not ss.eos?
|
34
|
+
out << ss.getch
|
35
|
+
c = ss.scan(ANSIColorRegexp)
|
36
|
+
out << c unless c.nil?
|
37
|
+
used += 1
|
38
|
+
|
39
|
+
cut_at = out.length if used == cut_length
|
40
|
+
end
|
41
|
+
|
42
|
+
if not ss.eos?
|
43
|
+
out = out[0, cut_at]
|
44
|
+
out << omission
|
45
|
+
end
|
46
|
+
|
47
|
+
out
|
48
|
+
end
|
21
49
|
end
|
data/muflax.gemspec
CHANGED
data.tar.gz.sig
CHANGED
Binary file
|
metadata
CHANGED
metadata.gz.sig
CHANGED
Binary file
|