Parent

Class Index [+]

Quicksearch

PhusionPassenger::ConsoleTextTemplate

Constants

TEMPLATE_DIR
DEFAULT_TERMINAL_COLORS

Public Class Methods

new(input, options = {}) click to toggle source
    # File lib/phusion_passenger/console_text_template.rb, line 30
30:         def initialize(input, options = {})
31:                 @buffer = ''
32:                 if input[:file]
33:                         data = File.read("#{TEMPLATE_DIR}/#{input[:file]}.txt.erb")
34:                 else
35:                         data = input[:text]
36:                 end
37:                 @template = ERB.new(substitute_color_tags(data),
38:                         nil, nil, '@buffer')
39:                 options.each_pair do |name, value|
40:                         self[name] = value
41:                 end
42:         end

Public Instance Methods

[]=(name, value) click to toggle source
    # File lib/phusion_passenger/console_text_template.rb, line 44
44:         def []=(name, value)
45:                 instance_variable_set("@#{name}".to_sym, value)
46:                 return self
47:         end
result() click to toggle source
    # File lib/phusion_passenger/console_text_template.rb, line 49
49:         def result
50:                 return @template.result(binding)
51:         end

Private Instance Methods

substitute_color_tags(data) click to toggle source
    # File lib/phusion_passenger/console_text_template.rb, line 56
56:         def substitute_color_tags(data)
57:                 data = data.gsub(%{<b>(.*?)</b>}, "\e[1m\\1#{DEFAULT_TERMINAL_COLORS}")
58:                 data.gsub!(%{<red>(.*?)</red>}, "\e[1m\e[31m\\1#{DEFAULT_TERMINAL_COLORS}")
59:                 data.gsub!(%{<green>(.*?)</green>}, "\e[1m\e[32m\\1#{DEFAULT_TERMINAL_COLORS}")
60:                 data.gsub!(%{<yellow>(.*?)</yellow>}, "\e[1m\e[33m\\1#{DEFAULT_TERMINAL_COLORS}")
61:                 data.gsub!(%{<banner>(.*?)</banner>}, "\e[33m\e[44m\e[1m\\1#{DEFAULT_TERMINAL_COLORS}")
62:                 return data
63:         end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.