Module: OCRunner::Console
- Included in:
- CLI, OutputProcessor, TestRunner
- Defined in:
- lib/ocrunner/console.rb
Instance Attribute Summary collapse
-
#output ⇒ Object
readonly
Returns the value of attribute output.
Instance Method Summary collapse
- #blue(text) ⇒ Object
- #clean_path(path) ⇒ Object
- #colorize(text, color_code) ⇒ Object
- #execute(cmd, &block) ⇒ Object
- #green(text) ⇒ Object
- #growl(message) ⇒ Object
- #indent(*args) ⇒ Object
- #out(line = '') ⇒ Object
- #present(&block) ⇒ Object
- #red(text) ⇒ Object
Instance Attribute Details
#output ⇒ Object (readonly)
Returns the value of attribute output.
6 7 8 |
# File 'lib/ocrunner/console.rb', line 6 def output @output end |
Instance Method Details
#blue(text) ⇒ Object
14 |
# File 'lib/ocrunner/console.rb', line 14 def blue(text); colorize(text, "\033[34m"); end |
#clean_path(path) ⇒ Object
41 42 43 44 45 |
# File 'lib/ocrunner/console.rb', line 41 def clean_path(path) return 'unknown' if path.nil? @current_directory = Dir.pwd path.gsub(@current_directory + '/', '') end |
#colorize(text, color_code) ⇒ Object
8 9 10 |
# File 'lib/ocrunner/console.rb', line 8 def colorize(text, color_code) "#{color_code}#{text.to_s}\033[0m" end |
#execute(cmd, &block) ⇒ Object
27 28 29 30 31 32 33 |
# File 'lib/ocrunner/console.rb', line 27 def execute(cmd, &block) IO.popen("#{cmd} 2>&1") do |f| while line = f.gets do yield line end end end |
#green(text) ⇒ Object
13 |
# File 'lib/ocrunner/console.rb', line 13 def green(text); colorize(text, "\033[32m"); end |
#growl(message) ⇒ Object
52 53 54 55 56 57 58 59 60 |
# File 'lib/ocrunner/console.rb', line 52 def growl() if @options[:growl] execute "growlnotify -i \"xcodeproj\" -m \"#{}\"" do |error| if error =~ /command not found/ out red('You must have growl and growl notify installed to enable growl support. See http://growl.info.') end end end end |
#indent(*args) ⇒ Object
16 17 18 19 20 21 22 23 24 25 |
# File 'lib/ocrunner/console.rb', line 16 def indent(*args) if args.first.is_a? Numeric indents = args.first text = args.last else indents = 1 text = args.first end " " * indents + text.to_s end |
#out(line = '') ⇒ Object
47 48 49 50 |
# File 'lib/ocrunner/console.rb', line 47 def out(line = '') @output ||= [] @output << line.rstrip end |
#present(&block) ⇒ Object
35 36 37 38 39 |
# File 'lib/ocrunner/console.rb', line 35 def present(&block) puts yield puts end |
#red(text) ⇒ Object
12 |
# File 'lib/ocrunner/console.rb', line 12 def red(text); colorize(text, "\033[31m"); end |