mobj 2.5.0 → 2.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/lib/ext/array.rb +2 -0
- data/lib/ext/string.rb +45 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
MWJmMjVjMjVmZDI0MmQ0ZjkyODBhZjY3ZmYwMWU3MWQyMjkxMDdlZQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
NDM2M2FjMmQ4MzY3NjI0OTRlZDc0YTVjNjNlMmUwZDliZGYzYjgyMQ==
|
7
7
|
!binary "U0hBNTEy":
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
ZGYzOGE5NDFkOGU0YTJhNDNiN2M1MTM2MTE1MjllM2FhZmY4NzdiNzNkODY2
|
10
|
+
N2RiOGQwMTFkMjQ3YzU0N2U4ZTU1MDM2YmJkODljYmYyNjZkODU3MGRmYzY4
|
11
|
+
NTc1ZjM0MTljNTIwNzkwMmRjYzMyMTRkNTViMzk3YjJjMmI4MjA=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
ZjZmNTk3ZGJlMmY3OWJiMjJmOTRhYWM2NGMxNjljODBhMzMxNDBmNzUwOWQ5
|
14
|
+
NDdmMWVjMzBkZmQyZWQ1YjkyNDc1N2MzY2VkMjY2NzU2OTJlNjBlN2JhY2Jk
|
15
|
+
OTIzOWYyYjJhZDc2YzkzZjliOGNiMGQzOThlMWM4YTQ3MGVjMWM=
|
data/lib/ext/array.rb
CHANGED
data/lib/ext/string.rb
CHANGED
@@ -2,8 +2,53 @@ require 'mobj'
|
|
2
2
|
|
3
3
|
module Mobj
|
4
4
|
|
5
|
+
ANSI = {
|
6
|
+
colors: {
|
7
|
+
k: 0, #:black,
|
8
|
+
r: 1, #:red,
|
9
|
+
g: 2, #:green,
|
10
|
+
y: 3, #:yellow,
|
11
|
+
b: 4, #:blue,
|
12
|
+
m: 5, #:magenta,
|
13
|
+
c: 6, #:cyan,
|
14
|
+
w: 7 #:white,
|
15
|
+
},
|
16
|
+
options: {
|
17
|
+
#:'*' => 90, #:bright,
|
18
|
+
#:'^' => 90, #:bright,
|
19
|
+
:'!' => 1, #:bold,
|
20
|
+
B: 1, #:bold,
|
21
|
+
f: 2, #:faint,
|
22
|
+
i: 3, #:italics,
|
23
|
+
u: 4, #:underline,
|
24
|
+
_: 4, #:underline,
|
25
|
+
x: 5, #:blink,
|
26
|
+
F: 6, #:blink_fast,
|
27
|
+
U: 21 #:double_underline
|
28
|
+
}
|
29
|
+
}
|
30
|
+
|
5
31
|
class ::String
|
6
32
|
|
33
|
+
def cfmt
|
34
|
+
colors = ANSI.colors.keys.join
|
35
|
+
opts = ANSI.options.keys.join
|
36
|
+
formatted = self
|
37
|
+
matches(/\{(?<color>[#{colors}]?)(?<opts>[#{opts}*^]*)\|(?<str>.*?)\}/).each do |m|
|
38
|
+
opts = m.opts.split(//).map(&:sym)
|
39
|
+
bright = (opts.delete(:'*') || opts.delete(:'^')) ? 90 : 30
|
40
|
+
codes = [(ANSI.colors[m.color].to_i + bright)] + ANSI.options.values_at(*opts).compact
|
41
|
+
formatted = formatted.sub(m[0], "\033[#{codes.join(';')}m#{m.str}\033[m")
|
42
|
+
end
|
43
|
+
|
44
|
+
formatted
|
45
|
+
end
|
46
|
+
alias_method :c!, :cfmt
|
47
|
+
|
48
|
+
def <(*args)
|
49
|
+
self.cfmt.%(*args)
|
50
|
+
end
|
51
|
+
|
7
52
|
def matches(regexp)
|
8
53
|
start = 0
|
9
54
|
matches = []
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mobj
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mason
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-04-
|
11
|
+
date: 2013-04-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|