brakeman 6.2.2 → 7.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGES.md +26 -0
- data/README.md +1 -1
- data/bundle/load.rb +10 -8
- data/bundle/ruby/3.1.0/gems/csv-3.3.3/LICENSE.txt +33 -0
- data/bundle/ruby/3.1.0/gems/csv-3.3.3/NEWS.md +990 -0
- data/bundle/ruby/3.1.0/gems/csv-3.3.3/README.md +55 -0
- data/bundle/ruby/3.1.0/gems/csv-3.3.3/lib/csv/core_ext/array.rb +9 -0
- data/bundle/ruby/3.1.0/gems/csv-3.3.3/lib/csv/core_ext/string.rb +9 -0
- data/bundle/ruby/3.1.0/gems/csv-3.3.3/lib/csv/fields_converter.rb +96 -0
- data/bundle/ruby/3.1.0/gems/csv-3.3.3/lib/csv/input_record_separator.rb +18 -0
- data/bundle/ruby/3.1.0/gems/csv-3.3.3/lib/csv/parser.rb +1302 -0
- data/bundle/ruby/3.1.0/gems/csv-3.3.3/lib/csv/row.rb +757 -0
- data/bundle/ruby/3.1.0/gems/csv-3.3.3/lib/csv/table.rb +1055 -0
- data/bundle/ruby/3.1.0/gems/csv-3.3.3/lib/csv/version.rb +6 -0
- data/bundle/ruby/3.1.0/gems/csv-3.3.3/lib/csv/writer.rb +209 -0
- data/bundle/ruby/3.1.0/gems/csv-3.3.3/lib/csv.rb +3017 -0
- data/bundle/ruby/3.1.0/gems/{highline-3.1.1 → highline-3.1.2}/Changelog.md +4 -0
- data/bundle/ruby/3.1.0/gems/{highline-3.1.1 → highline-3.1.2}/Gemfile +1 -0
- data/bundle/ruby/3.1.0/gems/{highline-3.1.1 → highline-3.1.2}/lib/highline/list_renderer.rb +2 -2
- data/bundle/ruby/3.1.0/gems/{highline-3.1.1 → highline-3.1.2}/lib/highline/menu.rb +7 -5
- data/bundle/ruby/3.1.0/gems/{highline-3.1.1 → highline-3.1.2}/lib/highline/version.rb +1 -1
- data/bundle/ruby/3.1.0/gems/{highline-3.1.1 → highline-3.1.2}/lib/highline.rb +17 -12
- 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.1}/NEWS.md +74 -0
- data/bundle/ruby/3.1.0/gems/{rexml-3.3.8 → rexml-3.4.1}/lib/rexml/parsers/baseparser.rb +78 -48
- data/bundle/ruby/3.1.0/gems/{rexml-3.3.8 → rexml-3.4.1}/lib/rexml/parsers/pullparser.rb +4 -0
- data/bundle/ruby/3.1.0/gems/{rexml-3.3.8 → rexml-3.4.1}/lib/rexml/rexml.rb +1 -1
- data/bundle/ruby/3.1.0/gems/{rexml-3.3.8 → rexml-3.4.1}/lib/rexml/source.rb +61 -6
- data/bundle/ruby/3.1.0/gems/{rexml-3.3.8 → rexml-3.4.1}/lib/rexml/text.rb +15 -40
- data/bundle/ruby/3.1.0/gems/{ruby2ruby-2.5.1 → ruby2ruby-2.5.2}/History.rdoc +6 -0
- data/bundle/ruby/3.1.0/gems/{ruby2ruby-2.5.1 → ruby2ruby-2.5.2}/lib/ruby2ruby.rb +7 -4
- 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-4.0.0/History.rdoc +149 -0
- data/bundle/ruby/3.1.0/gems/terminal-table-4.0.0/README.md +417 -0
- data/bundle/ruby/3.1.0/gems/{terminal-table-1.8.0 → terminal-table-4.0.0}/lib/terminal-table/cell.rb +9 -9
- data/bundle/ruby/3.1.0/gems/{terminal-table-1.8.0 → terminal-table-4.0.0}/lib/terminal-table/row.rb +18 -4
- data/bundle/ruby/3.1.0/gems/terminal-table-4.0.0/lib/terminal-table/separator.rb +66 -0
- data/bundle/ruby/3.1.0/gems/terminal-table-4.0.0/lib/terminal-table/style.rb +284 -0
- data/bundle/ruby/3.1.0/gems/{terminal-table-1.8.0 → terminal-table-4.0.0}/lib/terminal-table/table.rb +49 -18
- data/bundle/ruby/3.1.0/gems/terminal-table-4.0.0/lib/terminal-table/util.rb +13 -0
- data/bundle/ruby/3.1.0/gems/{terminal-table-1.8.0 → terminal-table-4.0.0}/lib/terminal-table/version.rb +1 -1
- data/bundle/ruby/3.1.0/gems/{terminal-table-1.8.0 → terminal-table-4.0.0}/lib/terminal-table.rb +2 -2
- data/bundle/ruby/3.1.0/gems/{terminal-table-1.8.0 → terminal-table-4.0.0}/terminal-table.gemspec +3 -4
- data/bundle/ruby/3.1.0/gems/{tilt-2.4.0 → tilt-2.6.0}/lib/tilt/creole.rb +2 -0
- data/bundle/ruby/3.1.0/gems/{tilt-2.4.0 → tilt-2.6.0}/lib/tilt/liquid.rb +0 -3
- data/bundle/ruby/3.1.0/gems/{tilt-2.4.0 → tilt-2.6.0}/lib/tilt/mapping.rb +3 -3
- data/bundle/ruby/3.1.0/gems/{tilt-2.4.0 → tilt-2.6.0}/lib/tilt/rdoc.rb +0 -8
- data/bundle/ruby/3.1.0/gems/{tilt-2.4.0 → tilt-2.6.0}/lib/tilt/template.rb +178 -27
- data/bundle/ruby/3.1.0/gems/{tilt-2.4.0 → tilt-2.6.0}/lib/tilt.rb +9 -4
- data/bundle/ruby/3.1.0/gems/unicode-display_width-3.1.4/CHANGELOG.md +291 -0
- data/bundle/ruby/3.1.0/gems/{unicode-display_width-1.8.0 → unicode-display_width-3.1.4}/MIT-LICENSE.txt +1 -1
- data/bundle/ruby/3.1.0/gems/unicode-display_width-3.1.4/README.md +194 -0
- data/bundle/ruby/3.1.0/gems/unicode-display_width-3.1.4/data/display_width.marshal.gz +0 -0
- data/bundle/ruby/3.1.0/gems/unicode-display_width-3.1.4/lib/unicode/display_width/constants.rb +10 -0
- data/bundle/ruby/3.1.0/gems/unicode-display_width-3.1.4/lib/unicode/display_width/emoji_support.rb +52 -0
- data/bundle/ruby/3.1.0/gems/unicode-display_width-3.1.4/lib/unicode/display_width/index.rb +34 -0
- data/bundle/ruby/3.1.0/gems/unicode-display_width-3.1.4/lib/unicode/display_width/no_string_ext.rb +8 -0
- data/bundle/ruby/3.1.0/gems/unicode-display_width-3.1.4/lib/unicode/display_width/reline_ext.rb +14 -0
- data/bundle/ruby/3.1.0/gems/unicode-display_width-3.1.4/lib/unicode/display_width/string_ext.rb +9 -0
- data/bundle/ruby/3.1.0/gems/unicode-display_width-3.1.4/lib/unicode/display_width.rb +247 -0
- data/bundle/ruby/3.1.0/gems/unicode-emoji-4.0.4/CHANGELOG.md +191 -0
- data/bundle/ruby/3.1.0/gems/unicode-emoji-4.0.4/CODE_OF_CONDUCT.md +74 -0
- data/bundle/ruby/3.1.0/gems/unicode-emoji-4.0.4/Gemfile +7 -0
- data/bundle/ruby/3.1.0/gems/unicode-emoji-4.0.4/Gemfile.lock +33 -0
- data/bundle/ruby/3.1.0/gems/unicode-emoji-4.0.4/MIT-LICENSE.txt +20 -0
- data/bundle/ruby/3.1.0/gems/unicode-emoji-4.0.4/README.md +205 -0
- data/bundle/ruby/3.1.0/gems/unicode-emoji-4.0.4/data/emoji.marshal.gz +0 -0
- data/bundle/ruby/3.1.0/gems/unicode-emoji-4.0.4/data/generate_constants.rb +344 -0
- data/bundle/ruby/3.1.0/gems/unicode-emoji-4.0.4/lib/unicode/emoji/constants.rb +49 -0
- data/bundle/ruby/3.1.0/gems/unicode-emoji-4.0.4/lib/unicode/emoji/generated/regex.rb +8 -0
- data/bundle/ruby/3.1.0/gems/unicode-emoji-4.0.4/lib/unicode/emoji/generated/regex_basic.rb +8 -0
- data/bundle/ruby/3.1.0/gems/unicode-emoji-4.0.4/lib/unicode/emoji/generated/regex_emoji_keycap.rb +8 -0
- data/bundle/ruby/3.1.0/gems/unicode-emoji-4.0.4/lib/unicode/emoji/generated/regex_include_mqe.rb +8 -0
- data/bundle/ruby/3.1.0/gems/unicode-emoji-4.0.4/lib/unicode/emoji/generated/regex_include_mqe_uqe.rb +8 -0
- data/bundle/ruby/3.1.0/gems/unicode-emoji-4.0.4/lib/unicode/emoji/generated/regex_include_text.rb +8 -0
- data/bundle/ruby/3.1.0/gems/unicode-emoji-4.0.4/lib/unicode/emoji/generated/regex_picto.rb +8 -0
- data/bundle/ruby/3.1.0/gems/unicode-emoji-4.0.4/lib/unicode/emoji/generated/regex_picto_no_emoji.rb +8 -0
- data/bundle/ruby/3.1.0/gems/unicode-emoji-4.0.4/lib/unicode/emoji/generated/regex_possible.rb +8 -0
- data/bundle/ruby/3.1.0/gems/unicode-emoji-4.0.4/lib/unicode/emoji/generated/regex_prop_component.rb +8 -0
- data/bundle/ruby/3.1.0/gems/unicode-emoji-4.0.4/lib/unicode/emoji/generated/regex_prop_emoji.rb +8 -0
- data/bundle/ruby/3.1.0/gems/unicode-emoji-4.0.4/lib/unicode/emoji/generated/regex_prop_modifier.rb +8 -0
- data/bundle/ruby/3.1.0/gems/unicode-emoji-4.0.4/lib/unicode/emoji/generated/regex_prop_modifier_base.rb +8 -0
- data/bundle/ruby/3.1.0/gems/unicode-emoji-4.0.4/lib/unicode/emoji/generated/regex_prop_presentation.rb +8 -0
- data/bundle/ruby/3.1.0/gems/unicode-emoji-4.0.4/lib/unicode/emoji/generated/regex_text.rb +8 -0
- data/bundle/ruby/3.1.0/gems/unicode-emoji-4.0.4/lib/unicode/emoji/generated/regex_text_presentation.rb +8 -0
- data/bundle/ruby/3.1.0/gems/unicode-emoji-4.0.4/lib/unicode/emoji/generated/regex_valid.rb +8 -0
- data/bundle/ruby/3.1.0/gems/unicode-emoji-4.0.4/lib/unicode/emoji/generated/regex_valid_include_text.rb +8 -0
- data/bundle/ruby/3.1.0/gems/unicode-emoji-4.0.4/lib/unicode/emoji/generated/regex_well_formed.rb +8 -0
- data/bundle/ruby/3.1.0/gems/unicode-emoji-4.0.4/lib/unicode/emoji/generated/regex_well_formed_include_text.rb +8 -0
- data/bundle/ruby/3.1.0/gems/unicode-emoji-4.0.4/lib/unicode/emoji/generated_native/regex.rb +8 -0
- data/bundle/ruby/3.1.0/gems/unicode-emoji-4.0.4/lib/unicode/emoji/generated_native/regex_basic.rb +8 -0
- data/bundle/ruby/3.1.0/gems/unicode-emoji-4.0.4/lib/unicode/emoji/generated_native/regex_emoji_keycap.rb +8 -0
- data/bundle/ruby/3.1.0/gems/unicode-emoji-4.0.4/lib/unicode/emoji/generated_native/regex_include_mqe.rb +8 -0
- data/bundle/ruby/3.1.0/gems/unicode-emoji-4.0.4/lib/unicode/emoji/generated_native/regex_include_mqe_uqe.rb +8 -0
- data/bundle/ruby/3.1.0/gems/unicode-emoji-4.0.4/lib/unicode/emoji/generated_native/regex_include_text.rb +8 -0
- data/bundle/ruby/3.1.0/gems/unicode-emoji-4.0.4/lib/unicode/emoji/generated_native/regex_picto.rb +8 -0
- data/bundle/ruby/3.1.0/gems/unicode-emoji-4.0.4/lib/unicode/emoji/generated_native/regex_picto_no_emoji.rb +8 -0
- data/bundle/ruby/3.1.0/gems/unicode-emoji-4.0.4/lib/unicode/emoji/generated_native/regex_possible.rb +8 -0
- data/bundle/ruby/3.1.0/gems/unicode-emoji-4.0.4/lib/unicode/emoji/generated_native/regex_prop_component.rb +8 -0
- data/bundle/ruby/3.1.0/gems/unicode-emoji-4.0.4/lib/unicode/emoji/generated_native/regex_prop_emoji.rb +8 -0
- data/bundle/ruby/3.1.0/gems/unicode-emoji-4.0.4/lib/unicode/emoji/generated_native/regex_prop_modifier.rb +8 -0
- data/bundle/ruby/3.1.0/gems/unicode-emoji-4.0.4/lib/unicode/emoji/generated_native/regex_prop_modifier_base.rb +8 -0
- data/bundle/ruby/3.1.0/gems/unicode-emoji-4.0.4/lib/unicode/emoji/generated_native/regex_prop_presentation.rb +8 -0
- data/bundle/ruby/3.1.0/gems/unicode-emoji-4.0.4/lib/unicode/emoji/generated_native/regex_text.rb +8 -0
- data/bundle/ruby/3.1.0/gems/unicode-emoji-4.0.4/lib/unicode/emoji/generated_native/regex_text_presentation.rb +8 -0
- data/bundle/ruby/3.1.0/gems/unicode-emoji-4.0.4/lib/unicode/emoji/generated_native/regex_valid.rb +8 -0
- data/bundle/ruby/3.1.0/gems/unicode-emoji-4.0.4/lib/unicode/emoji/generated_native/regex_valid_include_text.rb +8 -0
- data/bundle/ruby/3.1.0/gems/unicode-emoji-4.0.4/lib/unicode/emoji/generated_native/regex_well_formed.rb +8 -0
- data/bundle/ruby/3.1.0/gems/unicode-emoji-4.0.4/lib/unicode/emoji/generated_native/regex_well_formed_include_text.rb +8 -0
- data/bundle/ruby/3.1.0/gems/{unicode-display_width-1.8.0/lib/unicode/display_width → unicode-emoji-4.0.4/lib/unicode/emoji}/index.rb +5 -3
- data/bundle/ruby/3.1.0/gems/unicode-emoji-4.0.4/lib/unicode/emoji/lazy_constants.rb +56 -0
- data/bundle/ruby/3.1.0/gems/unicode-emoji-4.0.4/lib/unicode/emoji/list.rb +13 -0
- data/bundle/ruby/3.1.0/gems/unicode-emoji-4.0.4/lib/unicode/emoji.rb +111 -0
- data/bundle/ruby/3.1.0/gems/unicode-emoji-4.0.4/unicode-emoji.gemspec +22 -0
- data/lib/brakeman/app_tree.rb +29 -19
- data/lib/brakeman/checks/check_deserialize.rb +4 -1
- data/lib/brakeman/checks/check_evaluation.rb +45 -8
- data/lib/brakeman/checks/check_model_attr_accessible.rb +1 -0
- data/lib/brakeman/checks/check_weak_rsa_key.rb +1 -1
- data/lib/brakeman/file_parser.rb +2 -1
- data/lib/brakeman/options.rb +12 -5
- data/lib/brakeman/processors/alias_processor.rb +9 -4
- 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 +84 -51
- 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 +19 -2
- metadata +265 -199
- 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/CHANGELOG.md +0 -137
- data/bundle/ruby/3.1.0/gems/unicode-display_width-1.8.0/README.md +0 -124
- 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/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/{highline-3.1.1 → highline-3.1.2}/AUTHORS +0 -0
- /data/bundle/ruby/3.1.0/gems/{highline-3.1.1 → highline-3.1.2}/COPYING +0 -0
- /data/bundle/ruby/3.1.0/gems/{highline-3.1.1 → highline-3.1.2}/LICENSE +0 -0
- /data/bundle/ruby/3.1.0/gems/{highline-3.1.1 → highline-3.1.2}/README.md +0 -0
- /data/bundle/ruby/3.1.0/gems/{highline-3.1.1 → highline-3.1.2}/TODO +0 -0
- /data/bundle/ruby/3.1.0/gems/{highline-3.1.1 → highline-3.1.2}/highline.gemspec +0 -0
- /data/bundle/ruby/3.1.0/gems/{highline-3.1.1 → highline-3.1.2}/lib/highline/builtin_styles.rb +0 -0
- /data/bundle/ruby/3.1.0/gems/{highline-3.1.1 → highline-3.1.2}/lib/highline/color_scheme.rb +0 -0
- /data/bundle/ruby/3.1.0/gems/{highline-3.1.1 → highline-3.1.2}/lib/highline/compatibility.rb +0 -0
- /data/bundle/ruby/3.1.0/gems/{highline-3.1.1 → highline-3.1.2}/lib/highline/custom_errors.rb +0 -0
- /data/bundle/ruby/3.1.0/gems/{highline-3.1.1 → highline-3.1.2}/lib/highline/import.rb +0 -0
- /data/bundle/ruby/3.1.0/gems/{highline-3.1.1 → highline-3.1.2}/lib/highline/io_console_compatible.rb +0 -0
- /data/bundle/ruby/3.1.0/gems/{highline-3.1.1 → highline-3.1.2}/lib/highline/list.rb +0 -0
- /data/bundle/ruby/3.1.0/gems/{highline-3.1.1 → highline-3.1.2}/lib/highline/menu/item.rb +0 -0
- /data/bundle/ruby/3.1.0/gems/{highline-3.1.1 → highline-3.1.2}/lib/highline/paginator.rb +0 -0
- /data/bundle/ruby/3.1.0/gems/{highline-3.1.1 → highline-3.1.2}/lib/highline/question/answer_converter.rb +0 -0
- /data/bundle/ruby/3.1.0/gems/{highline-3.1.1 → highline-3.1.2}/lib/highline/question.rb +0 -0
- /data/bundle/ruby/3.1.0/gems/{highline-3.1.1 → highline-3.1.2}/lib/highline/question_asker.rb +0 -0
- /data/bundle/ruby/3.1.0/gems/{highline-3.1.1 → highline-3.1.2}/lib/highline/simulate.rb +0 -0
- /data/bundle/ruby/3.1.0/gems/{highline-3.1.1 → highline-3.1.2}/lib/highline/statement.rb +0 -0
- /data/bundle/ruby/3.1.0/gems/{highline-3.1.1 → highline-3.1.2}/lib/highline/string.rb +0 -0
- /data/bundle/ruby/3.1.0/gems/{highline-3.1.1 → highline-3.1.2}/lib/highline/string_extensions.rb +0 -0
- /data/bundle/ruby/3.1.0/gems/{highline-3.1.1 → highline-3.1.2}/lib/highline/style.rb +0 -0
- /data/bundle/ruby/3.1.0/gems/{highline-3.1.1 → highline-3.1.2}/lib/highline/template_renderer.rb +0 -0
- /data/bundle/ruby/3.1.0/gems/{highline-3.1.1 → highline-3.1.2}/lib/highline/terminal/io_console.rb +0 -0
- /data/bundle/ruby/3.1.0/gems/{highline-3.1.1 → highline-3.1.2}/lib/highline/terminal/ncurses.rb +0 -0
- /data/bundle/ruby/3.1.0/gems/{highline-3.1.1 → highline-3.1.2}/lib/highline/terminal/unix_stty.rb +0 -0
- /data/bundle/ruby/3.1.0/gems/{highline-3.1.1 → highline-3.1.2}/lib/highline/terminal.rb +0 -0
- /data/bundle/ruby/3.1.0/gems/{highline-3.1.1 → highline-3.1.2}/lib/highline/wrapper.rb +0 -0
- /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.1}/LICENSE.txt +0 -0
- /data/bundle/ruby/3.1.0/gems/{rexml-3.3.8 → rexml-3.4.1}/README.md +0 -0
- /data/bundle/ruby/3.1.0/gems/{rexml-3.3.8 → rexml-3.4.1}/lib/rexml/attlistdecl.rb +0 -0
- /data/bundle/ruby/3.1.0/gems/{rexml-3.3.8 → rexml-3.4.1}/lib/rexml/attribute.rb +0 -0
- /data/bundle/ruby/3.1.0/gems/{rexml-3.3.8 → rexml-3.4.1}/lib/rexml/cdata.rb +0 -0
- /data/bundle/ruby/3.1.0/gems/{rexml-3.3.8 → rexml-3.4.1}/lib/rexml/child.rb +0 -0
- /data/bundle/ruby/3.1.0/gems/{rexml-3.3.8 → rexml-3.4.1}/lib/rexml/comment.rb +0 -0
- /data/bundle/ruby/3.1.0/gems/{rexml-3.3.8 → rexml-3.4.1}/lib/rexml/doctype.rb +0 -0
- /data/bundle/ruby/3.1.0/gems/{rexml-3.3.8 → rexml-3.4.1}/lib/rexml/document.rb +0 -0
- /data/bundle/ruby/3.1.0/gems/{rexml-3.3.8 → rexml-3.4.1}/lib/rexml/dtd/attlistdecl.rb +0 -0
- /data/bundle/ruby/3.1.0/gems/{rexml-3.3.8 → rexml-3.4.1}/lib/rexml/dtd/dtd.rb +0 -0
- /data/bundle/ruby/3.1.0/gems/{rexml-3.3.8 → rexml-3.4.1}/lib/rexml/dtd/elementdecl.rb +0 -0
- /data/bundle/ruby/3.1.0/gems/{rexml-3.3.8 → rexml-3.4.1}/lib/rexml/dtd/entitydecl.rb +0 -0
- /data/bundle/ruby/3.1.0/gems/{rexml-3.3.8 → rexml-3.4.1}/lib/rexml/dtd/notationdecl.rb +0 -0
- /data/bundle/ruby/3.1.0/gems/{rexml-3.3.8 → rexml-3.4.1}/lib/rexml/element.rb +0 -0
- /data/bundle/ruby/3.1.0/gems/{rexml-3.3.8 → rexml-3.4.1}/lib/rexml/encoding.rb +0 -0
- /data/bundle/ruby/3.1.0/gems/{rexml-3.3.8 → rexml-3.4.1}/lib/rexml/entity.rb +0 -0
- /data/bundle/ruby/3.1.0/gems/{rexml-3.3.8 → rexml-3.4.1}/lib/rexml/formatters/default.rb +0 -0
- /data/bundle/ruby/3.1.0/gems/{rexml-3.3.8 → rexml-3.4.1}/lib/rexml/formatters/pretty.rb +0 -0
- /data/bundle/ruby/3.1.0/gems/{rexml-3.3.8 → rexml-3.4.1}/lib/rexml/formatters/transitive.rb +0 -0
- /data/bundle/ruby/3.1.0/gems/{rexml-3.3.8 → rexml-3.4.1}/lib/rexml/functions.rb +0 -0
- /data/bundle/ruby/3.1.0/gems/{rexml-3.3.8 → rexml-3.4.1}/lib/rexml/instruction.rb +0 -0
- /data/bundle/ruby/3.1.0/gems/{rexml-3.3.8 → rexml-3.4.1}/lib/rexml/light/node.rb +0 -0
- /data/bundle/ruby/3.1.0/gems/{rexml-3.3.8 → rexml-3.4.1}/lib/rexml/namespace.rb +0 -0
- /data/bundle/ruby/3.1.0/gems/{rexml-3.3.8 → rexml-3.4.1}/lib/rexml/node.rb +0 -0
- /data/bundle/ruby/3.1.0/gems/{rexml-3.3.8 → rexml-3.4.1}/lib/rexml/output.rb +0 -0
- /data/bundle/ruby/3.1.0/gems/{rexml-3.3.8 → rexml-3.4.1}/lib/rexml/parent.rb +0 -0
- /data/bundle/ruby/3.1.0/gems/{rexml-3.3.8 → rexml-3.4.1}/lib/rexml/parseexception.rb +0 -0
- /data/bundle/ruby/3.1.0/gems/{rexml-3.3.8 → rexml-3.4.1}/lib/rexml/parsers/lightparser.rb +0 -0
- /data/bundle/ruby/3.1.0/gems/{rexml-3.3.8 → rexml-3.4.1}/lib/rexml/parsers/sax2parser.rb +0 -0
- /data/bundle/ruby/3.1.0/gems/{rexml-3.3.8 → rexml-3.4.1}/lib/rexml/parsers/streamparser.rb +0 -0
- /data/bundle/ruby/3.1.0/gems/{rexml-3.3.8 → rexml-3.4.1}/lib/rexml/parsers/treeparser.rb +0 -0
- /data/bundle/ruby/3.1.0/gems/{rexml-3.3.8 → rexml-3.4.1}/lib/rexml/parsers/ultralightparser.rb +0 -0
- /data/bundle/ruby/3.1.0/gems/{rexml-3.3.8 → rexml-3.4.1}/lib/rexml/parsers/xpathparser.rb +0 -0
- /data/bundle/ruby/3.1.0/gems/{rexml-3.3.8 → rexml-3.4.1}/lib/rexml/quickpath.rb +0 -0
- /data/bundle/ruby/3.1.0/gems/{rexml-3.3.8 → rexml-3.4.1}/lib/rexml/sax2listener.rb +0 -0
- /data/bundle/ruby/3.1.0/gems/{rexml-3.3.8 → rexml-3.4.1}/lib/rexml/security.rb +0 -0
- /data/bundle/ruby/3.1.0/gems/{rexml-3.3.8 → rexml-3.4.1}/lib/rexml/streamlistener.rb +0 -0
- /data/bundle/ruby/3.1.0/gems/{rexml-3.3.8 → rexml-3.4.1}/lib/rexml/undefinednamespaceexception.rb +0 -0
- /data/bundle/ruby/3.1.0/gems/{rexml-3.3.8 → rexml-3.4.1}/lib/rexml/validation/relaxng.rb +0 -0
- /data/bundle/ruby/3.1.0/gems/{rexml-3.3.8 → rexml-3.4.1}/lib/rexml/validation/validation.rb +0 -0
- /data/bundle/ruby/3.1.0/gems/{rexml-3.3.8 → rexml-3.4.1}/lib/rexml/validation/validationexception.rb +0 -0
- /data/bundle/ruby/3.1.0/gems/{rexml-3.3.8 → rexml-3.4.1}/lib/rexml/xmldecl.rb +0 -0
- /data/bundle/ruby/3.1.0/gems/{rexml-3.3.8 → rexml-3.4.1}/lib/rexml/xmltokens.rb +0 -0
- /data/bundle/ruby/3.1.0/gems/{rexml-3.3.8 → rexml-3.4.1}/lib/rexml/xpath.rb +0 -0
- /data/bundle/ruby/3.1.0/gems/{rexml-3.3.8 → rexml-3.4.1}/lib/rexml/xpath_parser.rb +0 -0
- /data/bundle/ruby/3.1.0/gems/{rexml-3.3.8 → rexml-3.4.1}/lib/rexml.rb +0 -0
- /data/bundle/ruby/3.1.0/gems/{ruby2ruby-2.5.1 → ruby2ruby-2.5.2}/Manifest.txt +0 -0
- /data/bundle/ruby/3.1.0/gems/{ruby2ruby-2.5.1 → ruby2ruby-2.5.2}/README.rdoc +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-4.0.0}/Gemfile +0 -0
- /data/bundle/ruby/3.1.0/gems/{terminal-table-1.8.0 → terminal-table-4.0.0}/LICENSE.txt +0 -0
- /data/bundle/ruby/3.1.0/gems/{terminal-table-1.8.0 → terminal-table-4.0.0}/Manifest +0 -0
- /data/bundle/ruby/3.1.0/gems/{terminal-table-1.8.0 → terminal-table-4.0.0}/Todo.rdoc +0 -0
- /data/bundle/ruby/3.1.0/gems/{terminal-table-1.8.0 → terminal-table-4.0.0}/lib/terminal-table/import.rb +0 -0
- /data/bundle/ruby/3.1.0/gems/{terminal-table-1.8.0 → terminal-table-4.0.0}/lib/terminal-table/table_helper.rb +0 -0
- /data/bundle/ruby/3.1.0/gems/{tilt-2.4.0 → tilt-2.6.0}/COPYING +0 -0
- /data/bundle/ruby/3.1.0/gems/{tilt-2.4.0 → tilt-2.6.0}/lib/tilt/_emacs_org.rb +0 -0
- /data/bundle/ruby/3.1.0/gems/{tilt-2.4.0 → tilt-2.6.0}/lib/tilt/_handlebars.rb +0 -0
- /data/bundle/ruby/3.1.0/gems/{tilt-2.4.0 → tilt-2.6.0}/lib/tilt/_jbuilder.rb +0 -0
- /data/bundle/ruby/3.1.0/gems/{tilt-2.4.0 → tilt-2.6.0}/lib/tilt/_org.rb +0 -0
- /data/bundle/ruby/3.1.0/gems/{tilt-2.4.0 → tilt-2.6.0}/lib/tilt/asciidoc.rb +0 -0
- /data/bundle/ruby/3.1.0/gems/{tilt-2.4.0 → tilt-2.6.0}/lib/tilt/babel.rb +0 -0
- /data/bundle/ruby/3.1.0/gems/{tilt-2.4.0 → tilt-2.6.0}/lib/tilt/builder.rb +0 -0
- /data/bundle/ruby/3.1.0/gems/{tilt-2.4.0 → tilt-2.6.0}/lib/tilt/cli.rb +0 -0
- /data/bundle/ruby/3.1.0/gems/{tilt-2.4.0 → tilt-2.6.0}/lib/tilt/coffee.rb +0 -0
- /data/bundle/ruby/3.1.0/gems/{tilt-2.4.0 → tilt-2.6.0}/lib/tilt/commonmarker.rb +0 -0
- /data/bundle/ruby/3.1.0/gems/{tilt-2.4.0 → tilt-2.6.0}/lib/tilt/csv.rb +0 -0
- /data/bundle/ruby/3.1.0/gems/{tilt-2.4.0 → tilt-2.6.0}/lib/tilt/erb.rb +0 -0
- /data/bundle/ruby/3.1.0/gems/{tilt-2.4.0 → tilt-2.6.0}/lib/tilt/erubi.rb +0 -0
- /data/bundle/ruby/3.1.0/gems/{tilt-2.4.0 → tilt-2.6.0}/lib/tilt/etanni.rb +0 -0
- /data/bundle/ruby/3.1.0/gems/{tilt-2.4.0 → tilt-2.6.0}/lib/tilt/haml.rb +0 -0
- /data/bundle/ruby/3.1.0/gems/{tilt-2.4.0 → tilt-2.6.0}/lib/tilt/kramdown.rb +0 -0
- /data/bundle/ruby/3.1.0/gems/{tilt-2.4.0 → tilt-2.6.0}/lib/tilt/livescript.rb +0 -0
- /data/bundle/ruby/3.1.0/gems/{tilt-2.4.0 → tilt-2.6.0}/lib/tilt/markaby.rb +0 -0
- /data/bundle/ruby/3.1.0/gems/{tilt-2.4.0 → tilt-2.6.0}/lib/tilt/nokogiri.rb +0 -0
- /data/bundle/ruby/3.1.0/gems/{tilt-2.4.0 → tilt-2.6.0}/lib/tilt/pandoc.rb +0 -0
- /data/bundle/ruby/3.1.0/gems/{tilt-2.4.0 → tilt-2.6.0}/lib/tilt/pipeline.rb +0 -0
- /data/bundle/ruby/3.1.0/gems/{tilt-2.4.0 → tilt-2.6.0}/lib/tilt/plain.rb +0 -0
- /data/bundle/ruby/3.1.0/gems/{tilt-2.4.0 → tilt-2.6.0}/lib/tilt/prawn.rb +0 -0
- /data/bundle/ruby/3.1.0/gems/{tilt-2.4.0 → tilt-2.6.0}/lib/tilt/radius.rb +0 -0
- /data/bundle/ruby/3.1.0/gems/{tilt-2.4.0 → tilt-2.6.0}/lib/tilt/rdiscount.rb +0 -0
- /data/bundle/ruby/3.1.0/gems/{tilt-2.4.0 → tilt-2.6.0}/lib/tilt/redcarpet.rb +0 -0
- /data/bundle/ruby/3.1.0/gems/{tilt-2.4.0 → tilt-2.6.0}/lib/tilt/redcloth.rb +0 -0
- /data/bundle/ruby/3.1.0/gems/{tilt-2.4.0 → tilt-2.6.0}/lib/tilt/rst-pandoc.rb +0 -0
- /data/bundle/ruby/3.1.0/gems/{tilt-2.4.0 → tilt-2.6.0}/lib/tilt/sass.rb +0 -0
- /data/bundle/ruby/3.1.0/gems/{tilt-2.4.0 → tilt-2.6.0}/lib/tilt/slim.rb +0 -0
- /data/bundle/ruby/3.1.0/gems/{tilt-2.4.0 → tilt-2.6.0}/lib/tilt/string.rb +0 -0
- /data/bundle/ruby/3.1.0/gems/{tilt-2.4.0 → tilt-2.6.0}/lib/tilt/typescript.rb +0 -0
- /data/bundle/ruby/3.1.0/gems/{tilt-2.4.0 → tilt-2.6.0}/lib/tilt/yajl.rb +0 -0
@@ -0,0 +1,194 @@
|
|
1
|
+
# Unicode::DisplayWidth [![[version]](https://badge.fury.io/rb/unicode-display_width.svg)](https://badge.fury.io/rb/unicode-display_width) [<img src="https://github.com/janlelis/unicode-display_width/workflows/Test/badge.svg" />](https://github.com/janlelis/unicode-display_width/actions?query=workflow%3ATest)
|
2
|
+
|
3
|
+
Determines the monospace display width of a string in Ruby, which is useful for all kinds of terminal-based applications. The implementation is based on [EastAsianWidth.txt](https://www.unicode.org/Public/UNIDATA/EastAsianWidth.txt), the [Emoji specfication](https://www.unicode.org/reports/tr51/) and other data, 100% in Ruby. It does not rely on the OS vendor ([wcwidth()](https://github.com/janlelis/wcswidth-ruby)) to provide an up-to-date method for measuring string width in terminals.
|
4
|
+
|
5
|
+
Unicode version: **16.0.0** (September 2024)
|
6
|
+
|
7
|
+
## Gem Version 3 — Improved Emoji Support
|
8
|
+
|
9
|
+
**Emoji support is now enabled by default.** See below for description and configuration possibilities.
|
10
|
+
|
11
|
+
**Unicode::DisplayWidth.of now takes keyword arguments:** { ambiguous:, emoji:, overwrite: }
|
12
|
+
|
13
|
+
See [CHANGELOG](/CHANGELOG.md) for details.
|
14
|
+
|
15
|
+
## Gem Version 2.4.2 — Performance Updates
|
16
|
+
|
17
|
+
**If you use this gem, you should really upgrade to 2.4.2 or newer. It's often 100x faster, sometimes even 1000x and more!**
|
18
|
+
|
19
|
+
This is possible because the gem now detects if you use very basic (and common) characters, like ASCII characters. Furthermore, the character width lookup code has been optimized, so even when the string involves full-width or ambiguous characters, the gem is much faster now.
|
20
|
+
|
21
|
+
## Introduction to Character Widths
|
22
|
+
|
23
|
+
Guessing the correct space a character will consume on terminals is not easy. There is no single standard. Most implementations combine data from [East Asian Width](https://www.unicode.org/reports/tr11/), some [General Categories](https://en.wikipedia.org/wiki/Unicode_character_property#General_Category), and hand-picked adjustments.
|
24
|
+
|
25
|
+
### How this Library Handles Widths
|
26
|
+
|
27
|
+
Further at the top means higher precedence. Please expect changes to this algorithm with every MINOR version update (the X in 1.X.0)!
|
28
|
+
|
29
|
+
Width | Characters | Comment
|
30
|
+
-------|------------------------------|--------------------------------------------------
|
31
|
+
? | (user defined) | Overwrites any other values
|
32
|
+
? | Emoji | See "How this Library Handles Emoji Width" below
|
33
|
+
-1 | `"\b"` | Backspace (total width never below 0)
|
34
|
+
0 | `"\0"`, `"\x05"`, `"\a"`, `"\n"`, `"\v"`, `"\f"`, `"\r"`, `"\x0E"`, `"\x0F"` | [C0 control codes](https://en.wikipedia.org/wiki/C0_and_C1_control_codes#C0_.28ASCII_and_derivatives.29) which do not change horizontal width
|
35
|
+
1 | `"\u{00AD}"` | SOFT HYPHEN
|
36
|
+
2 | `"\u{2E3A}"` | TWO-EM DASH
|
37
|
+
3 | `"\u{2E3B}"` | THREE-EM DASH
|
38
|
+
0 | General Categories: Mn, Me, Zl, Zp, Cf (non-arabic)| Excludes ARABIC format characters
|
39
|
+
0 | Derived Property: Default_Ignorable_Code_Point | Ignorable ranges
|
40
|
+
0 | `"\u{1160}".."\u{11FF}"`, `"\u{D7B0}".."\u{D7FF}"` | HANGUL JUNGSEONG
|
41
|
+
2 | East Asian Width: F, W | Full-width characters
|
42
|
+
2 | `"\u{3400}".."\u{4DBF}"`, `"\u{4E00}".."\u{9FFF}"`, `"\u{F900}".."\u{FAFF}"`, `"\u{20000}".."\u{2FFFD}"`, `"\u{30000}".."\u{3FFFD}"` | Full-width ranges
|
43
|
+
1 or 2 | East Asian Width: A | Ambiguous characters, user defined, default: 1
|
44
|
+
1 | All other codepoints | -
|
45
|
+
|
46
|
+
## Install
|
47
|
+
|
48
|
+
Install the gem with:
|
49
|
+
|
50
|
+
$ gem install unicode-display_width
|
51
|
+
|
52
|
+
Or add to your Gemfile:
|
53
|
+
|
54
|
+
gem 'unicode-display_width'
|
55
|
+
|
56
|
+
## Usage
|
57
|
+
|
58
|
+
```ruby
|
59
|
+
require 'unicode/display_width'
|
60
|
+
|
61
|
+
Unicode::DisplayWidth.of("⚀") # => 1
|
62
|
+
Unicode::DisplayWidth.of("一") # => 2
|
63
|
+
```
|
64
|
+
|
65
|
+
### Ambiguous Characters
|
66
|
+
|
67
|
+
The second parameter defines the value returned by characters defined as ambiguous:
|
68
|
+
|
69
|
+
```ruby
|
70
|
+
Unicode::DisplayWidth.of("·", 1) # => 1
|
71
|
+
Unicode::DisplayWidth.of("·", 2) # => 2
|
72
|
+
```
|
73
|
+
|
74
|
+
### Encoding Notes
|
75
|
+
|
76
|
+
- Data with *BINARY* encoding is interpreted as UTF-8, if possible
|
77
|
+
- Non-UTF-8 strings are converted to UTF-8 before measuring, using the [`{invalid: :replace, undef: :replace}`) options](https://ruby-doc.org/3.3.5/encodings_rdoc.html#label-Encoding+Options)
|
78
|
+
|
79
|
+
### Custom Overwrites
|
80
|
+
|
81
|
+
You can overwrite how to handle specific code points by passing a hash (or even a proc) as `overwrite:` parameter:
|
82
|
+
|
83
|
+
```ruby
|
84
|
+
Unicode::DisplayWidth.of("a\tb", 1, overwrite: { "\t".ord => 10 })) # => TAB counted as 10, result is 12
|
85
|
+
```
|
86
|
+
|
87
|
+
Please note that using overwrites disables some perfomance optimizations of this gem.
|
88
|
+
|
89
|
+
### Emoji
|
90
|
+
|
91
|
+
If your terminal supports it, the gem detects Emoji and Emoji sequences and adjusts the width of the measured string. This can be disabled by passing `emoji: false` as an argument:
|
92
|
+
|
93
|
+
```ruby
|
94
|
+
Unicode::DisplayWidth.of "🤾🏽♀️", emoji: :all # => 2
|
95
|
+
Unicode::DisplayWidth.of "🤾🏽♀️", emoji: false # => 5
|
96
|
+
```
|
97
|
+
|
98
|
+
#### How this Library Handles Emoji Width
|
99
|
+
|
100
|
+
There are many Emoji which get constructed by combining other Emoji in a sequence. This makes measuring the width complicated, since terminals might either display the combined Emoji or the separate parts of the Emoji individually.
|
101
|
+
|
102
|
+
Another aspect where terminals disagree is whether Emoji characters which have a text presentation by default (width 1) should be turned into full-width (width 2) when combined with Variation Selector 16 (*U+FEOF*).
|
103
|
+
|
104
|
+
Finally, it varies if Skin Tone Modifiers can be applied to all characters or just to those with the "Emoji Base" property.
|
105
|
+
|
106
|
+
Emoji Type | Width / Comment
|
107
|
+
------------|----------------
|
108
|
+
Basic/Single Emoji character without Variation Selector | No special handling
|
109
|
+
Basic/Single Emoji character with VS15 (Text) | No special handling
|
110
|
+
Basic/Single Emoji character with VS16 (Emoji) | 2 or East Asian Width (see table below)
|
111
|
+
Single Emoji character with Skin Tone Modifier | 2
|
112
|
+
Skin Tone Modifier used in isolation or with invalid base | 2 if Emoji mode is configured to `:rgi` / `:rgi_at`
|
113
|
+
Emoji Sequence | 2 if Emoji belongs to configured Emoji set (see table below)
|
114
|
+
|
115
|
+
#### Emoji Modes
|
116
|
+
|
117
|
+
The `emoji:` option can be used to configure which type of Emoji should be considered to have a width of 2 and if VS16-Emoji should be widened. Other sequences are treated as non-combined Emoji, so the widths of all partial Emoji add up (e.g. width of one basic Emoji + one skin tone modifier + another basic Emoji). The following Emoji settings can be used:
|
118
|
+
|
119
|
+
`emoji:` Option | VS16-Emoji Width | Emoji Sequences Width / Comment | Example Terminals
|
120
|
+
----------------|------------------|---------------------------------|------------------
|
121
|
+
`true` or `:auto` | - | Automatically use recommended Emoji setting for your terminal | -
|
122
|
+
`:all` | 2 | 2 for all ZWJ/modifier/keycap sequences, even if they are not well-formed Emoji sequences | iTerm, foot
|
123
|
+
`:all_no_vs16` | EAW (1 or 2) | 2 for all ZWJ/modifier/keycap sequences, even if they are not well-formed Emoji sequences | WezTerm
|
124
|
+
`:possible`| 2 | 2 for all possible/well-formed Emoji sequences | ?
|
125
|
+
`:rgi` | 2 | 2 for all [RGI Emoji](https://www.unicode.org/reports/tr51/#def_rgi_set) sequences | ?
|
126
|
+
`:rgi_at` | EAW (1 or 2) | 1 or 2: Like `:rgi`, but Emoji sequences starting with a default-text Emoji have EAW | Apple Terminal
|
127
|
+
`:vs16` | 2 | 2 * number of partial Emoji (sequences never considered to represent a combined Emoji) | kitty?
|
128
|
+
`false` or `:none` | EAW (1 or 2) | No Emoji adjustments | gnome-terminal, many older terminals
|
129
|
+
|
130
|
+
- *EAW:* East Asian Width
|
131
|
+
- *RGI Emoji:* Emoji Recommended for General Interchange
|
132
|
+
- *ZWJ:* Zero-width Joiner: Codepoint `U+200D`,used in many Emoji sequences
|
133
|
+
|
134
|
+
#### Emoji Support in Terminals
|
135
|
+
|
136
|
+
Unfortunately, the level of Emoji support varies a lot between terminals. While some of them are able to display (almost) all Emoji sequences correctly, others fall back to displaying sequences of basic Emoji. When `emoji: true` or `emoji: :auto` is used, the gem will attempt to set the best fitting Emoji setting for you (e.g. `:rgi_at` on "Apple_Terminal" or `false` on Gnome's terminal widget).
|
137
|
+
|
138
|
+
Please note that Emoji display and number of terminal columns used might differs a lot. For example, it might be the case that a terminal does not understand which Emoji to display, but still manages to calculate the proper amount of terminal cells. The automatic Emoji support level per terminal only considers the latter (cursor position), not the actual Emoji image(s) displayed. Please [open an issue](https://github.com/janlelis/unicode-display_width/issues/new) if you notice your terminal application could use a better default value. Also see the [ucs-detect project](https://ucs-detect.readthedocs.io/results.html), which is a great resource that compares various terminal's Unicode/Emoji capabilities. You can visually check how your terminals renders different kind of Emoji types with the [terminal-emoji-width.rb script](https://github.com/janlelis/unicode-display_width/blob/main/misc/terminal-emoji-width.rb).
|
139
|
+
|
140
|
+
**To terminal implementors reading this:** Although the practice of giving all Emoji/ZWJ sequences a width of 2 (`:all` mode described above) has some advantages, it does not lead to a particularly good developer experience. Since there is always the possibility of well-formed Emoji that are currently not supported (non-RGI / future Unicode) appearing, those sequences will take more cells. Instead of overflowing, cutting off sequences or displaying placeholder-Emoji, could it be worthwile to implement the `:rgi` option (only known Emoji get width 2) and give those unknown Emoji the space they need? This would support the idea that the meaning of an unknown Emoji sequence can still be conveyed (without messing up the terminal at the same time). Just a thought…
|
141
|
+
|
142
|
+
### Usage with String Extension
|
143
|
+
|
144
|
+
```ruby
|
145
|
+
require 'unicode/display_width/string_ext'
|
146
|
+
|
147
|
+
"⚀".display_width # => 1
|
148
|
+
'一'.display_width # => 2
|
149
|
+
```
|
150
|
+
|
151
|
+
### Usage with Config Object
|
152
|
+
|
153
|
+
You can use a config object that allows you to save your configuration for later-reuse. This requires an extra line of code, but has the advantage that you'll need to define your string-width options only once:
|
154
|
+
|
155
|
+
```ruby
|
156
|
+
require 'unicode/display_width'
|
157
|
+
|
158
|
+
display_width = Unicode::DisplayWidth.new(
|
159
|
+
# ambiguous: 1,
|
160
|
+
overwrite: { "A".ord => 100 },
|
161
|
+
emoji: :all,
|
162
|
+
)
|
163
|
+
|
164
|
+
display_width.of "⚀" # => 1
|
165
|
+
display_width.of "🤠🤢" # => 2
|
166
|
+
display_width.of "A" # => 100
|
167
|
+
```
|
168
|
+
|
169
|
+
### Usage from the Command-Line
|
170
|
+
|
171
|
+
Use this one-liner to print out display widths for strings from the command-line:
|
172
|
+
|
173
|
+
```
|
174
|
+
$ gem install unicode-display_width
|
175
|
+
$ ruby -r unicode/display_width -e 'puts Unicode::DisplayWidth.of $*[0]' -- "一"
|
176
|
+
```
|
177
|
+
Replace "一" with the actual string to measure
|
178
|
+
|
179
|
+
## Other Implementations & Discussion
|
180
|
+
|
181
|
+
- Python: https://github.com/jquast/wcwidth
|
182
|
+
- JavaScript: https://github.com/mycoboco/wcwidth.js
|
183
|
+
- C: https://www.cl.cam.ac.uk/~mgk25/ucs/wcwidth.c
|
184
|
+
- C for Julia: https://github.com/JuliaLang/utf8proc/issues/2
|
185
|
+
- Golang: https://github.com/rivo/uniseg
|
186
|
+
|
187
|
+
See [unicode-x](https://github.com/janlelis/unicode-x) for more Unicode related micro libraries.
|
188
|
+
|
189
|
+
## Copyright & Info
|
190
|
+
|
191
|
+
- Copyright (c) 2011, 2015-2024 Jan Lelis, https://janlelis.com, released under the MIT
|
192
|
+
license
|
193
|
+
- Early versions based on runpaint's unicode-data interface: Copyright (c) 2009 Run Paint Run Run
|
194
|
+
- Unicode data: https://www.unicode.org/copyright.html#Exhibit1
|
Binary file
|
data/bundle/ruby/3.1.0/gems/unicode-display_width-3.1.4/lib/unicode/display_width/constants.rb
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Unicode
|
4
|
+
class DisplayWidth
|
5
|
+
VERSION = "3.1.4"
|
6
|
+
UNICODE_VERSION = "16.0.0"
|
7
|
+
DATA_DIRECTORY = File.expand_path(File.dirname(__FILE__) + "/../../../data/")
|
8
|
+
INDEX_FILENAME = DATA_DIRECTORY + "/display_width.marshal.gz"
|
9
|
+
end
|
10
|
+
end
|
data/bundle/ruby/3.1.0/gems/unicode-display_width-3.1.4/lib/unicode/display_width/emoji_support.rb
ADDED
@@ -0,0 +1,52 @@
|
|
1
|
+
# require "rbconfig"
|
2
|
+
# RbConfig::CONFIG["host_os"] =~ /mswin|mingw/ # windows
|
3
|
+
|
4
|
+
module Unicode
|
5
|
+
class DisplayWidth
|
6
|
+
module EmojiSupport
|
7
|
+
# Tries to find out which terminal emulator is used to
|
8
|
+
# set emoji: config to best suiting value
|
9
|
+
#
|
10
|
+
# Please also see section in README.md and
|
11
|
+
# misc/terminal-emoji-width.rb
|
12
|
+
#
|
13
|
+
# Please note: Many terminals do not set any ENV vars,
|
14
|
+
# maybe CSI queries can help?
|
15
|
+
def self.recommended
|
16
|
+
if ENV["CI"]
|
17
|
+
return :rqi
|
18
|
+
end
|
19
|
+
|
20
|
+
case ENV["TERM_PROGRAM"]
|
21
|
+
when "iTerm.app"
|
22
|
+
return :all
|
23
|
+
when "Apple_Terminal"
|
24
|
+
return :rgi_at
|
25
|
+
when "WezTerm"
|
26
|
+
return :all_no_vs16
|
27
|
+
end
|
28
|
+
|
29
|
+
case ENV["TERM"]
|
30
|
+
when "contour","foot"
|
31
|
+
# konsole: all, how to detect?
|
32
|
+
return :all
|
33
|
+
when /kitty/
|
34
|
+
return :vs16
|
35
|
+
end
|
36
|
+
|
37
|
+
if ENV["WT_SESSION"] # Windows Terminal
|
38
|
+
return :vs16
|
39
|
+
end
|
40
|
+
|
41
|
+
# As of last time checked: gnome-terminal, vscode, alacritty
|
42
|
+
:none
|
43
|
+
end
|
44
|
+
|
45
|
+
# Maybe: Implement something like https://github.com/jquast/ucs-detect
|
46
|
+
# which uses the terminal cursor to check for best support level
|
47
|
+
# at runtime
|
48
|
+
# def self.detect!
|
49
|
+
# end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "zlib"
|
4
|
+
require_relative "constants"
|
5
|
+
|
6
|
+
module Unicode
|
7
|
+
class DisplayWidth
|
8
|
+
File.open(INDEX_FILENAME, "rb") do |file|
|
9
|
+
serialized_data = Zlib::GzipReader.new(file).read
|
10
|
+
serialized_data.force_encoding Encoding::BINARY
|
11
|
+
INDEX = Marshal.load(serialized_data)
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.decompress_index(index, level)
|
15
|
+
index.flat_map{ |value|
|
16
|
+
if level > 0
|
17
|
+
if value.instance_of?(Array)
|
18
|
+
value[15] ||= nil
|
19
|
+
decompress_index(value, level - 1)
|
20
|
+
else
|
21
|
+
decompress_index([value] * 16, level - 1)
|
22
|
+
end
|
23
|
+
else
|
24
|
+
if value.instance_of?(Array)
|
25
|
+
value[15] ||= nil
|
26
|
+
value
|
27
|
+
else
|
28
|
+
[value] * 16
|
29
|
+
end
|
30
|
+
end
|
31
|
+
}
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
data/bundle/ruby/3.1.0/gems/unicode-display_width-3.1.4/lib/unicode/display_width/no_string_ext.rb
ADDED
@@ -0,0 +1,8 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
warn "You are loading 'unicode-display_width/no_string_ext'\n" \
|
4
|
+
"Beginning with version 2.0, this is not necessary anymore\n"\
|
5
|
+
"You can just require 'unicode-display_width' now and no\n"\
|
6
|
+
"string extension will be loaded"
|
7
|
+
|
8
|
+
require_relative "../display_width"
|
data/bundle/ruby/3.1.0/gems/unicode-display_width-3.1.4/lib/unicode/display_width/reline_ext.rb
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
# Experimental
|
2
|
+
# Patches Reline's get_mbchar_width to use Unicode::DisplayWidth
|
3
|
+
|
4
|
+
require "reline"
|
5
|
+
require "reline/unicode"
|
6
|
+
|
7
|
+
require_relative "../display_width"
|
8
|
+
|
9
|
+
class Reline::Unicode
|
10
|
+
def self.get_mbchar_width(mbchar)
|
11
|
+
Unicode::DisplayWidth.of(mbchar, Reline.ambiguous_width)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
data/bundle/ruby/3.1.0/gems/unicode-display_width-3.1.4/lib/unicode/display_width/string_ext.rb
ADDED
@@ -0,0 +1,9 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "../display_width"
|
4
|
+
|
5
|
+
class String
|
6
|
+
def display_width(ambiguous = nil, overwrite = nil, old_options = {}, **options)
|
7
|
+
Unicode::DisplayWidth.of(self, ambiguous, overwrite, old_options = {}, **options)
|
8
|
+
end
|
9
|
+
end
|
@@ -0,0 +1,247 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "unicode/emoji"
|
4
|
+
|
5
|
+
require_relative "display_width/constants"
|
6
|
+
require_relative "display_width/index"
|
7
|
+
require_relative "display_width/emoji_support"
|
8
|
+
|
9
|
+
module Unicode
|
10
|
+
class DisplayWidth
|
11
|
+
DEFAULT_AMBIGUOUS = 1
|
12
|
+
INITIAL_DEPTH = 0x10000
|
13
|
+
ASCII_NON_ZERO_REGEX = /[\0\x05\a\b\n-\x0F]/
|
14
|
+
ASCII_NON_ZERO_STRING = "\0\x05\a\b\n-\x0F"
|
15
|
+
ASCII_BACKSPACE = "\b"
|
16
|
+
AMBIGUOUS_MAP = {
|
17
|
+
1 => :WIDTH_ONE,
|
18
|
+
2 => :WIDTH_TWO,
|
19
|
+
}
|
20
|
+
FIRST_AMBIGUOUS = {
|
21
|
+
WIDTH_ONE: 768,
|
22
|
+
WIDTH_TWO: 161,
|
23
|
+
}
|
24
|
+
NOT_COMMON_NARROW_REGEX = {
|
25
|
+
WIDTH_ONE: /[^\u{10}-\u{2FF}]/m,
|
26
|
+
WIDTH_TWO: /[^\u{10}-\u{A1}]/m,
|
27
|
+
}
|
28
|
+
FIRST_4096 = {
|
29
|
+
WIDTH_ONE: decompress_index(INDEX[:WIDTH_ONE][0][0], 1),
|
30
|
+
WIDTH_TWO: decompress_index(INDEX[:WIDTH_TWO][0][0], 1),
|
31
|
+
}
|
32
|
+
EMOJI_SEQUENCES_REGEX_MAPPING = {
|
33
|
+
rgi: :REGEX_INCLUDE_MQE_UQE,
|
34
|
+
rgi_at: :REGEX_INCLUDE_MQE_UQE,
|
35
|
+
possible: :REGEX_WELL_FORMED,
|
36
|
+
}
|
37
|
+
REGEX_EMOJI_VS16 = Regexp.union(
|
38
|
+
Regexp.compile(
|
39
|
+
Unicode::Emoji::REGEX_TEXT_PRESENTATION.source +
|
40
|
+
"(?<![#*0-9])" +
|
41
|
+
"\u{FE0F}"
|
42
|
+
),
|
43
|
+
Unicode::Emoji::REGEX_EMOJI_KEYCAP
|
44
|
+
)
|
45
|
+
|
46
|
+
# ebase = Unicode::Emoji::REGEX_PROP_MODIFIER_BASE.source
|
47
|
+
REGEX_EMOJI_ALL_SEQUENCES = Regexp.union(/.[\u{1F3FB}-\u{1F3FF}\u{FE0F}]?(\u{200D}.[\u{1F3FB}-\u{1F3FF}\u{FE0F}]?)+|.[\u{1F3FB}-\u{1F3FF}]/, Unicode::Emoji::REGEX_EMOJI_KEYCAP)
|
48
|
+
REGEX_EMOJI_ALL_SEQUENCES_AND_VS16 = Regexp.union(REGEX_EMOJI_ALL_SEQUENCES, REGEX_EMOJI_VS16)
|
49
|
+
|
50
|
+
# Returns monospace display width of string
|
51
|
+
def self.of(string, ambiguous = nil, overwrite = nil, old_options = {}, **options)
|
52
|
+
# Binary strings don't make much sense when calculating display width.
|
53
|
+
# Assume it's valid UTF-8
|
54
|
+
if string.encoding == Encoding::BINARY && !string.force_encoding(Encoding::UTF_8).valid_encoding?
|
55
|
+
# Didn't work out, go back to binary
|
56
|
+
string.force_encoding(Encoding::BINARY)
|
57
|
+
end
|
58
|
+
|
59
|
+
string = string.encode(Encoding::UTF_8, invalid: :replace, undef: :replace) unless string.encoding == Encoding::UTF_8
|
60
|
+
options = normalize_options(string, ambiguous, overwrite, old_options, **options)
|
61
|
+
|
62
|
+
width = 0
|
63
|
+
|
64
|
+
unless options[:overwrite].empty?
|
65
|
+
width, string = width_custom(string, options[:overwrite])
|
66
|
+
end
|
67
|
+
|
68
|
+
if string.ascii_only?
|
69
|
+
return width + width_ascii(string)
|
70
|
+
end
|
71
|
+
|
72
|
+
ambiguous_index_name = AMBIGUOUS_MAP[options[:ambiguous]]
|
73
|
+
|
74
|
+
unless string.match?(NOT_COMMON_NARROW_REGEX[ambiguous_index_name])
|
75
|
+
return width + string.size
|
76
|
+
end
|
77
|
+
|
78
|
+
# Retrieve Emoji width
|
79
|
+
if options[:emoji] != :none
|
80
|
+
e_width, string = emoji_width(
|
81
|
+
string,
|
82
|
+
options[:emoji],
|
83
|
+
options[:ambiguous],
|
84
|
+
)
|
85
|
+
width += e_width
|
86
|
+
|
87
|
+
unless string.match?(NOT_COMMON_NARROW_REGEX[ambiguous_index_name])
|
88
|
+
return width + string.size
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
index_full = INDEX[ambiguous_index_name]
|
93
|
+
index_low = FIRST_4096[ambiguous_index_name]
|
94
|
+
first_ambiguous = FIRST_AMBIGUOUS[ambiguous_index_name]
|
95
|
+
|
96
|
+
string.each_codepoint{ |codepoint|
|
97
|
+
if codepoint > 15 && codepoint < first_ambiguous
|
98
|
+
width += 1
|
99
|
+
elsif codepoint < 0x1001
|
100
|
+
width += index_low[codepoint] || 1
|
101
|
+
else
|
102
|
+
d = INITIAL_DEPTH
|
103
|
+
w = index_full[codepoint / d]
|
104
|
+
while w.instance_of? Array
|
105
|
+
w = w[(codepoint %= d) / (d /= 16)]
|
106
|
+
end
|
107
|
+
|
108
|
+
width += w || 1
|
109
|
+
end
|
110
|
+
}
|
111
|
+
|
112
|
+
# Return result + prevent negative lengths
|
113
|
+
width < 0 ? 0 : width
|
114
|
+
end
|
115
|
+
|
116
|
+
# Returns width of custom overwrites and remaining string
|
117
|
+
def self.width_custom(string, overwrite)
|
118
|
+
width = 0
|
119
|
+
|
120
|
+
string = string.each_codepoint.select{ |codepoint|
|
121
|
+
if overwrite[codepoint]
|
122
|
+
width += overwrite[codepoint]
|
123
|
+
nil
|
124
|
+
else
|
125
|
+
codepoint
|
126
|
+
end
|
127
|
+
}.pack("U*")
|
128
|
+
|
129
|
+
[width, string]
|
130
|
+
end
|
131
|
+
|
132
|
+
# Returns width for ASCII-only strings. Will consider zero-width control symbols.
|
133
|
+
def self.width_ascii(string)
|
134
|
+
if string.match?(ASCII_NON_ZERO_REGEX)
|
135
|
+
res = string.delete(ASCII_NON_ZERO_STRING).bytesize - string.count(ASCII_BACKSPACE)
|
136
|
+
return res < 0 ? 0 : res
|
137
|
+
end
|
138
|
+
|
139
|
+
string.bytesize
|
140
|
+
end
|
141
|
+
|
142
|
+
# Returns width of all considered Emoji and remaining string
|
143
|
+
def self.emoji_width(string, mode = :all, ambiguous = DEFAULT_AMBIGUOUS)
|
144
|
+
res = 0
|
145
|
+
|
146
|
+
if emoji_set_regex = EMOJI_SEQUENCES_REGEX_MAPPING[mode]
|
147
|
+
emoji_width_via_possible(
|
148
|
+
string,
|
149
|
+
Unicode::Emoji.const_get(emoji_set_regex),
|
150
|
+
mode == :rgi_at,
|
151
|
+
ambiguous,
|
152
|
+
)
|
153
|
+
|
154
|
+
elsif mode == :all_no_vs16
|
155
|
+
no_emoji_string = string.gsub(REGEX_EMOJI_ALL_SEQUENCES){ res += 2; "" }
|
156
|
+
[res, no_emoji_string]
|
157
|
+
|
158
|
+
elsif mode == :vs16
|
159
|
+
no_emoji_string = string.gsub(REGEX_EMOJI_VS16){ res += 2; "" }
|
160
|
+
[res, no_emoji_string]
|
161
|
+
|
162
|
+
elsif mode == :all
|
163
|
+
no_emoji_string = string.gsub(REGEX_EMOJI_ALL_SEQUENCES_AND_VS16){ res += 2; "" }
|
164
|
+
[res, no_emoji_string]
|
165
|
+
|
166
|
+
else
|
167
|
+
[0, string]
|
168
|
+
|
169
|
+
end
|
170
|
+
end
|
171
|
+
|
172
|
+
# Match possible Emoji first, then refine
|
173
|
+
def self.emoji_width_via_possible(string, emoji_set_regex, strict_eaw = false, ambiguous = DEFAULT_AMBIGUOUS)
|
174
|
+
res = 0
|
175
|
+
|
176
|
+
# For each string possibly an emoji
|
177
|
+
no_emoji_string = string.gsub(REGEX_EMOJI_ALL_SEQUENCES_AND_VS16){ |emoji_candidate|
|
178
|
+
# Check if we have a combined Emoji with width 2 (or EAW an Apple Terminal)
|
179
|
+
if emoji_candidate == emoji_candidate[emoji_set_regex]
|
180
|
+
if strict_eaw
|
181
|
+
res += self.of(emoji_candidate[0], ambiguous, emoji: false)
|
182
|
+
else
|
183
|
+
res += 2
|
184
|
+
end
|
185
|
+
""
|
186
|
+
|
187
|
+
# We are dealing with a default text presentation emoji or a well-formed sequence not matching the above Emoji set
|
188
|
+
else
|
189
|
+
if !strict_eaw
|
190
|
+
# Ensure all explicit VS16 sequences have width 2
|
191
|
+
emoji_candidate.gsub!(REGEX_EMOJI_VS16){ res += 2; "" }
|
192
|
+
end
|
193
|
+
|
194
|
+
emoji_candidate
|
195
|
+
end
|
196
|
+
}
|
197
|
+
|
198
|
+
[res, no_emoji_string]
|
199
|
+
end
|
200
|
+
|
201
|
+
def self.normalize_options(string, ambiguous = nil, overwrite = nil, old_options = {}, **options)
|
202
|
+
unless old_options.empty?
|
203
|
+
warn "Unicode::DisplayWidth: Please migrate to keyword arguments - #{old_options.inspect}"
|
204
|
+
options.merge! old_options
|
205
|
+
end
|
206
|
+
|
207
|
+
options[:ambiguous] = ambiguous if ambiguous
|
208
|
+
options[:ambiguous] ||= DEFAULT_AMBIGUOUS
|
209
|
+
|
210
|
+
if options[:ambiguous] != 1 && options[:ambiguous] != 2
|
211
|
+
raise ArgumentError, "Unicode::DisplayWidth: Ambiguous width must be 1 or 2"
|
212
|
+
end
|
213
|
+
|
214
|
+
if overwrite && !overwrite.empty?
|
215
|
+
warn "Unicode::DisplayWidth: Please migrate to keyword arguments - overwrite: #{overwrite.inspect}"
|
216
|
+
options[:overwrite] = overwrite
|
217
|
+
end
|
218
|
+
options[:overwrite] ||= {}
|
219
|
+
|
220
|
+
if [nil, true, :auto].include?(options[:emoji])
|
221
|
+
options[:emoji] = EmojiSupport.recommended
|
222
|
+
elsif options[:emoji] == false
|
223
|
+
options[:emoji] = :none
|
224
|
+
end
|
225
|
+
|
226
|
+
options
|
227
|
+
end
|
228
|
+
|
229
|
+
def initialize(ambiguous: DEFAULT_AMBIGUOUS, overwrite: {}, emoji: true)
|
230
|
+
@ambiguous = ambiguous
|
231
|
+
@overwrite = overwrite
|
232
|
+
@emoji = emoji
|
233
|
+
end
|
234
|
+
|
235
|
+
def get_config(**kwargs)
|
236
|
+
{
|
237
|
+
ambiguous: kwargs[:ambiguous] || @ambiguous,
|
238
|
+
overwrite: kwargs[:overwrite] || @overwrite,
|
239
|
+
emoji: kwargs[:emoji] || @emoji,
|
240
|
+
}
|
241
|
+
end
|
242
|
+
|
243
|
+
def of(string, **kwargs)
|
244
|
+
self.class.of(string, **get_config(**kwargs))
|
245
|
+
end
|
246
|
+
end
|
247
|
+
end
|