Module: Railbow::RoutesFormatter
- Defined in:
- lib/railbow/routes_formatter.rb
Constant Summary collapse
- VERB_COLORS =
{ "GET" => Formatters::Base::GREEN, "POST" => Formatters::Base::YELLOW, "PATCH" => Formatters::Base::CYAN, "PUT" => Formatters::Base::CYAN, "DELETE" => Formatters::Base::RED }.freeze
- RESET =
Formatters::Base::RESET
- BOLD =
Formatters::Base::BOLD
- DIM =
Formatters::Base::DIM
- CYAN =
Formatters::Base::CYAN
- HELP_TEXT_COLOR =
<<~HELP #{BOLD}Railbow Routes Options:#{RESET} #{CYAN}RBW_VERB=GET#{RESET} Show only GET routes #{CYAN}RBW_VERB=POST,PUT#{RESET} Show only POST and PUT routes #{CYAN}RBW_COMPACT=strip-format#{RESET} Strip (.:format) suffixes #{CYAN}RBW_COMPACT=oneline#{RESET} Truncate instead of wrapping #{CYAN}RBW_COMPACT=dense#{RESET} Remove cell padding #{CYAN}RBW_COMPACT=noheader#{RESET} Hide table header row #{CYAN}RBW_COMPACT=maxw:40#{RESET} Cap column widths #{CYAN}RBW_COMPACT=hide:prefix#{RESET} Hide a column by name #{CYAN}RBW_PLAIN=1#{RESET} Disable Railbow formatting (plain Rails output) #{CYAN}RBW_HELP=1#{RESET} Show this help message #{DIM}Combine: RBW_COMPACT=strip-format,dense,noheader#{RESET} #{DIM}Auto-disabled when piped, in CI, or when called by an LLM agent.#{RESET} #{DIM}Example: RBW_VERB=GET rails routes#{RESET} HELP
Instance Method Summary collapse
Instance Method Details
#header(routes) ⇒ Object
50 51 52 |
# File 'lib/railbow/routes_formatter.rb', line 50 def header(routes) super unless tty? end |
#section(routes) ⇒ Object
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/railbow/routes_formatter.rb', line 54 def section(routes) return super unless tty? if Railbow::Params.help? unless @help_shown @buffer << HELP_TEXT_COLOR @help_shown = true end return end strip_format = Railbow::Params.compact_strip_format? prepared = routes.map { |r| prepare_route(r, strip_format) } prepared = filter_by_verb(prepared) groups = group_routes(prepared) groups.each { |label, group| render_group(label, group) } end |