safe_colorize 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +14 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +21 -0
- data/Rakefile +1 -0
- data/lib/safe_colorize/version.rb +3 -0
- data/lib/safe_colorize.rb +43 -0
- data/safe_colorize.gemspec +21 -0
- metadata +80 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: fa35acb3b7f2bd6889c7e20bfa19ec16afb3520d
|
4
|
+
data.tar.gz: 30a394cdc8dfda61be7828b356b72b8b5005af90
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 6f95fcdc49b6f782f79c64ae1286c700f47b374f3a5ac8fc122db3bfa4758f1a3e9b9180df99e2792267f308b5aeb010861287863617fcaec83a256c51eb3bbc
|
7
|
+
data.tar.gz: 28902c860cc41b55afe84b57899737cd4b42b75c0baff7c80520aa6631e840b1510804bfbdfae1f675e6223ee56ae72959ee109bf80d3626ebc398099be46367
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 kaihar4
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
# SafeColorize
|
2
|
+
|
3
|
+
Safe coloring extensions of String.
|
4
|
+
|
5
|
+
## Description
|
6
|
+
|
7
|
+
SafeColorize is implemented by Refinements.
|
8
|
+
|
9
|
+
Therefore, it is safer than openclass.
|
10
|
+
|
11
|
+
## Installation
|
12
|
+
|
13
|
+
Add this line to your application's Gemfile:
|
14
|
+
|
15
|
+
```ruby
|
16
|
+
gem 'safe_colorize'
|
17
|
+
```
|
18
|
+
|
19
|
+
## Requirements
|
20
|
+
|
21
|
+
* Ruby 2.1.0 or higher
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require 'bundler/gem_tasks'
|
@@ -0,0 +1,43 @@
|
|
1
|
+
module SafeColorize
|
2
|
+
refine String do
|
3
|
+
COLORS = {
|
4
|
+
black: 0,
|
5
|
+
red: 1,
|
6
|
+
green: 2,
|
7
|
+
yellow: 3,
|
8
|
+
blue: 4,
|
9
|
+
magenta: 5,
|
10
|
+
cyan: 6,
|
11
|
+
white: 7
|
12
|
+
}
|
13
|
+
|
14
|
+
STYLES = {
|
15
|
+
reset: 0,
|
16
|
+
bold: 1,
|
17
|
+
underscore: 4,
|
18
|
+
blink: 5,
|
19
|
+
reverse: 6,
|
20
|
+
concealed: 7
|
21
|
+
}
|
22
|
+
|
23
|
+
def color(color)
|
24
|
+
to_ansi("3#{COLORS[color]}")
|
25
|
+
end
|
26
|
+
|
27
|
+
def bg_color(color)
|
28
|
+
to_ansi("4#{COLORS[color]}")
|
29
|
+
end
|
30
|
+
|
31
|
+
def style(style)
|
32
|
+
to_ansi(STYLES[style])
|
33
|
+
end
|
34
|
+
|
35
|
+
def to_ansi(code)
|
36
|
+
"\e[#{code.to_i}m#{self}\e[0m"
|
37
|
+
end
|
38
|
+
|
39
|
+
def to_pure
|
40
|
+
gsub(/\x1B\[[0-9]{1,3}[mK]/, '')
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
$LOAD_PATH << File.expand_path('../lib', __FILE__)
|
2
|
+
require 'safe_colorize/version'
|
3
|
+
|
4
|
+
Gem::Specification.new do |spec|
|
5
|
+
spec.name = 'safe_colorize'
|
6
|
+
spec.version = SafeColorize::VERSION
|
7
|
+
spec.authors = ['kaihar4']
|
8
|
+
spec.email = ['kaihar4@gmail.com']
|
9
|
+
spec.summary = 'Safe coloring extensions of String.'
|
10
|
+
spec.description = spec.summary
|
11
|
+
spec.homepage = 'https://github.com/kaihar4/safe_colorize'
|
12
|
+
spec.license = 'MIT'
|
13
|
+
|
14
|
+
spec.files = `git ls-files -z`.split("\x0")
|
15
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
16
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
17
|
+
spec.require_paths = ['lib']
|
18
|
+
|
19
|
+
spec.add_development_dependency 'bundler', '~> 1.7'
|
20
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
21
|
+
end
|
metadata
ADDED
@@ -0,0 +1,80 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: safe_colorize
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- kaihar4
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-10-14 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.7'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.7'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
description: Safe coloring extensions of String.
|
42
|
+
email:
|
43
|
+
- kaihar4@gmail.com
|
44
|
+
executables: []
|
45
|
+
extensions: []
|
46
|
+
extra_rdoc_files: []
|
47
|
+
files:
|
48
|
+
- ".gitignore"
|
49
|
+
- Gemfile
|
50
|
+
- LICENSE.txt
|
51
|
+
- README.md
|
52
|
+
- Rakefile
|
53
|
+
- lib/safe_colorize.rb
|
54
|
+
- lib/safe_colorize/version.rb
|
55
|
+
- safe_colorize.gemspec
|
56
|
+
homepage: https://github.com/kaihar4/safe_colorize
|
57
|
+
licenses:
|
58
|
+
- MIT
|
59
|
+
metadata: {}
|
60
|
+
post_install_message:
|
61
|
+
rdoc_options: []
|
62
|
+
require_paths:
|
63
|
+
- lib
|
64
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
70
|
+
requirements:
|
71
|
+
- - ">="
|
72
|
+
- !ruby/object:Gem::Version
|
73
|
+
version: '0'
|
74
|
+
requirements: []
|
75
|
+
rubyforge_project:
|
76
|
+
rubygems_version: 2.2.2
|
77
|
+
signing_key:
|
78
|
+
specification_version: 4
|
79
|
+
summary: Safe coloring extensions of String.
|
80
|
+
test_files: []
|