yummi 0.8.0 → 0.8.1
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.
- data/LICENSE +1 -1
- data/bin/yummi +29 -1
- data/examples/cash_flow_table.rb +1 -1
- data/examples/license_box.rb +2 -2
- data/examples/list_files.rb +1 -1
- data/examples/logcat_colorizer.rb +1 -1
- data/examples/logger.rb +1 -1
- data/examples/monitor_table.rb +1 -1
- data/lib/yummi.rb +15 -4
- data/lib/yummi/color_mapping.rb +1 -1
- data/lib/yummi/colorizers.rb +1 -1
- data/lib/yummi/data_parser.rb +1 -1
- data/lib/yummi/extensions.rb +1 -1
- data/lib/yummi/formatters.rb +1 -1
- data/lib/yummi/generate/colorize.sh.erb +23 -0
- data/lib/yummi/generator.rb +47 -0
- data/lib/yummi/logger.rb +3 -3
- data/lib/yummi/no_colors.rb +1 -1
- data/lib/yummi/table.rb +1 -1
- data/lib/yummi/table_builder.rb +1 -1
- data/lib/yummi/text_box.rb +1 -1
- data/lib/yummi/version.rb +2 -2
- metadata +4 -2
data/LICENSE
CHANGED
data/bin/yummi
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
# The MIT License
|
|
4
4
|
#
|
|
5
|
-
# Copyright (c)
|
|
5
|
+
# Copyright (c) 2013 Marcelo Guimarães <ataxexe@gmail.com>
|
|
6
6
|
#
|
|
7
7
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
8
8
|
# of this software and associated documentation files (the "Software"), to deal
|
|
@@ -27,6 +27,13 @@ require 'optparse'
|
|
|
27
27
|
|
|
28
28
|
@params = []
|
|
29
29
|
|
|
30
|
+
def get_input message, default
|
|
31
|
+
puts(message.colorize(:blue) << ": " << " [#{default}]".colorize(:yellow))
|
|
32
|
+
input = gets.chomp
|
|
33
|
+
return default if input.empty?
|
|
34
|
+
input
|
|
35
|
+
end
|
|
36
|
+
|
|
30
37
|
opt = OptionParser::new
|
|
31
38
|
opt.on '-c COLOR', '--color=COLOR', 'Colorize using the given color' do |color|
|
|
32
39
|
@color = color
|
|
@@ -60,6 +67,27 @@ opt.on '-l FILES', '--load=FILES', Array, 'Include the files for extending compo
|
|
|
60
67
|
load File.expand_path(file)
|
|
61
68
|
end
|
|
62
69
|
end
|
|
70
|
+
opt.on '--shell-script', 'Outputs a shell script program to colorize texts without a ruby environment' do
|
|
71
|
+
abort "Environment not supported" unless Yummi::Color::supported?
|
|
72
|
+
|
|
73
|
+
generator = Yummi::Generator::ShellScript::new
|
|
74
|
+
puts generator.generate
|
|
75
|
+
exit 0
|
|
76
|
+
end
|
|
77
|
+
opt.on '--install', 'Installs a shell script program to colorize texts without a ruby environment' do
|
|
78
|
+
abort "Environment not supported" unless Yummi::Color::supported?
|
|
79
|
+
|
|
80
|
+
puts ".: Yummi shell script installation :.".colorize(:bold_yellow)
|
|
81
|
+
name = get_input "Program name", "colorize"
|
|
82
|
+
location = File.expand_path(get_input("Install location", "~/bin"))
|
|
83
|
+
file = File.join(location, name)
|
|
84
|
+
|
|
85
|
+
generator = Yummi::Generator::ShellScript::new
|
|
86
|
+
generator.install file
|
|
87
|
+
|
|
88
|
+
puts "Program installed!".colorize(:bold_green)
|
|
89
|
+
exit 0
|
|
90
|
+
end
|
|
63
91
|
opt.on '-h', '--help', 'Display this help message' do
|
|
64
92
|
puts opt
|
|
65
93
|
exit 0
|
data/examples/cash_flow_table.rb
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# The MIT License
|
|
2
2
|
#
|
|
3
|
-
# Copyright (c)
|
|
3
|
+
# Copyright (c) 2013 Marcelo Guimarães <ataxexe@gmail.com>
|
|
4
4
|
#
|
|
5
5
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
6
|
# of this software and associated documentation files (the "Software"), to deal
|
data/examples/license_box.rb
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# The MIT License
|
|
2
2
|
#
|
|
3
|
-
# Copyright (c)
|
|
3
|
+
# Copyright (c) 2013 Marcelo Guimarães <ataxexe@gmail.com>
|
|
4
4
|
#
|
|
5
5
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
6
|
# of this software and associated documentation files (the "Software"), to deal
|
|
@@ -77,7 +77,7 @@ opt.parse! ARGV
|
|
|
77
77
|
|
|
78
78
|
@box.add 'The MIT License', :color => :intense_yellow, :align => :center
|
|
79
79
|
@box.line_break
|
|
80
|
-
@box.add 'Copyright (c)
|
|
80
|
+
@box.add 'Copyright (c) 2013 Marcelo Guimaraes <ataxexe@gmail.com>', :color => :green, :align => :center
|
|
81
81
|
@box.separator
|
|
82
82
|
@box.add 'Permission is hereby granted, free of charge, to any person obtaining a copy of
|
|
83
83
|
this software and associated documentation files (the "Software"), to deal in the Software
|
data/examples/list_files.rb
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# The MIT License
|
|
2
2
|
#
|
|
3
|
-
# Copyright (c)
|
|
3
|
+
# Copyright (c) 2013 Marcelo Guimarães <ataxexe@gmail.com>
|
|
4
4
|
#
|
|
5
5
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
6
|
# of this software and associated documentation files (the "Software"), to deal
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# The MIT License
|
|
2
2
|
#
|
|
3
|
-
# Copyright (c)
|
|
3
|
+
# Copyright (c) 2013 Marcelo Guimarães <ataxexe@gmail.com>
|
|
4
4
|
#
|
|
5
5
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
6
|
# of this software and associated documentation files (the "Software"), to deal
|
data/examples/logger.rb
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# The MIT License
|
|
2
2
|
#
|
|
3
|
-
# Copyright (c)
|
|
3
|
+
# Copyright (c) 2013 Marcelo Guimarães <ataxexe@gmail.com>
|
|
4
4
|
#
|
|
5
5
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
6
|
# of this software and associated documentation files (the "Software"), to deal
|
data/examples/monitor_table.rb
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# The MIT License
|
|
2
2
|
#
|
|
3
|
-
# Copyright (c)
|
|
3
|
+
# Copyright (c) 2013 Marcelo Guimarães <ataxexe@gmail.com>
|
|
4
4
|
#
|
|
5
5
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
6
|
# of this software and associated documentation files (the "Software"), to deal
|
data/lib/yummi.rb
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# The MIT License
|
|
2
2
|
#
|
|
3
|
-
# Copyright (c)
|
|
3
|
+
# Copyright (c) 2013 Marcelo Guimarães <ataxexe@gmail.com>
|
|
4
4
|
#
|
|
5
5
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
6
|
# of this software and associated documentation files (the "Software"), to deal
|
|
@@ -30,12 +30,12 @@ module Yummi
|
|
|
30
30
|
module Schema
|
|
31
31
|
# Normal Linux Terminal Colors, used by default in normal color types
|
|
32
32
|
NORMAL_COLORS = {
|
|
33
|
-
:colors => [:black, :red, :green, [:yellow, :orange], :blue, :purple, :cyan, [:gray, :white]],
|
|
33
|
+
:colors => [:black, :red, :green, [:yellow, :orange], :blue, [:purple, :magenta], :cyan, [:gray, :white]],
|
|
34
34
|
:default => :white
|
|
35
35
|
}
|
|
36
36
|
# Intense Linux Terminal Colors, used by default in bold color types
|
|
37
37
|
ALTERNATE_COLORS = {
|
|
38
|
-
:colors => [:gray, :red, :green, :yellow, :blue, :purple, :cyan, :white],
|
|
38
|
+
:colors => [:gray, :red, :green, :yellow, :blue, [:purple, :magenta], :cyan, :white],
|
|
39
39
|
:default => :gray
|
|
40
40
|
}
|
|
41
41
|
end
|
|
@@ -43,6 +43,16 @@ module Yummi
|
|
|
43
43
|
# Color mappings
|
|
44
44
|
COLORS = {}
|
|
45
45
|
|
|
46
|
+
#
|
|
47
|
+
# Checks if the environment is supported by Yummi.
|
|
48
|
+
#
|
|
49
|
+
# Currently (known) unsupported environments are:
|
|
50
|
+
# * Windows
|
|
51
|
+
#
|
|
52
|
+
def self.supported?
|
|
53
|
+
not RUBY_PLATFORM['mingw'] #Windows
|
|
54
|
+
end
|
|
55
|
+
|
|
46
56
|
#
|
|
47
57
|
# Clears all color mappings and add this ones
|
|
48
58
|
#
|
|
@@ -347,7 +357,7 @@ module Yummi
|
|
|
347
357
|
|
|
348
358
|
end
|
|
349
359
|
|
|
350
|
-
require_relative 'yummi/no_colors'
|
|
360
|
+
require_relative 'yummi/no_colors' unless Yummi::Color::supported?
|
|
351
361
|
|
|
352
362
|
require_relative 'yummi/extensions'
|
|
353
363
|
require_relative 'yummi/data_parser'
|
|
@@ -358,6 +368,7 @@ require_relative 'yummi/table'
|
|
|
358
368
|
require_relative 'yummi/table_builder'
|
|
359
369
|
require_relative 'yummi/text_box'
|
|
360
370
|
require_relative 'yummi/logger'
|
|
371
|
+
require_relative 'yummi/generator'
|
|
361
372
|
|
|
362
373
|
# if the output is being piped, turn off the colors
|
|
363
374
|
unless $stdout.isatty
|
data/lib/yummi/color_mapping.rb
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# The MIT License
|
|
2
2
|
#
|
|
3
|
-
# Copyright (c)
|
|
3
|
+
# Copyright (c) 2013 Marcelo Guimarães <ataxexe@gmail.com>
|
|
4
4
|
#
|
|
5
5
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
6
|
# of this software and associated documentation files (the "Software"), to deal
|
data/lib/yummi/colorizers.rb
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# The MIT License
|
|
2
2
|
#
|
|
3
|
-
# Copyright (c)
|
|
3
|
+
# Copyright (c) 2013 Marcelo Guimarães <ataxexe@gmail.com>
|
|
4
4
|
#
|
|
5
5
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
6
|
# of this software and associated documentation files (the "Software"), to deal
|
data/lib/yummi/data_parser.rb
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# The MIT License
|
|
2
2
|
#
|
|
3
|
-
# Copyright (c)
|
|
3
|
+
# Copyright (c) 2013 Marcelo Guimarães <ataxexe@gmail.com>
|
|
4
4
|
#
|
|
5
5
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
6
|
# of this software and associated documentation files (the "Software"), to deal
|
data/lib/yummi/extensions.rb
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# The MIT License
|
|
2
2
|
#
|
|
3
|
-
# Copyright (c)
|
|
3
|
+
# Copyright (c) 2013 Marcelo Guimarães <ataxexe@gmail.com>
|
|
4
4
|
#
|
|
5
5
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
6
|
# of this software and associated documentation files (the "Software"), to deal
|
data/lib/yummi/formatters.rb
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# The MIT License
|
|
2
2
|
#
|
|
3
|
-
# Copyright (c)
|
|
3
|
+
# Copyright (c) 2013 Marcelo Guimarães <ataxexe@gmail.com>
|
|
4
4
|
#
|
|
5
5
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
6
|
# of this software and associated documentation files (the "Software"), to deal
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
|
|
3
|
+
# .:: Generated by Yummi ::.
|
|
4
|
+
|
|
5
|
+
usage() {
|
|
6
|
+
echo "Usage: $0 COLOR TEXT [FORMAT]"
|
|
7
|
+
echo " COLOR: a name or a number [1..8]. A modifier may also be used in a form $MOD_$COLOR"
|
|
8
|
+
echo " TEXT: the text to colorize"
|
|
9
|
+
echo " FORMAT: a format to use (defaults to \"%s\\n\")"
|
|
10
|
+
exit 1
|
|
11
|
+
}
|
|
12
|
+
<% Yummi::Color::COLORS.each do |key, pattern| %>
|
|
13
|
+
function color_<%= key %> {
|
|
14
|
+
echo "<%= "$1".colorize(key) %>"
|
|
15
|
+
}
|
|
16
|
+
<% end %>
|
|
17
|
+
[ "$#" = "0" ] && usage
|
|
18
|
+
|
|
19
|
+
format="%s\n"
|
|
20
|
+
|
|
21
|
+
[ ! -z "$3" ] && format="$3"
|
|
22
|
+
|
|
23
|
+
printf "$format" $(color_"$@")
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
# The MIT License
|
|
2
|
+
#
|
|
3
|
+
# Copyright (c) 2013 Marcelo Guimarães <ataxexe@gmail.com>
|
|
4
|
+
#
|
|
5
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
# of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
# in the Software without restriction, including without limitation the rights
|
|
8
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
# copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
# furnished to do so, subject to the following conditions:
|
|
11
|
+
#
|
|
12
|
+
# The above copyright notice and this permission notice shall be included in
|
|
13
|
+
# all copies or substantial portions of the Software.
|
|
14
|
+
#
|
|
15
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
+
# THE SOFTWARE.
|
|
22
|
+
|
|
23
|
+
require 'erb'
|
|
24
|
+
|
|
25
|
+
module Yummi
|
|
26
|
+
|
|
27
|
+
class Generator
|
|
28
|
+
|
|
29
|
+
class ShellScript
|
|
30
|
+
|
|
31
|
+
def generate
|
|
32
|
+
file = File.join(File.dirname(__FILE__), "generate/colorize.sh.erb")
|
|
33
|
+
content = File.read(file)
|
|
34
|
+
erb = ERB::new(content, 0, "%<>")
|
|
35
|
+
erb.result binding
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def install file
|
|
39
|
+
File.open(file, "w") { |f| f.write generate }
|
|
40
|
+
File.chmod(0755, file)
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
end
|
data/lib/yummi/logger.rb
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# The MIT License
|
|
2
2
|
#
|
|
3
|
-
# Copyright (c)
|
|
3
|
+
# Copyright (c) 2013 Marcelo Guimarães <ataxexe@gmail.com>
|
|
4
4
|
#
|
|
5
5
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
6
|
# of this software and associated documentation files (the "Software"), to deal
|
|
@@ -56,7 +56,7 @@ 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 &block
|
|
59
|
+
def initialize colors = {}, &block
|
|
60
60
|
@colors = {
|
|
61
61
|
:debug => :blue,
|
|
62
62
|
:info => :white,
|
|
@@ -64,7 +64,7 @@ module Yummi
|
|
|
64
64
|
:error => :red,
|
|
65
65
|
:fatal => :intense_red,
|
|
66
66
|
:any => :intense_gray
|
|
67
|
-
}
|
|
67
|
+
}.merge! colors
|
|
68
68
|
@format_block = block
|
|
69
69
|
end
|
|
70
70
|
|
data/lib/yummi/no_colors.rb
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# The MIT License
|
|
2
2
|
#
|
|
3
|
-
# Copyright (c)
|
|
3
|
+
# Copyright (c) 2013 Marcelo Guimarães <ataxexe@gmail.com>
|
|
4
4
|
#
|
|
5
5
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
6
|
# of this software and associated documentation files (the "Software"), to deal
|
data/lib/yummi/table.rb
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# The MIT License
|
|
2
2
|
#
|
|
3
|
-
# Copyright (c)
|
|
3
|
+
# Copyright (c) 2013 Marcelo Guimarães <ataxexe@gmail.com>
|
|
4
4
|
#
|
|
5
5
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
6
|
# of this software and associated documentation files (the "Software"), to deal
|
data/lib/yummi/table_builder.rb
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# The MIT License
|
|
2
2
|
#
|
|
3
|
-
# Copyright (c)
|
|
3
|
+
# Copyright (c) 2013-2012 Marcelo Guimarães <ataxexe@gmail.com>
|
|
4
4
|
#
|
|
5
5
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
6
|
# of this software and associated documentation files (the "Software"), to deal
|
data/lib/yummi/text_box.rb
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# The MIT License
|
|
2
2
|
#
|
|
3
|
-
# Copyright (c)
|
|
3
|
+
# Copyright (c) 2013 Marcelo Guimarães <ataxexe@gmail.com>
|
|
4
4
|
#
|
|
5
5
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
6
|
# of this software and associated documentation files (the "Software"), to deal
|
data/lib/yummi/version.rb
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# The MIT License
|
|
2
2
|
#
|
|
3
|
-
# Copyright (c)
|
|
3
|
+
# Copyright (c) 2013 Marcelo Guimarães <ataxexe@gmail.com>
|
|
4
4
|
#
|
|
5
5
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
6
|
# of this software and associated documentation files (the "Software"), to deal
|
|
@@ -21,5 +21,5 @@
|
|
|
21
21
|
# THE SOFTWARE.
|
|
22
22
|
|
|
23
23
|
module Yummi
|
|
24
|
-
VERSION = "0.8.
|
|
24
|
+
VERSION = "0.8.1"
|
|
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.8.
|
|
4
|
+
version: 0.8.1
|
|
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: 2013-
|
|
12
|
+
date: 2013-04-07 00:00:00.000000000 Z
|
|
13
13
|
dependencies: []
|
|
14
14
|
description: A tool to colorize your console application.
|
|
15
15
|
email:
|
|
@@ -42,6 +42,8 @@ files:
|
|
|
42
42
|
- lib/yummi/data_parser.rb
|
|
43
43
|
- lib/yummi/extensions.rb
|
|
44
44
|
- lib/yummi/formatters.rb
|
|
45
|
+
- lib/yummi/generate/colorize.sh.erb
|
|
46
|
+
- lib/yummi/generator.rb
|
|
45
47
|
- lib/yummi/logger.rb
|
|
46
48
|
- lib/yummi/no_colors.rb
|
|
47
49
|
- lib/yummi/patterns/jboss.yaml
|