ix-cli 0.0.14 → 0.0.16

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/bin/ix-hls +7 -11
  3. data/bin/ix-log +2 -1
  4. data/bin/ix-timestamp2 +50 -8
  5. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d054eabc68581f7a85447e44ce7471bd3bfd361fec428cd6f52b07bc23d99f61
4
- data.tar.gz: ef9b8158e1a5282d68956f9188f47d2e0753a7e42606b8fd48a8e684f2379d1a
3
+ metadata.gz: 1457129da9fa04dd6d4241cf824afc2998a0302cdf9bd4b915088f61b48f53ac
4
+ data.tar.gz: 1837dc100f225e4fd9d919465003c3874d629ec6a5e5f2b125625ea82a588947
5
5
  SHA512:
6
- metadata.gz: 312c40f4c85f2c8919ddaa1ea33a9306dfc2be0eecf51782d18abaaabf4a5d1cc8fd00507674081ecf5598e694d9c28f4c31783b7416afd11a6d86024b096904
7
- data.tar.gz: 4f7d68947f74467984e028a8d66460d662b8a32d57cc2e0072bb63454b325b3ce7abaa7600ea02f7a8bf64b4e6c8355bb1a51d8b5be8c0b5bf3d095e11716cee
6
+ metadata.gz: 97c0c9b0879c2c6b557e09907db966a0a2fbdcbfade5477ac60ddc77fd9367b41bb5ddbd6a60b66525cf45dbe305872812cb0789f962395cd6347a671db1463b
7
+ data.tar.gz: dced22aa4a1e694ceaf0aa4113e6d7b7c6e5d6e4e175cd18e4a2ade63c1c141780a045ff40f138df6584f39f7fa2f0d9ab2ad9b04fd21db180c2c1f1c15e3c6b
data/bin/ix-hls CHANGED
@@ -1,21 +1,17 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- #
4
- # options
5
- #
6
- # line ix-highlight-line highlight a specific line
7
- # vertical ix-highlight-vertical highlight a particular column
8
- # highlight ix-highlight-match highlight whatever matches a regex
9
- #
10
-
3
+ require 'rubygems'
4
+ require 'isna'
11
5
 
12
6
  abort 'No pattern given' if ARGV[0].nil?
13
7
 
14
8
  trap('SIGINT') { }
15
9
 
16
- $stdout.sync = true
17
-
18
10
  STDIN.each_line do |line|
19
- puts line.gsub(/(#{ARGV[0]})/i) { |x| "#{$1}" }
11
+ ARGV.each do |setting|
12
+ matcher, color = setting.split(':')
13
+ line.gsub!(/(#{matcher})/i) { |x| "#{$1}".to_ansi.send(:"#{color}").to_s }
14
+ end
15
+ puts line
20
16
  end
21
17
 
data/bin/ix-log CHANGED
@@ -34,7 +34,8 @@ if print_markers
34
34
  end
35
35
 
36
36
  STDIN.each_line do |line|
37
- object = get_object(line.chomp!)
37
+ text = line.chomp!.force_encoding("utf-8")
38
+ object = get_object(text)
38
39
  puts JSON.dump(object)
39
40
  end
40
41
 
data/bin/ix-timestamp2 CHANGED
@@ -1,14 +1,56 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- # Expects a timestamp perline
3
+ require 'json'
4
+ require 'isna'
4
5
 
5
- require 'time'
6
+ start = false
7
+ prev = false
8
+ lineno = 0
9
+ colors = true
6
10
 
7
- STDIN.each do |line|
8
- puts '=' * 80
9
- orignal_time = line.chomp
10
- parsed_time = Time.at(line.chomp.to_i)
11
- puts "#{orignal_time} => #{parsed_time}"
12
- puts ''
11
+ STDIN.each_line do |line|
12
+ begin
13
+ lineno += 1
14
+ json = JSON.parse(line)
15
+ timestamp = json['timestamp'].to_f
16
+ unless start
17
+ start = timestamp
18
+ prev = timestamp
19
+ end
20
+
21
+ object = {
22
+ :timestamp => timestamp.to_s.rjust(20, ' '),
23
+ :time => Time.at(timestamp).to_s.rjust(20, ' '),
24
+ :elapsed => format('%1.5f', (timestamp - start)).to_s.rjust(10, ' '),
25
+ :diff => format('%2.5f', (timestamp - prev)).to_s.rjust(10, ' '),
26
+ :lineno => (('| ') + (lineno.to_s)).ljust(5, ' '),
27
+ :message => json['message']
28
+ }
29
+
30
+ if colors
31
+ object[:timestamp] = object[:timestamp].to_s.to_ansi.yellow.to_s
32
+ object[:time] = object[:time].to_s.to_ansi.cyan.to_s
33
+ object[:elapsed] = object[:elapsed].to_s.to_ansi.pink.to_s
34
+
35
+ if (timestamp - prev) > 1 and (timestamp - prev) < 10
36
+ object[:diff] = object[:diff].to_s.to_ansi.green.to_s
37
+ end
38
+
39
+ if (timestamp - prev) > 10 and (timestamp - prev) < 50
40
+ object[:diff] = object[:diff].to_s.to_ansi.yellow.to_s
41
+ end
42
+
43
+ if (timestamp - prev) > 50
44
+ object[:diff] = object[:diff].to_s.to_ansi.red.to_s
45
+ end
46
+
47
+ object[:lineno] = object[:lineno].to_s.to_ansi.cyan.to_s
48
+ end
49
+
50
+ puts format("%<timestamp>s %<time>s %<elapsed>s %<diff>s %<lineno>s %<message>s", object)
51
+ prev = timestamp
52
+ rescue => e
53
+ puts e.message
54
+ end
13
55
  end
14
56
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ix-cli
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.14
4
+ version: 0.0.16
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kazuyoshi Tlacaelel