Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Remove AS::Mb::Unicode::UnicodeDatabase

Remove AS::Mb::Unicode::UnicodeDatabase

ぎんざRuby会議01 発表資料

https://ginzarb.github.io/kaigi01/

Fumiaki MATSUSHIMA

August 05, 2017
Tweet

More Decks by Fumiaki MATSUSHIMA

Other Decks in Programming

Transcript

  1. $ find vendor/bundle/gems/acti* -type f -exec du -h -a {}

    + | sort -h -r | head -n 10 1.1M vendor/bundle/gems/activesupport-5.1.2/lib/active_support/values/unicode_tables.dat 104K vendor/bundle/gems/actionview-5.1.2/lib/action_view/helpers/form_helper.rb 100K vendor/bundle/gems/activerecord-5.1.2/lib/active_record/associations.rb 76K vendor/bundle/gems/actionpack-5.1.2/lib/action_dispatch/routing/mapper.rb 60K vendor/bundle/gems/actionview-5.1.2/lib/action_view/helpers/date_helper.rb 52K vendor/bundle/gems/activerecord-5.1.2/lib/active_record/connection_adapters/abstract/schema_statements.rb 44K vendor/bundle/gems/activerecord-5.1.2/lib/active_record/migration.rb 44K vendor/bundle/gems/actionview-5.1.2/lib/action_view/helpers/form_tag_helper.rb 44K vendor/bundle/gems/actionview-5.1.2/lib/action_view/helpers/form_options_helper.rb 40K vendor/bundle/gems/activerecord-5.1.2/lib/active_record/relation/query_methods.rb
  2. $ find vendor/bundle/gems/acti* -type f -exec du -h -a {}

    + | sort -h -r | head -n 10 1.1M vendor/bundle/gems/activesupport-5.1.2/lib/active_support/values/unicode_tables.dat 104K vendor/bundle/gems/actionview-5.1.2/lib/action_view/helpers/form_helper.rb 100K vendor/bundle/gems/activerecord-5.1.2/lib/active_record/associations.rb 76K vendor/bundle/gems/actionpack-5.1.2/lib/action_dispatch/routing/mapper.rb 60K vendor/bundle/gems/actionview-5.1.2/lib/action_view/helpers/date_helper.rb 52K vendor/bundle/gems/activerecord-5.1.2/lib/active_record/connection_adapters/abstract/schema_statements.rb 44K vendor/bundle/gems/activerecord-5.1.2/lib/active_record/migration.rb 44K vendor/bundle/gems/actionview-5.1.2/lib/action_view/helpers/form_tag_helper.rb 44K vendor/bundle/gems/actionview-5.1.2/lib/action_view/helpers/form_options_helper.rb 40K vendor/bundle/gems/activerecord-5.1.2/lib/active_record/relation/query_methods.rb 1.1M!
  3. - Normalize - Case mapping - Pack/unpack grapheme - Tidy

    bytes AS::Mb::Unicode::UnicodeDatabase 使ってない
  4. Unicode 正規化 - NFD - NFC - NFKD - NFKC

    Normalization Form Decopose Compose
  5. Unicode 正規化 - NFD - NFC - NFKD - NFKC

    Normalization Form Decopose Compose
  6. Unicode 正規化 - NFD - NFC - NFKD - NFKC

    Normalization Form Decopose Compose
  7. “In NFKC and NFKD, a K is used to stand

    for compatibility to avoid confusion with the C standing for composition.” http://unicode.org/reports/tr15/
  8. Unicode 正規化 - NFD - NFC - NFKD - NFKC

    Normalization Form Decopose Compose K(C)ompatibility (互換等価)
  9. String#unicode_normalize [1] pry(main)> '株'.codepoints => [26666] [2] pry(main)> '㈱'.codepoints =>

    [12849] [3] pry(main)> '㈱'.unicode_normalize(:nfc).codepoints => [12849] [4] pry(main)> '㈱'.unicode_normalize(:nfd).codepoints => [12849] [5] pry(main)> '㈱'.unicode_normalize(:nfkc).codepoints => [40, 26666, 41] [6] pry(main)> '㈱'.unicode_normalize(:nfkd).codepoints => [40, 26666, 41]
  10. $ docker run -e LANG=C.UTF-8 --rm ruby:2.3 \ ruby -e

    "p 'Ä'.downcase == 'ä'" false $ docker run -e LANG=C.UTF-8 --rm ruby:2.4 \ ruby -e "p 'Ä'.downcase == 'ä'" true
  11. - Normalize - Ruby 2.2 から - Case mapping -

    Ruby 2.4 から - Pack/unpack grapheme - Ruby 2.0 から - ただし、Unicode のテストが 通るのは 2.4 から
  12. まとめ - Rails 6 になると UnicodeDatabase が 消せて、3x Rails に近づくかも

    - 多数の人の力により、gem でやっていた ことが Ruby 本体でできるようになって いっている