urlpattern 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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 4087f8d670ecc5bb3901622507f4c30faa19cf3c45411eb16ac105bd17f88bdb
4
+ data.tar.gz: 38229915a8d7bcabbb6b29c42055f7c0cc3bcfe4ec1a6f855a550a2b0824af79
5
+ SHA512:
6
+ metadata.gz: e6343f07b3d32ddaf1e61b5d9c3a44df9f921afd698695eb411ed85a55884f301da904dbb8560561a6acc64fff1dea128cb7754bf27f8c4d81cf9e88315029c3
7
+ data.tar.gz: 41e2c84cf4929d2a05a729ad93af724d1b468993541bff10423b548a65808decef08fb0f94876fa99f4b369b7f6cb997652d2f5507b246943908c56fb52116a5
@@ -0,0 +1,10 @@
1
+ # Code of Conduct
2
+
3
+ "urlpattern" follows [The Ruby Community Conduct Guideline](https://www.ruby-lang.org/en/conduct) in all "collaborative space", which is defined as community communications channels (such as mailing lists, submitted patches, commit comments, etc.):
4
+
5
+ * Participants will be tolerant of opposing views.
6
+ * Participants must ensure that their language and actions are free of personal attacks and disparaging personal remarks.
7
+ * When interpreting the words and actions of others, participants should always assume good intentions.
8
+ * Behaviour which can be reasonably considered harassment will not be tolerated.
9
+
10
+ If you have any concerns about behaviour within this project, please contact us at ["bangseongbeom@gmail.com"](mailto:"bangseongbeom@gmail.com").
data/Cargo.lock ADDED
@@ -0,0 +1,628 @@
1
+ # This file is automatically @generated by Cargo.
2
+ # It is not intended for manual editing.
3
+ version = 4
4
+
5
+ [[package]]
6
+ name = "aho-corasick"
7
+ version = "1.1.4"
8
+ source = "registry+https://github.com/rust-lang/crates.io-index"
9
+ checksum = "ddd31a130427c27518df266943a5308ed92d4b226cc639f5a8f1002816174301"
10
+ dependencies = [
11
+ "memchr",
12
+ ]
13
+
14
+ [[package]]
15
+ name = "bindgen"
16
+ version = "0.72.1"
17
+ source = "registry+https://github.com/rust-lang/crates.io-index"
18
+ checksum = "993776b509cfb49c750f11b8f07a46fa23e0a1386ffc01fb1e7d343efc387895"
19
+ dependencies = [
20
+ "bitflags",
21
+ "cexpr",
22
+ "clang-sys",
23
+ "itertools",
24
+ "proc-macro2",
25
+ "quote",
26
+ "regex",
27
+ "rustc-hash",
28
+ "shlex",
29
+ "syn",
30
+ ]
31
+
32
+ [[package]]
33
+ name = "bitflags"
34
+ version = "2.11.0"
35
+ source = "registry+https://github.com/rust-lang/crates.io-index"
36
+ checksum = "843867be96c8daad0d758b57df9392b6d8d271134fce549de6ce169ff98a92af"
37
+
38
+ [[package]]
39
+ name = "cexpr"
40
+ version = "0.6.0"
41
+ source = "registry+https://github.com/rust-lang/crates.io-index"
42
+ checksum = "6fac387a98bb7c37292057cffc56d62ecb629900026402633ae9160df93a8766"
43
+ dependencies = [
44
+ "nom",
45
+ ]
46
+
47
+ [[package]]
48
+ name = "cfg-if"
49
+ version = "1.0.4"
50
+ source = "registry+https://github.com/rust-lang/crates.io-index"
51
+ checksum = "9330f8b2ff13f34540b44e946ef35111825727b38d33286ef986142615121801"
52
+
53
+ [[package]]
54
+ name = "clang-sys"
55
+ version = "1.8.1"
56
+ source = "registry+https://github.com/rust-lang/crates.io-index"
57
+ checksum = "0b023947811758c97c59bf9d1c188fd619ad4718dcaa767947df1cadb14f39f4"
58
+ dependencies = [
59
+ "glob",
60
+ "libc",
61
+ "libloading",
62
+ ]
63
+
64
+ [[package]]
65
+ name = "displaydoc"
66
+ version = "0.2.5"
67
+ source = "registry+https://github.com/rust-lang/crates.io-index"
68
+ checksum = "97369cbbc041bc366949bc74d34658d6cda5621039731c6310521892a3a20ae0"
69
+ dependencies = [
70
+ "proc-macro2",
71
+ "quote",
72
+ "syn",
73
+ ]
74
+
75
+ [[package]]
76
+ name = "either"
77
+ version = "1.15.0"
78
+ source = "registry+https://github.com/rust-lang/crates.io-index"
79
+ checksum = "48c757948c5ede0e46177b7add2e67155f70e33c07fea8284df6576da70b3719"
80
+
81
+ [[package]]
82
+ name = "form_urlencoded"
83
+ version = "1.2.2"
84
+ source = "registry+https://github.com/rust-lang/crates.io-index"
85
+ checksum = "cb4cb245038516f5f85277875cdaa4f7d2c9a0fa0468de06ed190163b1581fcf"
86
+ dependencies = [
87
+ "percent-encoding",
88
+ ]
89
+
90
+ [[package]]
91
+ name = "glob"
92
+ version = "0.3.3"
93
+ source = "registry+https://github.com/rust-lang/crates.io-index"
94
+ checksum = "0cc23270f6e1808e30a928bdc84dea0b9b4136a8bc82338574f23baf47bbd280"
95
+
96
+ [[package]]
97
+ name = "icu_collections"
98
+ version = "2.2.0"
99
+ source = "registry+https://github.com/rust-lang/crates.io-index"
100
+ checksum = "2984d1cd16c883d7935b9e07e44071dca8d917fd52ecc02c04d5fa0b5a3f191c"
101
+ dependencies = [
102
+ "displaydoc",
103
+ "potential_utf",
104
+ "utf8_iter",
105
+ "yoke",
106
+ "zerofrom",
107
+ "zerovec",
108
+ ]
109
+
110
+ [[package]]
111
+ name = "icu_locale_core"
112
+ version = "2.2.0"
113
+ source = "registry+https://github.com/rust-lang/crates.io-index"
114
+ checksum = "92219b62b3e2b4d88ac5119f8904c10f8f61bf7e95b640d25ba3075e6cac2c29"
115
+ dependencies = [
116
+ "displaydoc",
117
+ "litemap",
118
+ "tinystr",
119
+ "writeable",
120
+ "zerovec",
121
+ ]
122
+
123
+ [[package]]
124
+ name = "icu_normalizer"
125
+ version = "2.2.0"
126
+ source = "registry+https://github.com/rust-lang/crates.io-index"
127
+ checksum = "c56e5ee99d6e3d33bd91c5d85458b6005a22140021cc324cea84dd0e72cff3b4"
128
+ dependencies = [
129
+ "icu_collections",
130
+ "icu_normalizer_data",
131
+ "icu_properties",
132
+ "icu_provider",
133
+ "smallvec",
134
+ "zerovec",
135
+ ]
136
+
137
+ [[package]]
138
+ name = "icu_normalizer_data"
139
+ version = "2.2.0"
140
+ source = "registry+https://github.com/rust-lang/crates.io-index"
141
+ checksum = "da3be0ae77ea334f4da67c12f149704f19f81d1adf7c51cf482943e84a2bad38"
142
+
143
+ [[package]]
144
+ name = "icu_properties"
145
+ version = "2.2.0"
146
+ source = "registry+https://github.com/rust-lang/crates.io-index"
147
+ checksum = "bee3b67d0ea5c2cca5003417989af8996f8604e34fb9ddf96208a033901e70de"
148
+ dependencies = [
149
+ "icu_collections",
150
+ "icu_locale_core",
151
+ "icu_properties_data",
152
+ "icu_provider",
153
+ "zerotrie",
154
+ "zerovec",
155
+ ]
156
+
157
+ [[package]]
158
+ name = "icu_properties_data"
159
+ version = "2.2.0"
160
+ source = "registry+https://github.com/rust-lang/crates.io-index"
161
+ checksum = "8e2bbb201e0c04f7b4b3e14382af113e17ba4f63e2c9d2ee626b720cbce54a14"
162
+
163
+ [[package]]
164
+ name = "icu_provider"
165
+ version = "2.2.0"
166
+ source = "registry+https://github.com/rust-lang/crates.io-index"
167
+ checksum = "139c4cf31c8b5f33d7e199446eff9c1e02decfc2f0eec2c8d71f65befa45b421"
168
+ dependencies = [
169
+ "displaydoc",
170
+ "icu_locale_core",
171
+ "writeable",
172
+ "yoke",
173
+ "zerofrom",
174
+ "zerotrie",
175
+ "zerovec",
176
+ ]
177
+
178
+ [[package]]
179
+ name = "idna"
180
+ version = "1.1.0"
181
+ source = "registry+https://github.com/rust-lang/crates.io-index"
182
+ checksum = "3b0875f23caa03898994f6ddc501886a45c7d3d62d04d2d90788d47be1b1e4de"
183
+ dependencies = [
184
+ "idna_adapter",
185
+ "smallvec",
186
+ "utf8_iter",
187
+ ]
188
+
189
+ [[package]]
190
+ name = "idna_adapter"
191
+ version = "1.2.1"
192
+ source = "registry+https://github.com/rust-lang/crates.io-index"
193
+ checksum = "3acae9609540aa318d1bc588455225fb2085b9ed0c4f6bd0d9d5bcd86f1a0344"
194
+ dependencies = [
195
+ "icu_normalizer",
196
+ "icu_properties",
197
+ ]
198
+
199
+ [[package]]
200
+ name = "itertools"
201
+ version = "0.13.0"
202
+ source = "registry+https://github.com/rust-lang/crates.io-index"
203
+ checksum = "413ee7dfc52ee1a4949ceeb7dbc8a33f2d6c088194d9f922fb8318faf1f01186"
204
+ dependencies = [
205
+ "either",
206
+ ]
207
+
208
+ [[package]]
209
+ name = "lazy_static"
210
+ version = "1.5.0"
211
+ source = "registry+https://github.com/rust-lang/crates.io-index"
212
+ checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe"
213
+
214
+ [[package]]
215
+ name = "libc"
216
+ version = "0.2.184"
217
+ source = "registry+https://github.com/rust-lang/crates.io-index"
218
+ checksum = "48f5d2a454e16a5ea0f4ced81bd44e4cfc7bd3a507b61887c99fd3538b28e4af"
219
+
220
+ [[package]]
221
+ name = "libloading"
222
+ version = "0.8.9"
223
+ source = "registry+https://github.com/rust-lang/crates.io-index"
224
+ checksum = "d7c4b02199fee7c5d21a5ae7d8cfa79a6ef5bb2fc834d6e9058e89c825efdc55"
225
+ dependencies = [
226
+ "cfg-if",
227
+ "windows-link",
228
+ ]
229
+
230
+ [[package]]
231
+ name = "litemap"
232
+ version = "0.8.2"
233
+ source = "registry+https://github.com/rust-lang/crates.io-index"
234
+ checksum = "92daf443525c4cce67b150400bc2316076100ce0b3686209eb8cf3c31612e6f0"
235
+
236
+ [[package]]
237
+ name = "magnus"
238
+ version = "0.8.2"
239
+ source = "registry+https://github.com/rust-lang/crates.io-index"
240
+ checksum = "3b36a5b126bbe97eb0d02d07acfeb327036c6319fd816139a49824a83b7f9012"
241
+ dependencies = [
242
+ "magnus-macros",
243
+ "rb-sys",
244
+ "rb-sys-env",
245
+ "seq-macro",
246
+ ]
247
+
248
+ [[package]]
249
+ name = "magnus-macros"
250
+ version = "0.8.0"
251
+ source = "registry+https://github.com/rust-lang/crates.io-index"
252
+ checksum = "47607461fd8e1513cb4f2076c197d8092d921a1ea75bd08af97398f593751892"
253
+ dependencies = [
254
+ "proc-macro2",
255
+ "quote",
256
+ "syn",
257
+ ]
258
+
259
+ [[package]]
260
+ name = "memchr"
261
+ version = "2.8.0"
262
+ source = "registry+https://github.com/rust-lang/crates.io-index"
263
+ checksum = "f8ca58f447f06ed17d5fc4043ce1b10dd205e060fb3ce5b979b8ed8e59ff3f79"
264
+
265
+ [[package]]
266
+ name = "minimal-lexical"
267
+ version = "0.2.1"
268
+ source = "registry+https://github.com/rust-lang/crates.io-index"
269
+ checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a"
270
+
271
+ [[package]]
272
+ name = "nom"
273
+ version = "7.1.3"
274
+ source = "registry+https://github.com/rust-lang/crates.io-index"
275
+ checksum = "d273983c5a657a70a3e8f2a01329822f3b8c8172b73826411a55751e404a0a4a"
276
+ dependencies = [
277
+ "memchr",
278
+ "minimal-lexical",
279
+ ]
280
+
281
+ [[package]]
282
+ name = "percent-encoding"
283
+ version = "2.3.2"
284
+ source = "registry+https://github.com/rust-lang/crates.io-index"
285
+ checksum = "9b4f627cb1b25917193a259e49bdad08f671f8d9708acfd5fe0a8c1455d87220"
286
+
287
+ [[package]]
288
+ name = "potential_utf"
289
+ version = "0.1.5"
290
+ source = "registry+https://github.com/rust-lang/crates.io-index"
291
+ checksum = "0103b1cef7ec0cf76490e969665504990193874ea05c85ff9bab8b911d0a0564"
292
+ dependencies = [
293
+ "zerovec",
294
+ ]
295
+
296
+ [[package]]
297
+ name = "proc-macro2"
298
+ version = "1.0.106"
299
+ source = "registry+https://github.com/rust-lang/crates.io-index"
300
+ checksum = "8fd00f0bb2e90d81d1044c2b32617f68fcb9fa3bb7640c23e9c748e53fb30934"
301
+ dependencies = [
302
+ "unicode-ident",
303
+ ]
304
+
305
+ [[package]]
306
+ name = "quote"
307
+ version = "1.0.45"
308
+ source = "registry+https://github.com/rust-lang/crates.io-index"
309
+ checksum = "41f2619966050689382d2b44f664f4bc593e129785a36d6ee376ddf37259b924"
310
+ dependencies = [
311
+ "proc-macro2",
312
+ ]
313
+
314
+ [[package]]
315
+ name = "rb-sys"
316
+ version = "0.9.126"
317
+ source = "registry+https://github.com/rust-lang/crates.io-index"
318
+ checksum = "284799e73e899fe946fd77c7211b83bff61a1356e039ade7a2516a779e3212d0"
319
+ dependencies = [
320
+ "rb-sys-build",
321
+ ]
322
+
323
+ [[package]]
324
+ name = "rb-sys-build"
325
+ version = "0.9.126"
326
+ source = "registry+https://github.com/rust-lang/crates.io-index"
327
+ checksum = "855fc1ad8943d12c89ef12f9147f1cc531f5bf19fb744112fdd317bb6ee7b5c5"
328
+ dependencies = [
329
+ "bindgen",
330
+ "lazy_static",
331
+ "proc-macro2",
332
+ "quote",
333
+ "regex",
334
+ "shell-words",
335
+ "syn",
336
+ ]
337
+
338
+ [[package]]
339
+ name = "rb-sys-env"
340
+ version = "0.2.3"
341
+ source = "registry+https://github.com/rust-lang/crates.io-index"
342
+ checksum = "cca7ad6a7e21e72151d56fe2495a259b5670e204c3adac41ee7ef676ea08117a"
343
+
344
+ [[package]]
345
+ name = "rb-sys-test-helpers"
346
+ version = "0.3.0"
347
+ source = "registry+https://github.com/rust-lang/crates.io-index"
348
+ checksum = "ccc637c53cad6a6b49ad51c5857c64e36bd70c955ffafe9dc9cc5bc9dd0b3b18"
349
+ dependencies = [
350
+ "rb-sys",
351
+ "rb-sys-env",
352
+ "rb-sys-test-helpers-macros",
353
+ ]
354
+
355
+ [[package]]
356
+ name = "rb-sys-test-helpers-macros"
357
+ version = "0.3.0"
358
+ source = "registry+https://github.com/rust-lang/crates.io-index"
359
+ checksum = "b1c1fce35d9ac77a2745e539232fb82a75856675a5daf4ef8b1ca994d89f8b3f"
360
+ dependencies = [
361
+ "quote",
362
+ "syn",
363
+ ]
364
+
365
+ [[package]]
366
+ name = "regex"
367
+ version = "1.12.3"
368
+ source = "registry+https://github.com/rust-lang/crates.io-index"
369
+ checksum = "e10754a14b9137dd7b1e3e5b0493cc9171fdd105e0ab477f51b72e7f3ac0e276"
370
+ dependencies = [
371
+ "aho-corasick",
372
+ "memchr",
373
+ "regex-automata",
374
+ "regex-syntax",
375
+ ]
376
+
377
+ [[package]]
378
+ name = "regex-automata"
379
+ version = "0.4.14"
380
+ source = "registry+https://github.com/rust-lang/crates.io-index"
381
+ checksum = "6e1dd4122fc1595e8162618945476892eefca7b88c52820e74af6262213cae8f"
382
+ dependencies = [
383
+ "aho-corasick",
384
+ "memchr",
385
+ "regex-syntax",
386
+ ]
387
+
388
+ [[package]]
389
+ name = "regex-syntax"
390
+ version = "0.8.10"
391
+ source = "registry+https://github.com/rust-lang/crates.io-index"
392
+ checksum = "dc897dd8d9e8bd1ed8cdad82b5966c3e0ecae09fb1907d58efaa013543185d0a"
393
+
394
+ [[package]]
395
+ name = "rustc-hash"
396
+ version = "2.1.2"
397
+ source = "registry+https://github.com/rust-lang/crates.io-index"
398
+ checksum = "94300abf3f1ae2e2b8ffb7b58043de3d399c73fa6f4b73826402a5c457614dbe"
399
+
400
+ [[package]]
401
+ name = "seq-macro"
402
+ version = "0.3.6"
403
+ source = "registry+https://github.com/rust-lang/crates.io-index"
404
+ checksum = "1bc711410fbe7399f390ca1c3b60ad0f53f80e95c5eb935e52268a0e2cd49acc"
405
+
406
+ [[package]]
407
+ name = "serde"
408
+ version = "1.0.228"
409
+ source = "registry+https://github.com/rust-lang/crates.io-index"
410
+ checksum = "9a8e94ea7f378bd32cbbd37198a4a91436180c5bb472411e48b5ec2e2124ae9e"
411
+ dependencies = [
412
+ "serde_core",
413
+ "serde_derive",
414
+ ]
415
+
416
+ [[package]]
417
+ name = "serde_core"
418
+ version = "1.0.228"
419
+ source = "registry+https://github.com/rust-lang/crates.io-index"
420
+ checksum = "41d385c7d4ca58e59fc732af25c3983b67ac852c1a25000afe1175de458b67ad"
421
+ dependencies = [
422
+ "serde_derive",
423
+ ]
424
+
425
+ [[package]]
426
+ name = "serde_derive"
427
+ version = "1.0.228"
428
+ source = "registry+https://github.com/rust-lang/crates.io-index"
429
+ checksum = "d540f220d3187173da220f885ab66608367b6574e925011a9353e4badda91d79"
430
+ dependencies = [
431
+ "proc-macro2",
432
+ "quote",
433
+ "syn",
434
+ ]
435
+
436
+ [[package]]
437
+ name = "shell-words"
438
+ version = "1.1.1"
439
+ source = "registry+https://github.com/rust-lang/crates.io-index"
440
+ checksum = "dc6fe69c597f9c37bfeeeeeb33da3530379845f10be461a66d16d03eca2ded77"
441
+
442
+ [[package]]
443
+ name = "shlex"
444
+ version = "1.3.0"
445
+ source = "registry+https://github.com/rust-lang/crates.io-index"
446
+ checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64"
447
+
448
+ [[package]]
449
+ name = "smallvec"
450
+ version = "1.15.1"
451
+ source = "registry+https://github.com/rust-lang/crates.io-index"
452
+ checksum = "67b1b7a3b5fe4f1376887184045fcf45c69e92af734b7aaddc05fb777b6fbd03"
453
+
454
+ [[package]]
455
+ name = "stable_deref_trait"
456
+ version = "1.2.1"
457
+ source = "registry+https://github.com/rust-lang/crates.io-index"
458
+ checksum = "6ce2be8dc25455e1f91df71bfa12ad37d7af1092ae736f3a6cd0e37bc7810596"
459
+
460
+ [[package]]
461
+ name = "syn"
462
+ version = "2.0.117"
463
+ source = "registry+https://github.com/rust-lang/crates.io-index"
464
+ checksum = "e665b8803e7b1d2a727f4023456bbbbe74da67099c585258af0ad9c5013b9b99"
465
+ dependencies = [
466
+ "proc-macro2",
467
+ "quote",
468
+ "unicode-ident",
469
+ ]
470
+
471
+ [[package]]
472
+ name = "synstructure"
473
+ version = "0.13.2"
474
+ source = "registry+https://github.com/rust-lang/crates.io-index"
475
+ checksum = "728a70f3dbaf5bab7f0c4b1ac8d7ae5ea60a4b5549c8a5914361c99147a709d2"
476
+ dependencies = [
477
+ "proc-macro2",
478
+ "quote",
479
+ "syn",
480
+ ]
481
+
482
+ [[package]]
483
+ name = "tinystr"
484
+ version = "0.8.3"
485
+ source = "registry+https://github.com/rust-lang/crates.io-index"
486
+ checksum = "c8323304221c2a851516f22236c5722a72eaa19749016521d6dff0824447d96d"
487
+ dependencies = [
488
+ "displaydoc",
489
+ "zerovec",
490
+ ]
491
+
492
+ [[package]]
493
+ name = "unicode-ident"
494
+ version = "1.0.24"
495
+ source = "registry+https://github.com/rust-lang/crates.io-index"
496
+ checksum = "e6e4313cd5fcd3dad5cafa179702e2b244f760991f45397d14d4ebf38247da75"
497
+
498
+ [[package]]
499
+ name = "url"
500
+ version = "2.5.8"
501
+ source = "registry+https://github.com/rust-lang/crates.io-index"
502
+ checksum = "ff67a8a4397373c3ef660812acab3268222035010ab8680ec4215f38ba3d0eed"
503
+ dependencies = [
504
+ "form_urlencoded",
505
+ "idna",
506
+ "percent-encoding",
507
+ "serde",
508
+ ]
509
+
510
+ [[package]]
511
+ name = "urlpattern"
512
+ version = "0.1.0"
513
+ dependencies = [
514
+ "magnus",
515
+ "rb-sys",
516
+ "rb-sys-env",
517
+ "rb-sys-test-helpers",
518
+ "regex",
519
+ "url",
520
+ "urlpattern 0.6.0",
521
+ ]
522
+
523
+ [[package]]
524
+ name = "urlpattern"
525
+ version = "0.6.0"
526
+ source = "registry+https://github.com/rust-lang/crates.io-index"
527
+ checksum = "df16f50ef4cc145211879a3867ba757076b25dfee812040dcb0658bd9ae7904b"
528
+ dependencies = [
529
+ "icu_properties",
530
+ "regex",
531
+ "serde",
532
+ "url",
533
+ ]
534
+
535
+ [[package]]
536
+ name = "utf8_iter"
537
+ version = "1.0.4"
538
+ source = "registry+https://github.com/rust-lang/crates.io-index"
539
+ checksum = "b6c140620e7ffbb22c2dee59cafe6084a59b5ffc27a8859a5f0d494b5d52b6be"
540
+
541
+ [[package]]
542
+ name = "windows-link"
543
+ version = "0.2.1"
544
+ source = "registry+https://github.com/rust-lang/crates.io-index"
545
+ checksum = "f0805222e57f7521d6a62e36fa9163bc891acd422f971defe97d64e70d0a4fe5"
546
+
547
+ [[package]]
548
+ name = "writeable"
549
+ version = "0.6.3"
550
+ source = "registry+https://github.com/rust-lang/crates.io-index"
551
+ checksum = "1ffae5123b2d3fc086436f8834ae3ab053a283cfac8fe0a0b8eaae044768a4c4"
552
+
553
+ [[package]]
554
+ name = "yoke"
555
+ version = "0.8.2"
556
+ source = "registry+https://github.com/rust-lang/crates.io-index"
557
+ checksum = "abe8c5fda708d9ca3df187cae8bfb9ceda00dd96231bed36e445a1a48e66f9ca"
558
+ dependencies = [
559
+ "stable_deref_trait",
560
+ "yoke-derive",
561
+ "zerofrom",
562
+ ]
563
+
564
+ [[package]]
565
+ name = "yoke-derive"
566
+ version = "0.8.2"
567
+ source = "registry+https://github.com/rust-lang/crates.io-index"
568
+ checksum = "de844c262c8848816172cef550288e7dc6c7b7814b4ee56b3e1553f275f1858e"
569
+ dependencies = [
570
+ "proc-macro2",
571
+ "quote",
572
+ "syn",
573
+ "synstructure",
574
+ ]
575
+
576
+ [[package]]
577
+ name = "zerofrom"
578
+ version = "0.1.7"
579
+ source = "registry+https://github.com/rust-lang/crates.io-index"
580
+ checksum = "69faa1f2a1ea75661980b013019ed6687ed0e83d069bc1114e2cc74c6c04c4df"
581
+ dependencies = [
582
+ "zerofrom-derive",
583
+ ]
584
+
585
+ [[package]]
586
+ name = "zerofrom-derive"
587
+ version = "0.1.7"
588
+ source = "registry+https://github.com/rust-lang/crates.io-index"
589
+ checksum = "11532158c46691caf0f2593ea8358fed6bbf68a0315e80aae9bd41fbade684a1"
590
+ dependencies = [
591
+ "proc-macro2",
592
+ "quote",
593
+ "syn",
594
+ "synstructure",
595
+ ]
596
+
597
+ [[package]]
598
+ name = "zerotrie"
599
+ version = "0.2.4"
600
+ source = "registry+https://github.com/rust-lang/crates.io-index"
601
+ checksum = "0f9152d31db0792fa83f70fb2f83148effb5c1f5b8c7686c3459e361d9bc20bf"
602
+ dependencies = [
603
+ "displaydoc",
604
+ "yoke",
605
+ "zerofrom",
606
+ ]
607
+
608
+ [[package]]
609
+ name = "zerovec"
610
+ version = "0.11.6"
611
+ source = "registry+https://github.com/rust-lang/crates.io-index"
612
+ checksum = "90f911cbc359ab6af17377d242225f4d75119aec87ea711a880987b18cd7b239"
613
+ dependencies = [
614
+ "yoke",
615
+ "zerofrom",
616
+ "zerovec-derive",
617
+ ]
618
+
619
+ [[package]]
620
+ name = "zerovec-derive"
621
+ version = "0.11.3"
622
+ source = "registry+https://github.com/rust-lang/crates.io-index"
623
+ checksum = "625dc425cab0dca6dc3c3319506e6593dcb08a9f387ea3b284dbd52a92c40555"
624
+ dependencies = [
625
+ "proc-macro2",
626
+ "quote",
627
+ "syn",
628
+ ]
data/Cargo.toml ADDED
@@ -0,0 +1,13 @@
1
+ # This Cargo.toml is here to let externals tools (IDEs, etc.) know that this is
2
+ # a Rust project. Your extensions dependencies should be added to the Cargo.toml
3
+ # in the ext/ directory.
4
+
5
+ [workspace]
6
+ members = ["./ext/urlpattern"]
7
+ resolver = "2"
8
+
9
+ [profile.release]
10
+ # By default, debug symbols are stripped from the final binary which makes it
11
+ # harder to debug if something goes wrong. It's recommended to keep debug
12
+ # symbols in the release build so that you can debug the final binary if needed.
13
+ debug = true
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2026 방성범 (Bang Seongbeom)
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,47 @@
1
+ # urlpattern
2
+
3
+ An implementation of [the URL Pattern Standard](https://urlpattern.spec.whatwg.org/) for Ruby written in Rust.
4
+
5
+ ## Description
6
+
7
+ It's a thin wrapper of [denoland/rust-urlpattern](https://github.com/denoland/rust-urlpattern) with [Magnus](https://github.com/matsadler/magnus).
8
+
9
+ It is useful on the server side when serving different pages based on the URL (a.k.a. routing). It provides pattern matching syntax like `/users/:id`, similar to [route parameters in Express](https://expressjs.com/en/guide/routing.html#route-parameters) or [Path-to-RegExp](https://github.com/pillarjs/path-to-regexp). You can use it as a foundation to build your own web server or framework.
10
+
11
+ ## Installation
12
+
13
+ TODO: Replace `UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG` with your gem name right after releasing it to RubyGems.org. Please do not do it earlier due to security reasons. Alternatively, replace this section with instructions to install your gem from git if you don't plan to release to RubyGems.org.
14
+
15
+ Install the gem and add to the application's Gemfile by executing:
16
+
17
+ ```bash
18
+ bundle add UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG
19
+ ```
20
+
21
+ If bundler is not being used to manage dependencies, install the gem by executing:
22
+
23
+ ```bash
24
+ gem install UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG
25
+ ```
26
+
27
+ ## Usage
28
+
29
+ TODO: Write usage instructions here
30
+
31
+ ## Development
32
+
33
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
34
+
35
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
36
+
37
+ ## Contributing
38
+
39
+ Bug reports and pull requests are welcome on GitHub at https://github.com/urlpattern/ruby-urlpattern. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/urlpattern/ruby-urlpattern/blob/main/CODE_OF_CONDUCT.md).
40
+
41
+ ## License
42
+
43
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
44
+
45
+ ## Code of Conduct
46
+
47
+ Everyone interacting in the Urlpattern project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/urlpattern/ruby-urlpattern/blob/main/CODE_OF_CONDUCT.md).
data/Rakefile ADDED
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ require "minitest/test_task"
5
+
6
+ Minitest::TestTask.create
7
+
8
+ require "rubocop/rake_task"
9
+
10
+ RuboCop::RakeTask.new
11
+
12
+ require "rb_sys/extensiontask"
13
+
14
+ task build: :compile
15
+
16
+ GEMSPEC = Gem::Specification.load("urlpattern.gemspec")
17
+
18
+ RbSys::ExtensionTask.new("urlpattern", GEMSPEC) do |ext|
19
+ ext.lib_dir = "lib/urlpattern"
20
+ end
21
+
22
+ task default: %i[compile test rubocop]
@@ -0,0 +1,23 @@
1
+ [package]
2
+ name = "urlpattern"
3
+ version = "0.1.0"
4
+ edition = "2024"
5
+ authors = ["방성범 (Bang Seongbeom) <bangseongbeom@gmail.com>"]
6
+ license = "MIT"
7
+ publish = false
8
+
9
+ [lib]
10
+ crate-type = ["cdylib"]
11
+
12
+ [dependencies]
13
+ magnus = { version = "0.8.2" }
14
+ rb-sys = { version = "0.9", features = ["stable-api-compiled-fallback"] }
15
+ regex = "1.12.3"
16
+ url = "2.5.8"
17
+ urlpattern = "0.6.0"
18
+
19
+ [build-dependencies]
20
+ rb-sys-env = "0.2.3"
21
+
22
+ [dev-dependencies]
23
+ rb-sys-test-helpers = { version = "0.3.0" }
@@ -0,0 +1,5 @@
1
+ pub fn main() -> Result<(), Box<dyn std::error::Error>> {
2
+ let _ = rb_sys_env::activate()?;
3
+
4
+ Ok(())
5
+ }
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "mkmf"
4
+ require "rb_sys/mkmf"
5
+
6
+ create_rust_makefile("urlpattern/urlpattern")
@@ -0,0 +1,384 @@
1
+ use magnus::{
2
+ Error, ExceptionClass, Module, RHash, RModule, RString, Ruby, Value, function, method,
3
+ prelude::*, scan_args::scan_args, wrap,
4
+ };
5
+
6
+ #[wrap(class = "URLPattern::URLPattern")]
7
+ struct UrlPattern(urlpattern::UrlPattern);
8
+
9
+ impl UrlPattern {
10
+ fn new(ruby: &Ruby, args: &[Value]) -> Result<Self, Error> {
11
+ let args = scan_args(args)?;
12
+ let _: () = args.required;
13
+ let (input, base_url, options): (Option<Value>, Option<Value>, Option<RHash>) =
14
+ args.optional;
15
+ let _: () = args.splat;
16
+ let _: () = args.trailing;
17
+ let _: () = args.keywords;
18
+ let _: () = args.block;
19
+
20
+ let module: RModule = ruby.class_object().const_get("URLPattern")?;
21
+ let error_class: ExceptionClass = module.const_get("Error")?;
22
+
23
+ let (base_url, options) = match base_url {
24
+ Some(base_url) => {
25
+ if base_url.is_kind_of(ruby.class_hash()) {
26
+ (None, Some(RHash::try_convert(base_url)?))
27
+ } else {
28
+ (Some(base_url), options)
29
+ }
30
+ }
31
+ None => (None, options),
32
+ };
33
+
34
+ let base_url = match base_url {
35
+ Some(base_url) => Some(
36
+ String::try_convert(base_url)?
37
+ .parse()
38
+ .map_err(|e: url::ParseError| Error::new(error_class, e.to_string()))?,
39
+ ),
40
+ None => None,
41
+ };
42
+
43
+ let options = match options {
44
+ Some(options) => urlpattern::UrlPatternOptions {
45
+ ignore_case: options.lookup2(ruby.to_symbol("ignore_case"), false)?,
46
+ ..urlpattern::UrlPatternOptions::default()
47
+ },
48
+ None => urlpattern::UrlPatternOptions::default(),
49
+ };
50
+
51
+ let init: urlpattern::UrlPatternInit = match input {
52
+ Some(input) if input.is_kind_of(ruby.class_string()) => {
53
+ urlpattern::UrlPatternInit::parse_constructor_string::<regex::Regex>(
54
+ String::try_convert(input)?.as_str(),
55
+ base_url,
56
+ )
57
+ .map_err(|e| Error::new(error_class, e.to_string()))?
58
+ }
59
+ Some(input) if input.is_kind_of(ruby.class_hash()) => {
60
+ if base_url.is_some() {
61
+ return Err(Error::new(
62
+ error_class,
63
+ "base_url cannot be provided when input is a Hash",
64
+ ));
65
+ }
66
+
67
+ let input = RHash::try_convert(input)?;
68
+
69
+ urlpattern::UrlPatternInit {
70
+ protocol: input.lookup(ruby.to_symbol("protocol"))?,
71
+ username: input.lookup(ruby.to_symbol("username"))?,
72
+ password: input.lookup(ruby.to_symbol("password"))?,
73
+ hostname: input.lookup(ruby.to_symbol("hostname"))?,
74
+ port: input.lookup(ruby.to_symbol("port"))?,
75
+ pathname: input.lookup(ruby.to_symbol("pathname"))?,
76
+ search: input.lookup(ruby.to_symbol("search"))?,
77
+ hash: input.lookup(ruby.to_symbol("hash"))?,
78
+ base_url: input
79
+ .lookup::<_, Option<String>>(ruby.to_symbol("base_url"))?
80
+ .map(|s| s.parse())
81
+ .transpose()
82
+ .map_err(|e: url::ParseError| Error::new(error_class, e.to_string()))?,
83
+ }
84
+ }
85
+ None => urlpattern::UrlPatternInit::default(),
86
+ Some(_) => {
87
+ return Err(Error::new(error_class, "invalid input type"));
88
+ }
89
+ };
90
+
91
+ Ok(Self(
92
+ urlpattern::UrlPattern::parse(init, options)
93
+ .map_err(|e| Error::new(error_class, e.to_string()))?,
94
+ ))
95
+ }
96
+
97
+ fn test(ruby: &Ruby, rb_self: &Self, args: &[Value]) -> Result<bool, Error> {
98
+ let args = scan_args(args)?;
99
+ let _: () = args.required;
100
+ let (input, base_url): (Option<Value>, Option<String>) = args.optional;
101
+ let _: () = args.splat;
102
+ let _: () = args.trailing;
103
+ let _: () = args.keywords;
104
+ let _: () = args.block;
105
+
106
+ let module: RModule = ruby.class_object().const_get("URLPattern")?;
107
+ let error_class: ExceptionClass = module.const_get("Error")?;
108
+
109
+ let input: urlpattern::UrlPatternMatchInput = match input {
110
+ Some(input) if input.is_kind_of(ruby.class_string()) => {
111
+ let input = String::try_convert(input)?;
112
+
113
+ match base_url {
114
+ Some(base_url) => {
115
+ let base_url = match url::Url::parse(&base_url) {
116
+ Ok(url) => url,
117
+ Err(_) => return Ok(false),
118
+ };
119
+ ::urlpattern::UrlPatternMatchInput::Url(
120
+ match url::Url::options().base_url(Some(&base_url)).parse(&input) {
121
+ Ok(url) => url,
122
+ Err(_) => return Ok(false),
123
+ },
124
+ )
125
+ }
126
+ None => {
127
+ ::urlpattern::UrlPatternMatchInput::Url(match url::Url::parse(&input) {
128
+ Ok(url) => url,
129
+ Err(e) => return Err(Error::new(error_class, e.to_string())),
130
+ })
131
+ }
132
+ }
133
+ }
134
+ Some(input) if input.is_kind_of(ruby.class_hash()) => {
135
+ if base_url.is_some() {
136
+ return Err(Error::new(
137
+ error_class,
138
+ "base_url cannot be provided when input is a Hash",
139
+ ));
140
+ }
141
+
142
+ let input = RHash::try_convert(input)?;
143
+
144
+ urlpattern::UrlPatternMatchInput::Init(urlpattern::UrlPatternInit {
145
+ protocol: input.lookup(ruby.to_symbol("protocol"))?,
146
+ username: input.lookup(ruby.to_symbol("username"))?,
147
+ password: input.lookup(ruby.to_symbol("password"))?,
148
+ hostname: input.lookup(ruby.to_symbol("hostname"))?,
149
+ port: input.lookup(ruby.to_symbol("port"))?,
150
+ pathname: input.lookup(ruby.to_symbol("pathname"))?,
151
+ search: input.lookup(ruby.to_symbol("search"))?,
152
+ hash: input.lookup(ruby.to_symbol("hash"))?,
153
+ base_url: input
154
+ .lookup::<_, Option<String>>(ruby.to_symbol("base_url"))?
155
+ .map(|s| s.parse())
156
+ .transpose()
157
+ .map_err(|e: url::ParseError| Error::new(error_class, e.to_string()))?,
158
+ })
159
+ }
160
+ None => urlpattern::UrlPatternMatchInput::Init(urlpattern::UrlPatternInit::default()),
161
+ Some(_) => return Err(Error::new(error_class, "invalid input type")),
162
+ };
163
+
164
+ rb_self
165
+ .0
166
+ .test(input)
167
+ .map_err(|e| Error::new(error_class, e.to_string()))
168
+ }
169
+
170
+ fn exec(ruby: &Ruby, rb_self: &Self, args: &[Value]) -> Result<Option<RHash>, Error> {
171
+ let args = scan_args(args)?;
172
+ let _: () = args.required;
173
+ let (input, base_url): (Option<Value>, Option<RString>) = args.optional;
174
+ let _: () = args.splat;
175
+ let _: () = args.trailing;
176
+ let _: () = args.keywords;
177
+ let _: () = args.block;
178
+
179
+ let module: RModule = ruby.class_object().const_get("URLPattern")?;
180
+ let error_class: ExceptionClass = module.const_get("Error")?;
181
+
182
+ let urlpattern_input: urlpattern::UrlPatternMatchInput = match input {
183
+ Some(input) if input.is_kind_of(ruby.class_string()) => {
184
+ let input = String::try_convert(input)?;
185
+
186
+ match base_url {
187
+ Some(base_url) => {
188
+ let base_url = match url::Url::parse(&base_url.to_string()?) {
189
+ Ok(url) => url,
190
+ Err(_) => return Ok(None),
191
+ };
192
+ ::urlpattern::UrlPatternMatchInput::Url(
193
+ match url::Url::options().base_url(Some(&base_url)).parse(&input) {
194
+ Ok(url) => url,
195
+ Err(_) => return Ok(None),
196
+ },
197
+ )
198
+ }
199
+ None => {
200
+ ::urlpattern::UrlPatternMatchInput::Url(match url::Url::parse(&input) {
201
+ Ok(url) => url,
202
+ Err(e) => return Err(Error::new(error_class, e.to_string())),
203
+ })
204
+ }
205
+ }
206
+ }
207
+ Some(input) if input.is_kind_of(ruby.class_hash()) => {
208
+ if base_url.is_some() {
209
+ return Err(Error::new(
210
+ error_class,
211
+ "base_url cannot be provided when input is a Hash",
212
+ ));
213
+ }
214
+
215
+ let input = RHash::try_convert(input)?;
216
+
217
+ urlpattern::UrlPatternMatchInput::Init(urlpattern::UrlPatternInit {
218
+ protocol: input.lookup(ruby.to_symbol("protocol"))?,
219
+ username: input.lookup(ruby.to_symbol("username"))?,
220
+ password: input.lookup(ruby.to_symbol("password"))?,
221
+ hostname: input.lookup(ruby.to_symbol("hostname"))?,
222
+ port: input.lookup(ruby.to_symbol("port"))?,
223
+ pathname: input.lookup(ruby.to_symbol("pathname"))?,
224
+ search: input.lookup(ruby.to_symbol("search"))?,
225
+ hash: input.lookup(ruby.to_symbol("hash"))?,
226
+ base_url: input
227
+ .lookup::<_, Option<String>>(ruby.to_symbol("base_url"))?
228
+ .map(|s| s.parse())
229
+ .transpose()
230
+ .map_err(|e: url::ParseError| Error::new(error_class, e.to_string()))?,
231
+ })
232
+ }
233
+ None => urlpattern::UrlPatternMatchInput::Init(urlpattern::UrlPatternInit::default()),
234
+ Some(_) => return Err(Error::new(error_class, "invalid input type")),
235
+ };
236
+
237
+ let Some(urlpattern_result) = rb_self
238
+ .0
239
+ .exec(urlpattern_input)
240
+ .map_err(|e| Error::new(error_class, e.to_string()))?
241
+ else {
242
+ return Ok(None);
243
+ };
244
+
245
+ let result = ruby.hash_new();
246
+
247
+ let inputs = ruby.ary_new();
248
+ if let Some(input) = input {
249
+ inputs.push(input)?;
250
+ } else {
251
+ inputs.push(ruby.hash_new())?;
252
+ }
253
+ if let Some(base_url) = base_url {
254
+ inputs.push(base_url)?;
255
+ }
256
+ result.aset(ruby.to_symbol("inputs"), inputs)?;
257
+
258
+ let protocol = ruby.hash_new();
259
+ protocol.aset(ruby.to_symbol("input"), urlpattern_result.protocol.input)?;
260
+ let groups = ruby.hash_new();
261
+ for (key, value) in urlpattern_result.protocol.groups {
262
+ groups.aset(ruby.to_symbol(key), value)?;
263
+ }
264
+ protocol.aset(ruby.to_symbol("groups"), groups)?;
265
+ result.aset(ruby.to_symbol("protocol"), protocol)?;
266
+
267
+ let username = ruby.hash_new();
268
+ username.aset(ruby.to_symbol("input"), urlpattern_result.username.input)?;
269
+ let groups = ruby.hash_new();
270
+ for (key, value) in urlpattern_result.username.groups {
271
+ groups.aset(ruby.to_symbol(key), value)?;
272
+ }
273
+ username.aset(ruby.to_symbol("groups"), groups)?;
274
+ result.aset(ruby.to_symbol("username"), username)?;
275
+
276
+ let password = ruby.hash_new();
277
+ password.aset(ruby.to_symbol("input"), urlpattern_result.password.input)?;
278
+ let groups = ruby.hash_new();
279
+ for (key, value) in urlpattern_result.password.groups {
280
+ groups.aset(ruby.to_symbol(key), value)?;
281
+ }
282
+ password.aset(ruby.to_symbol("groups"), groups)?;
283
+ result.aset(ruby.to_symbol("password"), password)?;
284
+
285
+ let hostname = ruby.hash_new();
286
+ hostname.aset(ruby.to_symbol("input"), urlpattern_result.hostname.input)?;
287
+ let groups = ruby.hash_new();
288
+ for (key, value) in urlpattern_result.hostname.groups {
289
+ groups.aset(ruby.to_symbol(key), value)?;
290
+ }
291
+ hostname.aset(ruby.to_symbol("groups"), groups)?;
292
+ result.aset(ruby.to_symbol("hostname"), hostname)?;
293
+
294
+ let port = ruby.hash_new();
295
+ port.aset(ruby.to_symbol("input"), urlpattern_result.port.input)?;
296
+ let groups = ruby.hash_new();
297
+ for (key, value) in urlpattern_result.port.groups {
298
+ groups.aset(ruby.to_symbol(key), value)?;
299
+ }
300
+ port.aset(ruby.to_symbol("groups"), groups)?;
301
+ result.aset(ruby.to_symbol("port"), port)?;
302
+
303
+ let pathname = ruby.hash_new();
304
+ pathname.aset(ruby.to_symbol("input"), urlpattern_result.pathname.input)?;
305
+ let groups = ruby.hash_new();
306
+ for (key, value) in urlpattern_result.pathname.groups {
307
+ groups.aset(ruby.to_symbol(key), value)?;
308
+ }
309
+ pathname.aset(ruby.to_symbol("groups"), groups)?;
310
+ result.aset(ruby.to_symbol("pathname"), pathname)?;
311
+
312
+ let search = ruby.hash_new();
313
+ search.aset(ruby.to_symbol("input"), urlpattern_result.search.input)?;
314
+ let groups = ruby.hash_new();
315
+ for (key, value) in urlpattern_result.search.groups {
316
+ groups.aset(ruby.to_symbol(key), value)?;
317
+ }
318
+ search.aset(ruby.to_symbol("groups"), groups)?;
319
+ result.aset(ruby.to_symbol("search"), search)?;
320
+
321
+ let hash = ruby.hash_new();
322
+ hash.aset(ruby.to_symbol("input"), urlpattern_result.hash.input)?;
323
+ let groups = ruby.hash_new();
324
+ for (key, value) in urlpattern_result.hash.groups {
325
+ groups.aset(ruby.to_symbol(key), value)?;
326
+ }
327
+ hash.aset(ruby.to_symbol("groups"), groups)?;
328
+ result.aset(ruby.to_symbol("hash"), hash)?;
329
+
330
+ Ok(Some(result))
331
+ }
332
+
333
+ fn protocol(&self) -> &str {
334
+ self.0.protocol()
335
+ }
336
+ fn username(&self) -> &str {
337
+ self.0.username()
338
+ }
339
+ fn password(&self) -> &str {
340
+ self.0.password()
341
+ }
342
+ fn hostname(&self) -> &str {
343
+ self.0.hostname()
344
+ }
345
+ fn port(&self) -> &str {
346
+ self.0.port()
347
+ }
348
+ fn pathname(&self) -> &str {
349
+ self.0.pathname()
350
+ }
351
+ fn search(&self) -> &str {
352
+ self.0.search()
353
+ }
354
+ fn hash(&self) -> &str {
355
+ self.0.hash()
356
+ }
357
+
358
+ fn has_regexp_groups(&self) -> bool {
359
+ self.0.has_regexp_groups()
360
+ }
361
+ }
362
+
363
+ #[magnus::init]
364
+ fn init(ruby: &Ruby) -> Result<(), Error> {
365
+ let module = ruby.define_module("URLPattern")?;
366
+ let _error = module.define_error("Error", ruby.exception_standard_error())?;
367
+ let class = module.define_class("URLPattern", ruby.class_object())?;
368
+ class.define_singleton_method("new", function!(UrlPattern::new, -1))?;
369
+ class.define_method("test?", method!(UrlPattern::test, -1))?;
370
+ class.define_method("exec", method!(UrlPattern::exec, -1))?;
371
+ class.define_method("protocol", method!(UrlPattern::protocol, 0))?;
372
+ class.define_method("username", method!(UrlPattern::username, 0))?;
373
+ class.define_method("password", method!(UrlPattern::password, 0))?;
374
+ class.define_method("hostname", method!(UrlPattern::hostname, 0))?;
375
+ class.define_method("port", method!(UrlPattern::port, 0))?;
376
+ class.define_method("pathname", method!(UrlPattern::pathname, 0))?;
377
+ class.define_method("search", method!(UrlPattern::search, 0))?;
378
+ class.define_method("hash", method!(UrlPattern::hash, 0))?;
379
+ class.define_method(
380
+ "has_regexp_groups?",
381
+ method!(UrlPattern::has_regexp_groups, 0),
382
+ )?;
383
+ Ok(())
384
+ }
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module URLPattern
4
+ VERSION = "0.1.0"
5
+ end
data/lib/urlpattern.rb ADDED
@@ -0,0 +1,4 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "urlpattern/version"
4
+ require "urlpattern/urlpattern"
@@ -0,0 +1,63 @@
1
+ module URLPattern
2
+ VERSION: String
3
+ # See the writing guide of rbs: https://github.com/ruby/rbs#guides
4
+
5
+ class Error < StandardError
6
+ end
7
+
8
+ type urlpattern_input = String | urlpattern_init
9
+
10
+ class URLPattern
11
+ def initialize: (urlpattern_input input, String base_url, ?urlpattern_options options) -> void
12
+ | (?urlpattern_input input, ?urlpattern_options options) -> void
13
+
14
+ def test?: (?urlpattern_input input, ?String base_url) -> bool
15
+
16
+ def exec: (?urlpattern_input input, ?String base_url) -> urlpattern_result?
17
+
18
+ def protocol: () -> String
19
+ def username: () -> String
20
+ def password: () -> String
21
+ def hostname: () -> String
22
+ def port: () -> String
23
+ def pathname: () -> String
24
+ def search: () -> String
25
+ def hash: () -> String
26
+ def has_regexp_groups?: () -> bool
27
+ end
28
+
29
+ type urlpattern_init = {
30
+ ?protocol: String,
31
+ ?username: String,
32
+ ?password: String,
33
+ ?hostname: String,
34
+ ?port: String,
35
+ ?pathname: String,
36
+ ?search: String,
37
+ ?hash: String,
38
+ ?base_url: String
39
+ }
40
+
41
+ type urlpattern_options = {
42
+ ?ignore_case: bool
43
+ }
44
+
45
+ type urlpattern_result = {
46
+ ?inputs: Array[urlpattern_input],
47
+ ?protocol: urlpattern_component_result,
48
+ ?username: urlpattern_component_result,
49
+ ?password: urlpattern_component_result,
50
+ ?hostname: urlpattern_component_result,
51
+ ?port: urlpattern_component_result,
52
+ ?pathname: urlpattern_component_result,
53
+ ?search: urlpattern_component_result,
54
+ ?hash: urlpattern_component_result
55
+ }
56
+
57
+ type urlpattern_component_result = {
58
+ ?input: String,
59
+ ?groups: Hash[Symbol, String?]
60
+ }
61
+
62
+ type urlpattern_compatible = String | urlpattern_init | URLPattern
63
+ end
metadata ADDED
@@ -0,0 +1,73 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: urlpattern
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - 방성범 (Bang Seongbeom)
8
+ bindir: exe
9
+ cert_chain: []
10
+ date: 1980-01-02 00:00:00.000000000 Z
11
+ dependencies:
12
+ - !ruby/object:Gem::Dependency
13
+ name: rb_sys
14
+ requirement: !ruby/object:Gem::Requirement
15
+ requirements:
16
+ - - "~>"
17
+ - !ruby/object:Gem::Version
18
+ version: 0.9.91
19
+ type: :runtime
20
+ prerelease: false
21
+ version_requirements: !ruby/object:Gem::Requirement
22
+ requirements:
23
+ - - "~>"
24
+ - !ruby/object:Gem::Version
25
+ version: 0.9.91
26
+ description: |
27
+ It's a thin wrapper of denoland/rust-urlpattern with Magnus.
28
+
29
+ It is useful on the server side when serving different pages based on the URL (a.k.a. routing). It provides pattern matching syntax like /users/:id, similar to route parameters in Express or Path-to-RegExp. You can use it as a foundation to build your own web server or framework.
30
+ email:
31
+ - bangseongbeom@gmail.com
32
+ executables: []
33
+ extensions:
34
+ - ext/urlpattern/extconf.rb
35
+ extra_rdoc_files: []
36
+ files:
37
+ - CODE_OF_CONDUCT.md
38
+ - Cargo.lock
39
+ - Cargo.toml
40
+ - LICENSE.txt
41
+ - README.md
42
+ - Rakefile
43
+ - ext/urlpattern/Cargo.toml
44
+ - ext/urlpattern/build.rs
45
+ - ext/urlpattern/extconf.rb
46
+ - ext/urlpattern/src/lib.rs
47
+ - lib/urlpattern.rb
48
+ - lib/urlpattern/version.rb
49
+ - sig/urlpattern.rbs
50
+ homepage: https://github.com/urlpattern/ruby-urlpattern
51
+ licenses:
52
+ - MIT
53
+ metadata:
54
+ homepage_uri: https://github.com/urlpattern/ruby-urlpattern
55
+ source_code_uri: https://github.com/urlpattern/ruby-urlpattern
56
+ rdoc_options: []
57
+ require_paths:
58
+ - lib
59
+ required_ruby_version: !ruby/object:Gem::Requirement
60
+ requirements:
61
+ - - ">="
62
+ - !ruby/object:Gem::Version
63
+ version: 3.2.0
64
+ required_rubygems_version: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ requirements: []
70
+ rubygems_version: 4.0.6
71
+ specification_version: 4
72
+ summary: An implementation of the URL Pattern Standard for Ruby written in Rust.
73
+ test_files: []