colorit 0.3.0 → 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,4 +1,7 @@
1
1
 
2
+ ## 0.3.1
3
+
4
+ * add colors only if STDOUT is a TTY
2
5
 
3
6
  ## 0.3.0
4
7
 
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
+ [![Code Climate](https://codeclimate.com/badge.png)](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.
@@ -5,4 +5,4 @@ require "#{lib}/colorit"
5
5
 
6
6
  colorit_command = Colorit::Command.new(Colorit::Config.new)
7
7
  colorit_command.parse_options
8
- colorit_command.run(ARGF)
8
+ colorit_command.run(ARGF, $stdout)
@@ -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(stream_source)
37
- colors = prepare_patterns
36
+ def run(input, output)
37
+ colors = prepare_patterns if output.tty?
38
38
 
39
39
  begin
40
- stream_source.each do |line|
41
- colors.each do |color, pattern|
42
- line = line.colorize(pattern, color)
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 ...
@@ -1,3 +1,3 @@
1
1
  module Colorit
2
- VERSION = %w(0 3 0) unless defined?(::Colorit::VERSION)
2
+ VERSION = %w(0 3 1)
3
3
  end
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.0
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 00:00:00.000000000 Z
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/colors.rb
25
- - lib/colorit/command.rb
24
+ - lib/colorit.rb
26
25
  - lib/colorit/config.rb
27
- - lib/colorit/string.rb
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.16
52
+ rubygems_version: 1.8.24
53
53
  signing_key:
54
54
  specification_version: 3
55
55
  summary: colors your console outputs