flagnetic 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.
@@ -0,0 +1,180 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Generated by script/_unicode_tables from Go's unicode package (Unicode 15.0.0).
4
+ # Do not edit.
5
+
6
+ module Flagnetic
7
+ module Eval
8
+ # UnicodeTables holds what the reference evaluator's regular expressions
9
+ # take from Go's unicode package, so this evaluator folds case and accepts
10
+ # \p names the same way whatever Unicode version the running Ruby ships.
11
+ module UnicodeTables
12
+ # ORBITS are the simple case folding orbits (?i) folds with.
13
+ ORBITS = <<~ORBITS.split(",").map { |o| o.split.map(&:hex).freeze }.freeze
14
+ 41 61,42 62,43 63,44 64,45 65,46 66,47 67,48 68,49 69,4a 6a,4b 6b 212a,4c 6c,4d 6d,4e 6e,4f 6f,
15
+ 50 70,51 71,52 72,53 73 17f,54 74,55 75,56 76,57 77,58 78,59 79,5a 7a,b5 39c 3bc,c0 e0,c1 e1,c2 e2,
16
+ c3 e3,c4 e4,c5 e5 212b,c6 e6,c7 e7,c8 e8,c9 e9,ca ea,cb eb,cc ec,cd ed,ce ee,cf ef,d0 f0,d1 f1,
17
+ d2 f2,d3 f3,d4 f4,d5 f5,d6 f6,d8 f8,d9 f9,da fa,db fb,dc fc,dd fd,de fe,df 1e9e,ff 178,100 101,
18
+ 102 103,104 105,106 107,108 109,10a 10b,10c 10d,10e 10f,110 111,112 113,114 115,116 117,118 119,
19
+ 11a 11b,11c 11d,11e 11f,120 121,122 123,124 125,126 127,128 129,12a 12b,12c 12d,12e 12f,132 133,
20
+ 134 135,136 137,139 13a,13b 13c,13d 13e,13f 140,141 142,143 144,145 146,147 148,14a 14b,14c 14d,
21
+ 14e 14f,150 151,152 153,154 155,156 157,158 159,15a 15b,15c 15d,15e 15f,160 161,162 163,164 165,
22
+ 166 167,168 169,16a 16b,16c 16d,16e 16f,170 171,172 173,174 175,176 177,179 17a,17b 17c,17d 17e,
23
+ 180 243,181 253,182 183,184 185,186 254,187 188,189 256,18a 257,18b 18c,18e 1dd,18f 259,190 25b,
24
+ 191 192,193 260,194 263,195 1f6,196 269,197 268,198 199,19a 23d,19c 26f,19d 272,19e 220,19f 275,
25
+ 1a0 1a1,1a2 1a3,1a4 1a5,1a6 280,1a7 1a8,1a9 283,1ac 1ad,1ae 288,1af 1b0,1b1 28a,1b2 28b,1b3 1b4,
26
+ 1b5 1b6,1b7 292,1b8 1b9,1bc 1bd,1bf 1f7,1c4 1c5 1c6,1c7 1c8 1c9,1ca 1cb 1cc,1cd 1ce,1cf 1d0,1d1 1d2,
27
+ 1d3 1d4,1d5 1d6,1d7 1d8,1d9 1da,1db 1dc,1de 1df,1e0 1e1,1e2 1e3,1e4 1e5,1e6 1e7,1e8 1e9,1ea 1eb,
28
+ 1ec 1ed,1ee 1ef,1f1 1f2 1f3,1f4 1f5,1f8 1f9,1fa 1fb,1fc 1fd,1fe 1ff,200 201,202 203,204 205,206 207,
29
+ 208 209,20a 20b,20c 20d,20e 20f,210 211,212 213,214 215,216 217,218 219,21a 21b,21c 21d,21e 21f,
30
+ 222 223,224 225,226 227,228 229,22a 22b,22c 22d,22e 22f,230 231,232 233,23a 2c65,23b 23c,23e 2c66,
31
+ 23f 2c7e,240 2c7f,241 242,244 289,245 28c,246 247,248 249,24a 24b,24c 24d,24e 24f,250 2c6f,251 2c6d,
32
+ 252 2c70,25c a7ab,261 a7ac,265 a78d,266 a7aa,26a a7ae,26b 2c62,26c a7ad,271 2c6e,27d 2c64,282 a7c5,
33
+ 287 a7b1,29d a7b2,29e a7b0,345 399 3b9 1fbe,370 371,372 373,376 377,37b 3fd,37c 3fe,37d 3ff,37f 3f3,
34
+ 386 3ac,388 3ad,389 3ae,38a 3af,38c 3cc,38e 3cd,38f 3ce,391 3b1,392 3b2 3d0,393 3b3,394 3b4,
35
+ 395 3b5 3f5,396 3b6,397 3b7,398 3b8 3d1 3f4,39a 3ba 3f0,39b 3bb,39d 3bd,39e 3be,39f 3bf,3a0 3c0 3d6,
36
+ 3a1 3c1 3f1,3a3 3c2 3c3,3a4 3c4,3a5 3c5,3a6 3c6 3d5,3a7 3c7,3a8 3c8,3a9 3c9 2126,3aa 3ca,3ab 3cb,
37
+ 3cf 3d7,3d8 3d9,3da 3db,3dc 3dd,3de 3df,3e0 3e1,3e2 3e3,3e4 3e5,3e6 3e7,3e8 3e9,3ea 3eb,3ec 3ed,
38
+ 3ee 3ef,3f2 3f9,3f7 3f8,3fa 3fb,400 450,401 451,402 452,403 453,404 454,405 455,406 456,407 457,
39
+ 408 458,409 459,40a 45a,40b 45b,40c 45c,40d 45d,40e 45e,40f 45f,410 430,411 431,412 432 1c80,
40
+ 413 433,414 434 1c81,415 435,416 436,417 437,418 438,419 439,41a 43a,41b 43b,41c 43c,41d 43d,
41
+ 41e 43e 1c82,41f 43f,420 440,421 441 1c83,422 442 1c84 1c85,423 443,424 444,425 445,426 446,427 447,
42
+ 428 448,429 449,42a 44a 1c86,42b 44b,42c 44c,42d 44d,42e 44e,42f 44f,460 461,462 463 1c87,464 465,
43
+ 466 467,468 469,46a 46b,46c 46d,46e 46f,470 471,472 473,474 475,476 477,478 479,47a 47b,47c 47d,
44
+ 47e 47f,480 481,48a 48b,48c 48d,48e 48f,490 491,492 493,494 495,496 497,498 499,49a 49b,49c 49d,
45
+ 49e 49f,4a0 4a1,4a2 4a3,4a4 4a5,4a6 4a7,4a8 4a9,4aa 4ab,4ac 4ad,4ae 4af,4b0 4b1,4b2 4b3,4b4 4b5,
46
+ 4b6 4b7,4b8 4b9,4ba 4bb,4bc 4bd,4be 4bf,4c0 4cf,4c1 4c2,4c3 4c4,4c5 4c6,4c7 4c8,4c9 4ca,4cb 4cc,
47
+ 4cd 4ce,4d0 4d1,4d2 4d3,4d4 4d5,4d6 4d7,4d8 4d9,4da 4db,4dc 4dd,4de 4df,4e0 4e1,4e2 4e3,4e4 4e5,
48
+ 4e6 4e7,4e8 4e9,4ea 4eb,4ec 4ed,4ee 4ef,4f0 4f1,4f2 4f3,4f4 4f5,4f6 4f7,4f8 4f9,4fa 4fb,4fc 4fd,
49
+ 4fe 4ff,500 501,502 503,504 505,506 507,508 509,50a 50b,50c 50d,50e 50f,510 511,512 513,514 515,
50
+ 516 517,518 519,51a 51b,51c 51d,51e 51f,520 521,522 523,524 525,526 527,528 529,52a 52b,52c 52d,
51
+ 52e 52f,531 561,532 562,533 563,534 564,535 565,536 566,537 567,538 568,539 569,53a 56a,53b 56b,
52
+ 53c 56c,53d 56d,53e 56e,53f 56f,540 570,541 571,542 572,543 573,544 574,545 575,546 576,547 577,
53
+ 548 578,549 579,54a 57a,54b 57b,54c 57c,54d 57d,54e 57e,54f 57f,550 580,551 581,552 582,553 583,
54
+ 554 584,555 585,556 586,10a0 2d00,10a1 2d01,10a2 2d02,10a3 2d03,10a4 2d04,10a5 2d05,10a6 2d06,
55
+ 10a7 2d07,10a8 2d08,10a9 2d09,10aa 2d0a,10ab 2d0b,10ac 2d0c,10ad 2d0d,10ae 2d0e,10af 2d0f,10b0 2d10,
56
+ 10b1 2d11,10b2 2d12,10b3 2d13,10b4 2d14,10b5 2d15,10b6 2d16,10b7 2d17,10b8 2d18,10b9 2d19,10ba 2d1a,
57
+ 10bb 2d1b,10bc 2d1c,10bd 2d1d,10be 2d1e,10bf 2d1f,10c0 2d20,10c1 2d21,10c2 2d22,10c3 2d23,10c4 2d24,
58
+ 10c5 2d25,10c7 2d27,10cd 2d2d,10d0 1c90,10d1 1c91,10d2 1c92,10d3 1c93,10d4 1c94,10d5 1c95,10d6 1c96,
59
+ 10d7 1c97,10d8 1c98,10d9 1c99,10da 1c9a,10db 1c9b,10dc 1c9c,10dd 1c9d,10de 1c9e,10df 1c9f,10e0 1ca0,
60
+ 10e1 1ca1,10e2 1ca2,10e3 1ca3,10e4 1ca4,10e5 1ca5,10e6 1ca6,10e7 1ca7,10e8 1ca8,10e9 1ca9,10ea 1caa,
61
+ 10eb 1cab,10ec 1cac,10ed 1cad,10ee 1cae,10ef 1caf,10f0 1cb0,10f1 1cb1,10f2 1cb2,10f3 1cb3,10f4 1cb4,
62
+ 10f5 1cb5,10f6 1cb6,10f7 1cb7,10f8 1cb8,10f9 1cb9,10fa 1cba,10fd 1cbd,10fe 1cbe,10ff 1cbf,13a0 ab70,
63
+ 13a1 ab71,13a2 ab72,13a3 ab73,13a4 ab74,13a5 ab75,13a6 ab76,13a7 ab77,13a8 ab78,13a9 ab79,13aa ab7a,
64
+ 13ab ab7b,13ac ab7c,13ad ab7d,13ae ab7e,13af ab7f,13b0 ab80,13b1 ab81,13b2 ab82,13b3 ab83,13b4 ab84,
65
+ 13b5 ab85,13b6 ab86,13b7 ab87,13b8 ab88,13b9 ab89,13ba ab8a,13bb ab8b,13bc ab8c,13bd ab8d,13be ab8e,
66
+ 13bf ab8f,13c0 ab90,13c1 ab91,13c2 ab92,13c3 ab93,13c4 ab94,13c5 ab95,13c6 ab96,13c7 ab97,13c8 ab98,
67
+ 13c9 ab99,13ca ab9a,13cb ab9b,13cc ab9c,13cd ab9d,13ce ab9e,13cf ab9f,13d0 aba0,13d1 aba1,13d2 aba2,
68
+ 13d3 aba3,13d4 aba4,13d5 aba5,13d6 aba6,13d7 aba7,13d8 aba8,13d9 aba9,13da abaa,13db abab,13dc abac,
69
+ 13dd abad,13de abae,13df abaf,13e0 abb0,13e1 abb1,13e2 abb2,13e3 abb3,13e4 abb4,13e5 abb5,13e6 abb6,
70
+ 13e7 abb7,13e8 abb8,13e9 abb9,13ea abba,13eb abbb,13ec abbc,13ed abbd,13ee abbe,13ef abbf,13f0 13f8,
71
+ 13f1 13f9,13f2 13fa,13f3 13fb,13f4 13fc,13f5 13fd,1c88 a64a a64b,1d79 a77d,1d7d 2c63,1d8e a7c6,
72
+ 1e00 1e01,1e02 1e03,1e04 1e05,1e06 1e07,1e08 1e09,1e0a 1e0b,1e0c 1e0d,1e0e 1e0f,1e10 1e11,1e12 1e13,
73
+ 1e14 1e15,1e16 1e17,1e18 1e19,1e1a 1e1b,1e1c 1e1d,1e1e 1e1f,1e20 1e21,1e22 1e23,1e24 1e25,1e26 1e27,
74
+ 1e28 1e29,1e2a 1e2b,1e2c 1e2d,1e2e 1e2f,1e30 1e31,1e32 1e33,1e34 1e35,1e36 1e37,1e38 1e39,1e3a 1e3b,
75
+ 1e3c 1e3d,1e3e 1e3f,1e40 1e41,1e42 1e43,1e44 1e45,1e46 1e47,1e48 1e49,1e4a 1e4b,1e4c 1e4d,1e4e 1e4f,
76
+ 1e50 1e51,1e52 1e53,1e54 1e55,1e56 1e57,1e58 1e59,1e5a 1e5b,1e5c 1e5d,1e5e 1e5f,1e60 1e61 1e9b,
77
+ 1e62 1e63,1e64 1e65,1e66 1e67,1e68 1e69,1e6a 1e6b,1e6c 1e6d,1e6e 1e6f,1e70 1e71,1e72 1e73,1e74 1e75,
78
+ 1e76 1e77,1e78 1e79,1e7a 1e7b,1e7c 1e7d,1e7e 1e7f,1e80 1e81,1e82 1e83,1e84 1e85,1e86 1e87,1e88 1e89,
79
+ 1e8a 1e8b,1e8c 1e8d,1e8e 1e8f,1e90 1e91,1e92 1e93,1e94 1e95,1ea0 1ea1,1ea2 1ea3,1ea4 1ea5,1ea6 1ea7,
80
+ 1ea8 1ea9,1eaa 1eab,1eac 1ead,1eae 1eaf,1eb0 1eb1,1eb2 1eb3,1eb4 1eb5,1eb6 1eb7,1eb8 1eb9,1eba 1ebb,
81
+ 1ebc 1ebd,1ebe 1ebf,1ec0 1ec1,1ec2 1ec3,1ec4 1ec5,1ec6 1ec7,1ec8 1ec9,1eca 1ecb,1ecc 1ecd,1ece 1ecf,
82
+ 1ed0 1ed1,1ed2 1ed3,1ed4 1ed5,1ed6 1ed7,1ed8 1ed9,1eda 1edb,1edc 1edd,1ede 1edf,1ee0 1ee1,1ee2 1ee3,
83
+ 1ee4 1ee5,1ee6 1ee7,1ee8 1ee9,1eea 1eeb,1eec 1eed,1eee 1eef,1ef0 1ef1,1ef2 1ef3,1ef4 1ef5,1ef6 1ef7,
84
+ 1ef8 1ef9,1efa 1efb,1efc 1efd,1efe 1eff,1f00 1f08,1f01 1f09,1f02 1f0a,1f03 1f0b,1f04 1f0c,1f05 1f0d,
85
+ 1f06 1f0e,1f07 1f0f,1f10 1f18,1f11 1f19,1f12 1f1a,1f13 1f1b,1f14 1f1c,1f15 1f1d,1f20 1f28,1f21 1f29,
86
+ 1f22 1f2a,1f23 1f2b,1f24 1f2c,1f25 1f2d,1f26 1f2e,1f27 1f2f,1f30 1f38,1f31 1f39,1f32 1f3a,1f33 1f3b,
87
+ 1f34 1f3c,1f35 1f3d,1f36 1f3e,1f37 1f3f,1f40 1f48,1f41 1f49,1f42 1f4a,1f43 1f4b,1f44 1f4c,1f45 1f4d,
88
+ 1f51 1f59,1f53 1f5b,1f55 1f5d,1f57 1f5f,1f60 1f68,1f61 1f69,1f62 1f6a,1f63 1f6b,1f64 1f6c,1f65 1f6d,
89
+ 1f66 1f6e,1f67 1f6f,1f70 1fba,1f71 1fbb,1f72 1fc8,1f73 1fc9,1f74 1fca,1f75 1fcb,1f76 1fda,1f77 1fdb,
90
+ 1f78 1ff8,1f79 1ff9,1f7a 1fea,1f7b 1feb,1f7c 1ffa,1f7d 1ffb,1f80 1f88,1f81 1f89,1f82 1f8a,1f83 1f8b,
91
+ 1f84 1f8c,1f85 1f8d,1f86 1f8e,1f87 1f8f,1f90 1f98,1f91 1f99,1f92 1f9a,1f93 1f9b,1f94 1f9c,1f95 1f9d,
92
+ 1f96 1f9e,1f97 1f9f,1fa0 1fa8,1fa1 1fa9,1fa2 1faa,1fa3 1fab,1fa4 1fac,1fa5 1fad,1fa6 1fae,1fa7 1faf,
93
+ 1fb0 1fb8,1fb1 1fb9,1fb3 1fbc,1fc3 1fcc,1fd0 1fd8,1fd1 1fd9,1fe0 1fe8,1fe1 1fe9,1fe5 1fec,1ff3 1ffc,
94
+ 2132 214e,2160 2170,2161 2171,2162 2172,2163 2173,2164 2174,2165 2175,2166 2176,2167 2177,2168 2178,
95
+ 2169 2179,216a 217a,216b 217b,216c 217c,216d 217d,216e 217e,216f 217f,2183 2184,24b6 24d0,24b7 24d1,
96
+ 24b8 24d2,24b9 24d3,24ba 24d4,24bb 24d5,24bc 24d6,24bd 24d7,24be 24d8,24bf 24d9,24c0 24da,24c1 24db,
97
+ 24c2 24dc,24c3 24dd,24c4 24de,24c5 24df,24c6 24e0,24c7 24e1,24c8 24e2,24c9 24e3,24ca 24e4,24cb 24e5,
98
+ 24cc 24e6,24cd 24e7,24ce 24e8,24cf 24e9,2c00 2c30,2c01 2c31,2c02 2c32,2c03 2c33,2c04 2c34,2c05 2c35,
99
+ 2c06 2c36,2c07 2c37,2c08 2c38,2c09 2c39,2c0a 2c3a,2c0b 2c3b,2c0c 2c3c,2c0d 2c3d,2c0e 2c3e,2c0f 2c3f,
100
+ 2c10 2c40,2c11 2c41,2c12 2c42,2c13 2c43,2c14 2c44,2c15 2c45,2c16 2c46,2c17 2c47,2c18 2c48,2c19 2c49,
101
+ 2c1a 2c4a,2c1b 2c4b,2c1c 2c4c,2c1d 2c4d,2c1e 2c4e,2c1f 2c4f,2c20 2c50,2c21 2c51,2c22 2c52,2c23 2c53,
102
+ 2c24 2c54,2c25 2c55,2c26 2c56,2c27 2c57,2c28 2c58,2c29 2c59,2c2a 2c5a,2c2b 2c5b,2c2c 2c5c,2c2d 2c5d,
103
+ 2c2e 2c5e,2c2f 2c5f,2c60 2c61,2c67 2c68,2c69 2c6a,2c6b 2c6c,2c72 2c73,2c75 2c76,2c80 2c81,2c82 2c83,
104
+ 2c84 2c85,2c86 2c87,2c88 2c89,2c8a 2c8b,2c8c 2c8d,2c8e 2c8f,2c90 2c91,2c92 2c93,2c94 2c95,2c96 2c97,
105
+ 2c98 2c99,2c9a 2c9b,2c9c 2c9d,2c9e 2c9f,2ca0 2ca1,2ca2 2ca3,2ca4 2ca5,2ca6 2ca7,2ca8 2ca9,2caa 2cab,
106
+ 2cac 2cad,2cae 2caf,2cb0 2cb1,2cb2 2cb3,2cb4 2cb5,2cb6 2cb7,2cb8 2cb9,2cba 2cbb,2cbc 2cbd,2cbe 2cbf,
107
+ 2cc0 2cc1,2cc2 2cc3,2cc4 2cc5,2cc6 2cc7,2cc8 2cc9,2cca 2ccb,2ccc 2ccd,2cce 2ccf,2cd0 2cd1,2cd2 2cd3,
108
+ 2cd4 2cd5,2cd6 2cd7,2cd8 2cd9,2cda 2cdb,2cdc 2cdd,2cde 2cdf,2ce0 2ce1,2ce2 2ce3,2ceb 2cec,2ced 2cee,
109
+ 2cf2 2cf3,a640 a641,a642 a643,a644 a645,a646 a647,a648 a649,a64c a64d,a64e a64f,a650 a651,a652 a653,
110
+ a654 a655,a656 a657,a658 a659,a65a a65b,a65c a65d,a65e a65f,a660 a661,a662 a663,a664 a665,a666 a667,
111
+ a668 a669,a66a a66b,a66c a66d,a680 a681,a682 a683,a684 a685,a686 a687,a688 a689,a68a a68b,a68c a68d,
112
+ a68e a68f,a690 a691,a692 a693,a694 a695,a696 a697,a698 a699,a69a a69b,a722 a723,a724 a725,a726 a727,
113
+ a728 a729,a72a a72b,a72c a72d,a72e a72f,a732 a733,a734 a735,a736 a737,a738 a739,a73a a73b,a73c a73d,
114
+ a73e a73f,a740 a741,a742 a743,a744 a745,a746 a747,a748 a749,a74a a74b,a74c a74d,a74e a74f,a750 a751,
115
+ a752 a753,a754 a755,a756 a757,a758 a759,a75a a75b,a75c a75d,a75e a75f,a760 a761,a762 a763,a764 a765,
116
+ a766 a767,a768 a769,a76a a76b,a76c a76d,a76e a76f,a779 a77a,a77b a77c,a77e a77f,a780 a781,a782 a783,
117
+ a784 a785,a786 a787,a78b a78c,a790 a791,a792 a793,a794 a7c4,a796 a797,a798 a799,a79a a79b,a79c a79d,
118
+ a79e a79f,a7a0 a7a1,a7a2 a7a3,a7a4 a7a5,a7a6 a7a7,a7a8 a7a9,a7b3 ab53,a7b4 a7b5,a7b6 a7b7,a7b8 a7b9,
119
+ a7ba a7bb,a7bc a7bd,a7be a7bf,a7c0 a7c1,a7c2 a7c3,a7c7 a7c8,a7c9 a7ca,a7d0 a7d1,a7d6 a7d7,a7d8 a7d9,
120
+ a7f5 a7f6,ff21 ff41,ff22 ff42,ff23 ff43,ff24 ff44,ff25 ff45,ff26 ff46,ff27 ff47,ff28 ff48,ff29 ff49,
121
+ ff2a ff4a,ff2b ff4b,ff2c ff4c,ff2d ff4d,ff2e ff4e,ff2f ff4f,ff30 ff50,ff31 ff51,ff32 ff52,ff33 ff53,
122
+ ff34 ff54,ff35 ff55,ff36 ff56,ff37 ff57,ff38 ff58,ff39 ff59,ff3a ff5a,10400 10428,10401 10429,
123
+ 10402 1042a,10403 1042b,10404 1042c,10405 1042d,10406 1042e,10407 1042f,10408 10430,10409 10431,
124
+ 1040a 10432,1040b 10433,1040c 10434,1040d 10435,1040e 10436,1040f 10437,10410 10438,10411 10439,
125
+ 10412 1043a,10413 1043b,10414 1043c,10415 1043d,10416 1043e,10417 1043f,10418 10440,10419 10441,
126
+ 1041a 10442,1041b 10443,1041c 10444,1041d 10445,1041e 10446,1041f 10447,10420 10448,10421 10449,
127
+ 10422 1044a,10423 1044b,10424 1044c,10425 1044d,10426 1044e,10427 1044f,104b0 104d8,104b1 104d9,
128
+ 104b2 104da,104b3 104db,104b4 104dc,104b5 104dd,104b6 104de,104b7 104df,104b8 104e0,104b9 104e1,
129
+ 104ba 104e2,104bb 104e3,104bc 104e4,104bd 104e5,104be 104e6,104bf 104e7,104c0 104e8,104c1 104e9,
130
+ 104c2 104ea,104c3 104eb,104c4 104ec,104c5 104ed,104c6 104ee,104c7 104ef,104c8 104f0,104c9 104f1,
131
+ 104ca 104f2,104cb 104f3,104cc 104f4,104cd 104f5,104ce 104f6,104cf 104f7,104d0 104f8,104d1 104f9,
132
+ 104d2 104fa,104d3 104fb,10570 10597,10571 10598,10572 10599,10573 1059a,10574 1059b,10575 1059c,
133
+ 10576 1059d,10577 1059e,10578 1059f,10579 105a0,1057a 105a1,1057c 105a3,1057d 105a4,1057e 105a5,
134
+ 1057f 105a6,10580 105a7,10581 105a8,10582 105a9,10583 105aa,10584 105ab,10585 105ac,10586 105ad,
135
+ 10587 105ae,10588 105af,10589 105b0,1058a 105b1,1058c 105b3,1058d 105b4,1058e 105b5,1058f 105b6,
136
+ 10590 105b7,10591 105b8,10592 105b9,10594 105bb,10595 105bc,10c80 10cc0,10c81 10cc1,10c82 10cc2,
137
+ 10c83 10cc3,10c84 10cc4,10c85 10cc5,10c86 10cc6,10c87 10cc7,10c88 10cc8,10c89 10cc9,10c8a 10cca,
138
+ 10c8b 10ccb,10c8c 10ccc,10c8d 10ccd,10c8e 10cce,10c8f 10ccf,10c90 10cd0,10c91 10cd1,10c92 10cd2,
139
+ 10c93 10cd3,10c94 10cd4,10c95 10cd5,10c96 10cd6,10c97 10cd7,10c98 10cd8,10c99 10cd9,10c9a 10cda,
140
+ 10c9b 10cdb,10c9c 10cdc,10c9d 10cdd,10c9e 10cde,10c9f 10cdf,10ca0 10ce0,10ca1 10ce1,10ca2 10ce2,
141
+ 10ca3 10ce3,10ca4 10ce4,10ca5 10ce5,10ca6 10ce6,10ca7 10ce7,10ca8 10ce8,10ca9 10ce9,10caa 10cea,
142
+ 10cab 10ceb,10cac 10cec,10cad 10ced,10cae 10cee,10caf 10cef,10cb0 10cf0,10cb1 10cf1,10cb2 10cf2,
143
+ 118a0 118c0,118a1 118c1,118a2 118c2,118a3 118c3,118a4 118c4,118a5 118c5,118a6 118c6,118a7 118c7,
144
+ 118a8 118c8,118a9 118c9,118aa 118ca,118ab 118cb,118ac 118cc,118ad 118cd,118ae 118ce,118af 118cf,
145
+ 118b0 118d0,118b1 118d1,118b2 118d2,118b3 118d3,118b4 118d4,118b5 118d5,118b6 118d6,118b7 118d7,
146
+ 118b8 118d8,118b9 118d9,118ba 118da,118bb 118db,118bc 118dc,118bd 118dd,118be 118de,118bf 118df,
147
+ 16e40 16e60,16e41 16e61,16e42 16e62,16e43 16e63,16e44 16e64,16e45 16e65,16e46 16e66,16e47 16e67,
148
+ 16e48 16e68,16e49 16e69,16e4a 16e6a,16e4b 16e6b,16e4c 16e6c,16e4d 16e6d,16e4e 16e6e,16e4f 16e6f,
149
+ 16e50 16e70,16e51 16e71,16e52 16e72,16e53 16e73,16e54 16e74,16e55 16e75,16e56 16e76,16e57 16e77,
150
+ 16e58 16e78,16e59 16e79,16e5a 16e7a,16e5b 16e7b,16e5c 16e7c,16e5d 16e7d,16e5e 16e7e,16e5f 16e7f,
151
+ 1e900 1e922,1e901 1e923,1e902 1e924,1e903 1e925,1e904 1e926,1e905 1e927,1e906 1e928,1e907 1e929,
152
+ 1e908 1e92a,1e909 1e92b,1e90a 1e92c,1e90b 1e92d,1e90c 1e92e,1e90d 1e92f,1e90e 1e930,1e90f 1e931,
153
+ 1e910 1e932,1e911 1e933,1e912 1e934,1e913 1e935,1e914 1e936,1e915 1e937,1e916 1e938,1e917 1e939,
154
+ 1e918 1e93a,1e919 1e93b,1e91a 1e93c,1e91b 1e93d,1e91c 1e93e,1e91d 1e93f,1e91e 1e940,1e91f 1e941,
155
+ 1e920 1e942,1e921 1e943
156
+ ORBITS
157
+
158
+ # PROPERTY_NAMES are the category and script names \p accepts besides Any.
159
+ PROPERTY_NAMES = %w[
160
+ Adlam Ahom Anatolian_Hieroglyphs Arabic Armenian Avestan Balinese Bamum Bassa_Vah Batak Bengali
161
+ Bhaiksuki Bopomofo Brahmi Braille Buginese Buhid C Canadian_Aboriginal Carian Caucasian_Albanian Cc
162
+ Cf Chakma Cham Cherokee Chorasmian Cn Co Common Coptic Cs Cuneiform Cypriot Cypro_Minoan Cyrillic
163
+ Deseret Devanagari Dives_Akuru Dogra Duployan Egyptian_Hieroglyphs Elbasan Elymaic Ethiopic Georgian
164
+ Glagolitic Gothic Grantha Greek Gujarati Gunjala_Gondi Gurmukhi Han Hangul Hanifi_Rohingya Hanunoo
165
+ Hatran Hebrew Hiragana Imperial_Aramaic Inherited Inscriptional_Pahlavi Inscriptional_Parthian
166
+ Javanese Kaithi Kannada Katakana Kawi Kayah_Li Kharoshthi Khitan_Small_Script Khmer Khojki Khudawadi
167
+ L LC Lao Latin Lepcha Limbu Linear_A Linear_B Lisu Ll Lm Lo Lt Lu Lycian Lydian M Mahajani Makasar
168
+ Malayalam Mandaic Manichaean Marchen Masaram_Gondi Mc Me Medefaidrin Meetei_Mayek Mende_Kikakui
169
+ Meroitic_Cursive Meroitic_Hieroglyphs Miao Mn Modi Mongolian Mro Multani Myanmar N Nabataean
170
+ Nag_Mundari Nandinagari Nd New_Tai_Lue Newa Nko Nl No Nushu Nyiakeng_Puachue_Hmong Ogham Ol_Chiki
171
+ Old_Hungarian Old_Italic Old_North_Arabian Old_Permic Old_Persian Old_Sogdian Old_South_Arabian
172
+ Old_Turkic Old_Uyghur Oriya Osage Osmanya P Pahawh_Hmong Palmyrene Pau_Cin_Hau Pc Pd Pe Pf Phags_Pa
173
+ Phoenician Pi Po Ps Psalter_Pahlavi Rejang Runic S Samaritan Saurashtra Sc Sharada Shavian Siddham
174
+ SignWriting Sinhala Sk Sm So Sogdian Sora_Sompeng Soyombo Sundanese Syloti_Nagri Syriac Tagalog
175
+ Tagbanwa Tai_Le Tai_Tham Tai_Viet Takri Tamil Tangsa Tangut Telugu Thaana Thai Tibetan Tifinagh
176
+ Tirhuta Toto Ugaritic Vai Vithkuqi Wancho Warang_Citi Yezidi Yi Z Zanabazar_Square Zl Zp Zs
177
+ ].freeze
178
+ end
179
+ end
180
+ end
@@ -0,0 +1,38 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "eval/murmur3"
4
+ require_relative "eval/semver"
5
+ require_relative "eval/instant"
6
+ require_relative "eval/regex"
7
+ require_relative "eval/operators"
8
+ require_relative "eval/types"
9
+ require_relative "eval/ruleset"
10
+ require_relative "eval/evaluation"
11
+
12
+ module Flagnetic
13
+ # Eval is the Flagnetic evaluator: a pure function of a ruleset document
14
+ # and a context that computes a flag's value and evaluation reason.
15
+ #
16
+ # It mirrors the reference evaluator, the Go module in eval/, and passes
17
+ # the same language-agnostic conformance suite in conformance/fixtures.
18
+ # It has no dependencies outside the standard library, never reads a
19
+ # clock, never performs I/O and never records an exposure: exposure is an
20
+ # explicit SDK call, so being assigned a variation is never mistaken for
21
+ # having seen it.
22
+ #
23
+ # ruleset = Flagnetic::Eval::Ruleset.decode(document)
24
+ # result = ruleset.evaluate("new_matching", { units: { user: "u-1001" },
25
+ # attributes: { app_version: "1.42.0" } })
26
+ # result.reason # => :rule
27
+ #
28
+ # Operators: an absent attribute, nil, or a value of the wrong type makes
29
+ # every operator false except not_exists, which is then true. There is no
30
+ # coercion: "5" is not a number. An unparsable semver or date in a context
31
+ # is a value of the wrong type. In a condition value it makes the
32
+ # condition false, and so does one unparsable item of an in or not_in
33
+ # list. Strings compare byte-wise; numbers are IEEE 754
34
+ # doubles; regular expressions follow the policy in Regex. A unit type
35
+ # named as an attribute is a string attribute holding that unit's ID.
36
+ module Eval
37
+ end
38
+ end
@@ -0,0 +1,119 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "json"
4
+ require "time"
5
+ require "zlib"
6
+ require "stringio"
7
+
8
+ module Flagnetic
9
+ # EventBatch builds and sends the events endpoint's envelope for exposures,
10
+ # aliases and evaluation summaries alike: the gzip body, batching under
11
+ # the endpoint's limits, and what the platform's answer means for the
12
+ # caller. Shared by Exposures and Summaries; it holds no queue and no
13
+ # timers of its own.
14
+ module EventBatch
15
+ # Limits of POST /sdk/v1/events; they bound the decompressed
16
+ # envelope, so pack packs against them before the caller gzips.
17
+ MAX_EVENTS_PER_BATCH = 500
18
+ MAX_BATCH_BYTES = 1 << 20
19
+ MAX_RESULT_BYTES = 1 << 20
20
+
21
+ # Outcome is what the platform did with one batch, and what the caller
22
+ # does next: :accepted (202; done, rejected events included, a
23
+ # rejection is final), :retry (429, 5xx or a network error: the same
24
+ # events may be sent again), :unauthorized (401/403: retriable too, but
25
+ # at the unauthorized cap, since an operator restoring the key is what
26
+ # ends it) or :dropped (any other 4xx: sending it again would fail the
27
+ # same way).
28
+ Outcome = Struct.new(:kind, :status, :retry_after, :accepted, :duplicates, :dropped_rows, :rejected, :error,
29
+ keyword_init: true)
30
+
31
+ module_function
32
+
33
+ # pack splits events (an Array of Hash, JSON-ready) into batches the
34
+ # endpoint accepts: at most 500 events, and under 1 MiB decoded
35
+ # together with the envelope. An event too large on its own still
36
+ # becomes a batch of one, which the platform answers 413 and the
37
+ # caller drops.
38
+ def pack(events, identity)
39
+ budget = MAX_BATCH_BYTES - overhead(identity)
40
+ batches = []
41
+ current = []
42
+ size = 0
43
+ events.each do |e|
44
+ cost = JSON.generate(e).bytesize + 1 # one comma per event after the first
45
+ if current.any? && (current.size == MAX_EVENTS_PER_BATCH || size + cost > budget)
46
+ batches << current
47
+ current = []
48
+ size = 0
49
+ end
50
+ current << e
51
+ size += cost
52
+ end
53
+ batches << current if current.any?
54
+ batches
55
+ end
56
+
57
+ # send_batch posts one batch through transport, bounding the call by
58
+ # timeout seconds, and classifies the answer. It never raises.
59
+ def send_batch(transport, events, timeout)
60
+ classify(transport.post_events(encode(transport.identity, events), timeout))
61
+ rescue StandardError => e
62
+ Outcome.new(kind: :retry, error: "#{e.class}: #{e.message}")
63
+ end
64
+
65
+ def envelope(identity, events)
66
+ { "schema_version" => SCHEMA_VERSION_MAX, "sdk" => identity, "sent_at" => format_time(Time.now),
67
+ "events" => events }
68
+ end
69
+
70
+ def encode(identity, events)
71
+ doc = JSON.generate(envelope(identity, events))
72
+ io = StringIO.new
73
+ gz = Zlib::GzipWriter.new(io)
74
+ gz.write(doc)
75
+ gz.close
76
+ io.string
77
+ end
78
+
79
+ # overhead is how many bytes an empty envelope costs, so pack can stay
80
+ # under the endpoint's body limit; it is the decoded size, since the
81
+ # limit applies to the decompressed body.
82
+ def overhead(identity)
83
+ JSON.generate(envelope(identity, [])).bytesize
84
+ end
85
+
86
+ def format_time(time) = time.utc.iso8601(3)
87
+
88
+ def classify(response)
89
+ case response.status
90
+ when 202 then accepted(response)
91
+ when 429 then Outcome.new(kind: :retry, status: 429, retry_after: retry_after(response.retry_after))
92
+ when 401, 403 then Outcome.new(kind: :unauthorized, status: response.status)
93
+ when 500..599 then Outcome.new(kind: :retry, status: response.status)
94
+ else Outcome.new(kind: :dropped, status: response.status)
95
+ end
96
+ end
97
+
98
+ # accepted decodes the 202 answer. A body that does not decode leaves
99
+ # the counts unset: the batch was accepted either way, so nothing is
100
+ # retried.
101
+ def accepted(response)
102
+ json = JSON.parse(response.body.to_s.byteslice(0, MAX_RESULT_BYTES))
103
+ Outcome.new(kind: :accepted, status: 202, accepted: json["accepted"], duplicates: json["duplicates"],
104
+ dropped_rows: json["dropped_rows"], rejected: json["rejected"] || [])
105
+ rescue JSON::ParserError, TypeError
106
+ Outcome.new(kind: :accepted, status: 202, rejected: [])
107
+ end
108
+
109
+ # retry_after reads a Retry-After header in its delta-seconds form; an
110
+ # HTTP date or anything else means the caller backs off on its own.
111
+ def retry_after(header)
112
+ return nil unless header
113
+
114
+ seconds = Integer(header, exception: false)
115
+ seconds && !seconds.negative? ? seconds : nil
116
+ end
117
+ end
118
+ private_constant :EventBatch
119
+ end