yummi 0.9.3 → 0.9.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +4 -8
- data/bin/yummi +6 -3
- data/examples/cash_flow_table.rb +1 -1
- data/examples/cash_flow_table.yaml +5 -0
- data/examples/cash_flow_table_data.csv +7 -7
- data/examples/cash_flow_table_data.yaml +34 -35
- data/examples/monitor_table.rb +8 -2
- data/lib/yummi.rb +1 -1
- data/lib/yummi/data_parser.rb +4 -0
- data/lib/yummi/formatters.rb +26 -18
- data/lib/yummi/row_extractor.rb +55 -0
- data/lib/yummi/table.rb +40 -70
- data/lib/yummi/version.rb +1 -1
- data/yummi.iml +4 -1
- data/yummi.ipr +0 -4
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 944e82fa618cf8b6be32353227a58a1779fe68e9
|
4
|
+
data.tar.gz: 93afaa736b4054cb96732f1e3b575cdd95c40583
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c564e72e961de304e516de35736e348be15edfed66b2cf8bc09dc6a9fc8fee2645896260d5a908d391240dfb346d9d208c70b694c53e7964b8c8284c439184e5
|
7
|
+
data.tar.gz: 5e775b3e5207fc98c11b81a87bcc1285badcf1ae3aad998079ceb6dbe9f62e6215c32c1463359e04116687cf9b928c3bcebdaecff30111cb23f53d1670409412
|
data/README.md
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
# Yummi
|
2
2
|
|
3
|
-
This is a tool to make your console app more tasty. Yummi provides a set of console line elements
|
4
|
-
also with a delegator for colorizing Strings using the awesome gem term-ansicolor.
|
3
|
+
This is a tool to make your console app more tasty. Yummi provides a set of console line elements also with a delegator for colorizing Strings using the awesome gem [term-ansicolor](https://rubygems.org/gems/term-ansicolor).
|
5
4
|
|
6
5
|
## Installation
|
7
6
|
|
@@ -19,14 +18,11 @@ Or install it yourself as:
|
|
19
18
|
|
20
19
|
## Ruby Tools
|
21
20
|
|
22
|
-
Yummi module provides a set of tools to colorize inputs. Check docs for more information
|
23
|
-
about how to build tables, text boxes, colored log formatters and more. You can also check
|
24
|
-
the examples dir to see how to use Yummi features.
|
21
|
+
Yummi module provides a set of tools to colorize inputs. Check docs for more information about how to build tables, text boxes, colored log formatters and more. You can also check the examples dir to see how to use Yummi features.
|
25
22
|
|
26
23
|
## Command Line Tools
|
27
24
|
|
28
|
-
Yummi exposes a 'yummi' program that you can use to colorize texts and apply
|
29
|
-
patterns to colorize lines (usefull to tail logs).
|
25
|
+
Yummi exposes a 'yummi' program that you can use to colorize texts and apply patterns to colorize lines (usefull to tail logs).
|
30
26
|
|
31
27
|
Examples:
|
32
28
|
|
@@ -52,7 +48,7 @@ Example:
|
|
52
48
|
ERROR : red
|
53
49
|
FATAL : intense_red
|
54
50
|
|
55
|
-
Yummi provides a set of patterns, check yummi/patterns dir.
|
51
|
+
Yummi provides a set of patterns, check `yummi/patterns` dir.
|
56
52
|
|
57
53
|
tail -f $JBOSS_HOME/standalone/log/server.log | yummi -p jboss
|
58
54
|
|
data/bin/yummi
CHANGED
@@ -40,7 +40,7 @@ opt.on '-p PATTERNS', '--pattern=PATTERNS', Array,
|
|
40
40
|
'Sets a pattern to colorize each line' do |patterns|
|
41
41
|
@colorizer = Yummi::Colorizers.pattern(patterns)
|
42
42
|
end
|
43
|
-
opt.on '--log', 'Uses the default log pattern to colorize each line' do
|
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
46
|
opt.on '-m message', '--message=MESSAGE',
|
@@ -67,7 +67,7 @@ end
|
|
67
67
|
opt.on '--box', 'Wraps the given text in a box' do
|
68
68
|
@box = true
|
69
69
|
end
|
70
|
-
opt.on '-v', '--version'
|
70
|
+
opt.on '-v', '--version', 'Shows the yummi version' do
|
71
71
|
puts Yummi::VERSION
|
72
72
|
exit
|
73
73
|
end
|
@@ -106,7 +106,10 @@ elsif @table_builder
|
|
106
106
|
extension = File::extname(@data)[1..-1]
|
107
107
|
type = (@data_type or extension).to_sym
|
108
108
|
if Yummi::DataParser.respond_to? type
|
109
|
-
|
109
|
+
data = Yummi::DataParser.send(type, File.read(@data))
|
110
|
+
data.each do |row|
|
111
|
+
table.add row
|
112
|
+
end
|
110
113
|
else
|
111
114
|
abort "Unsupported extension #{extension}"
|
112
115
|
end
|
data/examples/cash_flow_table.rb
CHANGED
@@ -39,7 +39,7 @@ tablebuilder = Yummi::TableBuilder::new('cash_flow_table.yaml')
|
|
39
39
|
['Total', nil, 600.35, nil, nil]]
|
40
40
|
|
41
41
|
opt.on '--layout LAYOUT', 'Defines the table layout (horizontal or vertical)' do |layout|
|
42
|
-
@table.layout = layout
|
42
|
+
@table.layout = layout
|
43
43
|
end
|
44
44
|
|
45
45
|
opt.on '--box', 'Prints the table inside a box' do
|
@@ -1,12 +1,14 @@
|
|
1
1
|
title: Cash Flow
|
2
2
|
description: How you spend your money
|
3
3
|
layout: horizontal
|
4
|
+
|
4
5
|
header:
|
5
6
|
- Description
|
6
7
|
- Value
|
7
8
|
- Total
|
8
9
|
- Eletronic
|
9
10
|
- "Authentication\nCode"
|
11
|
+
|
10
12
|
format:
|
11
13
|
eletronic: boolean
|
12
14
|
value,total:
|
@@ -15,6 +17,7 @@ format:
|
|
15
17
|
negative: "(%.2f)"
|
16
18
|
undefined:
|
17
19
|
with: none
|
20
|
+
|
18
21
|
color:
|
19
22
|
description:
|
20
23
|
with: magenta
|
@@ -31,6 +34,7 @@ color:
|
|
31
34
|
negative: red
|
32
35
|
undefined:
|
33
36
|
with: red
|
37
|
+
|
34
38
|
row_color:
|
35
39
|
blessed_income: yellow
|
36
40
|
|
@@ -40,6 +44,7 @@ top:
|
|
40
44
|
with: "%.2f"
|
41
45
|
row_color:
|
42
46
|
with: intense_white
|
47
|
+
|
43
48
|
bottom:
|
44
49
|
- format:
|
45
50
|
total:
|
@@ -1,7 +1,7 @@
|
|
1
|
-
Initial
|
2
|
-
Deposit,
|
3
|
-
Withdraw
|
4
|
-
Withdraw
|
5
|
-
Deposit,
|
6
|
-
Deposit,
|
7
|
-
Total
|
1
|
+
Initial,,0,
|
2
|
+
Deposit,100.58,100.58,true,QAWSEDRFTGH535
|
3
|
+
Withdraw,-50.23,50.35,true,34ERDTF6GYU
|
4
|
+
Withdraw,-100,-49.65,true,2344EDRFT5
|
5
|
+
Deposit,50,0.35,false
|
6
|
+
Deposit,600,600.35,false
|
7
|
+
Total,,600.35
|
@@ -1,35 +1,34 @@
|
|
1
|
-
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
-
|
1
|
+
- description: Initial
|
2
|
+
total: 0
|
3
|
+
|
4
|
+
- description: Deposit
|
5
|
+
value: 100.58
|
6
|
+
total: 100.58
|
7
|
+
eletronic: true
|
8
|
+
authentication_code: QAWSEDRFTGH535
|
9
|
+
|
10
|
+
- description: Withdraw
|
11
|
+
value: -50.23
|
12
|
+
total: 50.35
|
13
|
+
eletronic: true
|
14
|
+
authentication_code: 34ERDTF6GYU
|
15
|
+
|
16
|
+
- description: Withdraw
|
17
|
+
value: -100
|
18
|
+
total: -49.65
|
19
|
+
eletronic: true
|
20
|
+
authentication_code: 2344EDRFT5
|
21
|
+
|
22
|
+
- description: Deposit
|
23
|
+
value: 50
|
24
|
+
total: 0.35
|
25
|
+
eletronic: false
|
26
|
+
|
27
|
+
- description: Deposit
|
28
|
+
value: 600
|
29
|
+
total: 600.35
|
30
|
+
eletronic: false
|
31
|
+
|
32
|
+
- description: Total
|
33
|
+
total: 600.35
|
34
|
+
|
data/examples/monitor_table.rb
CHANGED
@@ -32,9 +32,15 @@ opt = OptionParser::new
|
|
32
32
|
@table.title = 'Server Runtime Info'
|
33
33
|
# formats memory info for easily reading
|
34
34
|
@table.format [:max_memory, :free_memory], :using => Yummi::Formatters.byte
|
35
|
+
@table.format [:max_threads, :in_use_threads], :using => Yummi::Formatters.numeric(
|
36
|
+
:separator => ','
|
37
|
+
)
|
35
38
|
|
36
39
|
@table.bottom do
|
37
40
|
@table.format [:max_memory, :free_memory], :using => Yummi::Formatters.byte
|
41
|
+
@table.format [:max_threads, :in_use_threads], :using => Yummi::Formatters.numeric(
|
42
|
+
:separator => ','
|
43
|
+
)
|
38
44
|
@table.colorize_row :with => 'bold.white'
|
39
45
|
end
|
40
46
|
|
@@ -102,8 +108,8 @@ opt.parse ARGV
|
|
102
108
|
['Server 2', 1_000_000_000, 700_000_000, 200, 180],
|
103
109
|
['Server 3', 1_000_000_000, 50_000_000, 200, 50],
|
104
110
|
['Server 4', 1_000_000_000, 200_000_000, 200, 100],
|
105
|
-
['Server 5', 1_000_000_000, 5_000_000,
|
106
|
-
['Server 6', 1_000_000_000, 750_000_000, 200,
|
111
|
+
['Server 5', 1_000_000_000, 5_000_000, 2000, 50],
|
112
|
+
['Server 6', 1_000_000_000, 750_000_000, 200, 0],
|
107
113
|
]
|
108
114
|
|
109
115
|
@table.add :server_name => 'Server 7',
|
data/lib/yummi.rb
CHANGED
data/lib/yummi/data_parser.rb
CHANGED
data/lib/yummi/formatters.rb
CHANGED
@@ -26,7 +26,7 @@ module Yummi
|
|
26
26
|
module FormatterBlock
|
27
27
|
|
28
28
|
# Calls the :call: method
|
29
|
-
def format
|
29
|
+
def format(arg)
|
30
30
|
arg = Yummi::Context::new(arg) unless arg.is_a? Context
|
31
31
|
call value
|
32
32
|
end
|
@@ -34,7 +34,7 @@ module Yummi
|
|
34
34
|
end
|
35
35
|
|
36
36
|
# Extends the given block with #FormatterBlock
|
37
|
-
def self.to_format
|
37
|
+
def self.to_format(&block)
|
38
38
|
block.extend FormatterBlock
|
39
39
|
end
|
40
40
|
|
@@ -49,19 +49,19 @@ module Yummi
|
|
49
49
|
# :if_true => String to use when value is true
|
50
50
|
# :if_false => String to use when value is false
|
51
51
|
#
|
52
|
-
def self.boolean
|
52
|
+
def self.boolean(params = {})
|
53
53
|
Yummi::to_format do |ctx|
|
54
54
|
value = ctx.value
|
55
55
|
if value.to_s.downcase == 'true'
|
56
56
|
(params[:if_true] or 'Yes')
|
57
|
-
else
|
57
|
+
else
|
58
58
|
(params[:if_false] or 'No')
|
59
59
|
end
|
60
60
|
end
|
61
61
|
end
|
62
62
|
|
63
63
|
# A formatter to round float values
|
64
|
-
def self.round
|
64
|
+
def self.round(precision)
|
65
65
|
Yummi::to_format do |ctx|
|
66
66
|
value = ctx.value
|
67
67
|
"%.#{precision}f" % value
|
@@ -69,7 +69,7 @@ module Yummi
|
|
69
69
|
end
|
70
70
|
|
71
71
|
# A formatter that uses the given format
|
72
|
-
def self.with
|
72
|
+
def self.with(format)
|
73
73
|
Yummi::to_format do |ctx|
|
74
74
|
value = ctx.value
|
75
75
|
format % value
|
@@ -85,8 +85,9 @@ module Yummi
|
|
85
85
|
# :zero => format to use when value is zero
|
86
86
|
# :positive => format to use when value is positive
|
87
87
|
# :any => format to use for any value without a specific format
|
88
|
+
# :separator => a thousand separator for use instead of the formats above
|
88
89
|
#
|
89
|
-
def self.numeric
|
90
|
+
def self.numeric(params)
|
90
91
|
Yummi::to_format do |ctx|
|
91
92
|
value = ctx.value
|
92
93
|
negative = (params[:negative] or params[:any])
|
@@ -98,6 +99,12 @@ module Yummi
|
|
98
99
|
positive % value
|
99
100
|
elsif zero and value == 0
|
100
101
|
zero % value
|
102
|
+
else
|
103
|
+
if params[:separator]
|
104
|
+
value.to_s.gsub(/(\d)(?=(\d\d\d)+(?!\d))/, "\\1#{params[:separator]}")
|
105
|
+
else
|
106
|
+
value
|
107
|
+
end
|
101
108
|
end
|
102
109
|
end
|
103
110
|
end
|
@@ -108,7 +115,7 @@ module Yummi
|
|
108
115
|
# Parameters:
|
109
116
|
# The precision to use (defaults to 3)
|
110
117
|
#
|
111
|
-
def self.percentage
|
118
|
+
def self.percentage(precision = 3)
|
112
119
|
Yummi::to_format do |ctx|
|
113
120
|
value = ctx.value
|
114
121
|
"%.#{precision}f%%" % (value * 100)
|
@@ -117,14 +124,14 @@ module Yummi
|
|
117
124
|
|
118
125
|
# Defines the modes to format a byte value
|
119
126
|
BYTE_MODES = {
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
127
|
+
:iec => {
|
128
|
+
:range => %w{B KiB MiB GiB TiB PiB EiB ZiB YiB},
|
129
|
+
:step => 1024
|
130
|
+
},
|
131
|
+
:si => {
|
132
|
+
:range => %w{B KB MB GB TB PB EB ZB YB},
|
133
|
+
:step => 1000
|
134
|
+
}
|
128
135
|
}
|
129
136
|
|
130
137
|
#
|
@@ -139,7 +146,7 @@ module Yummi
|
|
139
146
|
#
|
140
147
|
# See #BYTE_MODES
|
141
148
|
#
|
142
|
-
def self.byte
|
149
|
+
def self.byte(params = {})
|
143
150
|
Yummi::to_format do |ctx|
|
144
151
|
value = ctx.value
|
145
152
|
value = value.to_i if value.is_a? String
|
@@ -150,7 +157,8 @@ module Yummi
|
|
150
157
|
result = value
|
151
158
|
range.each_index do |i|
|
152
159
|
minimun = (step.** i)
|
153
|
-
result = "%.#{params[:precision]}f #{range[i]}" %
|
160
|
+
result = "%.#{params[:precision]}f #{range[i]}" %
|
161
|
+
(value.to_f / minimun) if value >= minimun
|
154
162
|
end
|
155
163
|
result
|
156
164
|
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
module Yummi
|
2
|
+
module RowExtractor
|
3
|
+
|
4
|
+
def extract_row_from_hash(row, row_index)
|
5
|
+
array = []
|
6
|
+
@aliases.each_index do |column_index|
|
7
|
+
key = @aliases[column_index]
|
8
|
+
obj = TableContext::new(
|
9
|
+
:obj => row,
|
10
|
+
:row_index => row_index,
|
11
|
+
:column_index => column_index,
|
12
|
+
:value => (row[key.to_sym] or row[key.to_s])
|
13
|
+
)
|
14
|
+
array << obj
|
15
|
+
end
|
16
|
+
array
|
17
|
+
end
|
18
|
+
|
19
|
+
def extract_row_from_range(row, row_index)
|
20
|
+
row.to_a
|
21
|
+
end
|
22
|
+
|
23
|
+
def extract_row_from_array(row, row_index)
|
24
|
+
array = []
|
25
|
+
row.each_index do |column_index|
|
26
|
+
obj = TableContext::new(
|
27
|
+
:obj => IndexedData::new(@aliases, row),
|
28
|
+
:row_index => row_index,
|
29
|
+
:column_index => column_index,
|
30
|
+
:value => row[column_index]
|
31
|
+
)
|
32
|
+
array << obj
|
33
|
+
end
|
34
|
+
array
|
35
|
+
end
|
36
|
+
|
37
|
+
def extract_row_from_object(row, row_index)
|
38
|
+
array = []
|
39
|
+
@aliases.each_index do |column_index|
|
40
|
+
obj = TableContext::new(
|
41
|
+
:obj => row,
|
42
|
+
:row_index => row_index,
|
43
|
+
:column_index => column_index,
|
44
|
+
:value => row.send(@aliases[column_index])
|
45
|
+
)
|
46
|
+
def obj.[] (index)
|
47
|
+
obj.send(index)
|
48
|
+
end
|
49
|
+
array << obj
|
50
|
+
end
|
51
|
+
array
|
52
|
+
end
|
53
|
+
|
54
|
+
end
|
55
|
+
end
|
data/lib/yummi/table.rb
CHANGED
@@ -21,11 +21,13 @@
|
|
21
21
|
# THE SOFTWARE.
|
22
22
|
|
23
23
|
require 'ostruct'
|
24
|
+
require_relative 'row_extractor'
|
24
25
|
|
25
26
|
module Yummi
|
26
27
|
# A Table that supports colorizing title, header, values and also formatting the values.
|
27
28
|
class Table
|
28
29
|
include Yummi::OnBox
|
30
|
+
include Yummi::RowExtractor
|
29
31
|
|
30
32
|
# The table title
|
31
33
|
attr_accessor :title
|
@@ -67,7 +69,7 @@ module Yummi
|
|
67
69
|
# * Colspan (colspan): 2
|
68
70
|
# * Default Align (align): right and first element to left
|
69
71
|
#
|
70
|
-
def initialize
|
72
|
+
def initialize(params = {})
|
71
73
|
params = OpenStruct::new params
|
72
74
|
params.style ||= {}
|
73
75
|
@data = []
|
@@ -75,10 +77,10 @@ module Yummi
|
|
75
77
|
@title = (params.title or nil)
|
76
78
|
@description = (params.description or nil)
|
77
79
|
@style = {
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
80
|
+
:title => (params.style[:title] or 'bold.yellow'),
|
81
|
+
:description => (params.style[:description] or 'bold.black'),
|
82
|
+
:header => (params.style[:header] or 'bold.blue'),
|
83
|
+
:value => (params.style[:color] or nil)
|
82
84
|
}
|
83
85
|
|
84
86
|
@colspan = (params.colspan or 2)
|
@@ -98,9 +100,9 @@ module Yummi
|
|
98
100
|
# Indicates that the table should not use colors.
|
99
101
|
def no_colors
|
100
102
|
@style = {
|
101
|
-
|
102
|
-
|
103
|
-
|
103
|
+
:title => nil,
|
104
|
+
:header => nil,
|
105
|
+
:value => nil
|
104
106
|
}
|
105
107
|
@no_colors = true
|
106
108
|
end
|
@@ -152,8 +154,8 @@ module Yummi
|
|
152
154
|
|
153
155
|
# Sets the table print layout.
|
154
156
|
def layout=(layout)
|
155
|
-
@layout = layout
|
156
|
-
case layout
|
157
|
+
@layout = layout.to_sym
|
158
|
+
case @layout
|
157
159
|
when :horizontal
|
158
160
|
@default_align = :right
|
159
161
|
when :vertical
|
@@ -194,7 +196,7 @@ module Yummi
|
|
194
196
|
#
|
195
197
|
# table.header = ['Name', 'Email', 'Work Phone', "Home\nPhone"]
|
196
198
|
#
|
197
|
-
# This will create the following aliases: :
|
199
|
+
# This will create the following aliases: :key, :email, :work_phone and :home_phone
|
198
200
|
#
|
199
201
|
def header=(header)
|
200
202
|
header = [header] unless header.respond_to? :each
|
@@ -410,9 +412,9 @@ module Yummi
|
|
410
412
|
|
411
413
|
def _define_(context)
|
412
414
|
@components[context] = {
|
413
|
-
|
414
|
-
|
415
|
-
|
415
|
+
:formatters => [],
|
416
|
+
:colorizers => [],
|
417
|
+
:row_colorizer => nil,
|
416
418
|
}
|
417
419
|
end
|
418
420
|
|
@@ -507,21 +509,25 @@ module Yummi
|
|
507
509
|
_row_data = []
|
508
510
|
row.each_index do |col_index|
|
509
511
|
next if not @header.empty? and @header[0].size < col_index + 1
|
510
|
-
color = nil
|
511
|
-
value = nil
|
512
512
|
column = row[col_index]
|
513
513
|
colorizer = component[:colorizers][col_index]
|
514
|
-
if component[:null_colorizer] and column.nil?
|
515
|
-
|
514
|
+
color = if component[:null_colorizer] and column.value.nil?
|
515
|
+
component[:null_colorizer].call(column)
|
516
516
|
elsif colorizer
|
517
|
-
|
517
|
+
colorizer.call(column)
|
518
518
|
else
|
519
|
-
|
519
|
+
@style[:value]
|
520
|
+
end
|
521
|
+
formatter = if column.value.nil?
|
522
|
+
@null_formatter
|
523
|
+
else
|
524
|
+
component[:formatters][col_index]
|
525
|
+
end
|
526
|
+
value = if formatter
|
527
|
+
formatter.call(column)
|
528
|
+
else
|
529
|
+
column.value
|
520
530
|
end
|
521
|
-
formatter = component[:formatters][col_index]
|
522
|
-
formatter = component[:null_formatter] if column.nil? and @null_formatter
|
523
|
-
value = (formatter ? formatter.call(column) : column.value)
|
524
|
-
|
525
531
|
_row_data << {:value => value, :color => color}
|
526
532
|
end
|
527
533
|
row_colorizer = component[:row_colorizer]
|
@@ -531,13 +537,13 @@ module Yummi
|
|
531
537
|
end
|
532
538
|
|
533
539
|
_row_data = normalize(
|
534
|
-
|
535
|
-
|
536
|
-
|
537
|
-
|
538
|
-
|
539
|
-
|
540
|
-
|
540
|
+
_row_data,
|
541
|
+
:extract => proc do |data|
|
542
|
+
data[:value].to_s
|
543
|
+
end,
|
544
|
+
:new => proc do |value, data|
|
545
|
+
{:value => value, :color => data[:color]}
|
546
|
+
end
|
541
547
|
)
|
542
548
|
_row_data.each do |_row|
|
543
549
|
output << _row
|
@@ -547,45 +553,9 @@ module Yummi
|
|
547
553
|
end
|
548
554
|
|
549
555
|
def row_to_array (row, row_index = nil)
|
550
|
-
|
551
|
-
|
552
|
-
|
553
|
-
@aliases.each_index do |column_index|
|
554
|
-
obj = TableContext::new(
|
555
|
-
:obj => row,
|
556
|
-
:row_index => row_index,
|
557
|
-
:column_index => column_index,
|
558
|
-
:value => row[@aliases[column_index]]
|
559
|
-
)
|
560
|
-
array << obj
|
561
|
-
end
|
562
|
-
elsif row.is_a? Array
|
563
|
-
row.each_index do |column_index|
|
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]
|
569
|
-
)
|
570
|
-
array << obj
|
571
|
-
end
|
572
|
-
else
|
573
|
-
@aliases.each_index do |column_index|
|
574
|
-
obj = TableContext::new(
|
575
|
-
:obj => row,
|
576
|
-
:row_index => row_index,
|
577
|
-
:column_index => column_index,
|
578
|
-
:value => row.send(@aliases[column_index])
|
579
|
-
)
|
580
|
-
|
581
|
-
def obj.[] (index)
|
582
|
-
obj.send(index)
|
583
|
-
end
|
584
|
-
|
585
|
-
array << obj
|
586
|
-
end
|
587
|
-
end
|
588
|
-
array
|
556
|
+
message_name = "extract_row_from_#{row.class.to_s.downcase}".to_sym
|
557
|
+
message_name = :extract_row_from_object unless respond_to? message_name
|
558
|
+
send(message_name, row, row_index)
|
589
559
|
end
|
590
560
|
|
591
561
|
def component
|
data/lib/yummi/version.rb
CHANGED
data/yummi.iml
CHANGED
@@ -1,5 +1,8 @@
|
|
1
1
|
<?xml version="1.0" encoding="UTF-8"?>
|
2
2
|
<module type="RUBY_MODULE" version="4">
|
3
|
+
<component name="CompassSettings">
|
4
|
+
<option name="compassSupportEnabled" value="true" />
|
5
|
+
</component>
|
3
6
|
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
4
7
|
<exclude-output />
|
5
8
|
<content url="file://$MODULE_DIR$">
|
@@ -11,7 +14,7 @@
|
|
11
14
|
<orderEntry type="sourceFolder" forTests="false" />
|
12
15
|
<orderEntry type="library" scope="PROVIDED" name="bundler (v1.5.3, RVM: ruby-2.0.0-p247) [gem]" level="application" />
|
13
16
|
<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 (
|
17
|
+
<orderEntry type="library" scope="PROVIDED" name="tins (v1.0.0, RVM: ruby-2.0.0-p247) [gem]" level="application" />
|
15
18
|
</component>
|
16
19
|
<component name="org.twodividedbyzero.idea.findbugs">
|
17
20
|
<option name="_basePreferences">
|
data/yummi.ipr
CHANGED
@@ -43,9 +43,6 @@
|
|
43
43
|
<option name="SKIP_IMPORT_STATEMENTS" value="false" />
|
44
44
|
</component>
|
45
45
|
<component name="Encoding" useUTFGuessing="true" native2AsciiForPropertiesFiles="false" />
|
46
|
-
<component name="GradleSettings">
|
47
|
-
<option name="gradleHome" value="$USER_HOME$/build/gradle" />
|
48
|
-
</component>
|
49
46
|
<component name="GradleUISettings2">
|
50
47
|
<setting name="root" />
|
51
48
|
</component>
|
@@ -55,7 +52,6 @@
|
|
55
52
|
<profile version="1.0" is_locked="false">
|
56
53
|
<option name="myName" value="Project Default" />
|
57
54
|
<option name="myLocal" value="false" />
|
58
|
-
<inspection_tool class="Fix shebang" enabled="true" level="WARNING" enabled_by_default="true">/bin/sh#/bin/bash</inspection_tool>
|
59
55
|
<inspection_tool class="SpellCheckingInspection" enabled="true" level="TYPO" enabled_by_default="true">
|
60
56
|
<option name="processCode" value="false" />
|
61
57
|
<option name="processLiterals" value="false" />
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: yummi
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ataxexe
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-08-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: term-ansicolor
|
@@ -59,6 +59,7 @@ files:
|
|
59
59
|
- lib/yummi/patterns/log.yaml
|
60
60
|
- lib/yummi/patterns/weblogic.yaml
|
61
61
|
- lib/yummi/patterns/webserver.yaml
|
62
|
+
- lib/yummi/row_extractor.rb
|
62
63
|
- lib/yummi/table.rb
|
63
64
|
- lib/yummi/table_builder.rb
|
64
65
|
- lib/yummi/text_box.rb
|
@@ -90,3 +91,4 @@ signing_key:
|
|
90
91
|
specification_version: 4
|
91
92
|
summary: A tool to colorize your console application.
|
92
93
|
test_files: []
|
94
|
+
has_rdoc:
|