MrMurano 1.2.0 → 1.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: becf766cb2d799e7cd09460a9d1a9b0907074c49
4
- data.tar.gz: 007d4c8c73d94cb48a67a048bb8af95bdf3b3914
3
+ metadata.gz: dbf6540edd42b5a6cac68bb92b3f18f69cf0e90e
4
+ data.tar.gz: 311ff88459a51b3af06604d89d5c9b58f32b849f
5
5
  SHA512:
6
- metadata.gz: de75b5e29711198f832c96668eca04c83cee6b284c0287ad05e6b3480158f3cb816d41204d518f29989ffa9ff44cb25f1276377e65114a9cd71acc01a0cdff0b
7
- data.tar.gz: 7e73558588ce36f65fd90f524f5e870aeae5c69dc27408a1abd5ab8a266f7a1612c887bcb8902d9ac5b54040f9898bd686cf05c0fff8fd536daa2469b2792356
6
+ metadata.gz: d01eaf47965c58e51cd502e5a6268d799a5cc96d4eca6bc4930a4dbe555519114ecae0c8483c1876bfbf3bc29cde1ead1cb5a91ccf307d5580c86f0fec7df5ba
7
+ data.tar.gz: 8b2b715ba8955ad9ea54c02ad9a5acbc8781f7f70129929f7a295d6b17a5bd53893934f190ef79d1803f633e679a2ccfafbd3d201bde83174ff183ec7af60dcf
data/lib/MrMurano/logs.rb CHANGED
@@ -25,34 +25,72 @@ command :logs do |c|
25
25
  if ret.kind_of?(Hash) and ret.has_key?('items') then
26
26
  ret['items'].reverse.each do |line|
27
27
  curtime = ""
28
+ if line.kind_of?(String) then
28
29
 
29
- line.sub!(/^\[[^\]]*\]/) {|m| m.color(:red).background(:aliceblue)}
30
- line.sub!(/\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(?:\.\d+)(?:\+\d\d:\d\d)/) {|m|
31
- if options.localtime then
32
- m = DateTime.parse(m).to_time.localtime.to_datetime.iso8601(3)
30
+ line.sub!(/^\[[^\]]*\]/) {|m| m.color(:red).background(:aliceblue)}
31
+ line.sub!(/\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(?:\.\d+)(?:\+\d\d:\d\d)/) {|m|
32
+ if options.localtime then
33
+ m = DateTime.parse(m).to_time.localtime.to_datetime.iso8601(3)
34
+ end
35
+ curtime = m
36
+ m.color(:blue)
37
+ }
38
+
39
+ line.gsub!(/\{(?>[^}{]+|\g<0>)*\}/m) do |m|
40
+ if options.pretty then
41
+ js = JSON.parse(m, {:allow_nan=>true, :create_additions=>false})
42
+ ret = JSON.pretty_generate(js).to_s
43
+ ret[0] = ret[0].color(:magenta)
44
+ ret[-1] = ret[-1].color(:magenta)
45
+ ret
46
+ else
47
+ m.sub!(/^{/){|ml| ml.color(:magenta)}
48
+ m.sub!(/}$/){|ml| ml.color(:magenta)}
49
+ m
50
+ end
33
51
  end
34
- curtime = m
35
- m.color(:blue)
36
- }
37
52
 
38
- line.gsub!(/\{(?>[^}{]+|\g<0>)*\}/m) do |m|
53
+ out = line
54
+
55
+ elsif line.kind_of?(Hash) then
56
+ line = Hash.transform_keys_to_symbols(line)
57
+ out=""
58
+
59
+ out << "[#{line[:subject]}]".color(:red).background(:aliceblue)
60
+ out << " "
61
+ if options.localtime then
62
+ curtime = Time.at(line[:timestamp]).localtime.to_datetime.iso8601(3)
63
+ else
64
+ curtime = Time.at(line[:timestamp]).to_datetime.iso8601(3)
65
+ end
66
+ out << curtime.color(:blue)
67
+ out << ":"
68
+ out << "\n---------\nrequest:"
39
69
  if options.pretty then
40
- js = JSON.parse(m, {:allow_nan=>true, :create_additions=>false})
41
- ret = JSON.pretty_generate(js).to_s
70
+ ret = JSON.pretty_generate(line[:data][:request]).to_s
42
71
  ret[0] = ret[0].color(:magenta)
43
72
  ret[-1] = ret[-1].color(:magenta)
44
- ret
73
+ out << ret
45
74
  else
46
- m.sub!(/^{/){|ml| ml.color(:magenta)}
47
- m.sub!(/}$/){|ml| ml.color(:magenta)}
48
- m
75
+ out << line[:data][:request].to_json
49
76
  end
77
+ out << "\n---------\nresponse:"
78
+ if options.pretty then
79
+ ret = JSON.pretty_generate(line[:data][:response]).to_s
80
+ ret[0] = ret[0].color(:magenta)
81
+ ret[-1] = ret[-1].color(:magenta)
82
+ out << ret
83
+ else
84
+ out << line[:data][:response].to_json
85
+ end
86
+
50
87
  end
51
88
 
52
89
  if curtime > lasttime then
53
90
  lasttime = curtime
54
- puts line
91
+ puts out
55
92
  end
93
+
56
94
  end
57
95
  else
58
96
  say_error "Couldn't get logs: #{ret}"
@@ -1,4 +1,4 @@
1
1
  module MrMurano
2
- VERSION = '1.2.0'.freeze
2
+ VERSION = '1.2.1'.freeze
3
3
  end
4
4
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: MrMurano
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Conrad Tadpol Tilstra
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-08-30 00:00:00.000000000 Z
11
+ date: 2016-09-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: commander