Module: ActionsHelper
- Defined in:
- app/helpers/actions_helper.rb
Instance Method Summary collapse
Instance Method Details
#_add_white_space(json) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'app/helpers/actions_helper.rb', line 21 def _add_white_space(json) scanner = StringScanner.new(json) output = "" indent = 0 until scanner.eos? match = scanner.scan(/(?:[\[\]\{\}":,]|[^\[\]\{\}":,]+)/) case match when "{", "[" indent += 2 output << "#{match}\n#{" " * indent}" when "}", "]" indent -= 2 output << "\n#{" " * indent}#{match}" when "\"" # hopefully this grabs the entire string output << "\"" << scanner.scan(/.*?(?<!\\)"/) when ":" output << ": " when "," output << ",\n#{" " * indent}" else output << match end end output end |
#format_action_params(params) ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'app/helpers/actions_helper.rb', line 3 def format_action_params(params) return "<pre>{}</pre>".html_safe if params == {} <<-HTML.html_safe <div class="action-params-short"> <pre>{ #{params.keys.map(&:inspect).join(", ")} }</pre> </div> <div class="action-params-full modal"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button> <h3><code>{ #{params.keys.map(&:inspect).join(", ")} }</code></h3> </div> <div class="modal-body"> <pre>#{_add_white_space Houston::ParamsSerializer.new.dump(params)}</pre> </div> </div> HTML end |