fix_protocol_tools 1.1.2 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/bin/{fixgrep → fixlogviewer} +1 -1
- data/lib/fix_protocol_tools/messages_processor.rb +15 -17
- data/lib/fix_protocol_tools/runner.rb +34 -42
- data/lib/fix_protocol_tools/specification/dictionary.rb +4 -0
- data/lib/fix_protocol_tools/version.rb +1 -1
- metadata +4 -6
- data/bin/fixless +0 -9
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
MDg5Y2MxMzczNWRjMWRlNzhjOWNkMTYxZDE5NDUxNTNjYjJmYjBhZA==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
M2I4NjdjYzY0YjY1MTFmOTQ3MzRmNDNhZGMzMjI5OTQ5NGY1MTJiOA==
|
7
7
|
!binary "U0hBNTEy":
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
ZWRmZGFlMWI3Mjg2OTIyOGFjNzk4ZmFiZjIzMmZlZGVjOGVhYzliMjlkNWIz
|
10
|
+
YjRkYWE0NDllN2VkYjQ4Mzc3M2YxN2Q3YWM5ZjM0ZmVkNTg4OTJjYWRmZDRi
|
11
|
+
ZWJlZTc4YzY5MDEyZjczZTYxZTc1ZTZhZmY4NmJmNWVlNGFlZjQ=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
OWEwNjI1ZTRlYzVhYjUyNDNiNWVjMzg2MjQ2ZjMyNWU1NjJiN2U0NWY4YTZk
|
14
|
+
MDcyNzRhYWUyYmRiM2FiMzdiMzNiZjQzYjU5NDJmYWU5OTE0MTAxZjAxZWE3
|
15
|
+
Yjk4Y2E4ZGZkNzA5ZDlhOWY0OWY4NWRiYTc3MzMxYmRlZWU3YjY=
|
@@ -10,8 +10,10 @@ module FixProtocolTools
|
|
10
10
|
def initialize(options)
|
11
11
|
@spec = nil
|
12
12
|
@is_even_line = true
|
13
|
-
@output =
|
13
|
+
@output = STDOUT
|
14
14
|
@grep = options[:grep]
|
15
|
+
@highlights = options[:highlights] || []
|
16
|
+
@heartbeats = options[:heartbeats]
|
15
17
|
|
16
18
|
if options[:dictionary]
|
17
19
|
@spec = Specification::Dictionary.new(Specification::Reader.read_file(options[:dictionary]))
|
@@ -39,8 +41,6 @@ module FixProtocolTools
|
|
39
41
|
end
|
40
42
|
|
41
43
|
process_line(buffer) if buffer
|
42
|
-
|
43
|
-
@output.close
|
44
44
|
end
|
45
45
|
|
46
46
|
private
|
@@ -56,7 +56,7 @@ module FixProtocolTools
|
|
56
56
|
|
57
57
|
@spec ||= resolve_specification(fields)
|
58
58
|
rows = []
|
59
|
-
|
59
|
+
show_message = @grep.nil?
|
60
60
|
message_name = 'Undefined'
|
61
61
|
sender = 'Undefined'
|
62
62
|
target = 'Undefined'
|
@@ -74,13 +74,15 @@ module FixProtocolTools
|
|
74
74
|
|
75
75
|
if @grep && (value_name.include?(@grep) || value_id.include?(@grep))
|
76
76
|
value_name = red(value_name)
|
77
|
-
|
77
|
+
show_message = true
|
78
78
|
end
|
79
79
|
|
80
|
+
show_message = false if !@heartbeats && @spec.heartbeat?(field_id, value_id)
|
81
|
+
|
80
82
|
rows << formatted_row(field_id, value_id, field_name, value_name, field_name_padding)
|
81
83
|
end
|
82
84
|
|
83
|
-
if
|
85
|
+
if show_message
|
84
86
|
@is_even_line = false
|
85
87
|
@output.puts ''
|
86
88
|
@output.puts("[#{red(message_name + " #{sender} >>> #{target}")}]" +
|
@@ -90,9 +92,15 @@ module FixProtocolTools
|
|
90
92
|
end
|
91
93
|
|
92
94
|
def formatted_row(field_id, value_id, field_name, value_name, field_name_padding)
|
93
|
-
field_name + ' = '.rjust(field_name_padding) + value_name +
|
95
|
+
row = field_name + ' = '.rjust(field_name_padding) + value_name +
|
94
96
|
' '.rjust(35 - value_name.length) +
|
95
97
|
field_id + '=' + value_id
|
98
|
+
|
99
|
+
if @highlights and @highlights.include?(field_name)
|
100
|
+
yellow(row)
|
101
|
+
else
|
102
|
+
row
|
103
|
+
end
|
96
104
|
end
|
97
105
|
|
98
106
|
def resolve_specification(fields)
|
@@ -112,16 +120,6 @@ module FixProtocolTools
|
|
112
120
|
nil
|
113
121
|
end
|
114
122
|
end
|
115
|
-
|
116
|
-
def init_output_chanel(options)
|
117
|
-
if options[:less]
|
118
|
-
cmd = 'less'
|
119
|
-
cmd += ' -r' if options[:color]
|
120
|
-
IO.popen(cmd, 'w')
|
121
|
-
else
|
122
|
-
STDOUT
|
123
|
-
end
|
124
|
-
end
|
125
123
|
end
|
126
124
|
end
|
127
125
|
|
@@ -6,69 +6,61 @@ module FixProtocolTools
|
|
6
6
|
class Runner
|
7
7
|
DEFAULTS = {
|
8
8
|
:color => Term::ANSIColor::coloring = STDOUT.isatty,
|
9
|
-
:dictionary => ENV['FPT_DICT']
|
9
|
+
:dictionary => ENV['FPT_DICT'],
|
10
|
+
:highlights => ENV['FPT_HIGHLIGHTS'],
|
11
|
+
:heartbeats => false
|
10
12
|
}
|
11
13
|
|
12
14
|
def initialize
|
13
|
-
|
15
|
+
@options = DEFAULTS
|
14
16
|
end
|
15
17
|
|
16
|
-
def
|
17
|
-
@options.merge!(:less => false)
|
18
|
+
def run!
|
18
19
|
opt_parse = OptionParser.new do |opts|
|
19
|
-
opts.banner = "Usage:
|
20
|
+
opts.banner = "Usage: #{File.basename($0)} [options] [file]"
|
20
21
|
|
21
|
-
opts.on('
|
22
|
-
@options[:
|
22
|
+
opts.on('--dictionary PATH_TO_DICTIONARY', 'You can set up FPT_DICT env variable instead') do |dictionary|
|
23
|
+
@options[:dictionary] = dictionary
|
23
24
|
end
|
24
25
|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
end
|
26
|
+
opts.on('--highlight field1,field2', Array, 'Highlight number of fields, you can set FPT_HIGHLIGHTS env variable instead') do |highlights|
|
27
|
+
@options[:highlights] = highlights
|
28
|
+
end
|
29
29
|
|
30
|
-
|
30
|
+
opts.on('-c', '--[no-]color', 'Generate color output') do |color|
|
31
|
+
Term::ANSIColor::coloring = color
|
32
|
+
@options[:color] = color
|
33
|
+
end
|
31
34
|
|
32
|
-
|
33
|
-
|
35
|
+
opts.on('--grep', 'Grep by field id or name') do |pattern|
|
36
|
+
@options[:grep] = pattern
|
37
|
+
end
|
34
38
|
|
35
|
-
|
36
|
-
|
37
|
-
|
39
|
+
opts.on('--[no-]heartbeats', 'Show full report on heartbeat messages') do |heartbeats|
|
40
|
+
@options[:heartbeats] = heartbeats
|
41
|
+
end
|
38
42
|
|
39
|
-
opts.
|
40
|
-
|
43
|
+
opts.on_tail('-h', '--help', 'Display help message') do
|
44
|
+
puts opts
|
45
|
+
exit
|
41
46
|
end
|
42
47
|
|
43
|
-
|
44
|
-
|
45
|
-
|
48
|
+
opts.on_tail('-v', '--version', 'Display version message') do
|
49
|
+
puts FixProtocolTools::VERSION
|
50
|
+
exit
|
51
|
+
end
|
46
52
|
end
|
47
53
|
|
48
54
|
opt_parse.parse!
|
49
|
-
MessagesProcessor.new(@options).process
|
50
|
-
end
|
51
55
|
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
exit
|
58
|
-
end
|
59
|
-
end
|
60
|
-
|
61
|
-
def color(opts)
|
62
|
-
opts.on('-c', '--[no-]color', 'Generate color output') do |color|
|
63
|
-
Term::ANSIColor::coloring = color
|
64
|
-
@options[:color] = color
|
56
|
+
ARGV.each do |f|
|
57
|
+
unless File.exists?(f)
|
58
|
+
puts "File #{f} does not exists"
|
59
|
+
exit false
|
60
|
+
end
|
65
61
|
end
|
66
|
-
end
|
67
62
|
|
68
|
-
|
69
|
-
opts.on('-d', '--dictionary PATH_TO_DICTIONARY', 'You can set up FPT_DICT env variable instead') do |dictionary|
|
70
|
-
@options[:dictionary] = dictionary
|
71
|
-
end
|
63
|
+
MessagesProcessor.new(@options).process
|
72
64
|
end
|
73
65
|
end
|
74
66
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fix_protocol_tools
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Luxor
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-08-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: term-ansicolor
|
@@ -56,13 +56,11 @@ description: log viewer for fix protocol logs
|
|
56
56
|
email:
|
57
57
|
- atuzov@gmail.com
|
58
58
|
executables:
|
59
|
-
-
|
60
|
-
- fixless
|
59
|
+
- fixlogviewer
|
61
60
|
extensions: []
|
62
61
|
extra_rdoc_files: []
|
63
62
|
files:
|
64
|
-
- bin/
|
65
|
-
- bin/fixless
|
63
|
+
- bin/fixlogviewer
|
66
64
|
- lib/fix_protocol_tools.rb
|
67
65
|
- lib/fix_protocol_tools/messages_processor.rb
|
68
66
|
- lib/fix_protocol_tools/runner.rb
|