spiffup 1.0.0 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 329948c2030f3e129ad03d49f68195df2afbac8a
4
- data.tar.gz: 87d32bd94164da5f3705e45b9439690607c8ad6d
3
+ metadata.gz: 224cf81f22e7b7724a1267d6e2a9c3de797ee285
4
+ data.tar.gz: 6b990cfbb08131a0ec79c664e7c0d0abbe11ae71
5
5
  SHA512:
6
- metadata.gz: 67e993a2efb4f5e4546eea42672ce7c52fee41d09bad5380b7a8a63dea79036af50368dba26f58b31a297e3c38f3cffde327a2cdb9f7f710f62a343b05e52772
7
- data.tar.gz: 70f60ea37d368d0906baadd4aceb8c768d975100287ed4cc81d19934a24b04a2f6225180de357a398b2db0c8b56e078b437be15e5511aeb706add51b5324acd9
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:
@@ -5,5 +5,5 @@
5
5
  module Spiffup
6
6
 
7
7
  # Version
8
- VERSION = '1.0.0'
8
+ VERSION = '1.1.0'
9
9
  end
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.0.0
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-03-01 00:00:00.000000000 Z
11
+ date: 2017-05-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler