mmtop 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/lib/mmtop/host.rb +1 -1
- data/lib/mmtop/string_colorize.rb +41 -8
- data/lib/mmtop/term_printer.rb +17 -9
- metadata +21 -21
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5cfcb1f07b47fecbf593191304bff9f7cd599e8a
|
4
|
+
data.tar.gz: ddc820840fd231e0624da718b2b29b463f57bb3f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7b8cc1b894133ff4247442b21bdf076f1e9f814866c665054c0800847f585125643667f683e853c65b4b6f7eea7d76f5499ff07af6b9160629118e40b98a783c
|
7
|
+
data.tar.gz: 832ab1e621328f561c68cdf2239a13583d91c800187afb6c5b9fccc69709c79b0f850aa5c97ad801803d3bc22db584b96423eae1f651acacda1222731969be6d
|
data/lib/mmtop/host.rb
CHANGED
@@ -1,3 +1,42 @@
|
|
1
|
+
require 'delegate'
|
2
|
+
|
3
|
+
class ColorString < Delegator
|
4
|
+
OFF = "\e[0m"
|
5
|
+
def initialize(string, color)
|
6
|
+
@string = string
|
7
|
+
|
8
|
+
if color.is_a?(Array)
|
9
|
+
@color_offsets = color
|
10
|
+
else
|
11
|
+
@color_offsets = [ [0, string.size, color] ]
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
attr_reader :color_offsets
|
16
|
+
|
17
|
+
def __getobj__
|
18
|
+
@string
|
19
|
+
end
|
20
|
+
|
21
|
+
def to_s
|
22
|
+
@color_offsets.map { |o|
|
23
|
+
o.last + @string[o[0], o[1]] + OFF
|
24
|
+
}.join
|
25
|
+
end
|
26
|
+
|
27
|
+
def +(other)
|
28
|
+
res = @string + other
|
29
|
+
if other.is_a?(ColorString)
|
30
|
+
adjusted_offsets = other.color_offsets.map do |arr|
|
31
|
+
[arr[0] + @string.size, arr[1], arr[2]]
|
32
|
+
end
|
33
|
+
ColorString.new(res, @color_offsets + adjusted_offsets)
|
34
|
+
else
|
35
|
+
ColorString.new(res, @color_offsets + [[@string.size, other.size, OFF]])
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
1
40
|
class String
|
2
41
|
CODES = {
|
3
42
|
:off => "\e[0m",
|
@@ -33,8 +72,9 @@ class String
|
|
33
72
|
|
34
73
|
def colorize(*args)
|
35
74
|
color = args.map { |color| CODES[color] if color.is_a?(Symbol) }.join("")
|
36
|
-
|
75
|
+
ColorString.new(self, color)
|
37
76
|
end
|
77
|
+
|
38
78
|
def colourise(*args); colorize(*args); end
|
39
79
|
|
40
80
|
def red; colorize(:red); end
|
@@ -43,11 +83,4 @@ class String
|
|
43
83
|
def black; colorize(:black); end
|
44
84
|
def white; colorize(:white); end
|
45
85
|
def dark_gray; colorize(:dark_gray); end
|
46
|
-
|
47
|
-
def size_uncolorized
|
48
|
-
self.gsub(/\e.*?m/, '').size_raw
|
49
|
-
end
|
50
|
-
|
51
|
-
alias :size_raw :size
|
52
|
-
alias :size :size_uncolorized
|
53
86
|
end
|
data/lib/mmtop/term_printer.rb
CHANGED
@@ -59,8 +59,8 @@ module MMTop
|
|
59
59
|
fill * sep.size
|
60
60
|
end
|
61
61
|
|
62
|
-
def column_value_with_fill(index, str, fill, align)
|
63
|
-
fill_str = fill * (
|
62
|
+
def column_value_with_fill(index, max_size, str, fill, align)
|
63
|
+
fill_str = fill * (max_size - str.size)
|
64
64
|
if align == :left
|
65
65
|
str + fill_str
|
66
66
|
else
|
@@ -68,11 +68,15 @@ module MMTop
|
|
68
68
|
end
|
69
69
|
end
|
70
70
|
|
71
|
-
def column_value(
|
72
|
-
|
73
|
-
|
71
|
+
def column_value(indexes, str, fill=" ", align=:left)
|
72
|
+
indexes = Array(indexes)
|
73
|
+
max_size = indexes.inject(0) { |s, idx| s + table_header_columns[idx].size }
|
74
|
+
max_size += sep_fill.size * (indexes.size - 1)
|
75
|
+
|
76
|
+
if str.size < max_size
|
77
|
+
column_value_with_fill(indexes.first, max_size, str, fill, align)
|
74
78
|
else
|
75
|
-
str[0..
|
79
|
+
str[0..max_size - 1]
|
76
80
|
end
|
77
81
|
end
|
78
82
|
|
@@ -142,9 +146,13 @@ module MMTop
|
|
142
146
|
return if info.processlist.empty? && info.host.hide_if_empty?
|
143
147
|
|
144
148
|
display_name = info.host.display_name
|
145
|
-
|
146
|
-
|
147
|
-
|
149
|
+
if info.host.dead?
|
150
|
+
display_name = (display_name + "!").red
|
151
|
+
end
|
152
|
+
|
153
|
+
str = pipe + " " + column_value([0, 1, 2], display_name + " ", "-".dark_gray)
|
154
|
+
|
155
|
+
#str += sep_fill + column_fill(1) + sep_fill + column_fill(2)
|
148
156
|
str += info_sep + column_value(3, info.connections.size.to_s)
|
149
157
|
str += info_sep + column_value(4, format_slave_status(info.slave_status))
|
150
158
|
str += info_sep + column_value(5, format_slave_delay(info.slave_status))
|
metadata
CHANGED
@@ -1,97 +1,97 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mmtop
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ben Osheroff
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-01
|
11
|
+
date: 2014-07-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: mysql2
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '0'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: getopt-declare
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '0'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- -
|
38
|
+
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: debugger
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- -
|
45
|
+
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: '0'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- -
|
52
|
+
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
|
-
name:
|
56
|
+
name: rake
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- -
|
59
|
+
- - ">="
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: '0'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- -
|
66
|
+
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
|
-
name:
|
70
|
+
name: bump
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
|
-
- -
|
73
|
+
- - ">="
|
74
74
|
- !ruby/object:Gem::Version
|
75
75
|
version: '0'
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
|
-
- -
|
80
|
+
- - ">="
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '0'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: mysql_isolated_server
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
|
-
- -
|
87
|
+
- - ">="
|
88
88
|
- !ruby/object:Gem::Version
|
89
89
|
version: '0'
|
90
90
|
type: :development
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
|
-
- -
|
94
|
+
- - ">="
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: '0'
|
97
97
|
description:
|
@@ -102,6 +102,8 @@ executables:
|
|
102
102
|
extensions: []
|
103
103
|
extra_rdoc_files: []
|
104
104
|
files:
|
105
|
+
- bin/mmtop
|
106
|
+
- lib/mmtop.rb
|
105
107
|
- lib/mmtop/command.rb
|
106
108
|
- lib/mmtop/commands/basic.rb
|
107
109
|
- lib/mmtop/commands/filters.rb
|
@@ -118,8 +120,6 @@ files:
|
|
118
120
|
- lib/mmtop/string_colorize.rb
|
119
121
|
- lib/mmtop/term_input.rb
|
120
122
|
- lib/mmtop/term_printer.rb
|
121
|
-
- lib/mmtop.rb
|
122
|
-
- bin/mmtop
|
123
123
|
homepage: http://github.com/osheroff/mmtop
|
124
124
|
licenses: []
|
125
125
|
metadata: {}
|
@@ -129,17 +129,17 @@ require_paths:
|
|
129
129
|
- lib
|
130
130
|
required_ruby_version: !ruby/object:Gem::Requirement
|
131
131
|
requirements:
|
132
|
-
- -
|
132
|
+
- - ">="
|
133
133
|
- !ruby/object:Gem::Version
|
134
134
|
version: '0'
|
135
135
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
136
136
|
requirements:
|
137
|
-
- -
|
137
|
+
- - ">="
|
138
138
|
- !ruby/object:Gem::Version
|
139
139
|
version: '0'
|
140
140
|
requirements: []
|
141
141
|
rubyforge_project:
|
142
|
-
rubygems_version: 2.
|
142
|
+
rubygems_version: 2.2.2
|
143
143
|
signing_key:
|
144
144
|
specification_version: 4
|
145
145
|
summary: A mytop-ish variant that can watch many mysql servers
|