class AppDynamics::Generators::BusinessTransactionsGenerator::FileFormatter
Public Class Methods
new()
click to toggle source
# File lib/generators/app_dynamics/business_transactions_generator.rb, line 54 def initialize @buffer = [] end
Public Instance Methods
header(routes)
click to toggle source
# File lib/generators/app_dynamics/business_transactions_generator.rb, line 70 def header(routes) # @buffer << draw_header(routes) end
no_routes(*)
click to toggle source
# File lib/generators/app_dynamics/business_transactions_generator.rb, line 74 def no_routes(*) @buffer << "# No routes" end
result()
click to toggle source
# File lib/generators/app_dynamics/business_transactions_generator.rb, line 58 def result @buffer end
section(routes)
click to toggle source
# File lib/generators/app_dynamics/business_transactions_generator.rb, line 66 def section(routes) @buffer << draw_section(routes) end
section_title(title)
click to toggle source
# File lib/generators/app_dynamics/business_transactions_generator.rb, line 62 def section_title(title) @buffer << "# #{title}" end
Private Instance Methods
draw_header(routes)
click to toggle source
# File lib/generators/app_dynamics/business_transactions_generator.rb, line 96 def draw_header(routes) name_width, verb_width, path_width = widths(routes) "#{"Prefix".rjust(name_width)} #{"Verb".ljust(verb_width)} #{"URI Pattern".ljust(path_width)} Controller#Action" end
draw_section(routes)
click to toggle source
# File lib/generators/app_dynamics/business_transactions_generator.rb, line 80 def draw_section(routes) header_lengths = ["Prefix", "Verb", "URI Pattern"].map(&:length) name_width, verb_width, path_width = widths(routes).zip(header_lengths).map(&:max) routes.map do |r| unnamed = r[:name].empty? bt = "" bt << "# " if unnamed bt << "bt #{(unnamed ? "?" : "'" + r[:name] + "'").ljust(name_width+2)} => " bt << "#{r[:path]}" # "#{r[:name].rjust(name_width)} #{r[:verb].ljust(verb_width)} #{r[:path].ljust(path_width)} #{r[:reqs]}" bt end end
widths(routes)
click to toggle source
# File lib/generators/app_dynamics/business_transactions_generator.rb, line 102 def widths(routes) [routes.map { |r| r[:name].length }.max || 0, routes.map { |r| r[:verb].length }.max || 0, routes.map { |r| r[:path].length }.max || 0] end