simple-ansi 1.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/Gemfile +19 -0
- data/LICENSE +19 -0
- data/Rakefile +10 -0
- data/lib/simple/ansi.rb +70 -0
- data/lib/simple/ansi/version.rb +5 -0
- metadata +49 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 1548d2475544c03d3f186b884d0310ec86704415
|
4
|
+
data.tar.gz: eb01d62e6c6fc4f94ca2db7cfd039d31b6217464
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: dd43a1838cdc40cc44aec0e8071fbc9350928fbc301982a07441d0e10edaab4d3dd994c3046ea6c2d95dbc9387501c5b59d0b26292460fe84cf734507a7628ca
|
7
|
+
data.tar.gz: 1905d770b851830e8c82a654eb19aee55c3c8917e06220667b1ac18d7699c2f6b37ff31d0aa684d857fc635bd88175ec41ad47e5ee171b7fcbf8a95c05538ce2
|
data/Gemfile
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
# Frozen-string-literal: true
|
2
|
+
# Copyright: 2015-2016 Jordon Bedwell - Apache v2.0 License
|
3
|
+
# Encoding: utf-8
|
4
|
+
|
5
|
+
source "https://rubygems.org"
|
6
|
+
gem "rake", :require => false
|
7
|
+
gemspec
|
8
|
+
|
9
|
+
group :test do
|
10
|
+
gem "codeclimate-test-reporter", :require => false
|
11
|
+
end
|
12
|
+
|
13
|
+
group :development do
|
14
|
+
gem "rspec", :require => false
|
15
|
+
gem "guard-rspec", :require => false
|
16
|
+
gem "benchmark-ips", :require => false
|
17
|
+
gem "luna-rspec-formatters", :require => false
|
18
|
+
gem "pry", :require => false
|
19
|
+
end
|
data/LICENSE
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
Copyright (c) 2015-2016 Jordon Bedwell
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the "Software"),
|
5
|
+
to deal in the Software without restriction, including without limitation
|
6
|
+
the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
7
|
+
and/or sell copies of the Software, and to permit persons to whom the
|
8
|
+
Software is furnished to do so, subject to the following conditions:
|
9
|
+
|
10
|
+
The above copyright notice and this permission notice shall be included
|
11
|
+
in all copies or substantial portions of the Software.
|
12
|
+
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
14
|
+
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
18
|
+
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
19
|
+
USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/Rakefile
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
# Frozen-string-literal: true
|
2
|
+
# Copyright: 2015 Jordon Bedwell - Apache v2.0 License
|
3
|
+
# Encoding: utf-8
|
4
|
+
|
5
|
+
$LOAD_PATH.unshift(File.expand_path("../lib", __FILE__))
|
6
|
+
require "rspec/core/rake_task"
|
7
|
+
|
8
|
+
task :default => [:spec]
|
9
|
+
RSpec::Core::RakeTask.new :spec
|
10
|
+
task :test => :spec
|
data/lib/simple/ansi.rb
ADDED
@@ -0,0 +1,70 @@
|
|
1
|
+
# Frozen-string-literal: true
|
2
|
+
# Copyright: 2015-2016 Jordon Bedwell - Apache v2.0 License
|
3
|
+
# Encoding: utf-8
|
4
|
+
|
5
|
+
module Simple
|
6
|
+
module Ansi
|
7
|
+
extend self
|
8
|
+
|
9
|
+
ANSI_MATCH = /#{format("%c", 27)}\[(?:\d+)(?:;\d+)*(j|k|m|s|u|A|B|G)|\e\(B\e\[m/ix.freeze
|
10
|
+
# This tries to match the many types of Ansi's out there, there are more though.
|
11
|
+
|
12
|
+
COLORS = {
|
13
|
+
:red => 31,
|
14
|
+
:green => 32,
|
15
|
+
:black => 30,
|
16
|
+
:magenta => 35,
|
17
|
+
:yellow => 33,
|
18
|
+
:white => 37,
|
19
|
+
:blue => 34,
|
20
|
+
:cyan => 36
|
21
|
+
}.freeze
|
22
|
+
|
23
|
+
#
|
24
|
+
|
25
|
+
def strip(str)
|
26
|
+
str.gsub ANSI_MATCH, ""
|
27
|
+
end
|
28
|
+
|
29
|
+
#
|
30
|
+
|
31
|
+
def clear
|
32
|
+
$stdout.print(format("%c[H%c[2J", 27, 27))
|
33
|
+
end
|
34
|
+
|
35
|
+
#
|
36
|
+
|
37
|
+
def has?(str)
|
38
|
+
str.match(ANSI_MATCH).is_a?(MatchData)
|
39
|
+
end
|
40
|
+
|
41
|
+
# Jump the cursor, moving it up and then back down to it's spot,
|
42
|
+
# allowing you to do fancy things like multiple output (downloads) the
|
43
|
+
# way that Docker does them in an async way without breaking term.
|
44
|
+
|
45
|
+
def jump(str, num)
|
46
|
+
format("%c[%dA%s%c[%dB", 27, num, \
|
47
|
+
clear_line(str), 27, num)
|
48
|
+
end
|
49
|
+
|
50
|
+
#
|
51
|
+
|
52
|
+
def reset(str = "")
|
53
|
+
"#{format("%c[0m", 27)}#{str}"
|
54
|
+
end
|
55
|
+
|
56
|
+
#
|
57
|
+
|
58
|
+
def clear_line(str = "")
|
59
|
+
"#{format("%c[2K\r", 27)}#{str}\r"
|
60
|
+
end
|
61
|
+
|
62
|
+
#
|
63
|
+
|
64
|
+
COLORS.each do |color, num|
|
65
|
+
define_method color do |str|
|
66
|
+
"#{format("%c", 27)}[#{num}m#{str}#{reset}"
|
67
|
+
end; module_function color
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
metadata
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: simple-ansi
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Jordon Bedwell
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-01-03 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: A simple ansi library that does only what it needs to do.
|
14
|
+
email:
|
15
|
+
- jordon@envygeeks.io
|
16
|
+
executables: []
|
17
|
+
extensions: []
|
18
|
+
extra_rdoc_files: []
|
19
|
+
files:
|
20
|
+
- Gemfile
|
21
|
+
- LICENSE
|
22
|
+
- Rakefile
|
23
|
+
- lib/simple/ansi.rb
|
24
|
+
- lib/simple/ansi/version.rb
|
25
|
+
homepage: http://github.com/envygeeks/simple-ansi
|
26
|
+
licenses:
|
27
|
+
- MIT
|
28
|
+
metadata: {}
|
29
|
+
post_install_message:
|
30
|
+
rdoc_options: []
|
31
|
+
require_paths:
|
32
|
+
- lib
|
33
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
34
|
+
requirements:
|
35
|
+
- - ">="
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
39
|
+
requirements:
|
40
|
+
- - ">="
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
version: '0'
|
43
|
+
requirements: []
|
44
|
+
rubyforge_project:
|
45
|
+
rubygems_version: 2.5.1
|
46
|
+
signing_key:
|
47
|
+
specification_version: 4
|
48
|
+
summary: A basic ansi library that does only what it needs to.
|
49
|
+
test_files: []
|