yummi 0.0.3 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/.rakeTasks CHANGED
@@ -1,7 +1,13 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
2
  <Settings><!--This file was automatically generated by Ruby plugin.
3
3
  You are allowed to:
4
4
  1. Remove rake task
5
5
  2. Add existing rake tasks
6
6
  To add existing rake tasks automatically delete this file and reload the project.
7
- --><RakeGroup description="" fullCmd="" taksId="rake"><RakeTask description="Build yummi-0.0.1.gem into the pkg directory" fullCmd="build" taksId="build" /><RakeTask description="Build and install yummi-0.0.1.gem into system gems" fullCmd="install" taksId="install" /><RakeTask description="Create tag v0.0.1 and build and push yummi-0.0.1.gem to Rubygems" fullCmd="release" taksId="release" /></RakeGroup></Settings>
7
+ -->
8
+ <RakeGroup description="" fullCmd="" taksId="rake">
9
+ <RakeTask description="Build yummi gem into the pkg directory" fullCmd="build" taksId="build" />
10
+ <RakeTask description="Build and install yummi gem into system gems" fullCmd="install" taksId="install" />
11
+ <RakeTask description="Create tag, build and push yummi gem to Rubygems" fullCmd="release" taksId="release" />
12
+ </RakeGroup>
13
+ </Settings>
@@ -27,7 +27,7 @@ opt = OptionParser::new
27
27
 
28
28
  @table = Yummi::Table::new
29
29
  # setting the header sets the aliases automatically
30
- @table.header = ['Server Name', 'Max Memory', 'Free Memory', "Max\nThreads", "In Use\nThreads"]
30
+ @table.header = ['Server Name', 'Max Memory', 'Free Memory', "Max Threads", "In Use Threads"]
31
31
  # sets the title
32
32
  @table.title = 'Server Runtime Info'
33
33
  # formats memory info for easily reading
@@ -65,6 +65,16 @@ opt.on '--color TYPE', 'Specify the color type (zebra,row,cell,none)' do |type|
65
65
  else
66
66
  end
67
67
  end
68
+ opt.on '--layout LAYOUT', 'Specify the layout (horizontal or vertical)' do |layout|
69
+ case layout
70
+ when 'horizontal'
71
+ @table.layout = :horizontal
72
+ when 'vertical'
73
+ @table.layout = :vertical
74
+ else
75
+ abort "Not recognized layout: #{layout}"
76
+ end
77
+ end
68
78
  opt.on '--help', 'Prints this message' do
69
79
  puts opt
70
80
  exit 0
data/lib/yummi.rb CHANGED
@@ -87,7 +87,7 @@ module Yummi
87
87
  :highlight => 7
88
88
  }
89
89
  # Parses the key
90
- def self.parse(key)
90
+ def self.parse key
91
91
  keys = key.to_s.split '_'
92
92
  type = keys[0].to_sym
93
93
  color = keys[1].to_i
@@ -95,7 +95,7 @@ module Yummi
95
95
  end
96
96
 
97
97
  # Escape the given text with the given color code
98
- def self.escape(key)
98
+ def self.escape key
99
99
  return key unless key
100
100
  color = COLORS[key]
101
101
  color ||= parse(key)
@@ -103,12 +103,17 @@ module Yummi
103
103
  end
104
104
 
105
105
  # Colorize the given text with the given color
106
- def self.colorize(str, color)
106
+ def self.colorize string, color
107
107
  col, nocol = [color, :nothing].map { |key| Color.escape(key) }
108
- col ? "#{col}#{str}#{nocol}" : str
108
+ col ? "#{col}#{string}#{nocol}" : string
109
109
  end
110
110
  end
111
111
 
112
+ # see #Color#colorize
113
+ def self.colorize string, color
114
+ Color.colorize string, color
115
+ end
116
+
112
117
  #
113
118
  # A module to handle blocks by dynamically resolving parameters
114
119
  #
data/lib/yummi/table.rb CHANGED
@@ -42,6 +42,8 @@ module Yummi
42
42
  #
43
43
  # The colors must be supported by #Yummi#Color#parse or defined in #Yummi#Color#COLORS
44
44
  attr_accessor :colors
45
+ # The table layout (horizontal or vertical)
46
+ attr_accessor :layout
45
47
 
46
48
  # Creates a new table with the default attributes:
47
49
  #
@@ -61,7 +63,7 @@ module Yummi
61
63
  }
62
64
 
63
65
  @colspan = 2
64
-
66
+ @layout = :horizontal
65
67
  @aliases = []
66
68
 
67
69
  @align = [:left]
@@ -101,6 +103,7 @@ module Yummi
101
103
  # This will create the following aliases: :name, :email, :work_phone and :home_phone
102
104
  #
103
105
  def header= header
106
+ header = [header] unless header.respond_to? :each
104
107
  max = 0
105
108
  header.each_index do |i|
106
109
  max = [max, header[i].split("\n").size].max
@@ -243,8 +246,14 @@ module Yummi
243
246
 
244
247
  string = ""
245
248
  string << Color.colorize(@title, @colors[:title]) << $/ if @title
246
- string << content(header_color_map + data_color_map,
247
- header_output + data_output)
249
+ color_map = header_color_map + data_color_map
250
+ table_data = header_output + data_output
251
+ if @layout == :vertical
252
+ # don't use array transpose because the data may differ in each line size
253
+ color_map = rotate color_map
254
+ table_data = rotate table_data
255
+ end
256
+ string << content(color_map, table_data)
248
257
  end
249
258
 
250
259
  #
@@ -351,6 +360,17 @@ module Yummi
351
360
  max
352
361
  end
353
362
 
363
+ def rotate data
364
+ new_data = []
365
+ data.each_index do |i|
366
+ data[i].each_index do |j|
367
+ new_data[j] ||= []
368
+ new_data[j][i] = data[i][j]
369
+ end
370
+ end
371
+ new_data
372
+ end
373
+
354
374
  end
355
375
 
356
376
  end
data/lib/yummi/version.rb CHANGED
@@ -21,5 +21,5 @@
21
21
  # THE SOFTWARE.
22
22
 
23
23
  module Yummi
24
- VERSION = "0.0.3"
24
+ VERSION = "0.1.0"
25
25
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: yummi
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.1.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-04-15 00:00:00.000000000Z
12
+ date: 2012-04-30 00:00:00.000000000Z
13
13
  dependencies: []
14
14
  description: A tool to colorize your console application.
15
15
  email: