Class: ColorizeFilter
- Inherits:
-
Object
- Object
- ColorizeFilter
- Defined in:
- lib/wee-pm/colorize_filter.rb
Instance Method Summary collapse
-
#initialize(ruby_bin = "ruby", colorize_bin = File.join(File.dirname(__FILE__), "colorize.rb")) ⇒ ColorizeFilter
constructor
A new instance of ColorizeFilter.
- #run(lines, port, lang = "__auto__", filename = "") ⇒ Object
Constructor Details
#initialize(ruby_bin = "ruby", colorize_bin = File.join(File.dirname(__FILE__), "colorize.rb")) ⇒ ColorizeFilter
Returns a new instance of ColorizeFilter.
2 3 4 |
# File 'lib/wee-pm/colorize_filter.rb', line 2 def initialize(ruby_bin="ruby", colorize_bin=File.join(File.dirname(__FILE__), "colorize.rb")) @ruby_bin, @colorize_bin = ruby_bin, colorize_bin end |
Instance Method Details
#run(lines, port, lang = "__auto__", filename = "") ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/wee-pm/colorize_filter.rb', line 6 def run(lines, port, lang="__auto__", filename="") lang ||= '__auto__' cmd = "#{ @ruby_bin } #{ @colorize_bin } --cache --terminal=xterm-color --strip-ws --lang=#{ lang }" if lines.nil? cmd << " " + filename end IO.popen(cmd, "w+") { |f| if lines f << lines f.close_write end port << f.read } end |