ripl-color_streams 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,18 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require 'rubygems' unless Object.const_defined?(:Gem)
3
+ require File.dirname(__FILE__) + "/lib/ripl/color_streams"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "ripl-color_streams"
7
+ s.version = Ripl::ColorStreams::VERSION
8
+ s.authors = ["Jan Lelis"]
9
+ s.email = "mail@janlelis.de"
10
+ s.homepage = "http://github.com/janlelis/ripl-color_streams"
11
+ s.summary = "A ripl plugin to colorize stdout and stderr."
12
+ s.description = "This ripl plugin colorizes your stdout and stderr streams."
13
+ s.required_rubygems_version = ">= 1.3.6"
14
+ s.add_dependency 'ripl', '>= 0.2.3'
15
+ s.files = Dir.glob(%w[{lib,test}/**/*.rb bin/* [A-Z]*.{txt,rdoc} ext/**/*.{rb,c} **/deps.rip]) + %w{Rakefile .gemspec}
16
+ s.extra_rdoc_files = ["README.rdoc", "LICENSE.txt"]
17
+ s.license = 'MIT'
18
+ end
@@ -0,0 +1,2 @@
1
+ == 0.1.0
2
+ * Initial release.
@@ -0,0 +1,22 @@
1
+ The MIT LICENSE
2
+
3
+ Copyright (c) 2010 Jan Lelis
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,22 @@
1
+ == Description
2
+ This {ripl}[http://github.com/cldwalker/ripl] plugin colorizes your +stdout+ and +stderr+ streams.
3
+
4
+ == Install
5
+ Install the gem with:
6
+
7
+ sudo gem install ripl-color_streams
8
+
9
+ == Usage
10
+
11
+ Add to your ~/.riplrc
12
+
13
+ require 'ripl/color_streams'
14
+
15
+ The default colors are :dark_gray (1;30) and :light_red (1;31). You can change them like this:
16
+
17
+ Ripl.config[:color_streams_stdout] = :light_gray
18
+ Ripl.config[:color_streams_stderr] = :red
19
+
20
+ You can get a list of available colors with <tt>Ripl::ColorStreams::COLORS</tt>. It's also possible to directly set an ansi-escape string as value.
21
+
22
+ J-_-L
@@ -0,0 +1,35 @@
1
+ require 'rake'
2
+ require 'fileutils'
3
+
4
+ def gemspec
5
+ @gemspec ||= eval(File.read('.gemspec'), binding, '.gemspec')
6
+ end
7
+
8
+ desc "Build the gem"
9
+ task :gem=>:gemspec do
10
+ sh "gem build .gemspec"
11
+ FileUtils.mkdir_p 'pkg'
12
+ FileUtils.mv "#{gemspec.name}-#{gemspec.version}.gem", 'pkg'
13
+ end
14
+
15
+ desc "Install the gem locally"
16
+ task :install => :gem do
17
+ sh %{gem install pkg/#{gemspec.name}-#{gemspec.version}}
18
+ end
19
+
20
+ desc "Generate the gemspec"
21
+ task :generate do
22
+ puts gemspec.to_ruby
23
+ end
24
+
25
+ desc "Validate the gemspec"
26
+ task :gemspec do
27
+ gemspec.validate
28
+ end
29
+
30
+ desc 'Run tests'
31
+ task :test do |t|
32
+ sh 'bacon -q -Ilib -I. test/*_test.rb'
33
+ end
34
+
35
+ task :default => :test
@@ -0,0 +1 @@
1
+ ripl >=0.2.3
@@ -0,0 +1,74 @@
1
+ require 'ripl'
2
+
3
+ module Ripl
4
+ module ColorStreams
5
+ VERSION = '0.1.0'
6
+ COLORS = {
7
+ :nothing => '0;0',
8
+ :black => '0;30',
9
+ :red => '0;31',
10
+ :green => '0;32',
11
+ :brown => '0;33',
12
+ :blue => '0;34',
13
+ :purple => '0;35',
14
+ :cyan => '0;36',
15
+ :light_gray => '0;37',
16
+ :dark_gray => '1;30',
17
+ :light_red => '1;31',
18
+ :light_green => '1;32',
19
+ :yellow => '1;33',
20
+ :light_blue => '1;34',
21
+ :light_purple => '1;35',
22
+ :light_cyan => '1;36',
23
+ :white => '1;37',
24
+ }
25
+
26
+ def before_loop
27
+ # patch stream output (but do not activate)
28
+ $stdout.instance_eval do
29
+ alias real_write write
30
+ def color_write(*args)
31
+ Ripl::ColorStreams.write_stream :stdout, *args
32
+ end
33
+ end
34
+
35
+ $stderr.instance_eval do
36
+ alias real_write write
37
+ def color_write(*args)
38
+ Ripl::ColorStreams.write_stream :stderr, *args
39
+ end
40
+ end
41
+
42
+ # default settings
43
+ Ripl.config[:color_streams_stdout] ||= :dark_gray
44
+ Ripl.config[:color_streams_stderr] ||= :light_red
45
+
46
+ # call ripl / next plugin
47
+ super
48
+ end
49
+
50
+ def loop_eval(input)
51
+ $stdout.instance_eval do alias write color_write end
52
+ $stderr.instance_eval do alias write color_write end
53
+ super
54
+ ensure
55
+ $stdout.instance_eval do alias write real_write end
56
+ $stderr.instance_eval do alias write real_write end
57
+ end
58
+
59
+ class << self
60
+ def write_stream(stream_name, data)
61
+ stream = Object.const_get stream_name.to_s.upcase
62
+ color_config = Ripl.config[ ('color_streams_' + stream_name.to_s).to_sym ]
63
+ color_code = !color_config || color_config.to_s[/^[\d;]+$/] ?
64
+ color_config : Ripl::ColorStreams::COLORS[color_config.to_sym]
65
+
66
+ stream.real_write color_code ? "\e[#{ color_code }m#{ data }\e[0;0m" : data.to_s
67
+ end
68
+ end
69
+ end
70
+ end
71
+
72
+ Ripl::Shell.send :include, Ripl::ColorStreams if defined? Ripl::Shell
73
+
74
+ # J-_-L
metadata ADDED
@@ -0,0 +1,91 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ripl-color_streams
3
+ version: !ruby/object:Gem::Version
4
+ hash: 27
5
+ prerelease: false
6
+ segments:
7
+ - 0
8
+ - 1
9
+ - 0
10
+ version: 0.1.0
11
+ platform: ruby
12
+ authors:
13
+ - Jan Lelis
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2010-11-17 00:00:00 +01:00
19
+ default_executable:
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ name: ripl
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ hash: 17
30
+ segments:
31
+ - 0
32
+ - 2
33
+ - 3
34
+ version: 0.2.3
35
+ type: :runtime
36
+ version_requirements: *id001
37
+ description: This ripl plugin colorizes your stdout and stderr streams.
38
+ email: mail@janlelis.de
39
+ executables: []
40
+
41
+ extensions: []
42
+
43
+ extra_rdoc_files:
44
+ - README.rdoc
45
+ - LICENSE.txt
46
+ files:
47
+ - lib/ripl/color_streams.rb
48
+ - LICENSE.txt
49
+ - README.rdoc
50
+ - CHANGELOG.rdoc
51
+ - deps.rip
52
+ - Rakefile
53
+ - .gemspec
54
+ has_rdoc: true
55
+ homepage: http://github.com/janlelis/ripl-color_streams
56
+ licenses:
57
+ - MIT
58
+ post_install_message:
59
+ rdoc_options: []
60
+
61
+ require_paths:
62
+ - lib
63
+ required_ruby_version: !ruby/object:Gem::Requirement
64
+ none: false
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ hash: 3
69
+ segments:
70
+ - 0
71
+ version: "0"
72
+ required_rubygems_version: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ">="
76
+ - !ruby/object:Gem::Version
77
+ hash: 23
78
+ segments:
79
+ - 1
80
+ - 3
81
+ - 6
82
+ version: 1.3.6
83
+ requirements: []
84
+
85
+ rubyforge_project:
86
+ rubygems_version: 1.3.7
87
+ signing_key:
88
+ specification_version: 3
89
+ summary: A ripl plugin to colorize stdout and stderr.
90
+ test_files: []
91
+