Sha256: c85a62301ebd3e08003ffcfc2eb323e76b9bb9b624249d47744d00db9d16207a

Contents?: true

Size: 1.45 KB

Versions: 17

Compression:

Stored size: 1.45 KB

Contents

# Setup the include path
$:.unshift(File.dirname(__FILE__) + '/..')

$database = RequestLogAnalyzer::Database.new(ENV['RLA_DBCONSOLE_DATABASE'])
$database.load_database_schema!
$database.register_default_orm_classes!

require 'cli/tools'

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

class Request
  def inspect
    request_inspect = "Request[id: #{id}]"
    request_inspect << " <#{lines.first.source.filename}>" if lines.first.source

    inspected_lines = lines.map do |line|
      inspect_line = "   - #{line.line_type} (line #{line.lineno})"
      if (inspect_attributes = line.attributes.reject { |(k, v)| [:id, :source_id, :request_id, :lineno].include?(k.to_sym) }).any?
        inspect_attributes = inspect_attributes.map { |(k,v)| "#{k} = #{v.inspect}" }.join(', ')
        inspect_line << "\n      " + wordwrap(inspect_attributes, terminal_width - 6, "      ")
      end
      inspect_line
    end

    request_inspect << "\n" << inspected_lines.join("\n") << "\n\n"
  end
end

puts "request-log-analyzer database console"
puts "-------------------------------------"
puts "The following ActiveRecord classes are available:"
puts $database.orm_classes.map { |k| k.name.split('::').last }.join(", ")

Version data entries

17 entries across 17 versions & 2 rubygems

Version Path
request-log-analyzer-1.8.0 lib/cli/database_console_init.rb
request-log-analyzer-1.7.0 lib/cli/database_console_init.rb
request-log-analyzer-1.6.4 lib/cli/database_console_init.rb
request-log-analyzer-1.6.3 lib/cli/database_console_init.rb
request-log-analyzer-1.6.2 lib/cli/database_console_init.rb
request-log-analyzer-1.6.1 lib/cli/database_console_init.rb
request-log-analyzer-1.6.0 lib/cli/database_console_init.rb
request-log-analyzer-1.5.4 lib/cli/database_console_init.rb
request-log-analyzer-1.5.3 lib/cli/database_console_init.rb
request-log-analyzer-1.5.2 lib/cli/database_console_init.rb
request-log-analyzer-1.5.1 lib/cli/database_console_init.rb
request-log-analyzer-1.5.0 lib/cli/database_console_init.rb
request-log-analyzer-1.4.2 lib/cli/database_console_init.rb
ngmoco-request-log-analyzer-1.4.2 lib/cli/database_console_init.rb
request-log-analyzer-1.4.1 lib/cli/database_console_init.rb
request-log-analyzer-1.4.0.1 lib/cli/database_console_init.rb
request-log-analyzer-1.4.0 lib/cli/database_console_init.rb