yummi 0.9.2 → 0.9.3

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: 4089a0b7687580a80c189b1a1a5bdcffd0839b57
4
- data.tar.gz: 61844b4fa6a5b833419f6b7ef2f114cd38219d3d
3
+ metadata.gz: 84331096ac770ff2a1f04d8a7aee1aa7cdcc0ea3
4
+ data.tar.gz: 86b6f4dfd5643ec830049831d4366ed6d0a9cdd4
5
5
  SHA512:
6
- metadata.gz: c01ce312dd40c5cc027ed3dd6fceb87fb8ca10fce3f347d2052d63be28b727111f7c86d8f1b0fbd67cf7ca04cf56703214f1c01688aacdad4c16df57e81a7dad
7
- data.tar.gz: 758f36d1626400b8238810fb189de5bb29c228f08782203af4cc60a025a0981e583b511021826be147e25f3f34b2cf7a52ae5daee2f98f9b13106b1266b49718
6
+ metadata.gz: 2193710539b5a0ecb3fd18f0c7e78cc38a01363e1dfa128cd1d40e15cbcb59a3b83eb16af6e7307690f41e2361d332f89771c4adf92a20d035a43762fa3f9050
7
+ data.tar.gz: 82ca682f1c4df69360acf2abb1ebd6be342c66ac51adf122dd7cc2bb9fac917a2e3fb4518a2849badb73257c3cecf6f7e5ac22a5b9518b2cb716ffa404e65bd0
data/README.md CHANGED
@@ -32,7 +32,7 @@ Examples:
32
32
 
33
33
  yummi -c intense_red -m "some text"
34
34
  echo "some text" | yummi -c intense_red
35
- tail -f $JBOSS_HOME/standalone/log/server.log | yummi -p path-to-your-jboss7-mapping.yaml
35
+ tail -f $JBOSS_HOME/standalone/log/server.log | yummi -p defined-pattern
36
36
 
37
37
  Line patterns are configured with an yaml file containing:
38
38
 
@@ -56,8 +56,7 @@ Yummi provides a set of patterns, check yummi/patterns dir.
56
56
 
57
57
  tail -f $JBOSS_HOME/standalone/log/server.log | yummi -p jboss
58
58
 
59
- Patterns in ~/.yummi/patterns and provided by yummi may also be used by passing
60
- only the file name without extension
59
+ User patterns must be in `~/.yummi/patterns` directory with the name `$PATTERN_NAME.yaml`. User patterns can override builtin patterns.
61
60
 
62
61
  ## Contributing
63
62
 
data/bin/yummi CHANGED
@@ -28,34 +28,38 @@ require 'optparse'
28
28
  @params = []
29
29
 
30
30
  opt = OptionParser::new
31
- opt.on '-c COLOR', '--color=COLOR', 'Colorize using the given color' do |color|
31
+ opt.on '-c COLOR', '--color=COLOR',
32
+ 'Colorize using the given color' do |color|
32
33
  @color = color
33
34
  end
34
- opt.on '-f FORMAT', '--format=FORMAT', 'Sets the format to use (a "%s" means the colorized message)' do |format|
35
+ opt.on '-f FORMAT', '--format=FORMAT',
36
+ 'Sets the format to use (a "%s" means the colorized message)' do |format|
35
37
  @format = format
36
38
  end
37
- opt.on '-n LEVEL', '--level=LEVEL', Integer, 'Sets the level to filter the patterns' do |n|
38
- @level = n
39
- end
40
- opt.on '-p PATTERNS', '--pattern=PATTERNS', Array, 'Sets a pattern to colorize each line' do |patterns|
39
+ opt.on '-p PATTERNS', '--pattern=PATTERNS', Array,
40
+ 'Sets a pattern to colorize each line' do |patterns|
41
41
  @colorizer = Yummi::Colorizers.pattern(patterns)
42
42
  end
43
43
  opt.on '--log', 'Uses the default log pattern to colorize each line' do
44
44
  @colorizer = Yummi::Colorizers.pattern(:log)
45
45
  end
46
- opt.on '-m message', '--message=MESSAGE', 'Colorize the given message' do |message|
46
+ opt.on '-m message', '--message=MESSAGE',
47
+ 'Colorize the given message' do |message|
47
48
  @message = message
48
49
  end
49
- opt.on '-t file', '--table=FILE', 'Defines the file mapping the table to print' do |file|
50
+ opt.on '-t file', '--table=FILE',
51
+ 'Defines the file mapping the table to print' do |file|
50
52
  @table_builder = Yummi::TableBuilder::new(file).defaults
51
53
  end
52
- opt.on '-d data', '--data=FILE', 'Defines the file containing the data to print' do |data|
54
+ opt.on '-d data', '--data=FILE',
55
+ 'Defines the file containing the data to print' do |data|
53
56
  @data = File.expand_path(data)
54
57
  end
55
58
  opt.on '--data-type', 'Defines the data type to parse the values' do |data_type|
56
59
  @data_type = data_type
57
60
  end
58
- opt.on '-l FILES', '--load=FILES', Array, 'Include the files for extending components' do |files|
61
+ opt.on '-l FILES', '--load=FILES', Array,
62
+ 'Include the files for extending components' do |files|
59
63
  files.each do |file|
60
64
  load File.expand_path(file)
61
65
  end
@@ -79,9 +83,7 @@ end
79
83
 
80
84
  opt.parse! ARGV
81
85
 
82
- @colorizer.level = @level if @level
83
-
84
- def print_out message
86
+ def print_out(message)
85
87
  output_text = if @color
86
88
  Yummi::colorize message, @color
87
89
  elsif @colorizer
@@ -99,7 +101,7 @@ end
99
101
  if @message
100
102
  print_out @message
101
103
  elsif @table_builder
102
- abort "Please give the data to print".red unless @data
104
+ abort 'Please give the data to print'.red unless @data
103
105
  table = @table_builder.build_table
104
106
  extension = File::extname(@data)[1..-1]
105
107
  type = (@data_type or extension).to_sym
@@ -116,6 +118,6 @@ else
116
118
  print_out line.chomp
117
119
  end
118
120
  rescue Interrupt
119
- puts "Aborted!".red
121
+ puts 'Aborted!'.red
120
122
  end
121
123
  end
@@ -31,9 +31,9 @@ tablebuilder = Yummi::TableBuilder::new('cash_flow_table.yaml')
31
31
  @table = tablebuilder.defaults.build_table
32
32
 
33
33
  @table.data = [['Initial', nil, 0, nil, nil],
34
- ['Deposit', 100.58, 100.58, true, "QAWSEDRFTGH535"],
35
- ['Withdraw', -50.23, 50.35, true, "34ERDTF6GYU"],
36
- ['Withdraw', -100, -49.65, true, "2344EDRFT5"],
34
+ ['Deposit', 100.58, 100.58, true, 'QAWSEDRFTGH535'],
35
+ ['Withdraw', -50.23, 50.35, true, '34ERDTF6GYU'],
36
+ ['Withdraw', -100, -49.65, true, '2344EDRFT5'],
37
37
  ['Deposit', 50, 0.35, false, nil],
38
38
  ['Deposit', 600, 600.35, false, nil],
39
39
  ['Total', nil, 600.35, nil, nil]]
@@ -75,7 +75,7 @@ end
75
75
 
76
76
  opt.parse! ARGV
77
77
 
78
- @box.add 'The MIT License', :color => :intense_yellow, :align => :center
78
+ @box.add 'The MIT License', :color => 'bold.yellow', :align => :center
79
79
  @box.line_break
80
80
  @box.add 'Copyright (c) 2013 Marcelo Guimaraes <ataxexe@gmail.com>', :color => :green, :align => :center
81
81
  @box.separator
@@ -39,17 +39,17 @@ opt = OptionParser::new
39
39
  opt.on '--color TYPE', 'Specify the color type (zebra,file,none)' do |type|
40
40
  case type
41
41
  when 'zebra'
42
- @table.colorize_row :using => Yummi::Colorizers.stripe(:intense_black, :intense_white)
42
+ @table.colorize_row :using => Yummi::Colorizers.stripe('yellow.bold', 'white.bold')
43
43
  @table.bottom do
44
- @table.colorize_row :with => :intense_blue
44
+ @table.colorize_row :with => 'blue.bold'
45
45
  @table.format :size, :using => Yummi::Formatters.byte
46
46
  end
47
47
  when 'file'
48
48
  @table.colorize_row do |data| # or |data, index| if you need the index
49
- data[:directory] ? :intense_black : :intense_white
49
+ data[:directory] ? :intense_black : 'white.bold'
50
50
  end
51
51
  @table.bottom do
52
- @table.colorize_row :with => :intense_blue
52
+ @table.colorize_row :with => 'blue.bold'
53
53
  @table.format :size, :using => Yummi::Formatters.byte
54
54
  end
55
55
  when 'none'
@@ -72,6 +72,6 @@ files.each do |f|
72
72
  data << [f, File.size(f), File.directory?(f)] # the last value will not be printed
73
73
  end
74
74
  @table.data = data
75
- @table << ["Total", @table.column(:size).inject(:+)]
75
+ @table << ['Total', @table.column(:size).inject(:+)]
76
76
 
77
77
  @table.print
@@ -40,7 +40,7 @@ colorizer = Yummi::Colorizers.pattern :prefix => /\[/,
40
40
  :suffix => /\]/,
41
41
  :patterns => {
42
42
  'ERROR' => :red,
43
- 'FATAL' => :intense_red,
43
+ 'FATAL' => :'red.bold',
44
44
  'WARN' => :yellow,
45
45
  'INFO' => :green,
46
46
  'DEBUG' => :black
@@ -30,8 +30,8 @@ logger.formatter = Yummi::Formatter::LogFormatter.new do |severity, message|
30
30
  end
31
31
 
32
32
  logger.debug __FILE__
33
- logger.info "Example started"
34
- logger.warn "Warning message"
35
- logger.error "An error has occurred"
36
- logger.fatal "A fatal exception has occurred"
37
- logger.unknown "Unknown severity message"
33
+ logger.info 'Example started'
34
+ logger.warn 'Warning message'
35
+ logger.error 'An error has occurred'
36
+ logger.fatal 'A fatal exception has occurred'
37
+ logger.unknown 'Unknown severity message'
@@ -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 Threads", "In Use Threads"]
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
@@ -35,7 +35,7 @@ opt = OptionParser::new
35
35
 
36
36
  @table.bottom do
37
37
  @table.format [:max_memory, :free_memory], :using => Yummi::Formatters.byte
38
- @table.colorize_row :with => :intense_white
38
+ @table.colorize_row :with => 'bold.white'
39
39
  end
40
40
 
41
41
  # colorizer for memory
@@ -45,7 +45,7 @@ end
45
45
  @thread_colorizer = Yummi::Colorizers.percentage :max => :max_threads,
46
46
  :using => :in_use_threads,
47
47
  :colors => {
48
- :omg => :intense_red
48
+ :omg => 'bold.red'
49
49
  },
50
50
  :threshold => {
51
51
  :warn => 0.9,
@@ -61,7 +61,7 @@ def full_colors
61
61
  @table.colorize :server_name, :with => :magenta
62
62
  @table.colorize :free_memory, :using => @memory_colorizer
63
63
  @table.colorize :in_use_threads, :using => @thread_colorizer
64
- @table.colorize [:max_memory, :max_threads], :with => :black
64
+ @table.colorize [:max_memory, :max_threads], :with => :white
65
65
  end
66
66
 
67
67
  full_colors
@@ -115,7 +115,7 @@ opt.parse ARGV
115
115
  class ServerStatus
116
116
  attr_reader :server_name, :max_memory, :free_memory, :max_threads, :in_use_threads
117
117
 
118
- def initialize server_name, max_memory, free_memory, max_threads, in_use_threads
118
+ def initialize(server_name, max_memory, free_memory, max_threads, in_use_threads)
119
119
  @server_name = server_name
120
120
  @max_memory = max_memory
121
121
  @free_memory = free_memory
@@ -21,7 +21,7 @@
21
21
  # THE SOFTWARE.
22
22
 
23
23
  require 'term/ansicolor'
24
- require_relative "yummi/version"
24
+ require_relative 'yummi/version'
25
25
 
26
26
  module Yummi
27
27
 
@@ -274,8 +274,8 @@ Yummi.no_colors unless Yummi::coloring_supported?
274
274
 
275
275
  require_relative 'yummi/extensions'
276
276
  require_relative 'yummi/data_parser'
277
- require_relative "yummi/colorizers"
278
- require_relative "yummi/formatters"
277
+ require_relative 'yummi/colorizers'
278
+ require_relative 'yummi/formatters'
279
279
  require_relative 'yummi/table'
280
280
  require_relative 'yummi/table_builder'
281
281
  require_relative 'yummi/text_box'
@@ -85,10 +85,8 @@ module Yummi
85
85
  end
86
86
 
87
87
  # Returns a new instance of #PatternColorizer
88
- def self.pattern mappings, level = nil
89
- colorizer = PatternColorizer::new(mappings)
90
- colorizer.level = level if level
91
- colorizer
88
+ def self.pattern mappings
89
+ PatternColorizer::new(mappings)
92
90
  end
93
91
 
94
92
  #
@@ -127,7 +125,7 @@ module Yummi
127
125
  def self.boolean params = {}
128
126
  Yummi::to_colorize do |ctx|
129
127
  value = ctx.value
130
- if value.to_s.downcase == "true"
128
+ if value.to_s.downcase == 'true'
131
129
  (params[:if_true] or :green)
132
130
  else
133
131
  (params[:if_false] or :yellow)
@@ -136,10 +134,10 @@ module Yummi
136
134
  end
137
135
 
138
136
  #
139
- # A colorizer that uses a set of minimun values to use a color.
137
+ # A colorizer that uses a set of minimum values to use a color.
140
138
  #
141
139
  # Parameters:
142
- # - MINIMUN_VALUE: COLOR_TO_USE
140
+ # - MINIMUM_VALUE: COLOR_TO_USE
143
141
  #
144
142
  def self.threshold params
145
143
  params = params.dup
@@ -173,7 +171,7 @@ module Yummi
173
171
  # :negative => color to use when value is negative
174
172
  # :zero => color to use when value is zero
175
173
  # :positive => color to use when value is positive
176
- # :any => color to use for any value (overridable by the options above)
174
+ # :any => color to use for any value without specified color
177
175
  #
178
176
  def self.numeric params
179
177
  Yummi::to_format do |ctx|
@@ -228,7 +226,7 @@ module Yummi
228
226
  end
229
227
 
230
228
  #
231
- # A colorizer for strings that follows a pattern. This colorizer is usefull
229
+ # A colorizer for strings that follows a pattern. This colorizer is useful
232
230
  # for log files.
233
231
  #
234
232
  class PatternColorizer
@@ -236,7 +234,7 @@ module Yummi
236
234
 
237
235
  attr_writer :level
238
236
 
239
- def initialize mappings = nil
237
+ def initialize(mappings = nil)
240
238
  @patterns = []
241
239
  map mappings if mappings
242
240
  end
@@ -263,7 +261,7 @@ module Yummi
263
261
  # * $HOME/.yummi/patterns/PATTERN.yaml
264
262
  # * $YUMMI_GEM/yummy/patterns/PATTERN.yaml
265
263
  #
266
- def map params
264
+ def map(params)
267
265
  if params.is_a? Array
268
266
  params.each { |p| map p }
269
267
  elsif params.is_a? String or params.is_a? Symbol
@@ -273,14 +271,11 @@ module Yummi
273
271
  end
274
272
  end
275
273
 
276
- def call ctx
274
+ def call(ctx)
277
275
  ctx = Yummi::Context::new(ctx) unless ctx.is_a? Context
278
276
  text = ctx.value.to_s
279
277
  @patterns.each do |config|
280
- level = -1
281
- config[:patterns].each do |regex, color|
282
- level += 1
283
- return if @level and level > @level and not @last_color
278
+ config[:patterns].each_key do |regex|
284
279
  if regex.match(text)
285
280
  return match(text, config)
286
281
  end
@@ -294,16 +289,16 @@ module Yummi
294
289
 
295
290
  private
296
291
 
297
- def config params
292
+ def config(params)
298
293
  Yummi::Helpers.symbolize_keys(params)
299
- prefix = params[:prefix]
300
- suffix = params[:suffix]
294
+ prefix = params[:prefix]
295
+ suffix = params[:suffix]
301
296
  options = params[:options]
302
- mode = (params[:mode] or :all)
297
+ mode = (params[:mode] or :all)
303
298
 
304
299
  patterns = Hash[*(params[:patterns].collect do |pattern, color|
305
300
  [
306
- Regexp::new("#{prefix}#{pattern.to_s}#{suffix}",options),
301
+ Regexp::new("#{prefix}#{pattern.to_s}#{suffix}", options),
307
302
  color
308
303
  ]
309
304
  end).flatten]
@@ -350,7 +345,7 @@ module Yummi
350
345
  @count = -1
351
346
  end
352
347
 
353
- def call *args
348
+ def call(*args)
354
349
  @count += 1
355
350
  @colors[@count % @colors.size]
356
351
  end
@@ -27,7 +27,7 @@ module Yummi
27
27
  # Returns the string wrapped in a #Yummi#TextBox. The given parameters will be used
28
28
  # to instantiate the TextBox.
29
29
  #
30
- def on_box params = {}
30
+ def on_box(params = {})
31
31
  box = Yummi::TextBox::new params
32
32
  box.add self
33
33
  return box
@@ -47,9 +47,9 @@ class String
47
47
  # If params is a hash, the keys will be used as a regexp and the
48
48
  # result of #gsub will be colorized using the value color.
49
49
  #
50
- # Otherwise, the params will be sended to Yummi#colorize
50
+ # Otherwise, the params will be sent to Yummi#colorize
51
51
  #
52
- def colorize params
52
+ def colorize(params)
53
53
  if params.is_a? Hash
54
54
  text = self
55
55
  params.each do |regexp, color|
@@ -67,8 +67,8 @@ class Array
67
67
  #
68
68
  # Colorizes each array item in a new String array
69
69
  #
70
- def colorize params
71
- map {|n| n.to_s.colorize params}
70
+ def colorize(params)
71
+ map { |n| n.to_s.colorize params }
72
72
  end
73
73
 
74
74
  #
@@ -83,7 +83,7 @@ class Array
83
83
  #
84
84
  # The parameters will be used to instantiate the table.
85
85
  #
86
- def on_table params = {}
86
+ def on_table(params = {})
87
87
  table = Yummi::Table::new params
88
88
  table.data = self
89
89
  return table
@@ -52,10 +52,10 @@ module Yummi
52
52
  def self.boolean params = {}
53
53
  Yummi::to_format do |ctx|
54
54
  value = ctx.value
55
- if value.to_s.downcase == "true"
56
- (params[:if_true] or "Yes")
55
+ if value.to_s.downcase == 'true'
56
+ (params[:if_true] or 'Yes')
57
57
  else
58
- (params[:if_false] or "No")
58
+ (params[:if_false] or 'No')
59
59
  end
60
60
  end
61
61
  end
@@ -84,7 +84,7 @@ module Yummi
84
84
  # :negative => format to use when value is negative
85
85
  # :zero => format to use when value is zero
86
86
  # :positive => format to use when value is positive
87
- # :any => format to use for any value (overridable by the options above)
87
+ # :any => format to use for any value without a specific format
88
88
  #
89
89
  def self.numeric params
90
90
  Yummi::to_format do |ctx|
@@ -56,14 +56,14 @@ module Yummi
56
56
  # If a block is passed, it will be used to format the message. The block can use
57
57
  # the following variables: severity, time, program_name and message.
58
58
  #
59
- def initialize colors = {}, &block
59
+ def initialize(colors = {}, &block)
60
60
  @colors = {
61
- :debug => :blue,
62
- :info => :white,
63
- :warn => :yellow,
64
- :error => :red,
65
- :fatal => :intense_red,
66
- :any => :intense_black
61
+ :debug => :blue,
62
+ :info => :white,
63
+ :warn => :yellow,
64
+ :error => :red,
65
+ :fatal => 'bold.red',
66
+ :any => 'bold.black'
67
67
  }.merge! colors
68
68
  @format_block = block
69
69
  end
@@ -76,13 +76,13 @@ module Yummi
76
76
  end
77
77
 
78
78
  # Formats the message, override this method instead of #call
79
- def output severity, time, program_name, message
79
+ def output(severity, time, program_name, message)
80
80
  if @format_block
81
81
  context = {
82
- :severity => severity,
83
- :time => time,
84
- :program_name => program_name,
85
- :message => message
82
+ :severity => severity,
83
+ :time => time,
84
+ :program_name => program_name,
85
+ :message => message
86
86
  }
87
87
  block_call(context, &@format_block) << $/
88
88
  else
@@ -1,3 +1,4 @@
1
+ # A pattern for JBoss AS logs, works for versions 5 and above
1
2
  prefix: '(\d{4}-\d{2}-\d{2}\s)?\d{2}:\d{2}:\d{2},\d{3}\s'
2
3
  patterns:
3
4
  TRACE : cyan
@@ -1,3 +1,4 @@
1
+ # A common log pattern
1
2
  prefix: '.*'
2
3
  options: i
3
4
  patterns:
@@ -1,3 +1,4 @@
1
+ # A pattern for weblogic server log (but not for the diagnostic logs)
1
2
  prefix: '####<[^>]+>\s<'
2
3
  suffix: '>'
3
4
  patterns:
@@ -0,0 +1,15 @@
1
+ # Based on NCSA Common log format and applies colors using http status codes
2
+ # The suffix approach is more easy to understand than using a prefix, the two
3
+ # last numbers are http status and the total bytes, so, we only parse the status
4
+ suffix: \d{2}\s\d+$
5
+ patterns:
6
+ # info
7
+ 1 : white
8
+ # success
9
+ 2 : green
10
+ # redirect
11
+ 3 : yellow
12
+ # client error
13
+ 4 : red
14
+ # server error
15
+ 5 : bold.red
@@ -50,7 +50,7 @@ module Yummi
50
50
  attr_reader :layout
51
51
  # The table header
52
52
  attr_reader :header
53
-
53
+
54
54
  #
55
55
  # Creates a new table. A hash containing the style properties may be given to override
56
56
  # the defaults.
@@ -75,10 +75,10 @@ module Yummi
75
75
  @title = (params.title or nil)
76
76
  @description = (params.description or nil)
77
77
  @style = {
78
- :title => (params.style[:title] or "bold.yellow"),
79
- :description => (params.style[:description] or "bold.black"),
80
- :header => (params.style[:header] or "bold.blue"),
81
- :value => (params.style[:color] or nil)
78
+ :title => (params.style[:title] or 'bold.yellow'),
79
+ :description => (params.style[:description] or 'bold.black'),
80
+ :header => (params.style[:header] or 'bold.blue'),
81
+ :value => (params.style[:color] or nil)
82
82
  }
83
83
 
84
84
  @colspan = (params.colspan or 2)
@@ -98,9 +98,9 @@ module Yummi
98
98
  # Indicates that the table should not use colors.
99
99
  def no_colors
100
100
  @style = {
101
- :title => nil,
102
- :header => nil,
103
- :value => nil
101
+ :title => nil,
102
+ :header => nil,
103
+ :value => nil
104
104
  }
105
105
  @no_colors = true
106
106
  end
@@ -123,7 +123,7 @@ module Yummi
123
123
  # end
124
124
  # table.bottom { table.colorize :total, :with => :white }
125
125
  #
126
- def bottom params = {}, &block
126
+ def bottom(params = {}, &block)
127
127
  index = @contexts.size
128
128
  _context_ index, params, &block
129
129
  end
@@ -146,7 +146,7 @@ module Yummi
146
146
  # end
147
147
  # table.top { table.colorize :total, :with => :white }
148
148
  #
149
- def top params = {}, &block
149
+ def top(params = {}, &block)
150
150
  _context_ 0, params, &block
151
151
  end
152
152
 
@@ -196,7 +196,7 @@ module Yummi
196
196
  #
197
197
  # This will create the following aliases: :name, :email, :work_phone and :home_phone
198
198
  #
199
- def header= (header)
199
+ def header=(header)
200
200
  header = [header] unless header.respond_to? :each
201
201
  @header = normalize(header)
202
202
  @aliases = header.map do |n|
@@ -219,7 +219,7 @@ module Yummi
219
219
  # table.align :description, :left
220
220
  # table.align [:value, :total], :right
221
221
  #
222
- def align (indexes, type)
222
+ def align(indexes, type)
223
223
  [*indexes].each do |index|
224
224
  index = parse_index(index)
225
225
  raise Exception::new "Undefined column #{index}" unless index
@@ -236,13 +236,13 @@ module Yummi
236
236
  #
237
237
  # table.colorize_row { |i, row| :red if row[:value] < 0 }
238
238
  #
239
- def colorize_row (params = nil, &block)
239
+ def colorize_row(params = nil, &block)
240
240
  obj = extract_component(params, &block)
241
241
  component[:row_colorizer] = obj
242
242
  end
243
243
 
244
244
  # Sets the table data
245
- def data= (data)
245
+ def data=(data)
246
246
  @data = data
247
247
  end
248
248
 
@@ -250,7 +250,7 @@ module Yummi
250
250
  # Adds the given data as a row. If the argument is a hash, its keys will be used
251
251
  # to match header alias for building the row data.
252
252
  #
253
- def add (row)
253
+ def add(row)
254
254
  @data << row
255
255
  end
256
256
 
@@ -278,7 +278,7 @@ module Yummi
278
278
  # table.colorize :description, :with => :magenta
279
279
  # table.colorize([:value, :total]) { |value| :red if value < 0 }
280
280
  #
281
- def colorize (indexes, params = {}, &block)
281
+ def colorize(indexes, params = {}, &block)
282
282
  [*indexes].each do |index|
283
283
  index = parse_index(index)
284
284
  if index
@@ -300,7 +300,7 @@ module Yummi
300
300
  # - :using defines the component to use
301
301
  # - :with defines the format to use
302
302
  #
303
- def colorize_null (params = {}, &block)
303
+ def colorize_null(params = {}, &block)
304
304
  component[:null_colorizer] = (params[:using] or block)
305
305
  component[:null_colorizer] ||= proc do |value|
306
306
  params[:with]
@@ -328,7 +328,7 @@ module Yummi
328
328
  # table.format :value, :with => '%.2f'
329
329
  # table.format [:value, :total], :with => '%.2f'
330
330
  #
331
- def format (indexes, params = {}, &block)
331
+ def format(indexes, params = {}, &block)
332
332
  [*indexes].each do |index|
333
333
  index = parse_index(index)
334
334
  if index
@@ -352,7 +352,7 @@ module Yummi
352
352
  # - :using defines the component to use
353
353
  # - :with defines the format to use
354
354
  #
355
- def format_null (params = {}, &block)
355
+ def format_null(params = {}, &block)
356
356
  component[:null_formatter] = (params[:using] or block)
357
357
  component[:null_formatter] ||= proc do |value|
358
358
  params[:with] % value
@@ -362,7 +362,7 @@ module Yummi
362
362
  #
363
363
  # Prints the #to_s into the given object.
364
364
  #
365
- def print (to = $stdout)
365
+ def print(to = $stdout)
366
366
  to.print to_s
367
367
  end
368
368
 
@@ -373,7 +373,7 @@ module Yummi
373
373
  header_output = build_header_output
374
374
  data_output = build_data_output
375
375
 
376
- string = ""
376
+ string = ''
377
377
  string << Yummi.colorize(@title, @style[:title]) << $/ if @title
378
378
  string << Yummi.colorize(@description, @style[:description]) << $/ if @description
379
379
  table_data = header_output + data_output
@@ -398,7 +398,7 @@ module Yummi
398
398
 
399
399
  private
400
400
 
401
- def extract_component params, &block
401
+ def extract_component(params, &block)
402
402
  if params and params[:using]
403
403
  params[:using]
404
404
  elsif params and params[:with]
@@ -408,15 +408,15 @@ module Yummi
408
408
  end
409
409
  end
410
410
 
411
- def _define_ context
411
+ def _define_(context)
412
412
  @components[context] = {
413
- :formatters => [],
414
- :colorizers => [],
415
- :row_colorizer => nil,
413
+ :formatters => [],
414
+ :colorizers => [],
415
+ :row_colorizer => nil,
416
416
  }
417
417
  end
418
418
 
419
- def _context_ index, params, &block
419
+ def _context_(index, params, &block)
420
420
  params ||= {}
421
421
  rows = (params[:rows] or 1)
422
422
  ctx = @contexts.size
@@ -432,7 +432,7 @@ module Yummi
432
432
  # Gets the content string for the given color map and content
433
433
  #
434
434
  def content (data)
435
- string = ""
435
+ string = ''
436
436
  data.each_index do |i|
437
437
  row = data[i]
438
438
  row.each_index do |j|
@@ -531,13 +531,13 @@ module Yummi
531
531
  end
532
532
 
533
533
  _row_data = normalize(
534
- _row_data,
535
- :extract => proc do |data|
536
- data[:value].to_s
537
- end,
538
- :new => proc do |value, data|
539
- {:value => value, :color => data[:color]}
540
- end
534
+ _row_data,
535
+ :extract => proc do |data|
536
+ data[:value].to_s
537
+ end,
538
+ :new => proc do |value, data|
539
+ {:value => value, :color => data[:color]}
540
+ end
541
541
  )
542
542
  _row_data.each do |_row|
543
543
  output << _row
@@ -552,34 +552,36 @@ module Yummi
552
552
  if row.is_a? Hash
553
553
  @aliases.each_index do |column_index|
554
554
  obj = TableContext::new(
555
- :obj => row,
556
- :row_index => row_index,
557
- :column_index => column_index,
558
- :value => row[@aliases[column_index]]
555
+ :obj => row,
556
+ :row_index => row_index,
557
+ :column_index => column_index,
558
+ :value => row[@aliases[column_index]]
559
559
  )
560
560
  array << obj
561
561
  end
562
562
  elsif row.is_a? Array
563
563
  row.each_index do |column_index|
564
564
  obj = TableContext::new(
565
- :obj => IndexedData::new(@aliases, row),
566
- :row_index => row_index,
567
- :column_index => column_index,
568
- :value => row[column_index]
565
+ :obj => IndexedData::new(@aliases, row),
566
+ :row_index => row_index,
567
+ :column_index => column_index,
568
+ :value => row[column_index]
569
569
  )
570
570
  array << obj
571
571
  end
572
572
  else
573
573
  @aliases.each_index do |column_index|
574
574
  obj = TableContext::new(
575
- :obj => row,
576
- :row_index => row_index,
577
- :column_index => column_index,
578
- :value => row.send(@aliases[column_index])
575
+ :obj => row,
576
+ :row_index => row_index,
577
+ :column_index => column_index,
578
+ :value => row.send(@aliases[column_index])
579
579
  )
580
+
580
581
  def obj.[] (index)
581
582
  obj.send(index)
582
583
  end
584
+
583
585
  array << obj
584
586
  end
585
587
  end
@@ -644,7 +646,7 @@ module Yummi
644
646
 
645
647
  attr_reader :row_index, :column_index
646
648
 
647
- def initialize params
649
+ def initialize(params)
648
650
  @row_index = params[:row_index]
649
651
  @column_index = params[:column_index]
650
652
  @value = params[:value]
@@ -25,16 +25,16 @@ module Yummi
25
25
 
26
26
  attr_accessor :config, :repositories
27
27
 
28
- def initialize config = {}
28
+ def initialize(config = {})
29
29
  if config.is_a? String
30
30
  config = Yummi::Helpers::symbolize_keys(YAML::load_file(config))
31
31
  end
32
32
  @config = config
33
33
  @repositories = {}
34
-
35
- @repositories[:formatters] = [Yummi::Formatters]
36
- @repositories[:colorizers] = [Yummi::Colorizers]
37
- @repositories[:row_colorizers] = [Yummi::Colorizers]
34
+
35
+ @repositories[:formatters] = [Yummi::Formatters]
36
+ @repositories[:colorizers] = [Yummi::Colorizers]
37
+ @repositories[:row_colorizers] = [Yummi::Colorizers]
38
38
  end
39
39
 
40
40
  def defaults
@@ -56,7 +56,7 @@ module Yummi
56
56
  @components
57
57
  end
58
58
 
59
- def component keys, params
59
+ def component(keys, params)
60
60
  [*keys].each do |key|
61
61
  components[key] = params
62
62
  end
@@ -47,7 +47,7 @@ module Yummi
47
47
  #
48
48
  # TextBox::new :align => :center, :border => {:color => :red}, :separator => {:color => :green}
49
49
  #
50
- def initialize params = {}
50
+ def initialize(params = {})
51
51
  params = OpenStruct::new params
52
52
  params.separator ||= {}
53
53
  params.border ||= {}
@@ -60,11 +60,11 @@ module Yummi
60
60
  @style.separator = {}
61
61
  @style.separator[:pattern] = (params.separator[:pattern] or '-')
62
62
  @style.separator[:width] = (params.separator[:width] or nil)
63
- @style.separator[:color] = (params.separator[:color] or "bold.black")
63
+ @style.separator[:color] = (params.separator[:color] or 'bold.black')
64
64
  @style.separator[:align] = (params.separator[:align] or :left)
65
65
 
66
66
  @style.border = {}
67
- @style.border[:color] = (params.border[:color] or "bold.black")
67
+ @style.border[:color] = (params.border[:color] or 'bold.black')
68
68
  @style.border[:top] = (params.border[:top] or '-')
69
69
  @style.border[:bottom] = (params.border[:bottom] or '-')
70
70
  @style.border[:left] = (params.border[:left] or '|')
@@ -147,7 +147,7 @@ module Yummi
147
147
  def separator (params = {})
148
148
  params = style.separator.merge params
149
149
  params[:width] ||= style.width
150
- raise Exception::new("Define a width for using separators") unless params[:width]
150
+ raise Exception::new('Define a width for using separators') unless params[:width]
151
151
  line = fill(params[:pattern], params[:width])
152
152
  #replace the width with the box width to align the separator
153
153
  params[:width] = style.width
@@ -21,5 +21,5 @@
21
21
  # THE SOFTWARE.
22
22
 
23
23
  module Yummi
24
- VERSION = "0.9.2"
24
+ VERSION = '0.9.3'
25
25
  end
data/yummi.iml CHANGED
@@ -7,10 +7,11 @@
7
7
  <sourceFolder url="file://$MODULE_DIR$/examples" isTestSource="false" />
8
8
  <excludeFolder url="file://$MODULE_DIR$/pkg" />
9
9
  </content>
10
- <orderEntry type="inheritedJdk" />
10
+ <orderEntry type="jdk" jdkName="RVM: ruby-2.0.0-p247" jdkType="RUBY_SDK" />
11
11
  <orderEntry type="sourceFolder" forTests="false" />
12
- <orderEntry type="library" scope="PROVIDED" name="bundler (v1.2.3, RVM: ruby-1.9.3-p374) [gem]" level="application" />
13
- <orderEntry type="library" scope="PROVIDED" name="term-ansicolor (v1.1.5, RVM: ruby-1.9.3-p374) [gem]" level="application" />
12
+ <orderEntry type="library" scope="PROVIDED" name="bundler (v1.5.3, RVM: ruby-2.0.0-p247) [gem]" level="application" />
13
+ <orderEntry type="library" scope="PROVIDED" name="term-ansicolor (v1.3.0, RVM: ruby-2.0.0-p247) [gem]" level="application" />
14
+ <orderEntry type="library" scope="PROVIDED" name="tins (v0.12.0, RVM: ruby-2.0.0-p247) [gem]" level="application" />
14
15
  </component>
15
16
  <component name="org.twodividedbyzero.idea.findbugs">
16
17
  <option name="_basePreferences">
data/yummi.ipr CHANGED
@@ -4,9 +4,6 @@
4
4
  <asm skipDebug="false" skipFrames="false" skipCode="false" expandFrames="false" />
5
5
  <groovy codeStyle="LEGACY" />
6
6
  </component>
7
- <component name="AntConfiguration">
8
- <defaultAnt bundledAnt="true" />
9
- </component>
10
7
  <component name="CompilerConfiguration">
11
8
  <option name="DEFAULT_COMPILER" value="Javac" />
12
9
  <resourceExtensions />
@@ -52,6 +49,7 @@
52
49
  <component name="GradleUISettings2">
53
50
  <setting name="root" />
54
51
  </component>
52
+ <component name="IdProvider" IDEtalkID="18FE041D1C5C0BC3581F29459CFA0C24" />
55
53
  <component name="InspectionProjectProfileManager">
56
54
  <profiles>
57
55
  <profile version="1.0" is_locked="false">
metadata CHANGED
@@ -1,27 +1,27 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: yummi
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.2
4
+ version: 0.9.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ataxexe
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-03-11 00:00:00.000000000 Z
11
+ date: 2014-03-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: term-ansicolor
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - '>='
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: '1.1'
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: '1.1'
27
27
  description: A tool to colorize your console application.
@@ -32,8 +32,8 @@ executables:
32
32
  extensions: []
33
33
  extra_rdoc_files: []
34
34
  files:
35
- - .gitignore
36
- - .rakeTasks
35
+ - ".gitignore"
36
+ - ".rakeTasks"
37
37
  - Gemfile
38
38
  - LICENSE
39
39
  - README.md
@@ -58,6 +58,7 @@ files:
58
58
  - lib/yummi/patterns/jboss.yaml
59
59
  - lib/yummi/patterns/log.yaml
60
60
  - lib/yummi/patterns/weblogic.yaml
61
+ - lib/yummi/patterns/webserver.yaml
61
62
  - lib/yummi/table.rb
62
63
  - lib/yummi/table_builder.rb
63
64
  - lib/yummi/text_box.rb
@@ -74,12 +75,12 @@ require_paths:
74
75
  - lib
75
76
  required_ruby_version: !ruby/object:Gem::Requirement
76
77
  requirements:
77
- - - '>='
78
+ - - ">="
78
79
  - !ruby/object:Gem::Version
79
80
  version: '0'
80
81
  required_rubygems_version: !ruby/object:Gem::Requirement
81
82
  requirements:
82
- - - '>='
83
+ - - ">="
83
84
  - !ruby/object:Gem::Version
84
85
  version: '0'
85
86
  requirements: []