ansirc 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/ansirc.rb +37 -0
- metadata +45 -0
data/lib/ansirc.rb
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# ansirc - ANSI colors <-> IRC color codes and vice versa.
|
3
|
+
#
|
4
|
+
# Written by Ricky Elrod (github: @CodeBlock) and released an MIT license.
|
5
|
+
# https://www.github.com/CodeBlock/ansirc-gem
|
6
|
+
|
7
|
+
class ANSIRC
|
8
|
+
COLOR_MAP = {
|
9
|
+
"\033[0m" => '',
|
10
|
+
"\033[1;37m" => 0,
|
11
|
+
"\033[0;30m" => 1,
|
12
|
+
"\033[0;34m" => 2,
|
13
|
+
"\033[0;32m" => 3,
|
14
|
+
"\033[0;31m" => 4,
|
15
|
+
"\033[0;33m" => 5,
|
16
|
+
"\033[0;35m" => 6,
|
17
|
+
"\033[0;33m" => 7,
|
18
|
+
"\033[1;33m" => 8,
|
19
|
+
"\033[1;32m" => 9,
|
20
|
+
"\033[0;36m" => 10,
|
21
|
+
"\033[1;36m" => 11,
|
22
|
+
"\033[1;34m" => 12,
|
23
|
+
"\033[1;31m" => 13,
|
24
|
+
"\033[1;30m" => 14,
|
25
|
+
"\033[0;37m" => 15
|
26
|
+
}
|
27
|
+
|
28
|
+
def self.to_irc(text)
|
29
|
+
COLOR_MAP.each { |ansi, irc| text.gsub!(ansi, "#{3.chr}#{irc}") }
|
30
|
+
text
|
31
|
+
end
|
32
|
+
|
33
|
+
def self.to_ansi(text)
|
34
|
+
COLOR_MAP.each { |ansi, irc| text.gsub!("#{3.chr}#{irc}", ansi) }
|
35
|
+
text
|
36
|
+
end
|
37
|
+
end
|
metadata
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: ansirc
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Ricky Elrod
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-05-22 00:00:00.000000000 Z
|
13
|
+
dependencies: []
|
14
|
+
description: An extremely simple library to convert between ANSI and IRC color codes.
|
15
|
+
email: ricky@elrod.me
|
16
|
+
executables: []
|
17
|
+
extensions: []
|
18
|
+
extra_rdoc_files: []
|
19
|
+
files:
|
20
|
+
- lib/ansirc.rb
|
21
|
+
homepage: https://www.github.com/CodeBlock/ansirc-gem
|
22
|
+
licenses: []
|
23
|
+
post_install_message:
|
24
|
+
rdoc_options: []
|
25
|
+
require_paths:
|
26
|
+
- lib
|
27
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
28
|
+
none: false
|
29
|
+
requirements:
|
30
|
+
- - ! '>='
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0'
|
33
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
34
|
+
none: false
|
35
|
+
requirements:
|
36
|
+
- - ! '>='
|
37
|
+
- !ruby/object:Gem::Version
|
38
|
+
version: '0'
|
39
|
+
requirements: []
|
40
|
+
rubyforge_project:
|
41
|
+
rubygems_version: 1.8.17
|
42
|
+
signing_key:
|
43
|
+
specification_version: 3
|
44
|
+
summary: Convert IRC <-> ANSI color codes.
|
45
|
+
test_files: []
|