Top Level Namespace
Defined Under Namespace
Modules: CommandLine, RequestLogAnalyzer Classes: DatabaseConsole, Request
Instance Method Summary collapse
-
#install_rake_tasks(install_type = :rails) ⇒ Object
Copies request-log-analyzer analyzer rake tasks into the /lib/tasks folder of a project, for easy access and environment integration.
-
#terminal_width(default_width = 81) ⇒ Object
Try to determine the terminal with.
- #wordwrap(string, max = 80, indent = "") ⇒ Object
Instance Method Details
#install_rake_tasks(install_type = :rails) ⇒ Object
Copies request-log-analyzer analyzer rake tasks into the /lib/tasks folder of a project, for easy access and environment integration. install_type
Type of project to install into. Defaults to :rails. Raises if it cannot find the project folder or if the install_type is now known.
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/cli/tools.rb', line 30 def install_rake_tasks(install_type = :rails) if install_type.to_sym == :rails require 'ftools' if File.directory?('./lib/tasks/') File.copy(File.dirname(__FILE__) + '/../../tasks/request_log_analyzer.rake', './lib/tasks/request_log_analyze.rake') puts "Installed rake tasks." puts "To use, run: rake rla:report" else puts "Cannot find /lib/tasks folder. Are you in your Rails directory?" puts "Installation aborted." end else raise "Cannot perform this install type! (#{install_type.to_s})" end end |
#terminal_width(default_width = 81) ⇒ Object
Try to determine the terminal with. If it is not possible to to so, it returns the default_width. default_width
Defaults to 81
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/cli/tools.rb', line 4 def terminal_width(default_width = 81) tiocgwinsz = 0x5413 data = [0, 0, 0, 0].pack("SSSS") if @out.ioctl(tiocgwinsz, data) >= 0 rows, cols, xpixels, ypixels = data.unpack("SSSS") raise unless cols > 0 cols else raise end rescue begin IO.popen('stty -a 2>&1') do |pipe| column_line = pipe.detect { |line| /(\d+) columns/ =~ line } raise unless column_line $1.to_i end rescue default_width end end |
#wordwrap(string, max = 80, indent = "") ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/cli/database_console_init.rb', line 10 def wordwrap(string, max = 80, indent = "") strings = [""] string.split(", ").each do |item| if strings.last.length == 0 || strings.last.length + item.length <= max strings.last << item << ', ' else strings << (item + ', ') end end strings.map(&:strip).join("\n#{indent}").slice(0..-2) end |