spiffup 1.0.0 → 1.1.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/README.md +11 -0
- data/lib/spiffup/version.rb +1 -1
- data/lib/spiffup.rb +21 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 224cf81f22e7b7724a1267d6e2a9c3de797ee285
|
4
|
+
data.tar.gz: 6b990cfbb08131a0ec79c664e7c0d0abbe11ae71
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5dbcc86e81000394d1d7e866f24ebbb997a275a38b22499a3b097021585dcf8d0411f78c79437bbcc800ab72d974b581e7c4be5596398fdab3e673d578668c6a
|
7
|
+
data.tar.gz: 7a4b24a95fed43ba2d80dd3a03f9ffdcfadd3582e8d7c6c857972670f508f6206c2420f4070f15a0d13879de2e8f9a02f15ccb0251e0b23b76dd809ce1dea367
|
data/README.md
CHANGED
@@ -44,6 +44,17 @@ price = "#{amount} #{currency}"
|
|
44
44
|
puts "Total price: #{price.green}"
|
45
45
|
```
|
46
46
|
|
47
|
+
### Disabling colors
|
48
|
+
|
49
|
+
It may happen that a project should be configurable, such that in some environments it produces color output but not in some others.
|
50
|
+
|
51
|
+
This can be addressed via the _disable_color_ method - calling it will disable all color output (no control characters will be produced):
|
52
|
+
|
53
|
+
```ruby
|
54
|
+
require 'spiffup'
|
55
|
+
Spiffup.disable_color unless CONFIG[:color_enabled]
|
56
|
+
```
|
57
|
+
|
47
58
|
### Available Colors
|
48
59
|
|
49
60
|
The 8 classical terminal colors are available as the following:
|
data/lib/spiffup/version.rb
CHANGED
data/lib/spiffup.rb
CHANGED
@@ -10,4 +10,25 @@ require 'spiffup/string_color'
|
|
10
10
|
# Spiffup Module:
|
11
11
|
# Root Module for Spiffup.
|
12
12
|
module Spiffup
|
13
|
+
|
14
|
+
# Disable color:
|
15
|
+
# Disables color output (makes everything un-colored).
|
16
|
+
def self.disable_color
|
17
|
+
|
18
|
+
# Drop Terminal Colors
|
19
|
+
TermColor::COLS.each do |col, _idx|
|
20
|
+
|
21
|
+
# Clear Constants
|
22
|
+
remove_const col.upcase
|
23
|
+
remove_const "B#{col.upcase}"
|
24
|
+
const_set col.upcase, ''
|
25
|
+
const_set "B#{col.upcase}", ''
|
26
|
+
|
27
|
+
# Clear String Methods
|
28
|
+
String.send(:define_method, col) { self }
|
29
|
+
String.send(:define_method, "b#{col}") { self }
|
30
|
+
end
|
31
|
+
|
32
|
+
nil
|
33
|
+
end
|
13
34
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: spiffup
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Eresse
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-05-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|