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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c4ad6bf00dc4c1d535cb3285f3e6abcd136363a6
4
- data.tar.gz: 5ee9498dd03444d4e4f3851e571a00ebc1153f43
3
+ metadata.gz: 5cfcb1f07b47fecbf593191304bff9f7cd599e8a
4
+ data.tar.gz: ddc820840fd231e0624da718b2b29b463f57bb3f
5
5
  SHA512:
6
- metadata.gz: 67e8c1cf6d11276da68201686f4f0c53444313abab38496c5c7f95cbf9914f18d0ec623943c409f9d7f01473992b211e4de038f143e9b902a0a49c76172da987
7
- data.tar.gz: 0e40313f469d62685129cce49b0921818e7db30ec74f37439000c49e5f5d40251c12af28a77249a5987b92fc57e6be99b35061caf6f48108b6451e81b408531c
6
+ metadata.gz: 7b8cc1b894133ff4247442b21bdf076f1e9f814866c665054c0800847f585125643667f683e853c65b4b6f7eea7d76f5499ff07af6b9160629118e40b98a783c
7
+ data.tar.gz: 832ab1e621328f561c68cdf2239a13583d91c800187afb6c5b9fccc69709c79b0f850aa5c97ad801803d3bc22db584b96423eae1f651acacda1222731969be6d
data/lib/mmtop/host.rb CHANGED
@@ -53,7 +53,7 @@ module MMTop
53
53
  mark_dead!
54
54
  return []
55
55
  else
56
- puts "Got error number " + e.error_number.to_s
56
+ puts "Got error number " + e.error_number.to_s + " querying #{@name}"
57
57
  raise e
58
58
  end
59
59
  end
@@ -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
- "#{color}#{self}#{OFF}"
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
@@ -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 * (table_header_columns[index].size - str.size)
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(index, str, fill=" ", align=:left)
72
- if str.size < table_header_columns[index].size
73
- column_value_with_fill(index, str, fill, align)
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..table_header_columns[index].size - 1]
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
- display_name = (display_name + "!").red if info.host.dead?
146
- str = pipe + " " + column_value(0, display_name + " ", "-".dark_gray)
147
- str += sep_fill + column_fill(1) + sep_fill + column_fill(2)
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.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-15 00:00:00.000000000 Z
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: yaggy
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: rake
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.1.11
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