strings-ansi 0.1.0 → 0.2.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 +4 -4
- data/CHANGELOG.md +9 -1
- data/README.md +22 -7
- data/lib/strings/ansi/version.rb +1 -1
- data/spec/spec_helper.rb +5 -3
- data/spec/unit/sanitize_spec.rb +1 -1
- data/strings-ansi.gemspec +16 -7
- data/tasks/console.rake +5 -5
- data/tasks/coverage.rake +5 -5
- data/tasks/spec.rake +8 -8
- metadata +21 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a966ca7d6455dbc43c9e2c93124304c5ae31c0b1b26dfe9e6f469bda773f25d6
|
4
|
+
data.tar.gz: a39fc8ed1d904fc3dfcca887a5a24e27daae0a9e97b3d8aad487768261444898
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 61de476ad781d4e08d90a76486c1b696672693a5087fb691008c6203e4bc59da0df8542d7fb034bafb911b904bf998e773c98be2fc366f9560f50ceb3e7eb07b
|
7
|
+
data.tar.gz: 526b28d9c1b4a85230bc30f20a954cf992f00e701cdc7b399bb6095f45459ac86f358cfb85ade8a5d2930b673750d90913dae063e21834b32a889f09c8f7228c
|
data/CHANGELOG.md
CHANGED
@@ -1,7 +1,15 @@
|
|
1
1
|
# Change log
|
2
2
|
|
3
|
+
## [v0.2.0] - 2019-11-12
|
4
|
+
|
5
|
+
### Change
|
6
|
+
* Change gemspec to include metadata
|
7
|
+
* Change gemspec to limit Ruby version to >= 2.0
|
8
|
+
* Change gemspec to relax dev dependency of bundler version
|
9
|
+
|
3
10
|
## [v0.1.0] - 2018-08-27
|
4
11
|
|
5
|
-
*
|
12
|
+
* Initial implementation and release
|
6
13
|
|
14
|
+
[v0.2.0]: https://github.com/piotrmurach/strings-ansi/compare/v0.1.0...v0.2.0
|
7
15
|
[v0.1.0]: https://github.com/piotrmurach/strings-ansi/compare/v0.1.0
|
data/README.md
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
<div align="center">
|
2
|
-
<img width="225" src="https://
|
2
|
+
<img width="225" src="https://github.com/piotrmurach/strings/blob/master/assets/strings_logo.png" alt="strings logo" />
|
3
3
|
</div>
|
4
4
|
|
5
5
|
# Strings::ANSI
|
@@ -20,7 +20,7 @@
|
|
20
20
|
|
21
21
|
> Handle ANSI escape codes in strings.
|
22
22
|
|
23
|
-
**Strings::ANSI** provides ANSI handling for [Strings](https://github.com/piotrmurach/strings)
|
23
|
+
**Strings::ANSI** provides ANSI handling component for [Strings](https://github.com/piotrmurach/strings).
|
24
24
|
|
25
25
|
## Installation
|
26
26
|
|
@@ -49,10 +49,25 @@ Or install it yourself as:
|
|
49
49
|
|
50
50
|
## Usage
|
51
51
|
|
52
|
-
The `Strings::ANSI` is a module
|
52
|
+
The `Strings::ANSI` is a module that can check if a string has ANSI escape codes:
|
53
53
|
|
54
54
|
```ruby
|
55
|
-
Strings::ANSI.ansi?(
|
55
|
+
Strings::ANSI.ansi?("\e[32mHello\e[0m")
|
56
|
+
# => true
|
57
|
+
```
|
58
|
+
|
59
|
+
It can also check if a string consists of only ANSI codes:
|
60
|
+
|
61
|
+
```ruby
|
62
|
+
Strings::ANSI.only_ansi?("\e[32mHello\e[0m")
|
63
|
+
# => false
|
64
|
+
```
|
65
|
+
|
66
|
+
Finally, you can remove any ANSI codes from a string:
|
67
|
+
|
68
|
+
```ruby
|
69
|
+
Strings::ANSI.sanitize("\e[32mHello\e[0m")
|
70
|
+
# => "Hello"
|
56
71
|
```
|
57
72
|
|
58
73
|
## 2. API
|
@@ -86,7 +101,7 @@ Strings::ANSI.sanitize("\e[0;33;49mHello\e[0m")
|
|
86
101
|
|
87
102
|
## 3. Extending String class
|
88
103
|
|
89
|
-
Though it is highly discouraged to
|
104
|
+
Though it is highly discouraged to pollute core Ruby classes, you can add the required methods to `String` class by using refinements.
|
90
105
|
|
91
106
|
For example, if you wish to only extend strings with `sanitize` method do:
|
92
107
|
|
@@ -100,7 +115,7 @@ module MyStringExt
|
|
100
115
|
end
|
101
116
|
```
|
102
117
|
|
103
|
-
|
118
|
+
This will make `sanitize` method available for any strings where refinement is applied:
|
104
119
|
|
105
120
|
```ruby
|
106
121
|
using MyStringExt
|
@@ -133,7 +148,7 @@ The gem is available as open source under the terms of the [MIT License](https:/
|
|
133
148
|
|
134
149
|
## Code of Conduct
|
135
150
|
|
136
|
-
Everyone interacting in the Strings::
|
151
|
+
Everyone interacting in the Strings::ANSI project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/piotrmurach/strings-ansi/blob/master/CODE_OF_CONDUCT.md).
|
137
152
|
|
138
153
|
## Copyright
|
139
154
|
|
data/lib/strings/ansi/version.rb
CHANGED
data/spec/spec_helper.rb
CHANGED
@@ -1,11 +1,13 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
if ENV['COVERAGE'] || ENV['TRAVIS']
|
2
4
|
require 'simplecov'
|
3
5
|
require 'coveralls'
|
4
6
|
|
5
|
-
SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
|
7
|
+
SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter.new([
|
6
8
|
SimpleCov::Formatter::HTMLFormatter,
|
7
9
|
Coveralls::SimpleCov::Formatter
|
8
|
-
]
|
10
|
+
])
|
9
11
|
|
10
12
|
SimpleCov.start do
|
11
13
|
command_name 'spec'
|
@@ -14,7 +16,7 @@ if ENV['COVERAGE'] || ENV['TRAVIS']
|
|
14
16
|
end
|
15
17
|
|
16
18
|
require "bundler/setup"
|
17
|
-
require "strings
|
19
|
+
require "strings-ansi"
|
18
20
|
|
19
21
|
RSpec.configure do |config|
|
20
22
|
# Enable flags like --only-failures and --next-failure
|
data/spec/unit/sanitize_spec.rb
CHANGED
@@ -12,7 +12,7 @@ RSpec.describe Strings::ANSI, '#sanitize' do
|
|
12
12
|
"\eA" => '',
|
13
13
|
"\e[0;33;49;3;9;4m\e[0m" => ''
|
14
14
|
}.each do |code, expected|
|
15
|
-
it "
|
15
|
+
it "removes #{code.inspect} from string" do
|
16
16
|
expect(Strings::ANSI.sanitize(code)).to eq(expected)
|
17
17
|
end
|
18
18
|
end
|
data/strings-ansi.gemspec
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
|
2
1
|
lib = File.expand_path("../lib", __FILE__)
|
3
2
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
3
|
require "strings/ansi/version"
|
@@ -7,19 +6,29 @@ Gem::Specification.new do |spec|
|
|
7
6
|
spec.name = "strings-ansi"
|
8
7
|
spec.version = Strings::ANSI::VERSION
|
9
8
|
spec.authors = ["Piotr Murach"]
|
10
|
-
spec.email = [""]
|
9
|
+
spec.email = ["me@piotrmurach.com"]
|
11
10
|
|
12
11
|
spec.summary = %q{Methods for processing ANSI escape codes in strings.}
|
13
12
|
spec.description = %q{Methods for processing ANSI escape codes in strings.}
|
14
|
-
spec.homepage = "https://github.com/piotrmurach/strings"
|
13
|
+
spec.homepage = "https://github.com/piotrmurach/strings-ansi"
|
15
14
|
spec.license = "MIT"
|
16
15
|
|
17
|
-
spec.
|
18
|
-
spec.
|
16
|
+
spec.metadata["allowed_push_host"] = "https://rubygems.org"
|
17
|
+
spec.metadata["bug_tracker_uri"] = "https://github.com/piotrmurach/strings-ansi/issues"
|
18
|
+
spec.metadata["changelog_uri"] = "https://github.com/piotrmurach/strings-ansi/blob/master/CHANGELOG.md"
|
19
|
+
spec.metadata["documentation_uri"] = "https://www.rubydoc.info/gems/strings-ansi"
|
20
|
+
spec.metadata["homepage_uri"] = spec.homepage
|
21
|
+
spec.metadata["source_code_uri"] = "https://github.com/piotrmurach/strings-ansi"
|
22
|
+
|
23
|
+
spec.files = Dir["{lib,spec}/**/*.rb"]
|
24
|
+
spec.files += Dir["{bin,tasks}/*", "strings-ansi.gemspec"]
|
25
|
+
spec.files += Dir["README.md", "CHANGELOG.md", "LICENSE.txt", "Rakefile"]
|
19
26
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
20
27
|
spec.require_paths = ["lib"]
|
21
28
|
|
22
|
-
spec.
|
23
|
-
|
29
|
+
spec.required_ruby_version = ">= 2.0.0"
|
30
|
+
|
31
|
+
spec.add_development_dependency "bundler", ">= 1.5"
|
32
|
+
spec.add_development_dependency "rake"
|
24
33
|
spec.add_development_dependency "rspec", "~> 3.0"
|
25
34
|
end
|
data/tasks/console.rake
CHANGED
@@ -1,10 +1,10 @@
|
|
1
|
-
#
|
1
|
+
# frozen_string_literal: true
|
2
2
|
|
3
|
-
desc
|
3
|
+
desc "Load gem inside irb console"
|
4
4
|
task :console do
|
5
|
-
require
|
6
|
-
require
|
7
|
-
require File.join(__FILE__,
|
5
|
+
require "irb"
|
6
|
+
require "irb/completion"
|
7
|
+
require File.join(__FILE__, "../../lib/strings-ansi")
|
8
8
|
ARGV.clear
|
9
9
|
IRB.start
|
10
10
|
end
|
data/tasks/coverage.rake
CHANGED
@@ -1,11 +1,11 @@
|
|
1
|
-
#
|
1
|
+
# frozen_string_literal: true
|
2
2
|
|
3
|
-
desc
|
3
|
+
desc "Measure code coverage"
|
4
4
|
task :coverage do
|
5
5
|
begin
|
6
|
-
original, ENV[
|
7
|
-
Rake::Task[
|
6
|
+
original, ENV["COVERAGE"] = ENV["COVERAGE"], "true"
|
7
|
+
Rake::Task["spec"].invoke
|
8
8
|
ensure
|
9
|
-
ENV[
|
9
|
+
ENV["COVERAGE"] = original
|
10
10
|
end
|
11
11
|
end
|
data/tasks/spec.rake
CHANGED
@@ -1,22 +1,22 @@
|
|
1
|
-
#
|
1
|
+
# frozen_string_literal: true
|
2
2
|
|
3
3
|
begin
|
4
|
-
require
|
4
|
+
require "rspec/core/rake_task"
|
5
5
|
|
6
|
-
desc
|
6
|
+
desc "Run all specs"
|
7
7
|
RSpec::Core::RakeTask.new(:spec) do |task|
|
8
|
-
task.pattern =
|
8
|
+
task.pattern = "spec/{unit,integration}{,/*/**}/*_spec.rb"
|
9
9
|
end
|
10
10
|
|
11
11
|
namespace :spec do
|
12
|
-
desc
|
12
|
+
desc "Run unit specs"
|
13
13
|
RSpec::Core::RakeTask.new(:unit) do |task|
|
14
|
-
task.pattern =
|
14
|
+
task.pattern = "spec/unit{,/*/**}/*_spec.rb"
|
15
15
|
end
|
16
16
|
|
17
|
-
desc
|
17
|
+
desc "Run integration specs"
|
18
18
|
RSpec::Core::RakeTask.new(:integration) do |task|
|
19
|
-
task.pattern =
|
19
|
+
task.pattern = "spec/integration{,/*/**}/*_spec.rb"
|
20
20
|
end
|
21
21
|
end
|
22
22
|
|
metadata
CHANGED
@@ -1,43 +1,43 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: strings-ansi
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Piotr Murach
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-11-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '1.
|
19
|
+
version: '1.5'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - "
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '1.
|
26
|
+
version: '1.5'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - "
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
33
|
+
version: '0'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - "
|
38
|
+
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
40
|
+
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rspec
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -54,7 +54,7 @@ dependencies:
|
|
54
54
|
version: '3.0'
|
55
55
|
description: Methods for processing ANSI escape codes in strings.
|
56
56
|
email:
|
57
|
-
-
|
57
|
+
- me@piotrmurach.com
|
58
58
|
executables: []
|
59
59
|
extensions: []
|
60
60
|
extra_rdoc_files: []
|
@@ -78,10 +78,16 @@ files:
|
|
78
78
|
- tasks/console.rake
|
79
79
|
- tasks/coverage.rake
|
80
80
|
- tasks/spec.rake
|
81
|
-
homepage: https://github.com/piotrmurach/strings
|
81
|
+
homepage: https://github.com/piotrmurach/strings-ansi
|
82
82
|
licenses:
|
83
83
|
- MIT
|
84
|
-
metadata:
|
84
|
+
metadata:
|
85
|
+
allowed_push_host: https://rubygems.org
|
86
|
+
bug_tracker_uri: https://github.com/piotrmurach/strings-ansi/issues
|
87
|
+
changelog_uri: https://github.com/piotrmurach/strings-ansi/blob/master/CHANGELOG.md
|
88
|
+
documentation_uri: https://www.rubydoc.info/gems/strings-ansi
|
89
|
+
homepage_uri: https://github.com/piotrmurach/strings-ansi
|
90
|
+
source_code_uri: https://github.com/piotrmurach/strings-ansi
|
85
91
|
post_install_message:
|
86
92
|
rdoc_options: []
|
87
93
|
require_paths:
|
@@ -90,15 +96,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
90
96
|
requirements:
|
91
97
|
- - ">="
|
92
98
|
- !ruby/object:Gem::Version
|
93
|
-
version:
|
99
|
+
version: 2.0.0
|
94
100
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
95
101
|
requirements:
|
96
102
|
- - ">="
|
97
103
|
- !ruby/object:Gem::Version
|
98
104
|
version: '0'
|
99
105
|
requirements: []
|
100
|
-
|
101
|
-
rubygems_version: 2.7.3
|
106
|
+
rubygems_version: 3.0.3
|
102
107
|
signing_key:
|
103
108
|
specification_version: 4
|
104
109
|
summary: Methods for processing ANSI escape codes in strings.
|