rshell 0.1.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/CHANGELOG +5 -0
- data/README.rdoc +0 -0
- data/Rakefile +19 -0
- data/VERSION +1 -0
- data/lib/rshell.rb +14 -0
- data/lib/rshell/console.rb +78 -0
- data/lib/rshell/string.rb +12 -0
- data/rshell-0.1.0.gem +0 -0
- data/rshell.gemspec +44 -0
- metadata +76 -0
data/CHANGELOG
ADDED
data/README.rdoc
ADDED
File without changes
|
data/Rakefile
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake'
|
3
|
+
|
4
|
+
begin
|
5
|
+
require 'jeweler'
|
6
|
+
Jeweler::Tasks.new do |gemspec|
|
7
|
+
gemspec.name = "rshell"
|
8
|
+
gemspec.summary = "Useful console helper to easily use Ruby as console scripting language."
|
9
|
+
gemspec.description = "It help when you need to create some shell script with Ruby."
|
10
|
+
gemspec.email = "andrea@blomming.com"
|
11
|
+
gemspec.homepage = "http://github.com/knightq/rshell"
|
12
|
+
gemspec.authors = ["Andrea Salicetti"]
|
13
|
+
end
|
14
|
+
Jeweler::GemcutterTasks.new
|
15
|
+
rescue LoadError
|
16
|
+
puts "Jeweler not available. Install it with: sudo gem install jeweler -s http://gemcutter.org"
|
17
|
+
end
|
18
|
+
|
19
|
+
Dir["#{File.dirname(__FILE__)}/tasks/*.rake"].sort.each { |ext| load ext }
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.1.1
|
data/lib/rshell.rb
ADDED
@@ -0,0 +1,78 @@
|
|
1
|
+
class Console
|
2
|
+
def self.ascii(i)
|
3
|
+
$is_ascii = i
|
4
|
+
end
|
5
|
+
|
6
|
+
def self.clear # reset the terminal
|
7
|
+
print "\ec" # *42*
|
8
|
+
end
|
9
|
+
|
10
|
+
def self.color(*arg) # colorize a string
|
11
|
+
if arg[0].is_a?(Array)
|
12
|
+
arg = arg[0]
|
13
|
+
end
|
14
|
+
if arg.length == 0
|
15
|
+
arg = :default, :red, :bg_default
|
16
|
+
end
|
17
|
+
attribute = { # mapper for the attributes
|
18
|
+
:normal => 0,
|
19
|
+
:bright => 1,
|
20
|
+
:dim => 2,
|
21
|
+
:underscore => 4,
|
22
|
+
:blink => 5,
|
23
|
+
:reverse => 7,
|
24
|
+
:hidden => 8,
|
25
|
+
:default => 0
|
26
|
+
}
|
27
|
+
fg_color = { # mapper for the foreground color
|
28
|
+
:black => 30,
|
29
|
+
:red => 31,
|
30
|
+
:green => 32,
|
31
|
+
:yellow => 33,
|
32
|
+
:blue => 34,
|
33
|
+
:magenta => 35,
|
34
|
+
:cyan => 36,
|
35
|
+
:white => 37,
|
36
|
+
:default => 39
|
37
|
+
}
|
38
|
+
bg_color = { # mapper for the background color
|
39
|
+
:bg_black => 40,
|
40
|
+
:bg_red => 41,
|
41
|
+
:bg_green => 42,
|
42
|
+
:bg_yellow => 43,
|
43
|
+
:bg_blue => 44,
|
44
|
+
:bg_magenta => 45,
|
45
|
+
:bg_cyan => 46,
|
46
|
+
:bg_white => 47,
|
47
|
+
:bg_default => 49
|
48
|
+
}
|
49
|
+
if arg.length > 0 # turn symbols into numbers
|
50
|
+
arg[0] = attribute[arg[0]] # attributes
|
51
|
+
end
|
52
|
+
if arg.length > 1
|
53
|
+
arg[1] = fg_color[arg[1]] # foreground color
|
54
|
+
end
|
55
|
+
if arg.length > 2
|
56
|
+
arg[2] = bg_color[arg[2]] # background color
|
57
|
+
end
|
58
|
+
"\e[#{arg.join(";")}m" # magic ansi escape sequence
|
59
|
+
end
|
60
|
+
|
61
|
+
def self.color=(arg)
|
62
|
+
if not arg.is_a?(Array)
|
63
|
+
arg = [arg]
|
64
|
+
end
|
65
|
+
if arg.length == 0
|
66
|
+
arg = :default, :red, :bg_default
|
67
|
+
end
|
68
|
+
print self.color(arg)
|
69
|
+
end
|
70
|
+
|
71
|
+
def self.width
|
72
|
+
`tput cols`.chomp.to_i
|
73
|
+
end
|
74
|
+
|
75
|
+
def self.height
|
76
|
+
`tput lines`.chomp.to_i
|
77
|
+
end
|
78
|
+
end
|
data/rshell-0.1.0.gem
ADDED
Binary file
|
data/rshell.gemspec
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = %q{rshell}
|
8
|
+
s.version = "0.1.1"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["Andrea Salicetti"]
|
12
|
+
s.date = %q{2011-05-11}
|
13
|
+
s.description = %q{It help when you need to create some shell script with Ruby.}
|
14
|
+
s.email = %q{andrea@blomming.com}
|
15
|
+
s.extra_rdoc_files = [
|
16
|
+
"README.rdoc"
|
17
|
+
]
|
18
|
+
s.files = [
|
19
|
+
"CHANGELOG",
|
20
|
+
"README.rdoc",
|
21
|
+
"Rakefile",
|
22
|
+
"VERSION",
|
23
|
+
"lib/rshell.rb",
|
24
|
+
"lib/rshell/console.rb",
|
25
|
+
"lib/rshell/string.rb",
|
26
|
+
"rshell-0.1.0.gem",
|
27
|
+
"rshell-0.1.1.gem",
|
28
|
+
"rshell.gemspec"
|
29
|
+
]
|
30
|
+
s.homepage = %q{http://github.com/knightq/rshell}
|
31
|
+
s.require_paths = ["lib"]
|
32
|
+
s.rubygems_version = %q{1.6.2}
|
33
|
+
s.summary = %q{Useful console helper to easily use Ruby as console scripting language.}
|
34
|
+
|
35
|
+
if s.respond_to? :specification_version then
|
36
|
+
s.specification_version = 3
|
37
|
+
|
38
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
39
|
+
else
|
40
|
+
end
|
41
|
+
else
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
metadata
ADDED
@@ -0,0 +1,76 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rshell
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 25
|
5
|
+
prerelease:
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 1
|
9
|
+
- 1
|
10
|
+
version: 0.1.1
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- Andrea Salicetti
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2011-05-11 00:00:00 +02:00
|
19
|
+
default_executable:
|
20
|
+
dependencies: []
|
21
|
+
|
22
|
+
description: It help when you need to create some shell script with Ruby.
|
23
|
+
email: andrea@blomming.com
|
24
|
+
executables: []
|
25
|
+
|
26
|
+
extensions: []
|
27
|
+
|
28
|
+
extra_rdoc_files:
|
29
|
+
- README.rdoc
|
30
|
+
files:
|
31
|
+
- CHANGELOG
|
32
|
+
- README.rdoc
|
33
|
+
- Rakefile
|
34
|
+
- VERSION
|
35
|
+
- lib/rshell.rb
|
36
|
+
- lib/rshell/console.rb
|
37
|
+
- lib/rshell/string.rb
|
38
|
+
- rshell-0.1.0.gem
|
39
|
+
- rshell-0.1.1.gem
|
40
|
+
- rshell.gemspec
|
41
|
+
has_rdoc: true
|
42
|
+
homepage: http://github.com/knightq/rshell
|
43
|
+
licenses: []
|
44
|
+
|
45
|
+
post_install_message:
|
46
|
+
rdoc_options: []
|
47
|
+
|
48
|
+
require_paths:
|
49
|
+
- lib
|
50
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
51
|
+
none: false
|
52
|
+
requirements:
|
53
|
+
- - ">="
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
hash: 3
|
56
|
+
segments:
|
57
|
+
- 0
|
58
|
+
version: "0"
|
59
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
60
|
+
none: false
|
61
|
+
requirements:
|
62
|
+
- - ">="
|
63
|
+
- !ruby/object:Gem::Version
|
64
|
+
hash: 3
|
65
|
+
segments:
|
66
|
+
- 0
|
67
|
+
version: "0"
|
68
|
+
requirements: []
|
69
|
+
|
70
|
+
rubyforge_project:
|
71
|
+
rubygems_version: 1.6.2
|
72
|
+
signing_key:
|
73
|
+
specification_version: 3
|
74
|
+
summary: Useful console helper to easily use Ruby as console scripting language.
|
75
|
+
test_files: []
|
76
|
+
|