colorlog 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. data/bin/colorlog +55 -0
  2. metadata +64 -0
data/bin/colorlog ADDED
@@ -0,0 +1,55 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'optparse'
4
+ require 'rainbow'
5
+
6
+ options = {}
7
+ option_parser = OptionParser.new do |opts|
8
+ executable_name = File.basename($PROGRAM_NAME)
9
+ opts.banner = "Read a file and color the lines in " +
10
+ "green".foreground(:green) + ", " +
11
+ "yellow".foreground(:yellow) + " or " +
12
+ "red".foreground(:red) + " based on the content of the line
13
+
14
+ Usage: #{executable_name} [options] filename
15
+
16
+ "
17
+
18
+ options[:green] = "success"
19
+ opts.on('-g', '--green RegExp', 'RegExp that matched will turn the line green') do |green|
20
+ options[:green] = green
21
+ end
22
+
23
+ options[:yellow] = "warning"
24
+ opts.on('-y','--yellow RegExp', 'RegExp that matched will turn the line yellow') do |yellow|
25
+ options[:yellow] = yellow
26
+ end
27
+
28
+ options[:red] = /^(?:(?!\bTests\b).)*(?:failure|error).*$/i
29
+ opts.on('-r', '--red RedExp', 'RegExp that matched will turn the line red') do |red|
30
+ options[:red] = red
31
+ end
32
+
33
+ end
34
+
35
+ option_parser.parse!
36
+
37
+ success_check = Regexp.new(options[:green], Regexp::IGNORECASE)
38
+ warning_check = Regexp.new(options[:yellow], Regexp::IGNORECASE)
39
+ error_check = Regexp.new(options[:red])
40
+
41
+ ARGF.each do |line|
42
+
43
+ color = :default
44
+
45
+ if line =~ success_check
46
+ color = :green
47
+ end
48
+ if line =~ warning_check
49
+ color = :yellow
50
+ end
51
+ if line =~ error_check
52
+ color = :red
53
+ end
54
+ printf("%s".foreground(color), line)
55
+ end
metadata ADDED
@@ -0,0 +1,64 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: colorlog
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Nicolas Hurion
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-08-12 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: rainbow
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
30
+ description: colorlog allow you to read a file with sone lines colored in red, green
31
+ and yellow based on regexp
32
+ email:
33
+ - nicolas at hurion.eu
34
+ executables:
35
+ - colorlog
36
+ extensions: []
37
+ extra_rdoc_files: []
38
+ files:
39
+ - bin/colorlog
40
+ homepage: https://github.com/nhurion/colorlog
41
+ licenses: []
42
+ post_install_message:
43
+ rdoc_options: []
44
+ require_paths:
45
+ - lib
46
+ required_ruby_version: !ruby/object:Gem::Requirement
47
+ none: false
48
+ requirements:
49
+ - - ! '>='
50
+ - !ruby/object:Gem::Version
51
+ version: '0'
52
+ required_rubygems_version: !ruby/object:Gem::Requirement
53
+ none: false
54
+ requirements:
55
+ - - ! '>='
56
+ - !ruby/object:Gem::Version
57
+ version: '0'
58
+ requirements: []
59
+ rubyforge_project:
60
+ rubygems_version: 1.8.24
61
+ signing_key:
62
+ specification_version: 3
63
+ summary: An helper to color logs based on regexp
64
+ test_files: []