brakeman 6.2.2 → 7.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGES.md +17 -0
- data/bundle/load.rb +7 -6
- data/bundle/ruby/3.1.0/gems/csv-3.3.2/LICENSE.txt +33 -0
- data/bundle/ruby/3.1.0/gems/csv-3.3.2/NEWS.md +965 -0
- data/bundle/ruby/3.1.0/gems/csv-3.3.2/README.md +55 -0
- data/bundle/ruby/3.1.0/gems/csv-3.3.2/lib/csv/core_ext/array.rb +9 -0
- data/bundle/ruby/3.1.0/gems/csv-3.3.2/lib/csv/core_ext/string.rb +9 -0
- data/bundle/ruby/3.1.0/gems/csv-3.3.2/lib/csv/fields_converter.rb +96 -0
- data/bundle/ruby/3.1.0/gems/csv-3.3.2/lib/csv/input_record_separator.rb +18 -0
- data/bundle/ruby/3.1.0/gems/csv-3.3.2/lib/csv/parser.rb +1292 -0
- data/bundle/ruby/3.1.0/gems/csv-3.3.2/lib/csv/row.rb +757 -0
- data/bundle/ruby/3.1.0/gems/csv-3.3.2/lib/csv/table.rb +1055 -0
- data/bundle/ruby/3.1.0/gems/csv-3.3.2/lib/csv/version.rb +6 -0
- data/bundle/ruby/3.1.0/gems/csv-3.3.2/lib/csv/writer.rb +209 -0
- data/bundle/ruby/3.1.0/gems/csv-3.3.2/lib/csv.rb +3017 -0
- data/bundle/ruby/3.1.0/gems/{reline-0.5.10 → reline-0.6.0}/lib/reline/config.rb +22 -26
- data/bundle/ruby/3.1.0/gems/{reline-0.5.10 → reline-0.6.0}/lib/reline/history.rb +3 -3
- data/bundle/ruby/3.1.0/gems/{reline-0.5.10 → reline-0.6.0}/lib/reline/io/ansi.rb +64 -111
- data/bundle/ruby/3.1.0/gems/{reline-0.5.10 → reline-0.6.0}/lib/reline/io/dumb.rb +16 -2
- data/bundle/ruby/3.1.0/gems/{reline-0.5.10 → reline-0.6.0}/lib/reline/io/windows.rb +77 -60
- data/bundle/ruby/3.1.0/gems/{reline-0.5.10 → reline-0.6.0}/lib/reline/io.rb +14 -0
- data/bundle/ruby/3.1.0/gems/{reline-0.5.10 → reline-0.6.0}/lib/reline/key_actor/base.rb +10 -4
- data/bundle/ruby/3.1.0/gems/{reline-0.5.10 → reline-0.6.0}/lib/reline/key_actor/emacs.rb +96 -96
- data/bundle/ruby/3.1.0/gems/{reline-0.5.10 → reline-0.6.0}/lib/reline/key_actor/vi_command.rb +182 -182
- data/bundle/ruby/3.1.0/gems/{reline-0.5.10 → reline-0.6.0}/lib/reline/key_actor/vi_insert.rb +137 -137
- data/bundle/ruby/3.1.0/gems/{reline-0.5.10 → reline-0.6.0}/lib/reline/key_stroke.rb +26 -16
- data/bundle/ruby/3.1.0/gems/{reline-0.5.10 → reline-0.6.0}/lib/reline/line_editor.rb +238 -404
- data/bundle/ruby/3.1.0/gems/reline-0.6.0/lib/reline/unicode.rb +415 -0
- data/bundle/ruby/3.1.0/gems/reline-0.6.0/lib/reline/version.rb +3 -0
- data/bundle/ruby/3.1.0/gems/{reline-0.5.10 → reline-0.6.0}/lib/reline.rb +18 -18
- data/bundle/ruby/3.1.0/gems/{rexml-3.3.8 → rexml-3.4.0}/NEWS.md +50 -0
- data/bundle/ruby/3.1.0/gems/{rexml-3.3.8 → rexml-3.4.0}/lib/rexml/parsers/baseparser.rb +54 -45
- data/bundle/ruby/3.1.0/gems/{rexml-3.3.8 → rexml-3.4.0}/lib/rexml/parsers/pullparser.rb +4 -0
- data/bundle/ruby/3.1.0/gems/{rexml-3.3.8 → rexml-3.4.0}/lib/rexml/rexml.rb +1 -1
- data/bundle/ruby/3.1.0/gems/{rexml-3.3.8 → rexml-3.4.0}/lib/rexml/source.rb +45 -4
- data/bundle/ruby/3.1.0/gems/{rexml-3.3.8 → rexml-3.4.0}/lib/rexml/text.rb +15 -40
- data/bundle/ruby/3.1.0/gems/{sexp_processor-4.17.2 → sexp_processor-4.17.3}/History.rdoc +6 -0
- data/bundle/ruby/3.1.0/gems/{sexp_processor-4.17.2 → sexp_processor-4.17.3}/lib/sexp.rb +1 -1
- data/bundle/ruby/3.1.0/gems/{sexp_processor-4.17.2 → sexp_processor-4.17.3}/lib/sexp_processor.rb +1 -1
- data/bundle/ruby/3.1.0/gems/terminal-table-3.0.2/History.rdoc +142 -0
- data/bundle/ruby/3.1.0/gems/terminal-table-3.0.2/README.md +417 -0
- data/bundle/ruby/3.1.0/gems/{terminal-table-1.8.0 → terminal-table-3.0.2}/lib/terminal-table/cell.rb +8 -8
- data/bundle/ruby/3.1.0/gems/{terminal-table-1.8.0 → terminal-table-3.0.2}/lib/terminal-table/row.rb +18 -4
- data/bundle/ruby/3.1.0/gems/terminal-table-3.0.2/lib/terminal-table/separator.rb +66 -0
- data/bundle/ruby/3.1.0/gems/terminal-table-3.0.2/lib/terminal-table/style.rb +284 -0
- data/bundle/ruby/3.1.0/gems/{terminal-table-1.8.0 → terminal-table-3.0.2}/lib/terminal-table/table.rb +47 -18
- data/bundle/ruby/3.1.0/gems/terminal-table-3.0.2/lib/terminal-table/util.rb +13 -0
- data/bundle/ruby/3.1.0/gems/{terminal-table-1.8.0 → terminal-table-3.0.2}/lib/terminal-table/version.rb +1 -1
- data/bundle/ruby/3.1.0/gems/{terminal-table-1.8.0 → terminal-table-3.0.2}/lib/terminal-table.rb +2 -2
- data/bundle/ruby/3.1.0/gems/{terminal-table-1.8.0 → terminal-table-3.0.2}/terminal-table.gemspec +3 -3
- data/bundle/ruby/3.1.0/gems/{tilt-2.4.0 → tilt-2.5.0}/lib/tilt/creole.rb +2 -0
- data/bundle/ruby/3.1.0/gems/{tilt-2.4.0 → tilt-2.5.0}/lib/tilt/liquid.rb +0 -3
- data/bundle/ruby/3.1.0/gems/{tilt-2.4.0 → tilt-2.5.0}/lib/tilt/mapping.rb +3 -3
- data/bundle/ruby/3.1.0/gems/{tilt-2.4.0 → tilt-2.5.0}/lib/tilt/rdoc.rb +0 -8
- data/bundle/ruby/3.1.0/gems/{tilt-2.4.0 → tilt-2.5.0}/lib/tilt/template.rb +27 -3
- data/bundle/ruby/3.1.0/gems/{tilt-2.4.0 → tilt-2.5.0}/lib/tilt.rb +1 -4
- data/bundle/ruby/3.1.0/gems/{unicode-display_width-1.8.0 → unicode-display_width-2.6.0}/CHANGELOG.md +65 -2
- data/bundle/ruby/3.1.0/gems/{unicode-display_width-1.8.0 → unicode-display_width-2.6.0}/MIT-LICENSE.txt +1 -1
- data/bundle/ruby/3.1.0/gems/{unicode-display_width-1.8.0 → unicode-display_width-2.6.0}/README.md +67 -20
- data/bundle/ruby/3.1.0/gems/unicode-display_width-2.6.0/data/display_width.marshal.gz +0 -0
- data/bundle/ruby/3.1.0/gems/unicode-display_width-2.6.0/lib/unicode/display_width/constants.rb +10 -0
- data/bundle/ruby/3.1.0/gems/unicode-display_width-2.6.0/lib/unicode/display_width/index.rb +34 -0
- data/bundle/ruby/3.1.0/gems/unicode-display_width-2.6.0/lib/unicode/display_width/no_string_ext.rb +8 -0
- data/bundle/ruby/3.1.0/gems/unicode-display_width-2.6.0/lib/unicode/display_width/string_ext.rb +9 -0
- data/bundle/ruby/3.1.0/gems/unicode-display_width-2.6.0/lib/unicode/display_width.rb +123 -0
- data/lib/brakeman/app_tree.rb +23 -18
- data/lib/brakeman/checks/check_deserialize.rb +4 -1
- data/lib/brakeman/checks/check_evaluation.rb +20 -2
- data/lib/brakeman/checks/check_model_attr_accessible.rb +1 -0
- data/lib/brakeman/file_parser.rb +2 -1
- data/lib/brakeman/options.rb +8 -5
- data/lib/brakeman/processors/alias_processor.rb +6 -2
- data/lib/brakeman/processors/lib/file_type_detector.rb +9 -7
- data/lib/brakeman/report/ignore/config.rb +0 -1
- data/lib/brakeman/report/report_sarif.rb +122 -2
- data/lib/brakeman/rescanner.rb +40 -390
- data/lib/brakeman/scanner.rb +62 -38
- data/lib/brakeman/tracker/file_cache.rb +83 -0
- data/lib/brakeman/tracker.rb +19 -2
- data/lib/brakeman/version.rb +1 -1
- data/lib/brakeman.rb +12 -2
- metadata +170 -160
- data/bundle/ruby/3.1.0/gems/reline-0.5.10/lib/reline/terminfo.rb +0 -158
- data/bundle/ruby/3.1.0/gems/reline-0.5.10/lib/reline/unicode.rb +0 -671
- data/bundle/ruby/3.1.0/gems/reline-0.5.10/lib/reline/version.rb +0 -3
- data/bundle/ruby/3.1.0/gems/terminal-table-1.8.0/History.rdoc +0 -85
- data/bundle/ruby/3.1.0/gems/terminal-table-1.8.0/README.rdoc +0 -247
- data/bundle/ruby/3.1.0/gems/terminal-table-1.8.0/lib/terminal-table/separator.rb +0 -14
- data/bundle/ruby/3.1.0/gems/terminal-table-1.8.0/lib/terminal-table/style.rb +0 -79
- data/bundle/ruby/3.1.0/gems/tilt-2.4.0/lib/tilt/erubis.rb +0 -51
- data/bundle/ruby/3.1.0/gems/tilt-2.4.0/lib/tilt/maruku.rb +0 -10
- data/bundle/ruby/3.1.0/gems/tilt-2.4.0/lib/tilt/wikicloth.rb +0 -12
- data/bundle/ruby/3.1.0/gems/unicode-display_width-1.8.0/data/display_width.marshal.gz +0 -0
- data/bundle/ruby/3.1.0/gems/unicode-display_width-1.8.0/lib/unicode/display_width/constants.rb +0 -8
- data/bundle/ruby/3.1.0/gems/unicode-display_width-1.8.0/lib/unicode/display_width/index.rb +0 -12
- data/bundle/ruby/3.1.0/gems/unicode-display_width-1.8.0/lib/unicode/display_width/no_string_ext.rb +0 -7
- data/bundle/ruby/3.1.0/gems/unicode-display_width-1.8.0/lib/unicode/display_width/string_ext.rb +0 -17
- data/bundle/ruby/3.1.0/gems/unicode-display_width-1.8.0/lib/unicode/display_width.rb +0 -51
- /data/bundle/ruby/3.1.0/gems/{reline-0.5.10 → reline-0.6.0}/BSDL +0 -0
- /data/bundle/ruby/3.1.0/gems/{reline-0.5.10 → reline-0.6.0}/COPYING +0 -0
- /data/bundle/ruby/3.1.0/gems/{reline-0.5.10 → reline-0.6.0}/README.md +0 -0
- /data/bundle/ruby/3.1.0/gems/{reline-0.5.10 → reline-0.6.0}/lib/reline/face.rb +0 -0
- /data/bundle/ruby/3.1.0/gems/{reline-0.5.10 → reline-0.6.0}/lib/reline/key_actor/composite.rb +0 -0
- /data/bundle/ruby/3.1.0/gems/{reline-0.5.10 → reline-0.6.0}/lib/reline/key_actor.rb +0 -0
- /data/bundle/ruby/3.1.0/gems/{reline-0.5.10 → reline-0.6.0}/lib/reline/kill_ring.rb +0 -0
- /data/bundle/ruby/3.1.0/gems/{reline-0.5.10 → reline-0.6.0}/lib/reline/unicode/east_asian_width.rb +0 -0
- /data/bundle/ruby/3.1.0/gems/{reline-0.5.10 → reline-0.6.0}/license_of_rb-readline +0 -0
- /data/bundle/ruby/3.1.0/gems/{rexml-3.3.8 → rexml-3.4.0}/LICENSE.txt +0 -0
- /data/bundle/ruby/3.1.0/gems/{rexml-3.3.8 → rexml-3.4.0}/README.md +0 -0
- /data/bundle/ruby/3.1.0/gems/{rexml-3.3.8 → rexml-3.4.0}/lib/rexml/attlistdecl.rb +0 -0
- /data/bundle/ruby/3.1.0/gems/{rexml-3.3.8 → rexml-3.4.0}/lib/rexml/attribute.rb +0 -0
- /data/bundle/ruby/3.1.0/gems/{rexml-3.3.8 → rexml-3.4.0}/lib/rexml/cdata.rb +0 -0
- /data/bundle/ruby/3.1.0/gems/{rexml-3.3.8 → rexml-3.4.0}/lib/rexml/child.rb +0 -0
- /data/bundle/ruby/3.1.0/gems/{rexml-3.3.8 → rexml-3.4.0}/lib/rexml/comment.rb +0 -0
- /data/bundle/ruby/3.1.0/gems/{rexml-3.3.8 → rexml-3.4.0}/lib/rexml/doctype.rb +0 -0
- /data/bundle/ruby/3.1.0/gems/{rexml-3.3.8 → rexml-3.4.0}/lib/rexml/document.rb +0 -0
- /data/bundle/ruby/3.1.0/gems/{rexml-3.3.8 → rexml-3.4.0}/lib/rexml/dtd/attlistdecl.rb +0 -0
- /data/bundle/ruby/3.1.0/gems/{rexml-3.3.8 → rexml-3.4.0}/lib/rexml/dtd/dtd.rb +0 -0
- /data/bundle/ruby/3.1.0/gems/{rexml-3.3.8 → rexml-3.4.0}/lib/rexml/dtd/elementdecl.rb +0 -0
- /data/bundle/ruby/3.1.0/gems/{rexml-3.3.8 → rexml-3.4.0}/lib/rexml/dtd/entitydecl.rb +0 -0
- /data/bundle/ruby/3.1.0/gems/{rexml-3.3.8 → rexml-3.4.0}/lib/rexml/dtd/notationdecl.rb +0 -0
- /data/bundle/ruby/3.1.0/gems/{rexml-3.3.8 → rexml-3.4.0}/lib/rexml/element.rb +0 -0
- /data/bundle/ruby/3.1.0/gems/{rexml-3.3.8 → rexml-3.4.0}/lib/rexml/encoding.rb +0 -0
- /data/bundle/ruby/3.1.0/gems/{rexml-3.3.8 → rexml-3.4.0}/lib/rexml/entity.rb +0 -0
- /data/bundle/ruby/3.1.0/gems/{rexml-3.3.8 → rexml-3.4.0}/lib/rexml/formatters/default.rb +0 -0
- /data/bundle/ruby/3.1.0/gems/{rexml-3.3.8 → rexml-3.4.0}/lib/rexml/formatters/pretty.rb +0 -0
- /data/bundle/ruby/3.1.0/gems/{rexml-3.3.8 → rexml-3.4.0}/lib/rexml/formatters/transitive.rb +0 -0
- /data/bundle/ruby/3.1.0/gems/{rexml-3.3.8 → rexml-3.4.0}/lib/rexml/functions.rb +0 -0
- /data/bundle/ruby/3.1.0/gems/{rexml-3.3.8 → rexml-3.4.0}/lib/rexml/instruction.rb +0 -0
- /data/bundle/ruby/3.1.0/gems/{rexml-3.3.8 → rexml-3.4.0}/lib/rexml/light/node.rb +0 -0
- /data/bundle/ruby/3.1.0/gems/{rexml-3.3.8 → rexml-3.4.0}/lib/rexml/namespace.rb +0 -0
- /data/bundle/ruby/3.1.0/gems/{rexml-3.3.8 → rexml-3.4.0}/lib/rexml/node.rb +0 -0
- /data/bundle/ruby/3.1.0/gems/{rexml-3.3.8 → rexml-3.4.0}/lib/rexml/output.rb +0 -0
- /data/bundle/ruby/3.1.0/gems/{rexml-3.3.8 → rexml-3.4.0}/lib/rexml/parent.rb +0 -0
- /data/bundle/ruby/3.1.0/gems/{rexml-3.3.8 → rexml-3.4.0}/lib/rexml/parseexception.rb +0 -0
- /data/bundle/ruby/3.1.0/gems/{rexml-3.3.8 → rexml-3.4.0}/lib/rexml/parsers/lightparser.rb +0 -0
- /data/bundle/ruby/3.1.0/gems/{rexml-3.3.8 → rexml-3.4.0}/lib/rexml/parsers/sax2parser.rb +0 -0
- /data/bundle/ruby/3.1.0/gems/{rexml-3.3.8 → rexml-3.4.0}/lib/rexml/parsers/streamparser.rb +0 -0
- /data/bundle/ruby/3.1.0/gems/{rexml-3.3.8 → rexml-3.4.0}/lib/rexml/parsers/treeparser.rb +0 -0
- /data/bundle/ruby/3.1.0/gems/{rexml-3.3.8 → rexml-3.4.0}/lib/rexml/parsers/ultralightparser.rb +0 -0
- /data/bundle/ruby/3.1.0/gems/{rexml-3.3.8 → rexml-3.4.0}/lib/rexml/parsers/xpathparser.rb +0 -0
- /data/bundle/ruby/3.1.0/gems/{rexml-3.3.8 → rexml-3.4.0}/lib/rexml/quickpath.rb +0 -0
- /data/bundle/ruby/3.1.0/gems/{rexml-3.3.8 → rexml-3.4.0}/lib/rexml/sax2listener.rb +0 -0
- /data/bundle/ruby/3.1.0/gems/{rexml-3.3.8 → rexml-3.4.0}/lib/rexml/security.rb +0 -0
- /data/bundle/ruby/3.1.0/gems/{rexml-3.3.8 → rexml-3.4.0}/lib/rexml/streamlistener.rb +0 -0
- /data/bundle/ruby/3.1.0/gems/{rexml-3.3.8 → rexml-3.4.0}/lib/rexml/undefinednamespaceexception.rb +0 -0
- /data/bundle/ruby/3.1.0/gems/{rexml-3.3.8 → rexml-3.4.0}/lib/rexml/validation/relaxng.rb +0 -0
- /data/bundle/ruby/3.1.0/gems/{rexml-3.3.8 → rexml-3.4.0}/lib/rexml/validation/validation.rb +0 -0
- /data/bundle/ruby/3.1.0/gems/{rexml-3.3.8 → rexml-3.4.0}/lib/rexml/validation/validationexception.rb +0 -0
- /data/bundle/ruby/3.1.0/gems/{rexml-3.3.8 → rexml-3.4.0}/lib/rexml/xmldecl.rb +0 -0
- /data/bundle/ruby/3.1.0/gems/{rexml-3.3.8 → rexml-3.4.0}/lib/rexml/xmltokens.rb +0 -0
- /data/bundle/ruby/3.1.0/gems/{rexml-3.3.8 → rexml-3.4.0}/lib/rexml/xpath.rb +0 -0
- /data/bundle/ruby/3.1.0/gems/{rexml-3.3.8 → rexml-3.4.0}/lib/rexml/xpath_parser.rb +0 -0
- /data/bundle/ruby/3.1.0/gems/{rexml-3.3.8 → rexml-3.4.0}/lib/rexml.rb +0 -0
- /data/bundle/ruby/3.1.0/gems/{sexp_processor-4.17.2 → sexp_processor-4.17.3}/Manifest.txt +0 -0
- /data/bundle/ruby/3.1.0/gems/{sexp_processor-4.17.2 → sexp_processor-4.17.3}/README.rdoc +0 -0
- /data/bundle/ruby/3.1.0/gems/{sexp_processor-4.17.2 → sexp_processor-4.17.3}/lib/composite_sexp_processor.rb +0 -0
- /data/bundle/ruby/3.1.0/gems/{sexp_processor-4.17.2 → sexp_processor-4.17.3}/lib/pt_testcase.rb +0 -0
- /data/bundle/ruby/3.1.0/gems/{sexp_processor-4.17.2 → sexp_processor-4.17.3}/lib/sexp_matcher.rb +0 -0
- /data/bundle/ruby/3.1.0/gems/{sexp_processor-4.17.2 → sexp_processor-4.17.3}/lib/strict_sexp.rb +0 -0
- /data/bundle/ruby/3.1.0/gems/{sexp_processor-4.17.2 → sexp_processor-4.17.3}/lib/unique.rb +0 -0
- /data/bundle/ruby/3.1.0/gems/{terminal-table-1.8.0 → terminal-table-3.0.2}/Gemfile +0 -0
- /data/bundle/ruby/3.1.0/gems/{terminal-table-1.8.0 → terminal-table-3.0.2}/LICENSE.txt +0 -0
- /data/bundle/ruby/3.1.0/gems/{terminal-table-1.8.0 → terminal-table-3.0.2}/Manifest +0 -0
- /data/bundle/ruby/3.1.0/gems/{terminal-table-1.8.0 → terminal-table-3.0.2}/Todo.rdoc +0 -0
- /data/bundle/ruby/3.1.0/gems/{terminal-table-1.8.0 → terminal-table-3.0.2}/lib/terminal-table/import.rb +0 -0
- /data/bundle/ruby/3.1.0/gems/{terminal-table-1.8.0 → terminal-table-3.0.2}/lib/terminal-table/table_helper.rb +0 -0
- /data/bundle/ruby/3.1.0/gems/{tilt-2.4.0 → tilt-2.5.0}/COPYING +0 -0
- /data/bundle/ruby/3.1.0/gems/{tilt-2.4.0 → tilt-2.5.0}/lib/tilt/_emacs_org.rb +0 -0
- /data/bundle/ruby/3.1.0/gems/{tilt-2.4.0 → tilt-2.5.0}/lib/tilt/_handlebars.rb +0 -0
- /data/bundle/ruby/3.1.0/gems/{tilt-2.4.0 → tilt-2.5.0}/lib/tilt/_jbuilder.rb +0 -0
- /data/bundle/ruby/3.1.0/gems/{tilt-2.4.0 → tilt-2.5.0}/lib/tilt/_org.rb +0 -0
- /data/bundle/ruby/3.1.0/gems/{tilt-2.4.0 → tilt-2.5.0}/lib/tilt/asciidoc.rb +0 -0
- /data/bundle/ruby/3.1.0/gems/{tilt-2.4.0 → tilt-2.5.0}/lib/tilt/babel.rb +0 -0
- /data/bundle/ruby/3.1.0/gems/{tilt-2.4.0 → tilt-2.5.0}/lib/tilt/builder.rb +0 -0
- /data/bundle/ruby/3.1.0/gems/{tilt-2.4.0 → tilt-2.5.0}/lib/tilt/cli.rb +0 -0
- /data/bundle/ruby/3.1.0/gems/{tilt-2.4.0 → tilt-2.5.0}/lib/tilt/coffee.rb +0 -0
- /data/bundle/ruby/3.1.0/gems/{tilt-2.4.0 → tilt-2.5.0}/lib/tilt/commonmarker.rb +0 -0
- /data/bundle/ruby/3.1.0/gems/{tilt-2.4.0 → tilt-2.5.0}/lib/tilt/csv.rb +0 -0
- /data/bundle/ruby/3.1.0/gems/{tilt-2.4.0 → tilt-2.5.0}/lib/tilt/erb.rb +0 -0
- /data/bundle/ruby/3.1.0/gems/{tilt-2.4.0 → tilt-2.5.0}/lib/tilt/erubi.rb +0 -0
- /data/bundle/ruby/3.1.0/gems/{tilt-2.4.0 → tilt-2.5.0}/lib/tilt/etanni.rb +0 -0
- /data/bundle/ruby/3.1.0/gems/{tilt-2.4.0 → tilt-2.5.0}/lib/tilt/haml.rb +0 -0
- /data/bundle/ruby/3.1.0/gems/{tilt-2.4.0 → tilt-2.5.0}/lib/tilt/kramdown.rb +0 -0
- /data/bundle/ruby/3.1.0/gems/{tilt-2.4.0 → tilt-2.5.0}/lib/tilt/livescript.rb +0 -0
- /data/bundle/ruby/3.1.0/gems/{tilt-2.4.0 → tilt-2.5.0}/lib/tilt/markaby.rb +0 -0
- /data/bundle/ruby/3.1.0/gems/{tilt-2.4.0 → tilt-2.5.0}/lib/tilt/nokogiri.rb +0 -0
- /data/bundle/ruby/3.1.0/gems/{tilt-2.4.0 → tilt-2.5.0}/lib/tilt/pandoc.rb +0 -0
- /data/bundle/ruby/3.1.0/gems/{tilt-2.4.0 → tilt-2.5.0}/lib/tilt/pipeline.rb +0 -0
- /data/bundle/ruby/3.1.0/gems/{tilt-2.4.0 → tilt-2.5.0}/lib/tilt/plain.rb +0 -0
- /data/bundle/ruby/3.1.0/gems/{tilt-2.4.0 → tilt-2.5.0}/lib/tilt/prawn.rb +0 -0
- /data/bundle/ruby/3.1.0/gems/{tilt-2.4.0 → tilt-2.5.0}/lib/tilt/radius.rb +0 -0
- /data/bundle/ruby/3.1.0/gems/{tilt-2.4.0 → tilt-2.5.0}/lib/tilt/rdiscount.rb +0 -0
- /data/bundle/ruby/3.1.0/gems/{tilt-2.4.0 → tilt-2.5.0}/lib/tilt/redcarpet.rb +0 -0
- /data/bundle/ruby/3.1.0/gems/{tilt-2.4.0 → tilt-2.5.0}/lib/tilt/redcloth.rb +0 -0
- /data/bundle/ruby/3.1.0/gems/{tilt-2.4.0 → tilt-2.5.0}/lib/tilt/rst-pandoc.rb +0 -0
- /data/bundle/ruby/3.1.0/gems/{tilt-2.4.0 → tilt-2.5.0}/lib/tilt/sass.rb +0 -0
- /data/bundle/ruby/3.1.0/gems/{tilt-2.4.0 → tilt-2.5.0}/lib/tilt/slim.rb +0 -0
- /data/bundle/ruby/3.1.0/gems/{tilt-2.4.0 → tilt-2.5.0}/lib/tilt/string.rb +0 -0
- /data/bundle/ruby/3.1.0/gems/{tilt-2.4.0 → tilt-2.5.0}/lib/tilt/typescript.rb +0 -0
- /data/bundle/ruby/3.1.0/gems/{tilt-2.4.0 → tilt-2.5.0}/lib/tilt/yajl.rb +0 -0
@@ -0,0 +1,417 @@
|
|
1
|
+
[![CI status](https://github.com/tj/terminal-table/workflows/CI/badge.svg)](https://github.com/tj/terminal-table/actions)
|
2
|
+
[![Gem Version](https://badge.fury.io/rb/terminal-table.svg)](https://badge.fury.io/rb/terminal-table)
|
3
|
+
|
4
|
+
# Terminal Table
|
5
|
+
|
6
|
+
## Description
|
7
|
+
|
8
|
+
Terminal Table is a fast and simple, yet feature rich table generator
|
9
|
+
written in Ruby. It supports ASCII and Unicode formatted tables.
|
10
|
+
|
11
|
+
## Installation
|
12
|
+
|
13
|
+
```
|
14
|
+
$ gem install terminal-table
|
15
|
+
```
|
16
|
+
## Usage
|
17
|
+
|
18
|
+
### Basics
|
19
|
+
|
20
|
+
To use Terminal Table:
|
21
|
+
|
22
|
+
```ruby
|
23
|
+
require 'terminal-table'
|
24
|
+
```
|
25
|
+
To generate a table, provide an array of arrays (which are interpreted as
|
26
|
+
rows):
|
27
|
+
|
28
|
+
```ruby
|
29
|
+
rows = []
|
30
|
+
rows << ['One', 1]
|
31
|
+
rows << ['Two', 2]
|
32
|
+
rows << ['Three', 3]
|
33
|
+
table = Terminal::Table.new :rows => rows
|
34
|
+
|
35
|
+
# > puts table
|
36
|
+
#
|
37
|
+
# +-------+---+
|
38
|
+
# | One | 1 |
|
39
|
+
# | Two | 2 |
|
40
|
+
# | Three | 3 |
|
41
|
+
# +-------+---+
|
42
|
+
```
|
43
|
+
The constructor can also be given a block which is either yielded the Table
|
44
|
+
object or instance evaluated:
|
45
|
+
|
46
|
+
```ruby
|
47
|
+
table = Terminal::Table.new do |t|
|
48
|
+
t.rows = rows
|
49
|
+
end
|
50
|
+
|
51
|
+
table = Terminal::Table.new do
|
52
|
+
self.rows = rows
|
53
|
+
end
|
54
|
+
```
|
55
|
+
Adding rows one by one:
|
56
|
+
|
57
|
+
```ruby
|
58
|
+
table = Terminal::Table.new do |t|
|
59
|
+
t << ['One', 1]
|
60
|
+
t.add_row ['Two', 2]
|
61
|
+
end
|
62
|
+
```
|
63
|
+
To add separators between rows:
|
64
|
+
|
65
|
+
```ruby
|
66
|
+
table = Terminal::Table.new do |t|
|
67
|
+
t << ['One', 1] # Using << (push) as an alias for add_row
|
68
|
+
t << :separator # Using << with :separator as an alias for add_separator
|
69
|
+
t.add_row ['Two', 2]
|
70
|
+
t.add_separator # Note - this version allows setting the separator's border_type
|
71
|
+
t.add_row ['Three', 3]
|
72
|
+
end
|
73
|
+
|
74
|
+
# > puts table
|
75
|
+
#
|
76
|
+
# +-------+---+
|
77
|
+
# | One | 1 |
|
78
|
+
# +-------+---+
|
79
|
+
# | Two | 2 |
|
80
|
+
# +-------+---+
|
81
|
+
# | Three | 3 |
|
82
|
+
# +-------+---+
|
83
|
+
```
|
84
|
+
Cells can handle multiline content:
|
85
|
+
|
86
|
+
```ruby
|
87
|
+
table = Terminal::Table.new do |t|
|
88
|
+
t << ['One', 1]
|
89
|
+
t << :separator
|
90
|
+
t.add_row ["Two\nDouble", 2]
|
91
|
+
t.add_separator
|
92
|
+
t.add_row ['Three', 3]
|
93
|
+
end
|
94
|
+
|
95
|
+
# > puts table
|
96
|
+
#
|
97
|
+
# +--------+---+
|
98
|
+
# | One | 1 |
|
99
|
+
# +--------+---+
|
100
|
+
# | Two | 2 |
|
101
|
+
# | Double | |
|
102
|
+
# +--------+---+
|
103
|
+
# | Three | 3 |
|
104
|
+
# +--------+---+
|
105
|
+
```
|
106
|
+
### Head
|
107
|
+
|
108
|
+
To add a head to the table:
|
109
|
+
|
110
|
+
```ruby
|
111
|
+
table = Terminal::Table.new :headings => ['Word', 'Number'], :rows => rows
|
112
|
+
|
113
|
+
# > puts table
|
114
|
+
#
|
115
|
+
# +-------+--------+
|
116
|
+
# | Word | Number |
|
117
|
+
# +-------+--------+
|
118
|
+
# | One | 1 |
|
119
|
+
# | Two | 2 |
|
120
|
+
# | Three | 3 |
|
121
|
+
# +-------+--------+
|
122
|
+
```
|
123
|
+
### Title
|
124
|
+
|
125
|
+
To add a title to the table:
|
126
|
+
|
127
|
+
```ruby
|
128
|
+
table = Terminal::Table.new :title => "Cheatsheet", :headings => ['Word', 'Number'], :rows => rows
|
129
|
+
|
130
|
+
# > puts table
|
131
|
+
#
|
132
|
+
# +---------------------+
|
133
|
+
# | Cheatsheet |
|
134
|
+
# +------------+--------+
|
135
|
+
# | Word | Number |
|
136
|
+
# +------------+--------+
|
137
|
+
# | One | 1 |
|
138
|
+
# | Two | 2 |
|
139
|
+
# | Three | 3 |
|
140
|
+
# +------------+--------+
|
141
|
+
```
|
142
|
+
### Alignment
|
143
|
+
|
144
|
+
To align the second column to the right:
|
145
|
+
|
146
|
+
```ruby
|
147
|
+
table.align_column(1, :right)
|
148
|
+
|
149
|
+
# > puts table
|
150
|
+
#
|
151
|
+
# +-------+--------+
|
152
|
+
# | Word | Number |
|
153
|
+
# +-------+--------+
|
154
|
+
# | One | 1 |
|
155
|
+
# | Two | 2 |
|
156
|
+
# | Three | 3 |
|
157
|
+
# +-------+--------+
|
158
|
+
```
|
159
|
+
To align an individual cell, you specify the cell value in a hash along the
|
160
|
+
alignment:
|
161
|
+
|
162
|
+
```ruby
|
163
|
+
table << ["Four", {:value => 4.0, :alignment => :center}]
|
164
|
+
|
165
|
+
# > puts table
|
166
|
+
#
|
167
|
+
# +-------+--------+
|
168
|
+
# | Word | Number |
|
169
|
+
# +-------+--------+
|
170
|
+
# | One | 1 |
|
171
|
+
# | Two | 2 |
|
172
|
+
# | Three | 3 |
|
173
|
+
# | Four | 4.0 |
|
174
|
+
# +-------+--------+
|
175
|
+
```
|
176
|
+
### Style
|
177
|
+
|
178
|
+
To specify style options:
|
179
|
+
|
180
|
+
```ruby
|
181
|
+
table = Terminal::Table.new :headings => ['Word', 'Number'], :rows => rows, :style => {:width => 80}
|
182
|
+
|
183
|
+
# > puts table
|
184
|
+
#
|
185
|
+
# +--------------------------------------+---------------------------------------+
|
186
|
+
# | Word | Number |
|
187
|
+
# +--------------------------------------+---------------------------------------+
|
188
|
+
# | One | 1 |
|
189
|
+
# | Two | 2 |
|
190
|
+
# | Three | 3 |
|
191
|
+
# +--------------------------------------+---------------------------------------+
|
192
|
+
```
|
193
|
+
And change styles on the fly:
|
194
|
+
|
195
|
+
```ruby
|
196
|
+
table.style = {:width => 40, :padding_left => 3, :border_x => "=", :border_i => "x"}
|
197
|
+
|
198
|
+
# > puts table
|
199
|
+
#
|
200
|
+
# x======================================x
|
201
|
+
# | Cheatsheet |
|
202
|
+
# x====================x=================x
|
203
|
+
# | Word | Number |
|
204
|
+
# x====================x=================x
|
205
|
+
# | One | 1 |
|
206
|
+
# | Two | 2 |
|
207
|
+
# | Three | 3 |
|
208
|
+
# x====================x=================x
|
209
|
+
```
|
210
|
+
You can also use styles to add a separator after every row:
|
211
|
+
|
212
|
+
```ruby
|
213
|
+
table = Terminal::Table.new do |t|
|
214
|
+
t.add_row [1, 'One']
|
215
|
+
t.add_row [2, 'Two']
|
216
|
+
t.add_row [3, 'Three']
|
217
|
+
t.style = {:all_separators => true}
|
218
|
+
end
|
219
|
+
|
220
|
+
# > puts table
|
221
|
+
#
|
222
|
+
# +---+-------+
|
223
|
+
# | 1 | One |
|
224
|
+
# +---+-------+
|
225
|
+
# | 2 | Two |
|
226
|
+
# +---+-------+
|
227
|
+
# | 3 | Three |
|
228
|
+
# +---+-------+
|
229
|
+
```
|
230
|
+
You can also use styles to disable top and bottom borders of the table.
|
231
|
+
|
232
|
+
```ruby
|
233
|
+
table = Terminal::Table.new do |t|
|
234
|
+
t.headings = ['id', 'name']
|
235
|
+
t.rows = [[1, 'One'], [2, 'Two'], [3, 'Three']]
|
236
|
+
t.style = { :border_top => false, :border_bottom => false }
|
237
|
+
end
|
238
|
+
|
239
|
+
# > puts table
|
240
|
+
# | id | name |
|
241
|
+
# +----+-------+
|
242
|
+
# | 1 | One |
|
243
|
+
# | 2 | Two |
|
244
|
+
# | 3 | Three |
|
245
|
+
```
|
246
|
+
|
247
|
+
And also to disable left and right borders of the table.
|
248
|
+
|
249
|
+
```ruby
|
250
|
+
table = Terminal::Table.new do |t|
|
251
|
+
t.headings = ['id', 'name']
|
252
|
+
t.rows = [[1, 'One'], [2, 'Two'], [3, 'Three']]
|
253
|
+
t.style = { :border_left => false, :border_right => false }
|
254
|
+
end
|
255
|
+
|
256
|
+
# > puts table
|
257
|
+
# ----+-------
|
258
|
+
# id | name
|
259
|
+
# ----+-------
|
260
|
+
# 1 | One
|
261
|
+
# 2 | Two
|
262
|
+
# 3 | Three
|
263
|
+
# ----+-------
|
264
|
+
```
|
265
|
+
|
266
|
+
To change the default style options:
|
267
|
+
|
268
|
+
```ruby
|
269
|
+
Terminal::Table::Style.defaults = {:width => 80}
|
270
|
+
```
|
271
|
+
All Table objects created afterwards will inherit these defaults.
|
272
|
+
|
273
|
+
### Constructor options and setter methods
|
274
|
+
|
275
|
+
Valid options for the constructor are `:rows`, `:headings`, `:style` and `:title` -
|
276
|
+
and all options can also be set on the created table object by their setter
|
277
|
+
method:
|
278
|
+
|
279
|
+
```ruby
|
280
|
+
table = Terminal::Table.new
|
281
|
+
table.title = "Cheatsheet"
|
282
|
+
table.headings = ['Word', 'Number']
|
283
|
+
table.rows = rows
|
284
|
+
table.style = {:width => 40}
|
285
|
+
```
|
286
|
+
|
287
|
+
## New Formatting
|
288
|
+
|
289
|
+
### Unicode Table Borders
|
290
|
+
Support for Unicode 'box art' borders presented a challenge, as the original terminal-table only handled three border types: horizontal (x), vertical (y), and intersection (i). For proper box-art, it became necessary to enable different types of corners/edges for multiple intersection types.
|
291
|
+
|
292
|
+
For the sake of backward compatiblity, the previous interface is still supported, as this gem has been around a long time and making breaking changes would have been inconvenient. The new interface is required for any complex and/or Unicode style bordering. A few variations on border style are supported via some new classes and creation of additional classes (or modification of characters used in existing ones) will allow for customized border types.
|
293
|
+
|
294
|
+
The simplest way to use an alternate border is one of the following:
|
295
|
+
```
|
296
|
+
table.style = { :border => :unicode }
|
297
|
+
table.style = { :border => :unicode_round }
|
298
|
+
table.style = { :border => :unicode_thick_edge }
|
299
|
+
```
|
300
|
+
|
301
|
+
These are a convenience wrapper around setting border using an instance of a class that inherits from Table::Terminal::Border
|
302
|
+
```
|
303
|
+
table.style = { :border => Terminal::Table::UnicodeBorder.new() }
|
304
|
+
table.style = { :border => Terminal::Table::UnicodeRoundBorder.new() }
|
305
|
+
table.style = { :border => Terminal::Table::UnicodeThickEdgeBorder.new() }
|
306
|
+
```
|
307
|
+
|
308
|
+
If you define a custom class and wish to use the symbol shortcut, you must namespace within `Terminal::Table` and end your class name with `Border`.
|
309
|
+
|
310
|
+
### Markdown Compatiblity
|
311
|
+
Per popular request, Markdown formatted tables can be generated by using the following border style:
|
312
|
+
|
313
|
+
```
|
314
|
+
table.style = { :border => :markdown }
|
315
|
+
```
|
316
|
+
|
317
|
+
### Ascii Borders
|
318
|
+
Ascii borders are default, but can be explicitly set with:
|
319
|
+
```
|
320
|
+
table.style = { :border => :ascii }
|
321
|
+
```
|
322
|
+
|
323
|
+
### Customizing Borders
|
324
|
+
Inside the `UnicodeBorder` class, there are definitions for a variety of corner/intersection and divider types.
|
325
|
+
|
326
|
+
```ruby
|
327
|
+
@data = {
|
328
|
+
nil => nil,
|
329
|
+
nw: "┌", nx: "─", n: "┬", ne: "┐",
|
330
|
+
yw: "│", y: "│", ye: "│",
|
331
|
+
aw: "╞", ax: "═", ai: "╪", ae: "╡", ad: '╤', au: "╧", # double
|
332
|
+
bw: "┝", bx: "━", bi: "┿", be: "┥", bd: '┯', bu: "┷", # heavy/bold/thick
|
333
|
+
w: "├", x: "─", i: "┼", e: "┤", dn: "┬", up: "┴", # normal div
|
334
|
+
sw: "└", sx: "─", s: "┴", se: "┘",
|
335
|
+
# alternative dots/dashes
|
336
|
+
x_dot4: '┈', x_dot3: '┄', x_dash: '╌',
|
337
|
+
bx_dot4: '┉', bx_dot3: '┅', bx_dash: '╍',
|
338
|
+
}
|
339
|
+
```
|
340
|
+
|
341
|
+
Note that many are defined as directional (:nw == north-west), others defined in terms of 'x' or 'y'.
|
342
|
+
The border that separates headings (below each heading) is of type `:double` and is defined with `a*` entries.
|
343
|
+
Alternate `:heavy` types that can be applied to separators can be defined with `b*` entries.
|
344
|
+
|
345
|
+
When defining a new set of borders, it's probably easiest to define a new class that inherits from UnicodeBorder and replaces the `@data` Hash.
|
346
|
+
However, these elements can be these can be overridden by poking setting the Hash, should the need arise:
|
347
|
+
|
348
|
+
```
|
349
|
+
table.style = {border: :unicode}
|
350
|
+
table.style.border[:nw] = '*' # Override the north-west corner of the table
|
351
|
+
```
|
352
|
+
|
353
|
+
### Customizing row separators
|
354
|
+
|
355
|
+
Row-separators can now be customized in a variety of ways. The default separator's border_type is referred to as `:div`. Additional separator border types (e.g. `:double`, `:heavy`, `:dash` - see full list below) can be applied to separate the sections (e.g. header/footer/title).
|
356
|
+
|
357
|
+
The separator's `border_type` may be specified when a user-defined separator is added. Alternatively, borders may be adjusted after the table's rows are elaborated, but before the table is rendered.
|
358
|
+
|
359
|
+
Separator `border_type`s can be adjusted to be heavy, use double-lines, and different dash/dot styles. The border type should be one of:
|
360
|
+
|
361
|
+
div dash dot3 dot4
|
362
|
+
thick thick_dash thick_dot3 thick_dot4
|
363
|
+
heavy heavy_dash heavy_dot3 heavy_dot4
|
364
|
+
bold bold_dash bold_dot3 bold_dot4
|
365
|
+
double
|
366
|
+
|
367
|
+
To manually set the separator border_type, the `add_separator` method may be called.
|
368
|
+
```ruby
|
369
|
+
add_separator(border_type: :heavy_dash)
|
370
|
+
```
|
371
|
+
|
372
|
+
Alternatively, if `style: :all_separators` is used at the table level, it may be necessary to elaborate the implicit Separator rows prior to rendering.
|
373
|
+
```ruby
|
374
|
+
table = Terminal::Table.new do |t|
|
375
|
+
t.add_row [1, 'One']
|
376
|
+
t.add_row [2, 'Two']
|
377
|
+
t.add_row [3, 'Three']
|
378
|
+
t.style = {:all_separators => true}
|
379
|
+
end
|
380
|
+
rows = table.elaborate_rows
|
381
|
+
rows[2].border_type = :heavy # modify separator row: emphasize below title
|
382
|
+
puts table.render
|
383
|
+
```
|
384
|
+
|
385
|
+
## Example: Displaying a small CSV spreadsheet
|
386
|
+
|
387
|
+
This example code demonstrates using Terminal-table and CSV to display a small spreadsheet.
|
388
|
+
|
389
|
+
```ruby
|
390
|
+
#!/usr/bin/env ruby
|
391
|
+
require "csv"
|
392
|
+
require "terminal-table"
|
393
|
+
use_stdin = ARGV[0].nil? || (ARGV[0] == '-')
|
394
|
+
io_object = use_stdin ? $stdin : File.open(ARGV[0], 'r')
|
395
|
+
csv = CSV.new(io_object)
|
396
|
+
csv_array = csv.to_a
|
397
|
+
user_table = Terminal::Table.new do |v|
|
398
|
+
v.style = { :border => :unicode_round } # >= v3.0.0
|
399
|
+
v.title = "Some Title"
|
400
|
+
v.headings = csv_array[0]
|
401
|
+
v.rows = csv_array[1..-1]
|
402
|
+
end
|
403
|
+
puts user_table
|
404
|
+
```
|
405
|
+
|
406
|
+
See also `examples/show_csv_table.rb` in the source distribution.
|
407
|
+
|
408
|
+
## More examples
|
409
|
+
|
410
|
+
For more examples, please see the `examples` directory included in the
|
411
|
+
source distribution.
|
412
|
+
|
413
|
+
## Author
|
414
|
+
|
415
|
+
TJ Holowaychuk <tj@vision-media.ca>
|
416
|
+
|
417
|
+
Unicode table support by Ben Bowers https://github.com/nanobowers
|
data/bundle/ruby/3.1.0/gems/{terminal-table-1.8.0 → terminal-table-3.0.2}/lib/terminal-table/cell.rb
RENAMED
@@ -57,7 +57,7 @@ module Terminal
|
|
57
57
|
def render(line = 0)
|
58
58
|
left = " " * @table.style.padding_left
|
59
59
|
right = " " * @table.style.padding_right
|
60
|
-
display_width = Unicode::DisplayWidth.of(
|
60
|
+
display_width = Unicode::DisplayWidth.of(Util::ansi_escape(lines[line]))
|
61
61
|
render_width = lines[line].to_s.size - display_width + width
|
62
62
|
align("#{left}#{lines[line]}#{right}", alignment, render_width + @table.cell_padding)
|
63
63
|
end
|
@@ -68,7 +68,7 @@ module Terminal
|
|
68
68
|
# removes all ANSI escape sequences (e.g. color)
|
69
69
|
|
70
70
|
def value_for_column_width_recalc
|
71
|
-
lines.map{ |s|
|
71
|
+
lines.map{ |s| Util::ansi_escape(s) }.max_by{ |s| Unicode::DisplayWidth.of(s) }
|
72
72
|
end
|
73
73
|
|
74
74
|
##
|
@@ -82,12 +82,12 @@ module Terminal
|
|
82
82
|
inner_width + padding
|
83
83
|
end
|
84
84
|
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
85
|
+
def inspect
|
86
|
+
fields = %i[alignment colspan index value width].map do |name|
|
87
|
+
val = self.instance_variable_get('@'+name.to_s)
|
88
|
+
"@#{name}=#{val.inspect}"
|
89
|
+
end.join(', ')
|
90
|
+
return "#<#{self.class} #{fields}>"
|
91
91
|
end
|
92
92
|
end
|
93
93
|
end
|
data/bundle/ruby/3.1.0/gems/{terminal-table-1.8.0 → terminal-table-3.0.2}/lib/terminal-table/row.rb
RENAMED
@@ -12,7 +12,7 @@ module Terminal
|
|
12
12
|
##
|
13
13
|
# Initialize with _width_ and _options_.
|
14
14
|
|
15
|
-
def initialize table, array = []
|
15
|
+
def initialize table, array = [], **_kwargs
|
16
16
|
@cell_index = 0
|
17
17
|
@table = table
|
18
18
|
@cells = []
|
@@ -36,17 +36,31 @@ module Terminal
|
|
36
36
|
end
|
37
37
|
|
38
38
|
def render
|
39
|
-
|
39
|
+
vleft, vcenter, vright = @table.style.vertical
|
40
40
|
(0...height).to_a.map do |line|
|
41
|
-
|
41
|
+
vleft + cells.map do |cell|
|
42
42
|
cell.render(line)
|
43
|
-
end.join(
|
43
|
+
end.join(vcenter) + vright
|
44
44
|
end.join("\n")
|
45
45
|
end
|
46
46
|
|
47
47
|
def number_of_columns
|
48
48
|
@cells.collect(&:colspan).inject(0, &:+)
|
49
49
|
end
|
50
|
+
|
51
|
+
# used to find indices where we have table '+' crossings.
|
52
|
+
# in cases where the colspan > 1, then we will skip over some numbers
|
53
|
+
# if colspan is always 1, then the list should be incrementing by 1.
|
54
|
+
#
|
55
|
+
# skip 0 entry, because it's the left side.
|
56
|
+
# skip last entry, because it's the right side.
|
57
|
+
# we only care about "+/T" style crossings.
|
58
|
+
def crossings
|
59
|
+
idx = 0
|
60
|
+
@cells[0...-1].map { |c| idx += c.colspan }
|
61
|
+
end
|
62
|
+
|
50
63
|
end
|
64
|
+
|
51
65
|
end
|
52
66
|
end
|
@@ -0,0 +1,66 @@
|
|
1
|
+
module Terminal
|
2
|
+
class Table
|
3
|
+
class Separator < Row
|
4
|
+
|
5
|
+
##
|
6
|
+
# `prevrow`, `nextrow` contain references to adjacent rows.
|
7
|
+
#
|
8
|
+
# `border_type` is a symbol used to control which type of border is used
|
9
|
+
# on the separator (:top for top-edge, :bot for bottom-edge,
|
10
|
+
# :div for interior, and :strong for emphasized-interior)
|
11
|
+
#
|
12
|
+
# `implicit` is false for user-added separators, and true for
|
13
|
+
# implicit/auto-generated separators.
|
14
|
+
|
15
|
+
def initialize(*args, border_type: :div, implicit: false)
|
16
|
+
super
|
17
|
+
@prevrow, @nextrow = nil, nil
|
18
|
+
@border_type = border_type
|
19
|
+
@implicit = implicit
|
20
|
+
end
|
21
|
+
|
22
|
+
attr_accessor :border_type
|
23
|
+
attr_reader :implicit
|
24
|
+
|
25
|
+
def render
|
26
|
+
left_edge, ctrflat, ctrud, right_edge, ctrdn, ctrup = @table.style.horizontal(border_type)
|
27
|
+
|
28
|
+
prev_crossings = @prevrow.respond_to?(:crossings) ? @prevrow.crossings : []
|
29
|
+
next_crossings = @nextrow.respond_to?(:crossings) ? @nextrow.crossings : []
|
30
|
+
rval = [left_edge]
|
31
|
+
numcols = @table.number_of_columns
|
32
|
+
(0...numcols).each do |idx|
|
33
|
+
rval << ctrflat * (@table.column_width(idx) + @table.cell_padding)
|
34
|
+
pcinc = prev_crossings.include?(idx+1)
|
35
|
+
ncinc = next_crossings.include?(idx+1)
|
36
|
+
border_center = if pcinc && ncinc
|
37
|
+
ctrud
|
38
|
+
elsif pcinc
|
39
|
+
ctrup
|
40
|
+
elsif ncinc
|
41
|
+
ctrdn
|
42
|
+
elsif !ctrud.empty?
|
43
|
+
# special case if the center-up-down intersection is empty
|
44
|
+
# which happens when verticals/intersections are removed. in that case
|
45
|
+
# we do not want to replace with a flat element so return empty-string in else block
|
46
|
+
ctrflat
|
47
|
+
else
|
48
|
+
''
|
49
|
+
end
|
50
|
+
rval << border_center if idx < numcols-1
|
51
|
+
end
|
52
|
+
|
53
|
+
rval << right_edge
|
54
|
+
rval.join
|
55
|
+
end
|
56
|
+
|
57
|
+
# Save off neighboring rows, so that we can use them later in determining
|
58
|
+
# which types of table edges to use.
|
59
|
+
def save_adjacent_rows(prevrow, nextrow)
|
60
|
+
@prevrow = prevrow
|
61
|
+
@nextrow = nextrow
|
62
|
+
end
|
63
|
+
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|