vj 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/vj.rb +34 -30
- data/lib/vj/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3d433bddf2c46ed83bfb58731bbf0d0afea6fd4e
|
4
|
+
data.tar.gz: 8deaeecb5c33cf2f89ab6d30a5b506f8f51cffbe
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 295fffd3ebaabb25ba380b8c71641d1695697bc0a145b1ea869ca1d92e89e24bf3fe4240f89c812ab013a4e4b8ad42291bb60effe54ac7edde1cdebeadc805f7
|
7
|
+
data.tar.gz: 6ae8e7abb1e50b383c74f5f470f95debe78849120c967d917cb687c7620d80917e0e0a70f709f675b3aaaafc79e208c672b87b19dbfbb9421cab0777d550737c
|
data/Gemfile.lock
CHANGED
data/lib/vj.rb
CHANGED
@@ -53,41 +53,45 @@ module Vj
|
|
53
53
|
end
|
54
54
|
suppress_keys = Set.new(opts[:suppress])
|
55
55
|
hash = nil
|
56
|
-
|
57
|
-
line
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
56
|
+
begin
|
57
|
+
STDIN.each do |line|
|
58
|
+
line.chomp!
|
59
|
+
next if line == ''
|
60
|
+
begin
|
61
|
+
hash = Oj.load(line)
|
62
|
+
next if hash.nil?
|
63
|
+
rescue StandardError => e
|
64
|
+
hash = Marshal.load(Marshal.dump(base_json))
|
65
|
+
hash[base_json_line_key] = line
|
66
|
+
end
|
66
67
|
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
68
|
+
if opts[:jsonify]
|
69
|
+
puts Oj.dump(hash)
|
70
|
+
next
|
71
|
+
end
|
71
72
|
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
73
|
+
color = nil
|
74
|
+
if hash[opts[:color_key]]
|
75
|
+
color = palette[Digest::MD5.hexdigest(hash[opts[:color_key]].to_s).to_i(16) % palette.length]
|
76
|
+
print Paint[" #{hash[opts[:color_key]]} ", color, :inverse] + ' '
|
77
|
+
hash.delete(opts[:color_key])
|
78
|
+
end
|
78
79
|
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
80
|
+
keys = hash.keys.sort
|
81
|
+
opts[:prioritize].reverse.each do |pkey|
|
82
|
+
keys.unshift(keys.delete(pkey)) if keys.include? pkey
|
83
|
+
end
|
83
84
|
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
85
|
+
keys.each do |k|
|
86
|
+
next if suppress_keys.include?(k)
|
87
|
+
v = hash[k]
|
88
|
+
next if v.nil? || v == ''
|
89
|
+
print Paint[eval(format('"%s"', format(opts[:template], key: k, value: v).tr('"', "\001"))).tr("\001", '"'), color]
|
90
|
+
end
|
91
|
+
puts
|
89
92
|
end
|
90
|
-
|
93
|
+
rescue Interrupt
|
94
|
+
exit 130
|
91
95
|
end
|
92
96
|
end
|
93
97
|
|
data/lib/vj/version.rb
CHANGED