vj 1.0.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (5) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +1 -1
  3. data/lib/vj.rb +34 -30
  4. data/lib/vj/version.rb +1 -1
  5. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8650414a22b2447752eda609dcf1f5b342066151
4
- data.tar.gz: b1bc95966768b174d11b61e1351e7feeae0dd8c0
3
+ metadata.gz: 3d433bddf2c46ed83bfb58731bbf0d0afea6fd4e
4
+ data.tar.gz: 8deaeecb5c33cf2f89ab6d30a5b506f8f51cffbe
5
5
  SHA512:
6
- metadata.gz: 7c2d06e832de552f1aa0aa1352cd2e0bc64475174fc7c290278c8de8a10c21d5023e488b3126ad53fd69fbbefbb6e34ee151a620e96bd0f841212e5ba2db0319
7
- data.tar.gz: 5e1b352bf63c7fbbbc90d399a36c8e4e84cfcf78b33b5a16beb0b0976f99cfb75b589c04b8e7f2c1d4ffe68bff5ee81b1ff0e6487c67452eb505dc6a0215c379
6
+ metadata.gz: 295fffd3ebaabb25ba380b8c71641d1695697bc0a145b1ea869ca1d92e89e24bf3fe4240f89c812ab013a4e4b8ad42291bb60effe54ac7edde1cdebeadc805f7
7
+ data.tar.gz: 6ae8e7abb1e50b383c74f5f470f95debe78849120c967d917cb687c7620d80917e0e0a70f709f675b3aaaafc79e208c672b87b19dbfbb9421cab0777d550737c
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- vj (1.0.0)
4
+ vj (1.0.1)
5
5
  oj
6
6
  optix
7
7
  paint
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
- STDIN.each do |line|
57
- line.chomp!
58
- next if line == ''
59
- begin
60
- hash = Oj.load(line)
61
- next if hash.nil?
62
- rescue StandardError => e
63
- hash = Marshal.load(Marshal.dump(base_json))
64
- hash[base_json_line_key] = line
65
- end
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
- if opts[:jsonify]
68
- puts Oj.dump(hash)
69
- next
70
- end
68
+ if opts[:jsonify]
69
+ puts Oj.dump(hash)
70
+ next
71
+ end
71
72
 
72
- color = nil
73
- if hash[opts[:color_key]]
74
- color = palette[Digest::MD5.hexdigest(hash[opts[:color_key]].to_s).to_i(16) % palette.length]
75
- print Paint[" #{hash[opts[:color_key]]} ", color, :inverse] + ' '
76
- hash.delete(opts[:color_key])
77
- end
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
- keys = hash.keys.sort
80
- opts[:prioritize].reverse.each do |pkey|
81
- keys.unshift(keys.delete(pkey)) if keys.include? pkey
82
- end
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
- keys.each do |k|
85
- next if suppress_keys.include?(k)
86
- v = hash[k]
87
- next if v.nil? || v == ''
88
- print Paint[eval(format('"%s"', format(opts[:template], key: k, value: v).tr('"', "\001"))).tr("\001", '"'), color]
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
- puts
93
+ rescue Interrupt
94
+ exit 130
91
95
  end
92
96
  end
93
97
 
data/lib/vj/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Vj
2
- VERSION = '1.0.0'.freeze
2
+ VERSION = '1.0.1'.freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vj
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - moe