do_riak 0.10.1.pre
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +2 -0
- data/Gemfile +9 -0
- data/LICENSE +20 -0
- data/README.textile +23 -0
- data/TODO.txt +4 -0
- data/deps.rip +8 -0
- data/do_riak.gemspec +40 -0
- data/do_riak.pre.gemspec +8 -0
- data/gems/cache/bacon-1.1.0.gem +0 -0
- data/gems/cache/code-cleaner-0.8.1.gem +0 -0
- data/gems/cache/nake-0.0.8.gem +0 -0
- data/gems/cache/term-ansicolor-1.0.4.gem +0 -0
- data/gems/environment.rb +107 -0
- data/gems/gems/bacon-1.1.0/COPYING +18 -0
- data/gems/gems/bacon-1.1.0/ChangeLog +220 -0
- data/gems/gems/bacon-1.1.0/RDOX +69 -0
- data/gems/gems/bacon-1.1.0/README +290 -0
- data/gems/gems/bacon-1.1.0/Rakefile +138 -0
- data/gems/gems/bacon-1.1.0/bin/bacon +117 -0
- data/gems/gems/bacon-1.1.0/lib/autotest/bacon.rb +36 -0
- data/gems/gems/bacon-1.1.0/lib/autotest/bacon_rspec.rb +2 -0
- data/gems/gems/bacon-1.1.0/lib/autotest/discover.rb +9 -0
- data/gems/gems/bacon-1.1.0/lib/bacon.rb +354 -0
- data/gems/gems/bacon-1.1.0/test/spec_bacon.rb +374 -0
- data/gems/gems/bacon-1.1.0/test/spec_should.rb +32 -0
- data/gems/gems/code-cleaner-0.8.1/LICENSE +20 -0
- data/gems/gems/code-cleaner-0.8.1/README.textile +87 -0
- data/gems/gems/code-cleaner-0.8.1/TODO.txt +1 -0
- data/gems/gems/code-cleaner-0.8.1/bin/code-cleaner +143 -0
- data/gems/gems/code-cleaner-0.8.1/code-cleaner-0.8.gem +0 -0
- data/gems/gems/code-cleaner-0.8.1/code-cleaner.gemspec +25 -0
- data/gems/gems/code-cleaner-0.8.1/support/pre-commit.erb +70 -0
- data/gems/gems/code-cleaner-0.8.1/tasks.rb +13 -0
- data/gems/gems/code-cleaner-0.8.1/tasks/code-cleaner.nake +49 -0
- data/gems/gems/code-cleaner-0.8.1/tasks/code-cleaner.rake +22 -0
- data/gems/gems/code-cleaner-0.8.1/tasks/code-cleaner.thor +35 -0
- data/gems/gems/nake-0.0.8/CHANGELOG +48 -0
- data/gems/gems/nake-0.0.8/LICENSE +20 -0
- data/gems/gems/nake-0.0.8/README.textile +39 -0
- data/gems/gems/nake-0.0.8/TODO.txt +23 -0
- data/gems/gems/nake-0.0.8/bin/nake +66 -0
- data/gems/gems/nake-0.0.8/bin/nrake +4 -0
- data/gems/gems/nake-0.0.8/bin/rake2nake +1 -0
- data/gems/gems/nake-0.0.8/bin/snake +41 -0
- data/gems/gems/nake-0.0.8/bm/Rakefile +28 -0
- data/gems/gems/nake-0.0.8/bm/bms.rb +56 -0
- data/gems/gems/nake-0.0.8/bm/output.txt +5 -0
- data/gems/gems/nake-0.0.8/bm/tasks.rb +21 -0
- data/gems/gems/nake-0.0.8/bm/tmp/test.c +6 -0
- data/gems/gems/nake-0.0.8/bm/tmp/www/index.html +1 -0
- data/gems/gems/nake-0.0.8/deps.rb +5 -0
- data/gems/gems/nake-0.0.8/deps.rip +5 -0
- data/gems/gems/nake-0.0.8/examples/arguments.rb +38 -0
- data/gems/gems/nake-0.0.8/examples/basic.rb +5 -0
- data/gems/gems/nake-0.0.8/examples/boot.rb +18 -0
- data/gems/gems/nake-0.0.8/examples/complex.rb +9 -0
- data/gems/gems/nake-0.0.8/examples/configuration.rb +15 -0
- data/gems/gems/nake-0.0.8/examples/default.rb +10 -0
- data/gems/gems/nake-0.0.8/examples/default_proc.rb +11 -0
- data/gems/gems/nake-0.0.8/examples/dependencies.rb +10 -0
- data/gems/gems/nake-0.0.8/examples/description.rb +33 -0
- data/gems/gems/nake-0.0.8/examples/file.rb +22 -0
- data/gems/gems/nake-0.0.8/examples/helpers.rb +3 -0
- data/gems/gems/nake-0.0.8/examples/invoking.rb +14 -0
- data/gems/gems/nake-0.0.8/examples/rules.rb +0 -0
- data/gems/gems/nake-0.0.8/examples/script.rb +20 -0
- data/gems/gems/nake-0.0.8/examples/task_arguments.rb +27 -0
- data/gems/gems/nake-0.0.8/features/arguments.feature +22 -0
- data/gems/gems/nake-0.0.8/features/basic.feature +6 -0
- data/gems/gems/nake-0.0.8/features/boot.feature +5 -0
- data/gems/gems/nake-0.0.8/features/builtin_arguments.feature +14 -0
- data/gems/gems/nake-0.0.8/features/complex.feature +6 -0
- data/gems/gems/nake-0.0.8/features/configuration.feature +10 -0
- data/gems/gems/nake-0.0.8/features/default.feature +10 -0
- data/gems/gems/nake-0.0.8/features/default_proc.feature +6 -0
- data/gems/gems/nake-0.0.8/features/dependencies.feature +16 -0
- data/gems/gems/nake-0.0.8/features/description.feature +0 -0
- data/gems/gems/nake-0.0.8/features/env.rb +11 -0
- data/gems/gems/nake-0.0.8/features/executable.feature +29 -0
- data/gems/gems/nake-0.0.8/features/file.feature +23 -0
- data/gems/gems/nake-0.0.8/features/helpers.feature +6 -0
- data/gems/gems/nake-0.0.8/features/invoking.feature +14 -0
- data/gems/gems/nake-0.0.8/features/rules.feature +0 -0
- data/gems/gems/nake-0.0.8/features/script.feature +10 -0
- data/gems/gems/nake-0.0.8/features/steps.rb +39 -0
- data/gems/gems/nake-0.0.8/features/task_arguments.feature +10 -0
- data/gems/gems/nake-0.0.8/lib/nake.rb +103 -0
- data/gems/gems/nake-0.0.8/lib/nake/abstract_task.rb +175 -0
- data/gems/gems/nake-0.0.8/lib/nake/args.rb +65 -0
- data/gems/gems/nake-0.0.8/lib/nake/argv.rb +47 -0
- data/gems/gems/nake-0.0.8/lib/nake/colors.rb +22 -0
- data/gems/gems/nake-0.0.8/lib/nake/dsl.rb +70 -0
- data/gems/gems/nake-0.0.8/lib/nake/file_task.rb +62 -0
- data/gems/gems/nake-0.0.8/lib/nake/helpers.rb +65 -0
- data/gems/gems/nake-0.0.8/lib/nake/rake.rb +38 -0
- data/gems/gems/nake-0.0.8/lib/nake/rule.rb +35 -0
- data/gems/gems/nake-0.0.8/lib/nake/struct_hash.rb +22 -0
- data/gems/gems/nake-0.0.8/lib/nake/task.rb +6 -0
- data/gems/gems/nake-0.0.8/lib/nake/tasks/bundle.rb +30 -0
- data/gems/gems/nake-0.0.8/lib/nake/tasks/clean.rb +12 -0
- data/gems/gems/nake-0.0.8/lib/nake/tasks/gem.rb +29 -0
- data/gems/gems/nake-0.0.8/lib/nake/tasks/release.rb +43 -0
- data/gems/gems/nake-0.0.8/lib/nake/tasks/rip.rb +33 -0
- data/gems/gems/nake-0.0.8/lib/nake/tasks/spec.rb +20 -0
- data/gems/gems/nake-0.0.8/lib/nake/template.rb +51 -0
- data/gems/gems/nake-0.0.8/nake-0.0.8.pre.gem +0 -0
- data/gems/gems/nake-0.0.8/nake.gemspec +42 -0
- data/gems/gems/nake-0.0.8/nake.pre.gemspec +8 -0
- data/gems/gems/nake-0.0.8/spec/nake/abstract_task_spec.rb +0 -0
- data/gems/gems/nake-0.0.8/spec/nake/args_spec.rb +0 -0
- data/gems/gems/nake-0.0.8/spec/nake/argv_spec.rb +51 -0
- data/gems/gems/nake-0.0.8/spec/nake/colors_spec.rb +0 -0
- data/gems/gems/nake-0.0.8/spec/nake/dsl_spec.rb +35 -0
- data/gems/gems/nake-0.0.8/spec/nake/file_task_spec.rb +0 -0
- data/gems/gems/nake-0.0.8/spec/nake/helpers_spec.rb +14 -0
- data/gems/gems/nake-0.0.8/spec/nake/rake_spec.rb +0 -0
- data/gems/gems/nake-0.0.8/spec/nake/rule_spec.rb +72 -0
- data/gems/gems/nake-0.0.8/spec/nake/struct_hash_spec.rb +0 -0
- data/gems/gems/nake-0.0.8/spec/nake/task_spec.rb +72 -0
- data/gems/gems/nake-0.0.8/spec/nake/tasks/bundle_spec.rb +28 -0
- data/gems/gems/nake-0.0.8/spec/nake/tasks/clean_spec.rb +0 -0
- data/gems/gems/nake-0.0.8/spec/nake/tasks/gem_spec.rb +0 -0
- data/gems/gems/nake-0.0.8/spec/nake/tasks/release_spec.rb +0 -0
- data/gems/gems/nake-0.0.8/spec/nake/tasks/rip_spec.rb +0 -0
- data/gems/gems/nake-0.0.8/spec/nake/tasks/spec_spec.rb +0 -0
- data/gems/gems/nake-0.0.8/spec/nake/tasks_spec.rb +48 -0
- data/gems/gems/nake-0.0.8/spec/nake/template_spec.rb +84 -0
- data/gems/gems/nake-0.0.8/spec/nake_spec.rb +9 -0
- data/gems/gems/nake-0.0.8/spec/spec.opts +5 -0
- data/gems/gems/nake-0.0.8/spec/spec_helper.rb +29 -0
- data/gems/gems/nake-0.0.8/spec/stubs/database.yml.erb +9 -0
- data/gems/gems/nake-0.0.8/spec/stubs/database.yml.tt +9 -0
- data/gems/gems/nake-0.0.8/tasks.rb +42 -0
- data/gems/gems/term-ansicolor-1.0.4/CHANGES +22 -0
- data/gems/gems/term-ansicolor-1.0.4/COPYING +340 -0
- data/gems/gems/term-ansicolor-1.0.4/README +31 -0
- data/gems/gems/term-ansicolor-1.0.4/Rakefile +86 -0
- data/gems/gems/term-ansicolor-1.0.4/VERSION +1 -0
- data/gems/gems/term-ansicolor-1.0.4/doc-main.txt +119 -0
- data/gems/gems/term-ansicolor-1.0.4/examples/cdiff.rb +19 -0
- data/gems/gems/term-ansicolor-1.0.4/examples/example.rb +89 -0
- data/gems/gems/term-ansicolor-1.0.4/install.rb +15 -0
- data/gems/gems/term-ansicolor-1.0.4/lib/term/ansicolor.rb +102 -0
- data/gems/gems/term-ansicolor-1.0.4/lib/term/ansicolor/version.rb +10 -0
- data/gems/gems/term-ansicolor-1.0.4/term-ansicolor.gemspec +20 -0
- data/gems/specifications/bacon-1.1.0.gemspec +30 -0
- data/gems/specifications/code-cleaner-0.8.1.gemspec +31 -0
- data/gems/specifications/nake-0.0.8.gemspec +35 -0
- data/gems/specifications/term-ansicolor-1.0.4.gemspec +30 -0
- data/lib/do_riak.rb +10 -0
- data/lib/do_riak/errors.rb +11 -0
- data/lib/do_riak/transaction.rb +24 -0
- data/lib/do_riak/version.rb +7 -0
- data/script/bacon +3 -0
- data/script/code-cleaner +3 -0
- data/script/nake +3 -0
- data/spec/command_spec.rb +8 -0
- data/spec/connection_spec.rb +17 -0
- data/spec/reader_spec.rb +8 -0
- data/spec/result_spec.rb +12 -0
- data/spec/spec_helper.rb +19 -0
- data/spec/typecast/array_spec.rb +8 -0
- data/spec/typecast/bigdecimal_spec.rb +8 -0
- data/spec/typecast/boolean_spec.rb +8 -0
- data/spec/typecast/byte_array_spec.rb +8 -0
- data/spec/typecast/class_spec.rb +8 -0
- data/spec/typecast/date_spec.rb +8 -0
- data/spec/typecast/datetime_spec.rb +8 -0
- data/spec/typecast/float_spec.rb +12 -0
- data/spec/typecast/integer_spec.rb +8 -0
- data/spec/typecast/nil_spec.rb +16 -0
- data/spec/typecast/other_spec.rb +8 -0
- data/spec/typecast/range_spec.rb +8 -0
- data/spec/typecast/string_spec.rb +8 -0
- data/spec/typecast/time_spec.rb +8 -0
- data/tasks.rb +37 -0
- metadata +238 -0
@@ -0,0 +1,31 @@
|
|
1
|
+
Installation
|
2
|
+
============
|
3
|
+
|
4
|
+
Just type into the command line as root:
|
5
|
+
|
6
|
+
# ruby install.rb
|
7
|
+
|
8
|
+
Or if you prefer using Rake, try:
|
9
|
+
|
10
|
+
# rake install
|
11
|
+
|
12
|
+
Or if you want to use rubygems just type this and rubygems fetches the gem and
|
13
|
+
installs it for you:
|
14
|
+
|
15
|
+
# gem install term-ansicolor
|
16
|
+
|
17
|
+
Documentation
|
18
|
+
=============
|
19
|
+
|
20
|
+
Look into examples/example.rb to get an idea how this library is used.
|
21
|
+
|
22
|
+
Author
|
23
|
+
======
|
24
|
+
|
25
|
+
Florian Frank <flori@ping.de>
|
26
|
+
|
27
|
+
License
|
28
|
+
=======
|
29
|
+
|
30
|
+
GNU General Public License (GPL)
|
31
|
+
|
@@ -0,0 +1,86 @@
|
|
1
|
+
begin
|
2
|
+
require 'rake/gempackagetask'
|
3
|
+
rescue LoadError
|
4
|
+
end
|
5
|
+
require 'rake/clean'
|
6
|
+
require 'rbconfig'
|
7
|
+
include Config
|
8
|
+
|
9
|
+
PKG_NAME = 'term-ansicolor'
|
10
|
+
PKG_VERSION = File.read('VERSION').chomp
|
11
|
+
PKG_FILES = FileList['**/*'].exclude(/(CVS|\.svn|pkg|coverage|doc)/)
|
12
|
+
CLEAN.include 'coverage', 'doc'
|
13
|
+
|
14
|
+
desc "Installing library"
|
15
|
+
task :install do
|
16
|
+
ruby 'install.rb'
|
17
|
+
end
|
18
|
+
|
19
|
+
desc "Creating documentation"
|
20
|
+
task :doc do
|
21
|
+
ruby 'make_doc.rb'
|
22
|
+
end
|
23
|
+
|
24
|
+
|
25
|
+
if defined? Gem
|
26
|
+
spec_src =<<GEM
|
27
|
+
# -*- encoding: utf-8 -*-
|
28
|
+
Gem::Specification.new do |s|
|
29
|
+
s.name = '#{PKG_NAME}'
|
30
|
+
s.version = '#{PKG_VERSION}'
|
31
|
+
s.summary = "Ruby library that colors strings using ANSI escape sequences"
|
32
|
+
s.description = ""
|
33
|
+
|
34
|
+
s.files = #{PKG_FILES.to_a.sort.inspect}
|
35
|
+
|
36
|
+
s.require_path = 'lib'
|
37
|
+
|
38
|
+
s.has_rdoc = true
|
39
|
+
s.extra_rdoc_files << 'doc-main.txt'
|
40
|
+
s.rdoc_options << '--main' << 'doc-main.txt'
|
41
|
+
|
42
|
+
s.author = "Florian Frank"
|
43
|
+
s.email = "flori@ping.de"
|
44
|
+
s.homepage = "http://#{PKG_NAME}.rubyforge.org"
|
45
|
+
s.rubyforge_project = '#{PKG_NAME}'
|
46
|
+
end
|
47
|
+
GEM
|
48
|
+
|
49
|
+
desc 'Create a gemspec file'
|
50
|
+
task :gemspec do
|
51
|
+
File.open("#{PKG_NAME}.gemspec", 'w') do |f|
|
52
|
+
f.puts spec_src
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
spec = eval(spec_src)
|
57
|
+
Rake::GemPackageTask.new(spec) do |pkg|
|
58
|
+
pkg.need_tar = true
|
59
|
+
pkg.package_files += PKG_FILES
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
desc m = "Writing version information for #{PKG_VERSION}"
|
64
|
+
task :version do
|
65
|
+
puts m
|
66
|
+
File.open(File.join('lib', 'term', 'ansicolor', 'version.rb'), 'w') do |v|
|
67
|
+
v.puts <<EOT
|
68
|
+
module Term
|
69
|
+
module ANSIColor
|
70
|
+
# Term::ANSIColor version
|
71
|
+
VERSION = '#{PKG_VERSION}'
|
72
|
+
VERSION_ARRAY = VERSION.split(/\\./).map { |x| x.to_i } # :nodoc:
|
73
|
+
VERSION_MAJOR = VERSION_ARRAY[0] # :nodoc:
|
74
|
+
VERSION_MINOR = VERSION_ARRAY[1] # :nodoc:
|
75
|
+
VERSION_BUILD = VERSION_ARRAY[2] # :nodoc:
|
76
|
+
end
|
77
|
+
end
|
78
|
+
EOT
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
desc "Default"
|
83
|
+
task :default => [ :version, :gemspec ]
|
84
|
+
|
85
|
+
desc "Prepare a release"
|
86
|
+
task :release => [ :clean, :version, :gemspec, :package ]
|
@@ -0,0 +1 @@
|
|
1
|
+
1.0.4
|
@@ -0,0 +1,119 @@
|
|
1
|
+
== Term::ANSIColor - ANSI escape sequences in Ruby
|
2
|
+
|
3
|
+
=== Description
|
4
|
+
|
5
|
+
This library can be used to color/uncolor strings using ANSI escape sequences.
|
6
|
+
|
7
|
+
=== Author
|
8
|
+
|
9
|
+
Florian Frank mailto:flori@ping.de
|
10
|
+
|
11
|
+
=== License
|
12
|
+
|
13
|
+
This is free software; you can redistribute it and/or modify it under the
|
14
|
+
terms of the GNU General Public License Version 2 as published by the Free
|
15
|
+
Software Foundation: www.gnu.org/copyleft/gpl.html
|
16
|
+
|
17
|
+
=== Download
|
18
|
+
|
19
|
+
The latest version of this library can be downloaded at
|
20
|
+
|
21
|
+
* http://rubyforge.org/frs?group_id=391
|
22
|
+
|
23
|
+
The homepage of this library is located at
|
24
|
+
|
25
|
+
* http://term-ansicolor.rubyforge.org
|
26
|
+
|
27
|
+
=== Examples
|
28
|
+
|
29
|
+
The file examples/example.rb in the source/gem-distribution shows how
|
30
|
+
this library can be used:
|
31
|
+
require 'term/ansicolor'
|
32
|
+
|
33
|
+
# Use this trick to work around namespace cluttering that
|
34
|
+
# happens if you just include Term::ANSIColor:
|
35
|
+
|
36
|
+
class Color
|
37
|
+
class << self
|
38
|
+
include Term::ANSIColor
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
print Color.red, Color.bold, "No Namespace cluttering:", Color.clear, "\n"
|
43
|
+
print Color.green + "green" + Color.clear, "\n"
|
44
|
+
print Color.on_red(Color.green("green")), "\n"
|
45
|
+
print Color.yellow { Color.on_black { "yellow on_black" } }, "\n\n"
|
46
|
+
|
47
|
+
# Or shortcut Term::ANSIColor by assignment:
|
48
|
+
c = Term::ANSIColor
|
49
|
+
|
50
|
+
print c.red, c.bold, "No Namespace cluttering (alternative):", c.clear, "\n"
|
51
|
+
print c.green + "green" + c.clear, "\n"
|
52
|
+
print c.on_red(c.green("green")), "\n"
|
53
|
+
print c.yellow { c.on_black { "yellow on_black" } }, "\n\n"
|
54
|
+
|
55
|
+
# Anyway, I don't define any of Term::ANSIColor's methods in this example
|
56
|
+
# and I want to keep it short:
|
57
|
+
include Term::ANSIColor
|
58
|
+
|
59
|
+
print red, bold, "Usage as constants:", reset, "\n"
|
60
|
+
print clear, "clear", reset, reset, "reset", reset,
|
61
|
+
bold, "bold", reset, dark, "dark", reset,
|
62
|
+
underscore, "underscore", reset, blink, "blink", reset,
|
63
|
+
negative, "negative", reset, concealed, "concealed", reset, "|\n",
|
64
|
+
black, "black", reset, red, "red", reset, green, "green", reset,
|
65
|
+
yellow, "yellow", reset, blue, "blue", reset, magenta, "magenta", reset,
|
66
|
+
cyan, "cyan", reset, white, "white", reset, "|\n",
|
67
|
+
on_black, "on_black", reset, on_red, "on_red", reset,
|
68
|
+
on_green, "on_green", reset, on_yellow, "on_yellow", reset,
|
69
|
+
on_blue, "on_blue", reset, on_magenta, "on_magenta", reset,
|
70
|
+
on_cyan, "on_cyan", reset, on_white, "on_white", reset, "|\n\n"
|
71
|
+
|
72
|
+
print red, bold, "Usage as unary argument methods:", reset, "\n"
|
73
|
+
print clear("clear"), reset("reset"), bold("bold"), dark("dark"),
|
74
|
+
underscore("underscore"), blink("blink"), negative("negative"),
|
75
|
+
concealed("concealed"), "|\n",
|
76
|
+
black("black"), red("red"), green("green"), yellow("yellow"),
|
77
|
+
blue("blue"), magenta("magenta"), cyan("cyan"), white("white"), "|\n",
|
78
|
+
on_black("on_black"), on_red("on_red"), on_green("on_green"),#
|
79
|
+
on_yellow("on_yellow"), on_blue("on_blue"), on_magenta("on_magenta"),
|
80
|
+
on_cyan("on_cyan"), on_white("on_white"), "|\n\n"
|
81
|
+
|
82
|
+
print red { bold { "Usage as block forms:" } }, "\n"
|
83
|
+
print clear { "clear" }, reset { "reset" }, bold { "bold" },
|
84
|
+
dark { "dark" }, underscore { "underscore" }, blink { "blink" },
|
85
|
+
negative { "negative" }, concealed { "concealed" }, "|\n",
|
86
|
+
black { "black" }, red { "red" }, green { "green" },
|
87
|
+
yellow { "yellow" }, blue { "blue" }, magenta { "magenta" },
|
88
|
+
cyan { "cyan" }, white { "white" }, "|\n",
|
89
|
+
on_black { "on_black" }, on_red { "on_red" }, on_green { "on_green" },
|
90
|
+
on_yellow { "on_yellow" }, on_blue { "on_blue" },
|
91
|
+
on_magenta { "on_magenta" }, on_cyan { "on_cyan" },
|
92
|
+
on_white { "on_white" }, "|\n\n"
|
93
|
+
|
94
|
+
# Usage as Mixin into String or its Subclasses
|
95
|
+
class String
|
96
|
+
include Term::ANSIColor
|
97
|
+
end
|
98
|
+
|
99
|
+
print "Usage as String Mixins:".red.bold, "\n"
|
100
|
+
print "clear".clear, "reset".reset, "bold".bold, "dark".dark,
|
101
|
+
"underscore".underscore, "blink".blink, "negative".negative,
|
102
|
+
"concealed".concealed, "|\n",
|
103
|
+
"black".black, "red".red, "green".green, "yellow".yellow,
|
104
|
+
"blue".blue, "magenta".magenta, "cyan".cyan, "white".white, "|\n",
|
105
|
+
"on_black".on_black, "on_red".on_red, "on_green".on_green,
|
106
|
+
"on_yellow".on_yellow, "on_blue".on_blue, "on_magenta".on_magenta,
|
107
|
+
"on_cyan".on_cyan, "on_white".on_white, "|\n\n"
|
108
|
+
|
109
|
+
symbols = Term::ANSIColor::attributes
|
110
|
+
print red { bold { "All supported attributes = " } },
|
111
|
+
blue { symbols.inspect }, "\n\n"
|
112
|
+
|
113
|
+
print "Send symbols to strings:".send(:red).send(:bold), "\n"
|
114
|
+
print symbols[12, 8].map { |c| c.to_s.send(c) }, "\n\n"
|
115
|
+
|
116
|
+
print red { bold { "Make strings monochromatic again:" } }, "\n"
|
117
|
+
print [ "red".red, "not red anymore".red.uncolored,
|
118
|
+
uncolored { "not red anymore".red }, uncolored("not red anymore".red)
|
119
|
+
].map { |x| x + "\n" }
|
@@ -0,0 +1,19 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
#
|
3
|
+
## Little unix filter that colorizes diff output
|
4
|
+
#
|
5
|
+
|
6
|
+
require 'term/ansicolor'
|
7
|
+
|
8
|
+
include Term::ANSIColor
|
9
|
+
|
10
|
+
ARGF.each do |line|
|
11
|
+
print(
|
12
|
+
case line
|
13
|
+
when /^\+/ then green { line }
|
14
|
+
when /^-/ then red { line }
|
15
|
+
when /^(@@|diff)/ then blue { line }
|
16
|
+
else line
|
17
|
+
end
|
18
|
+
)
|
19
|
+
end
|
@@ -0,0 +1,89 @@
|
|
1
|
+
require 'term/ansicolor'
|
2
|
+
|
3
|
+
# Use this trick to work around namespace cluttering that
|
4
|
+
# happens if you just include Term::ANSIColor:
|
5
|
+
|
6
|
+
class Color
|
7
|
+
class << self
|
8
|
+
include Term::ANSIColor
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
print Color.red, Color.bold, "No Namespace cluttering:", Color.clear, "\n"
|
13
|
+
print Color.green + "green" + Color.clear, "\n"
|
14
|
+
print Color.on_red(Color.green("green")), "\n"
|
15
|
+
print Color.yellow { Color.on_black { "yellow on_black" } }, "\n\n"
|
16
|
+
|
17
|
+
# Or shortcut Term::ANSIColor by assignment:
|
18
|
+
c = Term::ANSIColor
|
19
|
+
|
20
|
+
print c.red, c.bold, "No Namespace cluttering (alternative):", c.clear, "\n"
|
21
|
+
print c.green + "green" + c.clear, "\n"
|
22
|
+
print c.on_red(c.green("green")), "\n"
|
23
|
+
print c.yellow { c.on_black { "yellow on_black" } }, "\n\n"
|
24
|
+
|
25
|
+
# Anyway, I don't define any of Term::ANSIColor's methods in this example
|
26
|
+
# and I want to keep it short:
|
27
|
+
include Term::ANSIColor
|
28
|
+
|
29
|
+
print red, bold, "Usage as constants:", reset, "\n"
|
30
|
+
print clear, "clear", reset, reset, "reset", reset,
|
31
|
+
bold, "bold", reset, dark, "dark", reset,
|
32
|
+
underscore, "underscore", reset, blink, "blink", reset,
|
33
|
+
negative, "negative", reset, concealed, "concealed", reset, "|\n",
|
34
|
+
black, "black", reset, red, "red", reset, green, "green", reset,
|
35
|
+
yellow, "yellow", reset, blue, "blue", reset, magenta, "magenta", reset,
|
36
|
+
cyan, "cyan", reset, white, "white", reset, "|\n",
|
37
|
+
on_black, "on_black", reset, on_red, "on_red", reset,
|
38
|
+
on_green, "on_green", reset, on_yellow, "on_yellow", reset,
|
39
|
+
on_blue, "on_blue", reset, on_magenta, "on_magenta", reset,
|
40
|
+
on_cyan, "on_cyan", reset, on_white, "on_white", reset, "|\n\n"
|
41
|
+
|
42
|
+
print red, bold, "Usage as unary argument methods:", reset, "\n"
|
43
|
+
print clear("clear"), reset("reset"), bold("bold"), dark("dark"),
|
44
|
+
underscore("underscore"), blink("blink"), negative("negative"),
|
45
|
+
concealed("concealed"), "|\n",
|
46
|
+
black("black"), red("red"), green("green"), yellow("yellow"),
|
47
|
+
blue("blue"), magenta("magenta"), cyan("cyan"), white("white"), "|\n",
|
48
|
+
on_black("on_black"), on_red("on_red"), on_green("on_green"),#
|
49
|
+
on_yellow("on_yellow"), on_blue("on_blue"), on_magenta("on_magenta"),
|
50
|
+
on_cyan("on_cyan"), on_white("on_white"), "|\n\n"
|
51
|
+
|
52
|
+
print red { bold { "Usage as block forms:" } }, "\n"
|
53
|
+
print clear { "clear" }, reset { "reset" }, bold { "bold" },
|
54
|
+
dark { "dark" }, underscore { "underscore" }, blink { "blink" },
|
55
|
+
negative { "negative" }, concealed { "concealed" }, "|\n",
|
56
|
+
black { "black" }, red { "red" }, green { "green" },
|
57
|
+
yellow { "yellow" }, blue { "blue" }, magenta { "magenta" },
|
58
|
+
cyan { "cyan" }, white { "white" }, "|\n",
|
59
|
+
on_black { "on_black" }, on_red { "on_red" }, on_green { "on_green" },
|
60
|
+
on_yellow { "on_yellow" }, on_blue { "on_blue" },
|
61
|
+
on_magenta { "on_magenta" }, on_cyan { "on_cyan" },
|
62
|
+
on_white { "on_white" }, "|\n\n"
|
63
|
+
|
64
|
+
# Usage as Mixin into String or its Subclasses
|
65
|
+
class String
|
66
|
+
include Term::ANSIColor
|
67
|
+
end
|
68
|
+
|
69
|
+
print "Usage as String Mixins:".red.bold, "\n"
|
70
|
+
print "clear".clear, "reset".reset, "bold".bold, "dark".dark,
|
71
|
+
"underscore".underscore, "blink".blink, "negative".negative,
|
72
|
+
"concealed".concealed, "|\n",
|
73
|
+
"black".black, "red".red, "green".green, "yellow".yellow,
|
74
|
+
"blue".blue, "magenta".magenta, "cyan".cyan, "white".white, "|\n",
|
75
|
+
"on_black".on_black, "on_red".on_red, "on_green".on_green,
|
76
|
+
"on_yellow".on_yellow, "on_blue".on_blue, "on_magenta".on_magenta,
|
77
|
+
"on_cyan".on_cyan, "on_white".on_white, "|\n\n"
|
78
|
+
|
79
|
+
symbols = Term::ANSIColor::attributes
|
80
|
+
print red { bold { "All supported attributes = " } },
|
81
|
+
blue { symbols.inspect }, "\n\n"
|
82
|
+
|
83
|
+
print "Send symbols to strings:".send(:red).send(:bold), "\n"
|
84
|
+
print symbols[12, 8].map { |c| c.to_s.send(c) }, "\n\n"
|
85
|
+
|
86
|
+
print red { bold { "Make strings monochromatic again:" } }, "\n"
|
87
|
+
print [ "red".red, "not red anymore".red.uncolored,
|
88
|
+
uncolored { "not red anymore".red }, uncolored("not red anymore".red)
|
89
|
+
].map { |x| x + "\n" }
|
@@ -0,0 +1,15 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'rbconfig'
|
4
|
+
include Config
|
5
|
+
require 'fileutils'
|
6
|
+
include FileUtils::Verbose
|
7
|
+
|
8
|
+
destdir = "#{ENV['DESTDIR']}"
|
9
|
+
libdir = CONFIG["sitelibdir"]
|
10
|
+
dest = destdir + File.join(libdir, 'term')
|
11
|
+
mkdir_p dest
|
12
|
+
install 'lib/term/ansicolor.rb', dest
|
13
|
+
dest = destdir + File.join(libdir, 'term', 'ansicolor')
|
14
|
+
mkdir_p dest
|
15
|
+
install 'lib/term/ansicolor/version.rb', dest
|
@@ -0,0 +1,102 @@
|
|
1
|
+
require 'term/ansicolor/version'
|
2
|
+
|
3
|
+
module Term
|
4
|
+
# The ANSIColor module can be used for namespacing and mixed into your own
|
5
|
+
# classes.
|
6
|
+
module ANSIColor
|
7
|
+
# :stopdoc:
|
8
|
+
ATTRIBUTES = [
|
9
|
+
[ :clear , 0 ],
|
10
|
+
[ :reset , 0 ], # synonym for :clear
|
11
|
+
[ :bold , 1 ],
|
12
|
+
[ :dark , 2 ],
|
13
|
+
[ :italic , 3 ], # not widely implemented
|
14
|
+
[ :underline , 4 ],
|
15
|
+
[ :underscore , 4 ], # synonym for :underline
|
16
|
+
[ :blink , 5 ],
|
17
|
+
[ :rapid_blink , 6 ], # not widely implemented
|
18
|
+
[ :negative , 7 ], # no reverse because of String#reverse
|
19
|
+
[ :concealed , 8 ],
|
20
|
+
[ :strikethrough, 9 ], # not widely implemented
|
21
|
+
[ :black , 30 ],
|
22
|
+
[ :red , 31 ],
|
23
|
+
[ :green , 32 ],
|
24
|
+
[ :yellow , 33 ],
|
25
|
+
[ :blue , 34 ],
|
26
|
+
[ :magenta , 35 ],
|
27
|
+
[ :cyan , 36 ],
|
28
|
+
[ :white , 37 ],
|
29
|
+
[ :on_black , 40 ],
|
30
|
+
[ :on_red , 41 ],
|
31
|
+
[ :on_green , 42 ],
|
32
|
+
[ :on_yellow , 43 ],
|
33
|
+
[ :on_blue , 44 ],
|
34
|
+
[ :on_magenta , 45 ],
|
35
|
+
[ :on_cyan , 46 ],
|
36
|
+
[ :on_white , 47 ],
|
37
|
+
]
|
38
|
+
|
39
|
+
ATTRIBUTE_NAMES = ATTRIBUTES.transpose.first
|
40
|
+
# :startdoc:
|
41
|
+
|
42
|
+
# Returns true, if the coloring function of this module
|
43
|
+
# is switched on, false otherwise.
|
44
|
+
def self.coloring?
|
45
|
+
@coloring
|
46
|
+
end
|
47
|
+
|
48
|
+
# Turns the coloring on or off globally, so you can easily do
|
49
|
+
# this for example:
|
50
|
+
# Term::ANSIColor::coloring = STDOUT.isatty
|
51
|
+
def self.coloring=(val)
|
52
|
+
@coloring = val
|
53
|
+
end
|
54
|
+
self.coloring = true
|
55
|
+
|
56
|
+
ATTRIBUTES.each do |c, v|
|
57
|
+
eval %Q{
|
58
|
+
def #{c}(string = nil)
|
59
|
+
result = ''
|
60
|
+
result << "\e[#{v}m" if Term::ANSIColor.coloring?
|
61
|
+
if block_given?
|
62
|
+
result << yield
|
63
|
+
elsif string
|
64
|
+
result << string
|
65
|
+
elsif respond_to?(:to_str)
|
66
|
+
result << self
|
67
|
+
else
|
68
|
+
return result #only switch on
|
69
|
+
end
|
70
|
+
result << "\e[0m" if Term::ANSIColor.coloring?
|
71
|
+
result
|
72
|
+
end
|
73
|
+
}
|
74
|
+
end
|
75
|
+
|
76
|
+
# Regular expression that is used to scan for ANSI-sequences while
|
77
|
+
# uncoloring strings.
|
78
|
+
COLORED_REGEXP = /\e\[([34][0-7]|[0-9])m/
|
79
|
+
|
80
|
+
# Returns an uncolored version of the string, that is all
|
81
|
+
# ANSI-sequences are stripped from the string.
|
82
|
+
def uncolored(string = nil) # :yields:
|
83
|
+
if block_given?
|
84
|
+
yield.gsub(COLORED_REGEXP, '')
|
85
|
+
elsif string
|
86
|
+
string.gsub(COLORED_REGEXP, '')
|
87
|
+
elsif respond_to?(:to_str)
|
88
|
+
gsub(COLORED_REGEXP, '')
|
89
|
+
else
|
90
|
+
''
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
module_function
|
95
|
+
|
96
|
+
# Returns an array of all Term::ANSIColor attributes as symbols.
|
97
|
+
def attributes
|
98
|
+
ATTRIBUTE_NAMES
|
99
|
+
end
|
100
|
+
extend self
|
101
|
+
end
|
102
|
+
end
|