liblouis-rb 0.1.0
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 +7 -0
- data/LICENSE +520 -0
- data/README.md +100 -0
- data/Rakefile +80 -0
- data/ext/liblouis/braille_character.c +200 -0
- data/ext/liblouis/braille_table.c +198 -0
- data/ext/liblouis/braille_text.c +223 -0
- data/ext/liblouis/extconf.rb +73 -0
- data/ext/liblouis/liblouis.c +168 -0
- data/ext/liblouis/liblouis_ext.h +49 -0
- data/ext/liblouis/table_source.c +161 -0
- data/ext/liblouis/translation.c +443 -0
- data/liblouis-rb.gemspec +49 -0
- data/spec/liblouis_spec.rb +62 -0
- data/test/integration/packaging_test.rb +82 -0
- data/test/table_source_cases.rb +9 -0
- data/test/test_braille_character.rb +62 -0
- data/test/test_braille_table.rb +379 -0
- data/test/test_braille_text.rb +30 -0
- data/test/test_helper.rb +7 -0
- data/test/translation_cases.rb +33 -0
- data/vendor/liblouis/COPYING +674 -0
- data/vendor/liblouis/COPYING.LESSER +502 -0
- data/vendor/liblouis/configure.ac +290 -0
- data/vendor/liblouis/liblouis/commonTranslationFunctions.c +95 -0
- data/vendor/liblouis/liblouis/compileTranslationTable.c +5515 -0
- data/vendor/liblouis/liblouis/internal.h +781 -0
- data/vendor/liblouis/liblouis/liblouis.h.in +514 -0
- data/vendor/liblouis/liblouis/logging.c +233 -0
- data/vendor/liblouis/liblouis/lou_backTranslateString.c +1855 -0
- data/vendor/liblouis/liblouis/lou_translateString.c +4177 -0
- data/vendor/liblouis/liblouis/maketable.c +463 -0
- data/vendor/liblouis/liblouis/metadata.c +1258 -0
- data/vendor/liblouis/liblouis/pattern.c +1632 -0
- data/vendor/liblouis/liblouis/utils.c +448 -0
- data/vendor/liblouis/tables/Es-Es-G0.utb +248 -0
- data/vendor/liblouis/tables/IPA-unicode-range.uti +200 -0
- data/vendor/liblouis/tables/IPA.utb +164 -0
- data/vendor/liblouis/tables/Lv-Lv-g1.utb +509 -0
- data/vendor/liblouis/tables/Makefile.am +503 -0
- data/vendor/liblouis/tables/Pl-Pl-g1.utb +312 -0
- data/vendor/liblouis/tables/README +6 -0
- data/vendor/liblouis/tables/afr-za-g1.ctb +63 -0
- data/vendor/liblouis/tables/afr-za-g2.ctb +1050 -0
- data/vendor/liblouis/tables/akk-borger.utb +997 -0
- data/vendor/liblouis/tables/akk.utb +1002 -0
- data/vendor/liblouis/tables/ancient-languages-borger.utb +114 -0
- data/vendor/liblouis/tables/ancient-languages-us.utb +114 -0
- data/vendor/liblouis/tables/ar-ar-comp8.utb +293 -0
- data/vendor/liblouis/tables/ar-ar-g1-core.uti +291 -0
- data/vendor/liblouis/tables/ar-ar-g1.utb +26 -0
- data/vendor/liblouis/tables/ar-ar-g2.ctb +447 -0
- data/vendor/liblouis/tables/ar-ar-math.uti +501 -0
- data/vendor/liblouis/tables/ar.tbl +17 -0
- data/vendor/liblouis/tables/as-in-g1.utb +27 -0
- data/vendor/liblouis/tables/as.tbl +18 -0
- data/vendor/liblouis/tables/aw-in-g1.utb +27 -0
- data/vendor/liblouis/tables/awa.tbl +18 -0
- data/vendor/liblouis/tables/ba.utb +64 -0
- data/vendor/liblouis/tables/be-in-g1.utb +27 -0
- data/vendor/liblouis/tables/bel-comp.utb +42 -0
- data/vendor/liblouis/tables/bel-detailed.utb +32 -0
- data/vendor/liblouis/tables/bel.utb +61 -0
- data/vendor/liblouis/tables/bengali.cti +238 -0
- data/vendor/liblouis/tables/bg.ctb +215 -0
- data/vendor/liblouis/tables/bg.dis +84 -0
- data/vendor/liblouis/tables/bg.tbl +21 -0
- data/vendor/liblouis/tables/bg.utb +454 -0
- data/vendor/liblouis/tables/bh.ctb +24 -0
- data/vendor/liblouis/tables/bh.tbl +17 -0
- data/vendor/liblouis/tables/bn.tbl +18 -0
- data/vendor/liblouis/tables/bo.ctb +184 -0
- data/vendor/liblouis/tables/bo.tbl +21 -0
- data/vendor/liblouis/tables/boxes.ctb +162 -0
- data/vendor/liblouis/tables/br-in-g1.utb +27 -0
- data/vendor/liblouis/tables/bra.tbl +18 -0
- data/vendor/liblouis/tables/braille-patterns.cti +287 -0
- data/vendor/liblouis/tables/ca-chardefs.cti +225 -0
- data/vendor/liblouis/tables/ca-g1.ctb +46 -0
- data/vendor/liblouis/tables/ca.tbl +18 -0
- data/vendor/liblouis/tables/chr-us-g1.ctb +180 -0
- data/vendor/liblouis/tables/ckb-chardefs.cti +219 -0
- data/vendor/liblouis/tables/ckb-g1.ctb +31 -0
- data/vendor/liblouis/tables/ckb-translation.cti +131 -0
- data/vendor/liblouis/tables/ckb.tbl +18 -0
- data/vendor/liblouis/tables/compress.cti +44 -0
- data/vendor/liblouis/tables/controlchars.cti +27 -0
- data/vendor/liblouis/tables/cop-eg-comp8.utb +255 -0
- data/vendor/liblouis/tables/cop.utb +231 -0
- data/vendor/liblouis/tables/corrections.cti +47 -0
- data/vendor/liblouis/tables/countries.cti +263 -0
- data/vendor/liblouis/tables/critical-apparatus.uti +54 -0
- data/vendor/liblouis/tables/cs-chardefs.cti +385 -0
- data/vendor/liblouis/tables/cs-comp8.utb +405 -0
- data/vendor/liblouis/tables/cs-g1.ctb +37 -0
- data/vendor/liblouis/tables/cs-translation.cti +63 -0
- data/vendor/liblouis/tables/cs.tbl +20 -0
- data/vendor/liblouis/tables/cuneiform-transliterated-compact.utb +432 -0
- data/vendor/liblouis/tables/cuneiform-transliterated.utb +160 -0
- data/vendor/liblouis/tables/cy-cy-g1.utb +487 -0
- data/vendor/liblouis/tables/cy-cy-g2.ctb +199 -0
- data/vendor/liblouis/tables/cy.tbl +19 -0
- data/vendor/liblouis/tables/da-dk-6miscChars.cti +385 -0
- data/vendor/liblouis/tables/da-dk-6miscChars_1993.cti +412 -0
- data/vendor/liblouis/tables/da-dk-8miscChars.cti +90 -0
- data/vendor/liblouis/tables/da-dk-8miscChars_1993.cti +102 -0
- data/vendor/liblouis/tables/da-dk-g08.ctb +290 -0
- data/vendor/liblouis/tables/da-dk-g08_1993.ctb +331 -0
- data/vendor/liblouis/tables/da-dk-g16-lit_1993.ctb +294 -0
- data/vendor/liblouis/tables/da-dk-g16.ctb +289 -0
- data/vendor/liblouis/tables/da-dk-g16_1993.ctb +305 -0
- data/vendor/liblouis/tables/da-dk-g18.ctb +545 -0
- data/vendor/liblouis/tables/da-dk-g18_1993.ctb +563 -0
- data/vendor/liblouis/tables/da-dk-g2.dic +7439 -0
- data/vendor/liblouis/tables/da-dk-g26-lit_1993.ctb +898 -0
- data/vendor/liblouis/tables/da-dk-g26.ctb +1345 -0
- data/vendor/liblouis/tables/da-dk-g26_1993.ctb +1127 -0
- data/vendor/liblouis/tables/da-dk-g26l-lit_1993.ctb +588 -0
- data/vendor/liblouis/tables/da-dk-g26l_1993.ctb +604 -0
- data/vendor/liblouis/tables/da-dk-g28.ctb +2426 -0
- data/vendor/liblouis/tables/da-dk-g28_1993.ctb +2063 -0
- data/vendor/liblouis/tables/da-dk-g28l_1993.ctb +1594 -0
- data/vendor/liblouis/tables/da-dk-octobraille.dis +316 -0
- data/vendor/liblouis/tables/da-dk-octobraille_1993.dis +313 -0
- data/vendor/liblouis/tables/de-accents-detailed.cti +214 -0
- data/vendor/liblouis/tables/de-accents.cti +214 -0
- data/vendor/liblouis/tables/de-chardefs6.cti +289 -0
- data/vendor/liblouis/tables/de-chardefs8.cti +278 -0
- data/vendor/liblouis/tables/de-chess.ctb +37 -0
- data/vendor/liblouis/tables/de-comp6.utb +226 -0
- data/vendor/liblouis/tables/de-de-comp8.ctb +492 -0
- data/vendor/liblouis/tables/de-de.dis +331 -0
- data/vendor/liblouis/tables/de-eurobrl6.dis +101 -0
- data/vendor/liblouis/tables/de-eurobrl6u.dis +96 -0
- data/vendor/liblouis/tables/de-g0-core.uti +732 -0
- data/vendor/liblouis/tables/de-g0-detailed.utb +84 -0
- data/vendor/liblouis/tables/de-g0.utb +57 -0
- data/vendor/liblouis/tables/de-g1-core-patterns.dic +4863 -0
- data/vendor/liblouis/tables/de-g1-core.cti +67 -0
- data/vendor/liblouis/tables/de-g1-detailed.ctb +79 -0
- data/vendor/liblouis/tables/de-g1.ctb +54 -0
- data/vendor/liblouis/tables/de-g2-core-patterns.dic +26711 -0
- data/vendor/liblouis/tables/de-g2-core.cti +607 -0
- data/vendor/liblouis/tables/de-g2-detailed.ctb +60 -0
- data/vendor/liblouis/tables/de-g2.ctb +57 -0
- data/vendor/liblouis/tables/devanagari.cti +325 -0
- data/vendor/liblouis/tables/digits6Dots.uti +30 -0
- data/vendor/liblouis/tables/digits6DotsPlusDot6.uti +30 -0
- data/vendor/liblouis/tables/digits8Dots.uti +30 -0
- data/vendor/liblouis/tables/dra.ctb +23 -0
- data/vendor/liblouis/tables/dra.tbl +21 -0
- data/vendor/liblouis/tables/el.ctb +775 -0
- data/vendor/liblouis/tables/en-GB-g2.ctb +829 -0
- data/vendor/liblouis/tables/en-chardefs.cti +193 -0
- data/vendor/liblouis/tables/en-chess.ctb +37 -0
- data/vendor/liblouis/tables/en-g3-patterns.dic +11194 -0
- data/vendor/liblouis/tables/en-g3.ctb +2261 -0
- data/vendor/liblouis/tables/en-gb-comp8.ctb +282 -0
- data/vendor/liblouis/tables/en-gb-g1.utb +527 -0
- data/vendor/liblouis/tables/en-in-g1.ctb +162 -0
- data/vendor/liblouis/tables/en-nabcc.utb +166 -0
- data/vendor/liblouis/tables/en-nz-g1.utb +65 -0
- data/vendor/liblouis/tables/en-nz-g2.ctb +46 -0
- data/vendor/liblouis/tables/en-ueb-chardefs.uti +938 -0
- data/vendor/liblouis/tables/en-ueb-g1.ctb +167 -0
- data/vendor/liblouis/tables/en-ueb-g2.ctb +3925 -0
- data/vendor/liblouis/tables/en-ueb-math.ctb +71 -0
- data/vendor/liblouis/tables/en-us-brf.dis +102 -0
- data/vendor/liblouis/tables/en-us-comp6.ctb +149 -0
- data/vendor/liblouis/tables/en-us-comp8-ext.utb +626 -0
- data/vendor/liblouis/tables/en-us-comp8.ctb +62 -0
- data/vendor/liblouis/tables/en-us-compbrl.uti +69 -0
- data/vendor/liblouis/tables/en-us-emphasis.uti +45 -0
- data/vendor/liblouis/tables/en-us-g1.ctb +199 -0
- data/vendor/liblouis/tables/en-us-g2.ctb +1081 -0
- data/vendor/liblouis/tables/en-us-interline.ctb +1126 -0
- data/vendor/liblouis/tables/en-us-mathtext.ctb +880 -0
- data/vendor/liblouis/tables/en_CA.ctb +195 -0
- data/vendor/liblouis/tables/en_CA.tbl +21 -0
- data/vendor/liblouis/tables/en_GB.tbl +26 -0
- data/vendor/liblouis/tables/en_US-comp8-ext.tbl +15 -0
- data/vendor/liblouis/tables/en_US.tbl +26 -0
- data/vendor/liblouis/tables/eo-g1-x-system.ctb +85 -0
- data/vendor/liblouis/tables/eo-g1.ctb +165 -0
- data/vendor/liblouis/tables/eo.tbl +14 -0
- data/vendor/liblouis/tables/es-chardefs.cti +206 -0
- data/vendor/liblouis/tables/es-g1.ctb +36 -0
- data/vendor/liblouis/tables/es-g2.ctb +955 -0
- data/vendor/liblouis/tables/es-new.dis +284 -0
- data/vendor/liblouis/tables/es-no.utb +79 -0
- data/vendor/liblouis/tables/es-old.dis +284 -0
- data/vendor/liblouis/tables/es.tbl +19 -0
- data/vendor/liblouis/tables/et-6dot.utb +269 -0
- data/vendor/liblouis/tables/et-g0.utb +139 -0
- data/vendor/liblouis/tables/ethio-g1.ctb +335 -0
- data/vendor/liblouis/tables/eurodefs.cti +107 -0
- data/vendor/liblouis/tables/fa-ir-comp8.ctb +250 -0
- data/vendor/liblouis/tables/fa-ir-g1.utb +311 -0
- data/vendor/liblouis/tables/fi-fi-8dot.ctb +278 -0
- data/vendor/liblouis/tables/fi.utb +354 -0
- data/vendor/liblouis/tables/fil-g2.ctb +491 -0
- data/vendor/liblouis/tables/fr-bfu-comp6-puncs-math.uti +351 -0
- data/vendor/liblouis/tables/fr-bfu-comp6.utb +238 -0
- data/vendor/liblouis/tables/fr-bfu-comp68.cti +251 -0
- data/vendor/liblouis/tables/fr-bfu-comp8.utb +323 -0
- data/vendor/liblouis/tables/fr-bfu-g2.ctb +4644 -0
- data/vendor/liblouis/tables/ga-g1.utb +95 -0
- data/vendor/liblouis/tables/ga-g2.ctb +231 -0
- data/vendor/liblouis/tables/gd.ctb +123 -0
- data/vendor/liblouis/tables/gd.tbl +21 -0
- data/vendor/liblouis/tables/gez.tbl +21 -0
- data/vendor/liblouis/tables/gon.ctb +25 -0
- data/vendor/liblouis/tables/gon.tbl +17 -0
- data/vendor/liblouis/tables/gr-pl-comp8.uti +256 -0
- data/vendor/liblouis/tables/grc-international-common.uti +104 -0
- data/vendor/liblouis/tables/grc-international-composed.uti +268 -0
- data/vendor/liblouis/tables/grc-international-decomposed.uti +268 -0
- data/vendor/liblouis/tables/grc-international-en-composed.utb +54 -0
- data/vendor/liblouis/tables/grc-international-en.utb +206 -0
- data/vendor/liblouis/tables/grc-international-es.utb +228 -0
- data/vendor/liblouis/tables/gu-in-g1.utb +27 -0
- data/vendor/liblouis/tables/gu.tbl +18 -0
- data/vendor/liblouis/tables/gujarati.cti +221 -0
- data/vendor/liblouis/tables/gurumuki.cti +393 -0
- data/vendor/liblouis/tables/haw-us-g1.ctb +54 -0
- data/vendor/liblouis/tables/hbo-cantillated-rules.uti +71 -0
- data/vendor/liblouis/tables/hbo-cantillated.utb +109 -0
- data/vendor/liblouis/tables/hbo-common-rules.uti +152 -0
- data/vendor/liblouis/tables/hbo-ihbc-rules.uti +58 -0
- data/vendor/liblouis/tables/hbo-slim-rules.uti +68 -0
- data/vendor/liblouis/tables/hbo-slim.utb +100 -0
- data/vendor/liblouis/tables/hbo.utb +107 -0
- data/vendor/liblouis/tables/he-IL-comp8.utb +464 -0
- data/vendor/liblouis/tables/he-IL.utb +406 -0
- data/vendor/liblouis/tables/he-common-consonants.uti +102 -0
- data/vendor/liblouis/tables/he-common-vowels-ihbc.uti +161 -0
- data/vendor/liblouis/tables/hi-in-g1.utb +27 -0
- data/vendor/liblouis/tables/hi.tbl +18 -0
- data/vendor/liblouis/tables/hr-chardefs.cti +278 -0
- data/vendor/liblouis/tables/hr-comp8.tbl +21 -0
- data/vendor/liblouis/tables/hr-comp8.utb +239 -0
- data/vendor/liblouis/tables/hr-digits.uti +40 -0
- data/vendor/liblouis/tables/hr-g1.ctb +36 -0
- data/vendor/liblouis/tables/hr-g1.tbl +9 -0
- data/vendor/liblouis/tables/hr-translation.cti +364 -0
- data/vendor/liblouis/tables/ht-frenchcompatibility.uti +61 -0
- data/vendor/liblouis/tables/ht-g1.utb +114 -0
- data/vendor/liblouis/tables/hu-backtranslate-correction.dis +38 -0
- data/vendor/liblouis/tables/hu-backtranslate-word-corrections.cti +4293 -0
- data/vendor/liblouis/tables/hu-chardefs.cti +298 -0
- data/vendor/liblouis/tables/hu-exceptionwords.cti +3204 -0
- data/vendor/liblouis/tables/hu-hu-comp8.ctb +183 -0
- data/vendor/liblouis/tables/hu-hu-g1.ctb +129 -0
- data/vendor/liblouis/tables/hu-hu-g1_braille_input.cti +486 -0
- data/vendor/liblouis/tables/hu-hu-g2.ctb +270 -0
- data/vendor/liblouis/tables/hu-hu-g2_exceptions.cti +1164 -0
- data/vendor/liblouis/tables/hy.ctb +121 -0
- data/vendor/liblouis/tables/hy.tbl +21 -0
- data/vendor/liblouis/tables/hyph_cs_CZ.dic +3637 -0
- data/vendor/liblouis/tables/hyph_da_DK.dic +8896 -0
- data/vendor/liblouis/tables/hyph_de_DE.dic +5799 -0
- data/vendor/liblouis/tables/hyph_en_US.dic +5537 -0
- data/vendor/liblouis/tables/hyph_eo.dic +1024 -0
- data/vendor/liblouis/tables/hyph_es_ES.dic +877 -0
- data/vendor/liblouis/tables/hyph_fr_FR.dic +1067 -0
- data/vendor/liblouis/tables/hyph_hu_HU.dic +98519 -0
- data/vendor/liblouis/tables/hyph_it_IT.dic +410 -0
- data/vendor/liblouis/tables/hyph_nb_NO.dic +27142 -0
- data/vendor/liblouis/tables/hyph_nl_NL.dic +12725 -0
- data/vendor/liblouis/tables/hyph_nn_NO.dic +27142 -0
- data/vendor/liblouis/tables/hyph_pl_PL.dic +4074 -0
- data/vendor/liblouis/tables/hyph_pt_PT.dic +308 -0
- data/vendor/liblouis/tables/hyph_ru.dic +6480 -0
- data/vendor/liblouis/tables/hyph_sv_SE.dic +4697 -0
- data/vendor/liblouis/tables/is-chardefs6.cti +170 -0
- data/vendor/liblouis/tables/is-chardefs8.cti +293 -0
- data/vendor/liblouis/tables/is.ctb +157 -0
- data/vendor/liblouis/tables/is.tbl +18 -0
- data/vendor/liblouis/tables/it-it-comp6.utb +404 -0
- data/vendor/liblouis/tables/it-it-comp8.utb +663 -0
- data/vendor/liblouis/tables/iu-ca-g1.ctb +236 -0
- data/vendor/liblouis/tables/ja-kantenji-ucs2.utb +11448 -0
- data/vendor/liblouis/tables/ja-kantenji.utb +53 -0
- data/vendor/liblouis/tables/ja-rokutenkanji.utb +8710 -0
- data/vendor/liblouis/tables/ka-in-g1.utb +27 -0
- data/vendor/liblouis/tables/ka.utb +128 -0
- data/vendor/liblouis/tables/kannada.cti +282 -0
- data/vendor/liblouis/tables/kh-in-g1.utb +26 -0
- data/vendor/liblouis/tables/kha.tbl +18 -0
- data/vendor/liblouis/tables/kk.utb +77 -0
- data/vendor/liblouis/tables/km-g1.utb +412 -0
- data/vendor/liblouis/tables/kmr.tbl +108 -0
- data/vendor/liblouis/tables/kn.tbl +18 -0
- data/vendor/liblouis/tables/ko-2006-g1.ctb +49 -0
- data/vendor/liblouis/tables/ko-2006-g2.ctb +53 -0
- data/vendor/liblouis/tables/ko-2006.cti +190 -0
- data/vendor/liblouis/tables/ko-chars.cti +15140 -0
- data/vendor/liblouis/tables/ko-g1-rules.cti +634 -0
- data/vendor/liblouis/tables/ko-g1.ctb +48 -0
- data/vendor/liblouis/tables/ko-g2-rules.cti +9263 -0
- data/vendor/liblouis/tables/ko-g2.ctb +52 -0
- data/vendor/liblouis/tables/ko.cti +223 -0
- data/vendor/liblouis/tables/kok.ctb +24 -0
- data/vendor/liblouis/tables/kok.tbl +17 -0
- data/vendor/liblouis/tables/kru.ctb +24 -0
- data/vendor/liblouis/tables/kru.tbl +17 -0
- data/vendor/liblouis/tables/ks-in-g1.utb +27 -0
- data/vendor/liblouis/tables/latinLetterDef6Dots.uti +78 -0
- data/vendor/liblouis/tables/latinLetterDef8Dots.uti +75 -0
- data/vendor/liblouis/tables/latinLowercase.uti +389 -0
- data/vendor/liblouis/tables/latinUppercaseComp6.uti +78 -0
- data/vendor/liblouis/tables/lg-ug-g1.utb +60 -0
- data/vendor/liblouis/tables/litdigits6Dots.uti +30 -0
- data/vendor/liblouis/tables/litdigits6DotsPlusDot6.uti +30 -0
- data/vendor/liblouis/tables/lo-g1.utb +3127 -0
- data/vendor/liblouis/tables/loweredDigits6Dots.uti +30 -0
- data/vendor/liblouis/tables/loweredDigits8Dots.uti +30 -0
- data/vendor/liblouis/tables/lt-6dot.utb +308 -0
- data/vendor/liblouis/tables/lt-8dot.utb +281 -0
- data/vendor/liblouis/tables/lt.ctb +313 -0
- data/vendor/liblouis/tables/lv.tbl +22 -0
- data/vendor/liblouis/tables/maketablelist.sh +52 -0
- data/vendor/liblouis/tables/malayalam.cti +674 -0
- data/vendor/liblouis/tables/mao-nz-g1.ctb +65 -0
- data/vendor/liblouis/tables/marburg_single_cell_defs.cti +66 -0
- data/vendor/liblouis/tables/marburg_unicode_defs.cti +297 -0
- data/vendor/liblouis/tables/mk-g1.utb +240 -0
- data/vendor/liblouis/tables/ml-in-g1.utb +27 -0
- data/vendor/liblouis/tables/ml.tbl +21 -0
- data/vendor/liblouis/tables/mn-MN-common.cti +110 -0
- data/vendor/liblouis/tables/mn-MN-g1.utb +52 -0
- data/vendor/liblouis/tables/mn-MN-g2.ctb +50 -0
- data/vendor/liblouis/tables/mn-in-g1.utb +27 -0
- data/vendor/liblouis/tables/mni.tbl +18 -0
- data/vendor/liblouis/tables/mr-in-g1.utb +27 -0
- data/vendor/liblouis/tables/mr.tbl +18 -0
- data/vendor/liblouis/tables/ms-my-g2.ctb +4897 -0
- data/vendor/liblouis/tables/mt.ctb +114 -0
- data/vendor/liblouis/tables/mt.tbl +21 -0
- data/vendor/liblouis/tables/mun.ctb +24 -0
- data/vendor/liblouis/tables/mun.tbl +17 -0
- data/vendor/liblouis/tables/mwr.ctb +24 -0
- data/vendor/liblouis/tables/mwr.tbl +17 -0
- data/vendor/liblouis/tables/my-g1.utb +771 -0
- data/vendor/liblouis/tables/my-g2.ctb +3805 -0
- data/vendor/liblouis/tables/ne.ctb +22 -0
- data/vendor/liblouis/tables/ne.tbl +18 -0
- data/vendor/liblouis/tables/nemethdefs.cti +382 -0
- data/vendor/liblouis/tables/nl-BE.dis +532 -0
- data/vendor/liblouis/tables/nl-NL-g0.utb.in +646 -0
- data/vendor/liblouis/tables/nl-chardefs.uti.in +455 -0
- data/vendor/liblouis/tables/nl-comp8.utb +411 -0
- data/vendor/liblouis/tables/nl-print.dis +551 -0
- data/vendor/liblouis/tables/nl-unicode.dis +540 -0
- data/vendor/liblouis/tables/no-no-8dot-fallback-6dot-g0.utb +59 -0
- data/vendor/liblouis/tables/no-no-8dot.utb +629 -0
- data/vendor/liblouis/tables/no-no-braillo-047-01.dis +247 -0
- data/vendor/liblouis/tables/no-no-chardefs6.uti +305 -0
- data/vendor/liblouis/tables/no-no-comp8.ctb +323 -0
- data/vendor/liblouis/tables/no-no-cyrillic6dot.uti +95 -0
- data/vendor/liblouis/tables/no-no-g0.utb +320 -0
- data/vendor/liblouis/tables/no-no-g1.ctb +272 -0
- data/vendor/liblouis/tables/no-no-g2.ctb +737 -0
- data/vendor/liblouis/tables/no-no-g3.ctb +3597 -0
- data/vendor/liblouis/tables/no-no-generic.ctb +295 -0
- data/vendor/liblouis/tables/no-no-generic.dis +295 -0
- data/vendor/liblouis/tables/no-no-latinLetterDef6Dots_diacritics.uti +852 -0
- data/vendor/liblouis/tables/no-no.dis +291 -0
- data/vendor/liblouis/tables/np-in-g1.utb +27 -0
- data/vendor/liblouis/tables/nso-za-g1.utb +38 -0
- data/vendor/liblouis/tables/nso-za-g2.ctb +38 -0
- data/vendor/liblouis/tables/ny-mw.utb +70 -0
- data/vendor/liblouis/tables/or-in-g1.utb +27 -0
- data/vendor/liblouis/tables/or.tbl +18 -0
- data/vendor/liblouis/tables/oriya.cti +238 -0
- data/vendor/liblouis/tables/ovd-6g0.utb +64 -0
- data/vendor/liblouis/tables/ovd-8g0.utb +81 -0
- data/vendor/liblouis/tables/pa.tbl +18 -0
- data/vendor/liblouis/tables/pi.ctb +24 -0
- data/vendor/liblouis/tables/pi.tbl +17 -0
- data/vendor/liblouis/tables/pl-pl-comp8.ctb +658 -0
- data/vendor/liblouis/tables/pl.tbl +12 -0
- data/vendor/liblouis/tables/printables.cti +70 -0
- data/vendor/liblouis/tables/pt-comp6.utb +299 -0
- data/vendor/liblouis/tables/pt-pt-comp8.ctb +395 -0
- data/vendor/liblouis/tables/pt-pt-g1.utb +1312 -0
- data/vendor/liblouis/tables/pt-pt-g2.ctb +874 -0
- data/vendor/liblouis/tables/pt.tbl +20 -0
- data/vendor/liblouis/tables/pu-in-g1.utb +42 -0
- data/vendor/liblouis/tables/quotation-marks.uti +30 -0
- data/vendor/liblouis/tables/ro-g0.utb +85 -0
- data/vendor/liblouis/tables/ro.ctb +126 -0
- data/vendor/liblouis/tables/ro.tbl +21 -0
- data/vendor/liblouis/tables/ru-brf.dis +116 -0
- data/vendor/liblouis/tables/ru-comp6.utb +258 -0
- data/vendor/liblouis/tables/ru-comp8.utb +740 -0
- data/vendor/liblouis/tables/ru-letters.dis +145 -0
- data/vendor/liblouis/tables/ru-litbrl-detailed.utb +77 -0
- data/vendor/liblouis/tables/ru-litbrl.ctb +857 -0
- data/vendor/liblouis/tables/ru-math.uti +395 -0
- data/vendor/liblouis/tables/ru-ru-g1.ctb +804 -0
- data/vendor/liblouis/tables/ru-unicode.dis +121 -0
- data/vendor/liblouis/tables/rw-rw-g1.utb +133 -0
- data/vendor/liblouis/tables/sa-in-g1.utb +27 -0
- data/vendor/liblouis/tables/sa.tbl +18 -0
- data/vendor/liblouis/tables/sah.utb +72 -0
- data/vendor/liblouis/tables/sd.tbl +18 -0
- data/vendor/liblouis/tables/se-se.ctb +246 -0
- data/vendor/liblouis/tables/se-se.dis +334 -0
- data/vendor/liblouis/tables/si-in-g1.utb +27 -0
- data/vendor/liblouis/tables/sin.cti +213 -0
- data/vendor/liblouis/tables/sin.utb +35 -0
- data/vendor/liblouis/tables/sk-g1.ctb +1019 -0
- data/vendor/liblouis/tables/sk-sk-g1.utb +206 -0
- data/vendor/liblouis/tables/sk-sk.utb +112 -0
- data/vendor/liblouis/tables/sl-si-comp8.ctb +204 -0
- data/vendor/liblouis/tables/sl-si-g1.utb +471 -0
- data/vendor/liblouis/tables/sl.tbl +20 -0
- data/vendor/liblouis/tables/smi-6g0.utb +64 -0
- data/vendor/liblouis/tables/smi-8g0.utb +61 -0
- data/vendor/liblouis/tables/sot-za-g1.ctb +72 -0
- data/vendor/liblouis/tables/sot-za-g2.ctb +244 -0
- data/vendor/liblouis/tables/spaces.uti +62 -0
- data/vendor/liblouis/tables/sr-Cyrl.ctb +59 -0
- data/vendor/liblouis/tables/sr-common.cti +161 -0
- data/vendor/liblouis/tables/sr-cyrletters.cti +92 -0
- data/vendor/liblouis/tables/sr-g1.ctb +57 -0
- data/vendor/liblouis/tables/sr-latletters.cti +45 -0
- data/vendor/liblouis/tables/sv-1989.ctb +241 -0
- data/vendor/liblouis/tables/sv-1996.ctb +180 -0
- data/vendor/liblouis/tables/sv-6common.uti +1199 -0
- data/vendor/liblouis/tables/sv-6g0d.utb +508 -0
- data/vendor/liblouis/tables/sv-6g0p.utb +61 -0
- data/vendor/liblouis/tables/sv-6g1.uti +106 -0
- data/vendor/liblouis/tables/sv-6g1d.ctb +57 -0
- data/vendor/liblouis/tables/sv-6g2.uti +254 -0
- data/vendor/liblouis/tables/sv-6g2d.ctb +57 -0
- data/vendor/liblouis/tables/sv-8g0d.utb +495 -0
- data/vendor/liblouis/tables/sv-8g0n.utb +1236 -0
- data/vendor/liblouis/tables/sv-8g1.uti +199 -0
- data/vendor/liblouis/tables/sv-8g1d.ctb +73 -0
- data/vendor/liblouis/tables/sv-8g1n.ctb +73 -0
- data/vendor/liblouis/tables/sv-8g2.uti +486 -0
- data/vendor/liblouis/tables/sv-8g2d.ctb +73 -0
- data/vendor/liblouis/tables/sv-8g2n.ctb +73 -0
- data/vendor/liblouis/tables/sv-g0.utb +65 -0
- data/vendor/liblouis/tables/sv-g1.ctb +57 -0
- data/vendor/liblouis/tables/sv-g2.ctb +57 -0
- data/vendor/liblouis/tables/sv-phon.uti +241 -0
- data/vendor/liblouis/tables/sw-ke-g1-2.ctb +90 -0
- data/vendor/liblouis/tables/sw-ke-g1-3.ctb +109 -0
- data/vendor/liblouis/tables/sw-ke-g1-4.ctb +107 -0
- data/vendor/liblouis/tables/sw-ke-g1-5.ctb +73 -0
- data/vendor/liblouis/tables/sw-ke-g1.utb +278 -0
- data/vendor/liblouis/tables/sw-ke-g2.ctb +276 -0
- data/vendor/liblouis/tables/syc.utb +195 -0
- data/vendor/liblouis/tables/ta-ta-g1.ctb +167 -0
- data/vendor/liblouis/tables/ta.ctb +24 -0
- data/vendor/liblouis/tables/ta.tbl +21 -0
- data/vendor/liblouis/tables/tamil.cti +86 -0
- data/vendor/liblouis/tables/te-in-g1.utb +27 -0
- data/vendor/liblouis/tables/te.tbl +18 -0
- data/vendor/liblouis/tables/telugu.cti +239 -0
- data/vendor/liblouis/tables/text_nabcc.dis +426 -0
- data/vendor/liblouis/tables/th-comp8-backward.utb +226 -0
- data/vendor/liblouis/tables/th-g0.utb +177 -0
- data/vendor/liblouis/tables/th-g1.utb +89 -0
- data/vendor/liblouis/tables/th-g1.uti +315 -0
- data/vendor/liblouis/tables/th-g2.ctb +616 -0
- data/vendor/liblouis/tables/tr-g1.ctb +254 -0
- data/vendor/liblouis/tables/tr-g2.ctb +863 -0
- data/vendor/liblouis/tables/tr-g2.tbl +20 -0
- data/vendor/liblouis/tables/tr.ctb +324 -0
- data/vendor/liblouis/tables/tr.tbl +21 -0
- data/vendor/liblouis/tables/tsn-za-g1.ctb +33 -0
- data/vendor/liblouis/tables/tsn-za-g2.ctb +33 -0
- data/vendor/liblouis/tables/tt.utb +74 -0
- data/vendor/liblouis/tables/uga.utb +86 -0
- data/vendor/liblouis/tables/uk-comp.utb +53 -0
- data/vendor/liblouis/tables/uk-detailed.utb +32 -0
- data/vendor/liblouis/tables/uk.utb +101 -0
- data/vendor/liblouis/tables/ukchardefs.cti +106 -0
- data/vendor/liblouis/tables/ukmaths_single_cell_defs.cti +65 -0
- data/vendor/liblouis/tables/ukmaths_unicode_defs.cti +298 -0
- data/vendor/liblouis/tables/uni-text.dis +330 -0
- data/vendor/liblouis/tables/unicode-braille.utb +291 -0
- data/vendor/liblouis/tables/unicode-without-blank.dis +24 -0
- data/vendor/liblouis/tables/unicode.dis +278 -0
- data/vendor/liblouis/tables/ur-pk-g1.utb +248 -0
- data/vendor/liblouis/tables/ur-pk-g2.ctb +641 -0
- data/vendor/liblouis/tables/us-table.dis +67 -0
- data/vendor/liblouis/tables/uz-g1.utb +117 -0
- data/vendor/liblouis/tables/ve-za-g1.utb +69 -0
- data/vendor/liblouis/tables/ve-za-g2.ctb +208 -0
- data/vendor/liblouis/tables/vi-cb8.utb +49 -0
- data/vendor/liblouis/tables/vi-charsdef.uti +36 -0
- data/vendor/liblouis/tables/vi-lettersdef.uti +401 -0
- data/vendor/liblouis/tables/vi-puncsdef.uti +446 -0
- data/vendor/liblouis/tables/vi-saigon-g1.ctb +530 -0
- data/vendor/liblouis/tables/vi-vn-g0.utb +135 -0
- data/vendor/liblouis/tables/vi-vn-g1.ctb +574 -0
- data/vendor/liblouis/tables/vi-vn-g2.ctb +743 -0
- data/vendor/liblouis/tables/wiskunde-chardefs.cti +261 -0
- data/vendor/liblouis/tables/wordcx.dis +91 -0
- data/vendor/liblouis/tables/xh-za-g1.utb +61 -0
- data/vendor/liblouis/tables/xh-za-g2.ctb +386 -0
- data/vendor/liblouis/tables/yi.utb +236 -0
- data/vendor/liblouis/tables/zh-chn.ctb +45011 -0
- data/vendor/liblouis/tables/zh-hk.ctb +10461 -0
- data/vendor/liblouis/tables/zh-tw.ctb +53810 -0
- data/vendor/liblouis/tables/zh_CHN.tbl +23 -0
- data/vendor/liblouis/tables/zhcn-cbs.ctb +31523 -0
- data/vendor/liblouis/tables/zhcn-g1.ctb +26523 -0
- data/vendor/liblouis/tables/zhcn-g2.ctb +26519 -0
- data/vendor/liblouis/tables/zu-za-g1.utb +33 -0
- data/vendor/liblouis/tables/zu-za-g2.ctb +33 -0
- metadata +558 -0
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative "test_helper"
|
|
4
|
+
|
|
5
|
+
class BrailleCharacterTest < Minitest::Test
|
|
6
|
+
def test_builds_from_mask_dots_and_unicode
|
|
7
|
+
from_mask = LibLouis::BrailleCharacter.new(137)
|
|
8
|
+
from_dots = LibLouis::BrailleCharacter.new([1, 4, 8])
|
|
9
|
+
from_unicode = LibLouis::BrailleCharacter.new("⢉")
|
|
10
|
+
|
|
11
|
+
assert_equal [1, 4, 8], from_mask.dots
|
|
12
|
+
assert_equal from_mask, from_dots
|
|
13
|
+
assert_equal from_mask, from_unicode
|
|
14
|
+
assert_equal 137, from_mask.to_i
|
|
15
|
+
assert_equal "⢉", from_mask.unicode_character
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def test_dot_predicates_cover_all_eight_bits
|
|
19
|
+
character = LibLouis::BrailleCharacter.new(0b1010_0101)
|
|
20
|
+
|
|
21
|
+
assert character.dot1?
|
|
22
|
+
refute character.dot2?
|
|
23
|
+
assert character.dot3?
|
|
24
|
+
refute character.dot4?
|
|
25
|
+
refute character.dot5?
|
|
26
|
+
assert character.dot6?
|
|
27
|
+
refute character.dot7?
|
|
28
|
+
assert character.dot8?
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def test_copies_preserve_all_dot_masks_and_ruby_freeze_semantics
|
|
32
|
+
(0..255).each do |mask|
|
|
33
|
+
original = LibLouis::BrailleCharacter.new(mask)
|
|
34
|
+
copies = [original.dup, original.clone, original.clone(freeze: false)]
|
|
35
|
+
copies.each do |copy|
|
|
36
|
+
refute_same original, copy
|
|
37
|
+
assert_equal original, copy
|
|
38
|
+
assert_equal original.hash, copy.hash
|
|
39
|
+
assert_equal mask, copy.mask
|
|
40
|
+
end
|
|
41
|
+
refute copies[0].frozen?
|
|
42
|
+
assert copies[1].frozen?
|
|
43
|
+
refute copies[2].frozen?
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
def test_frozen_cells_cannot_be_reinitialised_or_overwritten
|
|
48
|
+
cell = LibLouis::BrailleCharacter.new(137)
|
|
49
|
+
replacement = LibLouis::BrailleCharacter.new(1)
|
|
50
|
+
|
|
51
|
+
assert_raises(FrozenError) { cell.send(:initialize, 1) }
|
|
52
|
+
assert_raises(FrozenError) { cell.send(:initialize_copy, replacement) }
|
|
53
|
+
assert_equal 137, cell.mask
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
def test_rejects_invalid_values
|
|
57
|
+
assert_raises(RangeError) { LibLouis::BrailleCharacter.new(256) }
|
|
58
|
+
assert_raises(RangeError) { LibLouis::BrailleCharacter.new([9]) }
|
|
59
|
+
assert_raises(ArgumentError) { LibLouis::BrailleCharacter.new("a") }
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
|
|
@@ -0,0 +1,379 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative "test_helper"
|
|
4
|
+
require_relative "translation_cases"
|
|
5
|
+
require_relative "table_source_cases"
|
|
6
|
+
require "pathname"
|
|
7
|
+
require "stringio"
|
|
8
|
+
require "tmpdir"
|
|
9
|
+
|
|
10
|
+
class BrailleTableTest < Minitest::Test
|
|
11
|
+
def setup
|
|
12
|
+
@polish_case = TranslationCases.fetch("Pl-Pl-g1.utb")
|
|
13
|
+
@table = LibLouis::BrailleTable.new(@polish_case[:table])
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def test_reports_native_version_and_table
|
|
17
|
+
expected_version = File.read(File.expand_path("../vendor/liblouis/configure.ac", __dir__))[
|
|
18
|
+
/AC_INIT\(\[Liblouis\],\s*\[([0-9.]+)\]/, 1
|
|
19
|
+
]
|
|
20
|
+
assert_equal expected_version, LibLouis.version
|
|
21
|
+
assert @table.valid?
|
|
22
|
+
assert_equal "Pl-Pl-g1.utb", @table.file
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def test_hides_native_representation_details
|
|
26
|
+
refute_respond_to LibLouis, :char_size
|
|
27
|
+
refute LibLouis.const_defined?(:DOTS_IO, false)
|
|
28
|
+
refute LibLouis.const_defined?(:UC_BRL, false)
|
|
29
|
+
%i[
|
|
30
|
+
PLAIN_TEXT ITALIC UNDERLINE BOLD
|
|
31
|
+
COMPUTER_BRAILLE NO_TRANSLATE NO_CONTRACT
|
|
32
|
+
NO_CONTRACTIONS COMPBRL_AT_CURSOR COMPBRL_LEFT_CURSOR
|
|
33
|
+
NO_UNDEFINED PARTIAL_TRANSLATION
|
|
34
|
+
].each do |name|
|
|
35
|
+
refute LibLouis.const_defined?(name, false)
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def test_native_logging_is_enabled_only_in_debug_mode
|
|
40
|
+
LibLouis.debug = false
|
|
41
|
+
refute LibLouis.debug?
|
|
42
|
+
|
|
43
|
+
stdout, stderr = capture_subprocess_io do
|
|
44
|
+
refute LibLouis::BrailleTable.new("definitely-missing-silent.ctb").valid?
|
|
45
|
+
end
|
|
46
|
+
assert_empty stdout
|
|
47
|
+
assert_empty stderr
|
|
48
|
+
|
|
49
|
+
LibLouis.debug = true
|
|
50
|
+
assert LibLouis.debug?
|
|
51
|
+
_stdout, stderr = capture_subprocess_io do
|
|
52
|
+
refute LibLouis::BrailleTable.new("definitely-missing-debug.ctb").valid?
|
|
53
|
+
end
|
|
54
|
+
assert_match(/definitely-missing-debug\.ctb/, stderr)
|
|
55
|
+
assert_raises(TypeError) { LibLouis.debug = 1 }
|
|
56
|
+
ensure
|
|
57
|
+
LibLouis.debug = false
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
def test_prefers_the_current_directory_before_bundled_tables
|
|
61
|
+
Dir.mktmpdir("liblouis-rb-cwd") do |directory|
|
|
62
|
+
File.binwrite(File.join(directory, "en-gb-g1.utb"), TableSourceCases::CUSTOM_TABLE)
|
|
63
|
+
|
|
64
|
+
with_cleared_native_cache do
|
|
65
|
+
Dir.chdir(directory) do
|
|
66
|
+
table = LibLouis::BrailleTable.new("en-gb-g1.utb")
|
|
67
|
+
|
|
68
|
+
assert_equal "Custom table source", table.display_name
|
|
69
|
+
assert_equal "⠿", table.get_braille("a").to_s
|
|
70
|
+
end
|
|
71
|
+
end
|
|
72
|
+
end
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
def test_falls_back_to_the_bundled_table_repository
|
|
76
|
+
test_case = TranslationCases.fetch("en-gb-comp8.ctb")
|
|
77
|
+
|
|
78
|
+
Dir.mktmpdir("liblouis-rb-empty") do |directory|
|
|
79
|
+
with_cleared_native_cache do
|
|
80
|
+
Dir.chdir(directory) do
|
|
81
|
+
table = LibLouis::BrailleTable.new(test_case[:table])
|
|
82
|
+
|
|
83
|
+
assert table.valid?
|
|
84
|
+
assert_equal test_case[:braille], table.get_braille(test_case[:source]).to_s
|
|
85
|
+
end
|
|
86
|
+
end
|
|
87
|
+
end
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
def test_accepts_an_exact_file_path_and_path_like_object
|
|
91
|
+
Dir.mktmpdir("liblouis-rb-path") do |directory|
|
|
92
|
+
path = File.join(directory, "custom-table.ctb")
|
|
93
|
+
File.binwrite(path, TableSourceCases::CUSTOM_TABLE)
|
|
94
|
+
|
|
95
|
+
table = LibLouis::BrailleTable.new(path)
|
|
96
|
+
path_table = LibLouis::BrailleTable.new(Pathname.new(path))
|
|
97
|
+
|
|
98
|
+
assert_equal path, table.file
|
|
99
|
+
assert_equal path, path_table.file
|
|
100
|
+
assert_equal "⠿", table.get_braille("a").to_s
|
|
101
|
+
assert_equal "⠿", path_table.get_braille("a").to_s
|
|
102
|
+
end
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
def test_accepts_a_table_directly_from_io
|
|
106
|
+
source = StringIO.new(TableSourceCases::CUSTOM_TABLE)
|
|
107
|
+
table = LibLouis::BrailleTable.new(source)
|
|
108
|
+
|
|
109
|
+
assert_equal TableSourceCases::CUSTOM_TABLE.bytesize, source.pos
|
|
110
|
+
assert File.file?(table.file)
|
|
111
|
+
assert_equal "Custom table source", table.display_name
|
|
112
|
+
assert_equal "⠿", table.get_braille("a").to_s
|
|
113
|
+
|
|
114
|
+
LibLouis.free
|
|
115
|
+
assert table.valid?
|
|
116
|
+
assert_equal "⠿", table.get_braille("a").to_s
|
|
117
|
+
end
|
|
118
|
+
|
|
119
|
+
def test_accepts_an_open_file_as_io
|
|
120
|
+
Dir.mktmpdir("liblouis-rb-file-io") do |directory|
|
|
121
|
+
path = File.join(directory, "file-io.ctb")
|
|
122
|
+
File.binwrite(path, TableSourceCases::CUSTOM_TABLE)
|
|
123
|
+
|
|
124
|
+
File.open(path, "rb") do |source|
|
|
125
|
+
table = LibLouis::BrailleTable.new(source)
|
|
126
|
+
|
|
127
|
+
assert_equal source.size, source.pos
|
|
128
|
+
refute_equal path, table.file
|
|
129
|
+
assert File.file?(table.file)
|
|
130
|
+
assert_equal "⠿", table.get_braille("a").to_s
|
|
131
|
+
end
|
|
132
|
+
end
|
|
133
|
+
end
|
|
134
|
+
|
|
135
|
+
def test_translates_the_requested_corpus
|
|
136
|
+
TranslationCases::CASES.each do |test_case|
|
|
137
|
+
table = LibLouis::BrailleTable.new(test_case[:table])
|
|
138
|
+
braille = table.get_braille(test_case[:source])
|
|
139
|
+
|
|
140
|
+
assert table.valid?, test_case[:table]
|
|
141
|
+
assert_instance_of LibLouis::BrailleText, braille, test_case[:table]
|
|
142
|
+
assert_equal test_case[:braille], braille.to_s, test_case[:table]
|
|
143
|
+
assert_equal braille.length, braille.input_positions.length, test_case[:table]
|
|
144
|
+
assert_equal test_case[:source].length, braille.output_positions.length, test_case[:table]
|
|
145
|
+
end
|
|
146
|
+
end
|
|
147
|
+
|
|
148
|
+
def test_back_translates_bidirectional_corpus_cases
|
|
149
|
+
TranslationCases::CASES.each do |test_case|
|
|
150
|
+
next unless test_case.key?(:back_translation)
|
|
151
|
+
|
|
152
|
+
table = LibLouis::BrailleTable.new(test_case[:table])
|
|
153
|
+
braille = table.get_braille(test_case[:source])
|
|
154
|
+
|
|
155
|
+
assert_equal test_case[:back_translation], table.get_text(braille), test_case[:table]
|
|
156
|
+
assert_equal test_case[:back_translation], table.get_text(test_case[:braille]), test_case[:table]
|
|
157
|
+
end
|
|
158
|
+
end
|
|
159
|
+
|
|
160
|
+
def test_forward_translation_grows_output_and_preserves_positions_and_typeforms
|
|
161
|
+
source = "space \\s 0\nlowercase a 1\nalways a #{Array.new(40, '1').join('-')}\n"
|
|
162
|
+
table = LibLouis::BrailleTable.new(StringIO.new(source))
|
|
163
|
+
|
|
164
|
+
[1, 10].each do |length|
|
|
165
|
+
forms = Array.new(length, :plain_text).freeze
|
|
166
|
+
cursor = length == 1 ? 0 : 1
|
|
167
|
+
braille = table.translate("a" * length, cursor_position: cursor, typeform: forms)
|
|
168
|
+
|
|
169
|
+
assert_equal "\u2801" * (40 * length), braille.to_s
|
|
170
|
+
assert_equal Array.new(length) { |index| index * 40 }, braille.output_positions
|
|
171
|
+
assert_equal (0...length).flat_map { |index| [index] * 40 }, braille.input_positions
|
|
172
|
+
assert_equal cursor * 40, braille.cursor_position
|
|
173
|
+
assert_equal Array.new(length, :plain_text), forms
|
|
174
|
+
end
|
|
175
|
+
end
|
|
176
|
+
|
|
177
|
+
def test_back_translation_grows_output_without_losing_input
|
|
178
|
+
source = "space \\s 0\nlowercase a 1\nnofor always #{'a' * 40} 1\n"
|
|
179
|
+
table = LibLouis::BrailleTable.new(StringIO.new(source))
|
|
180
|
+
|
|
181
|
+
[1, 10].each do |length|
|
|
182
|
+
assert_equal "a" * (40 * length), table.back_translate("\u2801" * length)
|
|
183
|
+
end
|
|
184
|
+
end
|
|
185
|
+
|
|
186
|
+
def test_translation_rejects_embedded_nul_instead_of_returning_a_prefix
|
|
187
|
+
assert_raises(ArgumentError) { @table.translate("a\0a") }
|
|
188
|
+
assert_raises(ArgumentError) { @table.back_translate("a\0a") }
|
|
189
|
+
end
|
|
190
|
+
|
|
191
|
+
def test_handles_empty_input
|
|
192
|
+
braille = @table.translate("")
|
|
193
|
+
|
|
194
|
+
assert braille.empty?
|
|
195
|
+
assert_equal "", @table.back_translate(braille)
|
|
196
|
+
end
|
|
197
|
+
|
|
198
|
+
def test_translation_metadata_is_part_of_braille_text
|
|
199
|
+
source = "ala"
|
|
200
|
+
braille = @table.translate(source, cursor_position: 1)
|
|
201
|
+
|
|
202
|
+
assert_equal [0, 1, 2], braille.input_positions
|
|
203
|
+
assert_equal [0, 1, 2], braille.output_positions
|
|
204
|
+
assert_equal 1, braille.cursor_position
|
|
205
|
+
assert braille.input_positions.frozen?
|
|
206
|
+
assert braille.output_positions.frozen?
|
|
207
|
+
|
|
208
|
+
without_cursor = @table.translate(source)
|
|
209
|
+
assert_nil without_cursor.cursor_position
|
|
210
|
+
assert_equal [0, 1, 2], without_cursor.input_positions
|
|
211
|
+
assert_equal [0, 1, 2], without_cursor.output_positions
|
|
212
|
+
end
|
|
213
|
+
|
|
214
|
+
def test_table_and_translation_survive_gc_compaction
|
|
215
|
+
source = @polish_case[:source]
|
|
216
|
+
braille = @table.translate(source, cursor_position: 1)
|
|
217
|
+
cursor_position = braille.cursor_position
|
|
218
|
+
|
|
219
|
+
GC.start
|
|
220
|
+
GC.compact if GC.respond_to?(:compact)
|
|
221
|
+
|
|
222
|
+
assert_equal @polish_case[:braille], braille.to_s
|
|
223
|
+
assert_equal cursor_position, braille.cursor_position
|
|
224
|
+
assert_equal @polish_case[:table], @table.file
|
|
225
|
+
assert @table.valid?
|
|
226
|
+
end
|
|
227
|
+
|
|
228
|
+
def test_character_and_dot_conversion
|
|
229
|
+
test_case = TranslationCases.fetch("en-gb-comp8.ctb")
|
|
230
|
+
table = LibLouis::BrailleTable.new(test_case[:table])
|
|
231
|
+
dots = table.characters_to_dots(test_case[:source])
|
|
232
|
+
|
|
233
|
+
assert_equal test_case[:braille], dots.to_s
|
|
234
|
+
assert_equal test_case[:source], table.dots_to_characters(dots)
|
|
235
|
+
assert_nil dots.input_positions
|
|
236
|
+
assert_nil dots.output_positions
|
|
237
|
+
assert_nil dots.cursor_position
|
|
238
|
+
end
|
|
239
|
+
|
|
240
|
+
def test_table_metadata_search_and_listing
|
|
241
|
+
english = LibLouis::BrailleTable.new("en-gb-g1.utb")
|
|
242
|
+
|
|
243
|
+
assert_match(/English uncontracted braille/, english.display_name)
|
|
244
|
+
assert_equal "en", english.metadata("language")
|
|
245
|
+
assert_equal "en-GB", english.metadata("region")
|
|
246
|
+
refute_empty LibLouis.tables
|
|
247
|
+
assert_instance_of LibLouis::BrailleTable,
|
|
248
|
+
LibLouis.find_table("language:en grade:1")
|
|
249
|
+
end
|
|
250
|
+
|
|
251
|
+
def test_typeforms_use_symbols_and_table_emphasis_classes
|
|
252
|
+
test_case = TranslationCases.fetch("en-GB-g2.ctb")
|
|
253
|
+
table = LibLouis::BrailleTable.new(test_case[:table])
|
|
254
|
+
plain = Array.new(test_case[:source].length, :plain_text)
|
|
255
|
+
|
|
256
|
+
assert_equal %i[italic underline bold], table.emphasis_classes
|
|
257
|
+
refute_respond_to table, :typeform_for
|
|
258
|
+
assert_equal test_case[:braille], table.translate(test_case[:source], typeform: plain).to_s
|
|
259
|
+
|
|
260
|
+
styled = Array.new(test_case[:source].length, :plain_text)
|
|
261
|
+
styled[0] = %i[italic bold]
|
|
262
|
+
refute_equal test_case[:braille], table.translate(test_case[:source], typeform: styled).to_s
|
|
263
|
+
|
|
264
|
+
word = "the"
|
|
265
|
+
%i[computer_braille no_translate no_contract].each do |form|
|
|
266
|
+
assert_instance_of LibLouis::BrailleText,
|
|
267
|
+
table.translate(word, typeform: Array.new(word.length, form))
|
|
268
|
+
end
|
|
269
|
+
assert_equal "⠞⠓⠑",
|
|
270
|
+
table.translate(word, typeform: Array.new(word.length, :no_contract)).to_s
|
|
271
|
+
end
|
|
272
|
+
|
|
273
|
+
def test_translation_modes_use_symbols
|
|
274
|
+
table = LibLouis::BrailleTable.new("en-GB-g2.ctb")
|
|
275
|
+
word = "the"
|
|
276
|
+
|
|
277
|
+
assert_equal "⠮", table.translate(word).to_s
|
|
278
|
+
assert_equal "⠞⠓⠑", table.translate(word, mode: :no_contractions).to_s
|
|
279
|
+
assert_equal "⠞⠓⠑",
|
|
280
|
+
table.translate(word, mode: %i[no_contractions suppress_undefined]).to_s
|
|
281
|
+
|
|
282
|
+
at_cursor = table.translate(word, mode: :computer_braille_at_cursor,
|
|
283
|
+
cursor_position: 1)
|
|
284
|
+
before_cursor = table.translate(word, mode: :computer_braille_before_cursor,
|
|
285
|
+
cursor_position: 1)
|
|
286
|
+
assert_instance_of LibLouis::BrailleText, at_cursor
|
|
287
|
+
assert_instance_of LibLouis::BrailleText, before_cursor
|
|
288
|
+
|
|
289
|
+
braille = table.translate(word)
|
|
290
|
+
assert_instance_of String,
|
|
291
|
+
table.back_translate(braille, mode: :partial_translation)
|
|
292
|
+
end
|
|
293
|
+
|
|
294
|
+
def test_hyphenation_with_a_dictionary_table
|
|
295
|
+
table = LibLouis::BrailleTable.new(["en-gb-g1.utb", "hyph_en_US.dic"])
|
|
296
|
+
word = "friend"
|
|
297
|
+
hyphens = table.hyphenate(word)
|
|
298
|
+
|
|
299
|
+
assert_equal word.length, hyphens.length
|
|
300
|
+
assert_match(/\A[01]+\z/, hyphens)
|
|
301
|
+
assert_equal hyphens, table.hyphenate(word, translated: false)
|
|
302
|
+
assert_raises(ArgumentError) { table.hyphenate(word, mode: :suppress_undefined) }
|
|
303
|
+
assert_raises(TypeError) { table.hyphenate(word, translated: 1) }
|
|
304
|
+
end
|
|
305
|
+
|
|
306
|
+
def test_validates_translation_arguments
|
|
307
|
+
source = @polish_case[:source]
|
|
308
|
+
assert_raises(ArgumentError) do
|
|
309
|
+
@table.translate(source, typeform: [:plain_text])
|
|
310
|
+
end
|
|
311
|
+
assert_raises(RangeError) do
|
|
312
|
+
@table.translate(source, cursor_position: source.length + 1)
|
|
313
|
+
end
|
|
314
|
+
assert_raises(TypeError) do
|
|
315
|
+
@table.translate(source, typeform: Array.new(source.length, 0))
|
|
316
|
+
end
|
|
317
|
+
assert_raises(TypeError) do
|
|
318
|
+
typeform = Array.new(source.length, :plain_text)
|
|
319
|
+
typeform[0] = [:plain_text, 4]
|
|
320
|
+
@table.translate(source, typeform: typeform)
|
|
321
|
+
end
|
|
322
|
+
assert_raises(ArgumentError) do
|
|
323
|
+
@table.translate(source, typeform: Array.new(source.length, :unknown_emphasis))
|
|
324
|
+
end
|
|
325
|
+
assert_raises(TypeError) do
|
|
326
|
+
@table.translate(source, typeform: true)
|
|
327
|
+
end
|
|
328
|
+
end
|
|
329
|
+
|
|
330
|
+
def test_rejects_options_that_do_not_affect_the_returned_value
|
|
331
|
+
source = @polish_case[:source]
|
|
332
|
+
braille = @table.translate(source)
|
|
333
|
+
|
|
334
|
+
assert_raises(ArgumentError) do
|
|
335
|
+
@table.translate(source, spacing: "0" * source.length)
|
|
336
|
+
end
|
|
337
|
+
assert_raises(ArgumentError) do
|
|
338
|
+
@table.translate(source, input_hyphens: "0" * source.length)
|
|
339
|
+
end
|
|
340
|
+
assert_raises(ArgumentError) do
|
|
341
|
+
@table.back_translate(braille, cursor_position: 0)
|
|
342
|
+
end
|
|
343
|
+
assert_raises(ArgumentError) do
|
|
344
|
+
@table.characters_to_dots(source, mode: :suppress_undefined)
|
|
345
|
+
end
|
|
346
|
+
assert_raises(ArgumentError) do
|
|
347
|
+
LibLouis::BrailleTable.new(@polish_case[:table], unknown: true)
|
|
348
|
+
end
|
|
349
|
+
refute_respond_to @table, :translate_full
|
|
350
|
+
refute_respond_to @table, :back_translate_full
|
|
351
|
+
end
|
|
352
|
+
|
|
353
|
+
def test_validates_modes_by_translation_direction
|
|
354
|
+
source = @polish_case[:source]
|
|
355
|
+
braille = @table.translate(source)
|
|
356
|
+
|
|
357
|
+
assert_raises(ArgumentError) do
|
|
358
|
+
@table.translate(source, mode: :partial_translation)
|
|
359
|
+
end
|
|
360
|
+
assert_raises(ArgumentError) do
|
|
361
|
+
@table.back_translate(braille, mode: :no_contractions)
|
|
362
|
+
end
|
|
363
|
+
assert_raises(ArgumentError) do
|
|
364
|
+
@table.translate(source, mode: :computer_braille_at_cursor)
|
|
365
|
+
end
|
|
366
|
+
assert_raises(TypeError) { @table.translate(source, mode: 0) }
|
|
367
|
+
assert_raises(TypeError) { @table.translate(source, mode: [:suppress_undefined, 1]) }
|
|
368
|
+
assert_raises(ArgumentError) { @table.translate(source, mode: :unknown_mode) }
|
|
369
|
+
end
|
|
370
|
+
|
|
371
|
+
private
|
|
372
|
+
|
|
373
|
+
def with_cleared_native_cache
|
|
374
|
+
LibLouis.free
|
|
375
|
+
yield
|
|
376
|
+
ensure
|
|
377
|
+
LibLouis.free
|
|
378
|
+
end
|
|
379
|
+
end
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative "test_helper"
|
|
4
|
+
|
|
5
|
+
class BrailleTextTest < Minitest::Test
|
|
6
|
+
def test_is_an_immutable_native_collection
|
|
7
|
+
text = LibLouis::BrailleText.new([1, [1, 2], 255])
|
|
8
|
+
|
|
9
|
+
assert_equal "⠁⠃⣿", text.unicode_text
|
|
10
|
+
assert_equal [1, 3, 255], text.map(&:mask)
|
|
11
|
+
assert_equal 3, text.length
|
|
12
|
+
assert_equal 3, text[1].mask
|
|
13
|
+
assert text.frozen?
|
|
14
|
+
assert text.characters.frozen?
|
|
15
|
+
assert_nil text.input_positions
|
|
16
|
+
assert_nil text.output_positions
|
|
17
|
+
assert_nil text.cursor_position
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def test_builds_from_unicode_braille
|
|
21
|
+
text = LibLouis::BrailleText.new("⠀⠁⣿")
|
|
22
|
+
|
|
23
|
+
assert_equal [0, 1, 255], text.characters.map(&:mask)
|
|
24
|
+
assert_equal "⠀⠁⣿", text.to_s
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def test_rejects_non_braille_text
|
|
28
|
+
assert_raises(ArgumentError) { LibLouis::BrailleText.new("abc") }
|
|
29
|
+
end
|
|
30
|
+
end
|
data/test/test_helper.rb
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module TranslationCases
|
|
4
|
+
CASES = [
|
|
5
|
+
{
|
|
6
|
+
table: "en-gb-g1.utb",
|
|
7
|
+
source: "Speak, friend, and enter",
|
|
8
|
+
braille: "⠠⠎⠏⠑⠁⠅⠂⠀⠋⠗⠊⠑⠝⠙⠂⠀⠁⠝⠙⠀⠑⠝⠞⠑⠗"
|
|
9
|
+
},
|
|
10
|
+
{
|
|
11
|
+
table: "en-gb-comp8.ctb",
|
|
12
|
+
source: "Shall I compare thee to a summer's day?",
|
|
13
|
+
braille: "⡎⠓⠁⠇⠇⠀⡊⠀⠉⠕⠍⠏⠁⠗⠑⠀⠞⠓⠑⠑⠀⠞⠕⠀⠁⠀⠎⠥⠍⠍⠑⠗⠄⠎⠀⠙⠁⠽⠢",
|
|
14
|
+
back_translation: "Shall I compare thee to a summer's day?"
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
table: "en-GB-g2.ctb",
|
|
18
|
+
source: "To be, or not to be, that is the question.",
|
|
19
|
+
braille: "⠠⠖⠃⠑⠂⠀⠕⠗⠀⠝⠀⠖⠃⠑⠂⠀⠞⠀⠊⠎⠀⠮⠀⠐⠟⠲"
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
table: "Pl-Pl-g1.utb",
|
|
23
|
+
source: "Zażółć gęślą jaźń.",
|
|
24
|
+
braille: "⠨⠵⠁⠯⠬⠣⠩⠀⠛⠱⠪⠇⠡⠀⠚⠁⠮⠹⠄",
|
|
25
|
+
back_translation: "Zażółć gęślą jaźń."
|
|
26
|
+
}
|
|
27
|
+
].map(&:freeze).freeze
|
|
28
|
+
|
|
29
|
+
def self.fetch(table)
|
|
30
|
+
CASES.fetch(CASES.index { |test_case| test_case[:table] == table })
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
|