color_puts 0.0.0
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.
- checksums.yaml +7 -0
- data/.gitignore +10 -0
- data/Gemfile +2 -0
- data/README.md +50 -0
- data/color_puts.gemspec +20 -0
- data/color_puts.gemspec.lock +3 -0
- data/lib/color_puts.rb +43 -0
- data/lib/color_puts/version.rb +3 -0
- metadata +64 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: ce6017de43a93b4674922740d9a576f2250055fd
|
4
|
+
data.tar.gz: 545fe5b927a1e900f89f9f544c44a1e851e79cdf
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 1a1279e04c732a32fd0fb018de8cac5e99a0944a63bdc189a96caeeea28cd03e1ead746cd9ef649f9c6c56e66dd226515310cfa347a88a90a8e7588785a0f2e1
|
7
|
+
data.tar.gz: 0207c4bba8ab2d4b8c1b384c9c97669f550c22aa76e98e157675a4d9aeed02276134851f1c061f60457a3598d83cd2d5a71287c84dc097a283afbb73aa5872cb
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/README.md
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
# ColorPuts
|
2
|
+
|
3
|
+
Color your output with inline color codes.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'color_puts'
|
11
|
+
```
|
12
|
+
|
13
|
+
## Usage
|
14
|
+
|
15
|
+
Example:
|
16
|
+
|
17
|
+
```ruby
|
18
|
+
include ColorPuts
|
19
|
+
|
20
|
+
cputs "There was a %green{field} and %blue{sky}."
|
21
|
+
```
|
22
|
+
|
23
|
+
## Colors
|
24
|
+
|
25
|
+
List of colors names:
|
26
|
+
|
27
|
+
```
|
28
|
+
black
|
29
|
+
dblue
|
30
|
+
dgreen
|
31
|
+
dcyan
|
32
|
+
dred
|
33
|
+
dpurple
|
34
|
+
dgray
|
35
|
+
brown
|
36
|
+
gray
|
37
|
+
blue
|
38
|
+
green
|
39
|
+
cyan
|
40
|
+
red
|
41
|
+
purple
|
42
|
+
yellow
|
43
|
+
white
|
44
|
+
```
|
45
|
+
|
46
|
+
|
47
|
+
## Contributing
|
48
|
+
|
49
|
+
Contributions are welcome!
|
50
|
+
|
data/color_puts.gemspec
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'color_puts/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "color_puts"
|
8
|
+
spec.version = ColorPuts::VERSION
|
9
|
+
spec.authors = ["Ingemar"]
|
10
|
+
spec.email = ["ingemar@xox.se"]
|
11
|
+
|
12
|
+
spec.summary = %q{Color your output text}
|
13
|
+
spec.description = %q{Color your output with inline color codes}
|
14
|
+
spec.homepage = "https://github.com/ingemar/color_puts"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
17
|
+
spec.require_paths = ["lib"]
|
18
|
+
|
19
|
+
spec.add_development_dependency "bundler", "~> 1.11"
|
20
|
+
end
|
data/lib/color_puts.rb
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
require "color_puts/version"
|
2
|
+
|
3
|
+
module ColorPuts
|
4
|
+
COLORS = {
|
5
|
+
black: '0;30',
|
6
|
+
dblue: '0;34',
|
7
|
+
dgreen: '0;32',
|
8
|
+
dcyan: '0;36',
|
9
|
+
dred: '0;31',
|
10
|
+
dpurple: '0;35',
|
11
|
+
dgray: '1;30',
|
12
|
+
brown: '0;33',
|
13
|
+
gray: '0;37',
|
14
|
+
blue: '1;34',
|
15
|
+
green: '1;32',
|
16
|
+
cyan: '1;36',
|
17
|
+
red: '1;31',
|
18
|
+
purple: '1;35',
|
19
|
+
yellow: '1;33',
|
20
|
+
white: '1;37'
|
21
|
+
}
|
22
|
+
|
23
|
+
# Example:
|
24
|
+
#
|
25
|
+
# cputs "There was a %green{field} and %blue{sky}."
|
26
|
+
#
|
27
|
+
def cputs(string = "")
|
28
|
+
regexp = /%(\w+)\{[^}]*./
|
29
|
+
text_regexp = /%\w+{(.*)}/
|
30
|
+
|
31
|
+
string = string.dup
|
32
|
+
|
33
|
+
while m = string.match(regexp) do
|
34
|
+
string.gsub!(m.to_s) do |s|
|
35
|
+
color = ColorPuts::COLORS[m.captures.first.to_sym]
|
36
|
+
text = s.match(text_regexp).captures.first
|
37
|
+
"\e[#{color}m#{text}\e[0;39m"
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
puts string
|
42
|
+
end
|
43
|
+
end
|
metadata
ADDED
@@ -0,0 +1,64 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: color_puts
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Ingemar
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-02-22 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.11'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.11'
|
27
|
+
description: Color your output with inline color codes
|
28
|
+
email:
|
29
|
+
- ingemar@xox.se
|
30
|
+
executables: []
|
31
|
+
extensions: []
|
32
|
+
extra_rdoc_files: []
|
33
|
+
files:
|
34
|
+
- ".gitignore"
|
35
|
+
- Gemfile
|
36
|
+
- README.md
|
37
|
+
- color_puts.gemspec
|
38
|
+
- color_puts.gemspec.lock
|
39
|
+
- lib/color_puts.rb
|
40
|
+
- lib/color_puts/version.rb
|
41
|
+
homepage: https://github.com/ingemar/color_puts
|
42
|
+
licenses: []
|
43
|
+
metadata: {}
|
44
|
+
post_install_message:
|
45
|
+
rdoc_options: []
|
46
|
+
require_paths:
|
47
|
+
- lib
|
48
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
49
|
+
requirements:
|
50
|
+
- - ">="
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
version: '0'
|
53
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
54
|
+
requirements:
|
55
|
+
- - ">="
|
56
|
+
- !ruby/object:Gem::Version
|
57
|
+
version: '0'
|
58
|
+
requirements: []
|
59
|
+
rubyforge_project:
|
60
|
+
rubygems_version: 2.4.6
|
61
|
+
signing_key:
|
62
|
+
specification_version: 4
|
63
|
+
summary: Color your output text
|
64
|
+
test_files: []
|