colorit 0.3.0 → 0.3.1
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.
- data/CHANGELOG.md +3 -0
- data/README.md +3 -1
- data/bin/colorit +1 -1
- data/lib/colorit/command.rb +8 -6
- data/lib/colorit/version.rb +1 -1
- metadata +7 -7
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -2,6 +2,8 @@
|
|
2
2
|
|
3
3
|
Colorit colors your console outputs with the use of regular expressions and marks words for you in fancy colors.
|
4
4
|
|
5
|
+
[](https://codeclimate.com/github/domnikl/colorit)
|
6
|
+
|
5
7
|
## Example
|
6
8
|
|
7
9
|
This simple example will `tail -f` the systems auth.log file and mark all occurences of *root* in red and of *CRON* in green.
|
@@ -47,4 +49,4 @@ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
47
49
|
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
48
50
|
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
49
51
|
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
50
|
-
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
52
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/bin/colorit
CHANGED
data/lib/colorit/command.rb
CHANGED
@@ -33,16 +33,18 @@ module Colorit
|
|
33
33
|
|
34
34
|
# run the command line tool on the stream_source (ARGF in most cases)
|
35
35
|
#
|
36
|
-
def run(
|
37
|
-
colors = prepare_patterns
|
36
|
+
def run(input, output)
|
37
|
+
colors = prepare_patterns if output.tty?
|
38
38
|
|
39
39
|
begin
|
40
|
-
|
41
|
-
|
42
|
-
|
40
|
+
input.each do |line|
|
41
|
+
if output.tty?
|
42
|
+
colors.each do |color, pattern|
|
43
|
+
line = line.colorize(pattern, color)
|
44
|
+
end
|
43
45
|
end
|
44
46
|
|
45
|
-
puts line
|
47
|
+
output.puts line
|
46
48
|
end
|
47
49
|
rescue SystemExit, Interrupt
|
48
50
|
# do nothing but leaving the loop to exit ...
|
data/lib/colorit/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: colorit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-12-
|
12
|
+
date: 2012-12-13 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: colorit colors your console outputs using regular expressions to emphasize
|
15
15
|
special words in e.g. logfiles
|
@@ -21,12 +21,12 @@ extensions: []
|
|
21
21
|
extra_rdoc_files: []
|
22
22
|
files:
|
23
23
|
- bin/colorit
|
24
|
-
- lib/colorit
|
25
|
-
- lib/colorit/command.rb
|
24
|
+
- lib/colorit.rb
|
26
25
|
- lib/colorit/config.rb
|
27
|
-
- lib/colorit/
|
26
|
+
- lib/colorit/command.rb
|
27
|
+
- lib/colorit/colors.rb
|
28
28
|
- lib/colorit/version.rb
|
29
|
-
- lib/colorit.rb
|
29
|
+
- lib/colorit/string.rb
|
30
30
|
- README.md
|
31
31
|
- CHANGELOG.md
|
32
32
|
homepage: https://github.com/domnikl/colorit
|
@@ -49,7 +49,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
49
49
|
version: 1.3.6
|
50
50
|
requirements: []
|
51
51
|
rubyforge_project:
|
52
|
-
rubygems_version: 1.8.
|
52
|
+
rubygems_version: 1.8.24
|
53
53
|
signing_key:
|
54
54
|
specification_version: 3
|
55
55
|
summary: colors your console outputs
|