bs62 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 738d6cf159b7c3e700886b8798e412bf513e2e34296a4a149d7275494485cb73
4
+ data.tar.gz: ca54dfb2728d8552d5dd50949744b9405d3e22b36b4497841e12a4b244d54dc8
5
+ SHA512:
6
+ metadata.gz: 791379d785a4ca78f87ef241722880e4394d782189bd32abddbce9f4d05ef0dad34f17b9a295465d821a16ade0ed6c725d6edea8438166c55a2783af1e911ba6
7
+ data.tar.gz: 2f280976c841d3e51e03eb7aee53bfa20e54634164424f3bbd81aa7926afefe1710631e160666baf93255471cbbd3627fa27f4b0fe20ce78b3ef284f4552877d
data/Cargo.lock ADDED
@@ -0,0 +1,432 @@
1
+ # This file is automatically @generated by Cargo.
2
+ # It is not intended for manual editing.
3
+ version = 3
4
+
5
+ [[package]]
6
+ name = "addr2line"
7
+ version = "0.19.0"
8
+ source = "registry+https://github.com/rust-lang/crates.io-index"
9
+ checksum = "a76fd60b23679b7d19bd066031410fb7e458ccc5e958eb5c325888ce4baedc97"
10
+ dependencies = [
11
+ "gimli",
12
+ ]
13
+
14
+ [[package]]
15
+ name = "adler"
16
+ version = "1.0.2"
17
+ source = "registry+https://github.com/rust-lang/crates.io-index"
18
+ checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe"
19
+
20
+ [[package]]
21
+ name = "aho-corasick"
22
+ version = "1.0.2"
23
+ source = "registry+https://github.com/rust-lang/crates.io-index"
24
+ checksum = "43f6cb1bf222025340178f382c426f13757b2960e89779dfcb319c32542a5a41"
25
+ dependencies = [
26
+ "memchr",
27
+ ]
28
+
29
+ [[package]]
30
+ name = "autocfg"
31
+ version = "1.1.0"
32
+ source = "registry+https://github.com/rust-lang/crates.io-index"
33
+ checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa"
34
+
35
+ [[package]]
36
+ name = "backtrace"
37
+ version = "0.3.67"
38
+ source = "registry+https://github.com/rust-lang/crates.io-index"
39
+ checksum = "233d376d6d185f2a3093e58f283f60f880315b6c60075b01f36b3b85154564ca"
40
+ dependencies = [
41
+ "addr2line",
42
+ "cc",
43
+ "cfg-if",
44
+ "libc",
45
+ "miniz_oxide",
46
+ "object",
47
+ "rustc-demangle",
48
+ ]
49
+
50
+ [[package]]
51
+ name = "base-62"
52
+ version = "0.1.1"
53
+ source = "registry+https://github.com/rust-lang/crates.io-index"
54
+ checksum = "f28ebd71b3e708e895b83ec2d35c6e2ef96e34945706bf4d73826354e84f89b2"
55
+ dependencies = [
56
+ "failure",
57
+ "num-bigint",
58
+ "num-integer",
59
+ "num-traits",
60
+ ]
61
+
62
+ [[package]]
63
+ name = "bindgen"
64
+ version = "0.62.0"
65
+ source = "registry+https://github.com/rust-lang/crates.io-index"
66
+ checksum = "c6720a8b7b2d39dd533285ed438d458f65b31b5c257e6ac7bb3d7e82844dd722"
67
+ dependencies = [
68
+ "bitflags",
69
+ "cexpr",
70
+ "clang-sys",
71
+ "lazy_static",
72
+ "lazycell",
73
+ "peeking_take_while",
74
+ "proc-macro2",
75
+ "quote",
76
+ "regex",
77
+ "rustc-hash",
78
+ "shlex",
79
+ "syn",
80
+ ]
81
+
82
+ [[package]]
83
+ name = "bitflags"
84
+ version = "1.3.2"
85
+ source = "registry+https://github.com/rust-lang/crates.io-index"
86
+ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
87
+
88
+ [[package]]
89
+ name = "bs62"
90
+ version = "1.0.0"
91
+ dependencies = [
92
+ "base-62",
93
+ "magnus",
94
+ ]
95
+
96
+ [[package]]
97
+ name = "cc"
98
+ version = "1.0.79"
99
+ source = "registry+https://github.com/rust-lang/crates.io-index"
100
+ checksum = "50d30906286121d95be3d479533b458f87493b30a4b5f79a607db8f5d11aa91f"
101
+
102
+ [[package]]
103
+ name = "cexpr"
104
+ version = "0.6.0"
105
+ source = "registry+https://github.com/rust-lang/crates.io-index"
106
+ checksum = "6fac387a98bb7c37292057cffc56d62ecb629900026402633ae9160df93a8766"
107
+ dependencies = [
108
+ "nom",
109
+ ]
110
+
111
+ [[package]]
112
+ name = "cfg-if"
113
+ version = "1.0.0"
114
+ source = "registry+https://github.com/rust-lang/crates.io-index"
115
+ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
116
+
117
+ [[package]]
118
+ name = "clang-sys"
119
+ version = "1.6.1"
120
+ source = "registry+https://github.com/rust-lang/crates.io-index"
121
+ checksum = "c688fc74432808e3eb684cae8830a86be1d66a2bd58e1f248ed0960a590baf6f"
122
+ dependencies = [
123
+ "glob",
124
+ "libc",
125
+ "libloading",
126
+ ]
127
+
128
+ [[package]]
129
+ name = "failure"
130
+ version = "0.1.8"
131
+ source = "registry+https://github.com/rust-lang/crates.io-index"
132
+ checksum = "d32e9bd16cc02eae7db7ef620b392808b89f6a5e16bb3497d159c6b92a0f4f86"
133
+ dependencies = [
134
+ "backtrace",
135
+ "failure_derive",
136
+ ]
137
+
138
+ [[package]]
139
+ name = "failure_derive"
140
+ version = "0.1.8"
141
+ source = "registry+https://github.com/rust-lang/crates.io-index"
142
+ checksum = "aa4da3c766cd7a0db8242e326e9e4e081edd567072893ed320008189715366a4"
143
+ dependencies = [
144
+ "proc-macro2",
145
+ "quote",
146
+ "syn",
147
+ "synstructure",
148
+ ]
149
+
150
+ [[package]]
151
+ name = "gimli"
152
+ version = "0.27.2"
153
+ source = "registry+https://github.com/rust-lang/crates.io-index"
154
+ checksum = "ad0a93d233ebf96623465aad4046a8d3aa4da22d4f4beba5388838c8a434bbb4"
155
+
156
+ [[package]]
157
+ name = "glob"
158
+ version = "0.3.1"
159
+ source = "registry+https://github.com/rust-lang/crates.io-index"
160
+ checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b"
161
+
162
+ [[package]]
163
+ name = "lazy_static"
164
+ version = "1.4.0"
165
+ source = "registry+https://github.com/rust-lang/crates.io-index"
166
+ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
167
+
168
+ [[package]]
169
+ name = "lazycell"
170
+ version = "1.3.0"
171
+ source = "registry+https://github.com/rust-lang/crates.io-index"
172
+ checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55"
173
+
174
+ [[package]]
175
+ name = "libc"
176
+ version = "0.2.146"
177
+ source = "registry+https://github.com/rust-lang/crates.io-index"
178
+ checksum = "f92be4933c13fd498862a9e02a3055f8a8d9c039ce33db97306fd5a6caa7f29b"
179
+
180
+ [[package]]
181
+ name = "libloading"
182
+ version = "0.7.4"
183
+ source = "registry+https://github.com/rust-lang/crates.io-index"
184
+ checksum = "b67380fd3b2fbe7527a606e18729d21c6f3951633d0500574c4dc22d2d638b9f"
185
+ dependencies = [
186
+ "cfg-if",
187
+ "winapi",
188
+ ]
189
+
190
+ [[package]]
191
+ name = "magnus"
192
+ version = "0.5.3"
193
+ source = "registry+https://github.com/rust-lang/crates.io-index"
194
+ checksum = "c8dc14463c2552e753ef562961f486ca76f17a857c121db40e9f3ade3f35ab81"
195
+ dependencies = [
196
+ "magnus-macros",
197
+ "rb-sys",
198
+ "rb-sys-env",
199
+ ]
200
+
201
+ [[package]]
202
+ name = "magnus-macros"
203
+ version = "0.4.1"
204
+ source = "registry+https://github.com/rust-lang/crates.io-index"
205
+ checksum = "6cc17af1d45442c011aa579d727ec6cff8a69aea8a6bbad26736e7112d749bfb"
206
+ dependencies = [
207
+ "proc-macro2",
208
+ "quote",
209
+ "syn",
210
+ ]
211
+
212
+ [[package]]
213
+ name = "memchr"
214
+ version = "2.5.0"
215
+ source = "registry+https://github.com/rust-lang/crates.io-index"
216
+ checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d"
217
+
218
+ [[package]]
219
+ name = "minimal-lexical"
220
+ version = "0.2.1"
221
+ source = "registry+https://github.com/rust-lang/crates.io-index"
222
+ checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a"
223
+
224
+ [[package]]
225
+ name = "miniz_oxide"
226
+ version = "0.6.2"
227
+ source = "registry+https://github.com/rust-lang/crates.io-index"
228
+ checksum = "b275950c28b37e794e8c55d88aeb5e139d0ce23fdbbeda68f8d7174abdf9e8fa"
229
+ dependencies = [
230
+ "adler",
231
+ ]
232
+
233
+ [[package]]
234
+ name = "nom"
235
+ version = "7.1.3"
236
+ source = "registry+https://github.com/rust-lang/crates.io-index"
237
+ checksum = "d273983c5a657a70a3e8f2a01329822f3b8c8172b73826411a55751e404a0a4a"
238
+ dependencies = [
239
+ "memchr",
240
+ "minimal-lexical",
241
+ ]
242
+
243
+ [[package]]
244
+ name = "num-bigint"
245
+ version = "0.2.6"
246
+ source = "registry+https://github.com/rust-lang/crates.io-index"
247
+ checksum = "090c7f9998ee0ff65aa5b723e4009f7b217707f1fb5ea551329cc4d6231fb304"
248
+ dependencies = [
249
+ "autocfg",
250
+ "num-integer",
251
+ "num-traits",
252
+ ]
253
+
254
+ [[package]]
255
+ name = "num-integer"
256
+ version = "0.1.45"
257
+ source = "registry+https://github.com/rust-lang/crates.io-index"
258
+ checksum = "225d3389fb3509a24c93f5c29eb6bde2586b98d9f016636dff58d7c6f7569cd9"
259
+ dependencies = [
260
+ "autocfg",
261
+ "num-traits",
262
+ ]
263
+
264
+ [[package]]
265
+ name = "num-traits"
266
+ version = "0.2.15"
267
+ source = "registry+https://github.com/rust-lang/crates.io-index"
268
+ checksum = "578ede34cf02f8924ab9447f50c28075b4d3e5b269972345e7e0372b38c6cdcd"
269
+ dependencies = [
270
+ "autocfg",
271
+ ]
272
+
273
+ [[package]]
274
+ name = "object"
275
+ version = "0.30.4"
276
+ source = "registry+https://github.com/rust-lang/crates.io-index"
277
+ checksum = "03b4680b86d9cfafba8fc491dc9b6df26b68cf40e9e6cd73909194759a63c385"
278
+ dependencies = [
279
+ "memchr",
280
+ ]
281
+
282
+ [[package]]
283
+ name = "peeking_take_while"
284
+ version = "0.1.2"
285
+ source = "registry+https://github.com/rust-lang/crates.io-index"
286
+ checksum = "19b17cddbe7ec3f8bc800887bab5e717348c95ea2ca0b1bf0837fb964dc67099"
287
+
288
+ [[package]]
289
+ name = "proc-macro2"
290
+ version = "1.0.59"
291
+ source = "registry+https://github.com/rust-lang/crates.io-index"
292
+ checksum = "6aeca18b86b413c660b781aa319e4e2648a3e6f9eadc9b47e9038e6fe9f3451b"
293
+ dependencies = [
294
+ "unicode-ident",
295
+ ]
296
+
297
+ [[package]]
298
+ name = "quote"
299
+ version = "1.0.28"
300
+ source = "registry+https://github.com/rust-lang/crates.io-index"
301
+ checksum = "1b9ab9c7eadfd8df19006f1cf1a4aed13540ed5cbc047010ece5826e10825488"
302
+ dependencies = [
303
+ "proc-macro2",
304
+ ]
305
+
306
+ [[package]]
307
+ name = "rb-sys"
308
+ version = "0.9.78"
309
+ source = "registry+https://github.com/rust-lang/crates.io-index"
310
+ checksum = "91447d8cbb45afb5c915bad4dd44bd4b4e9be37648122409ceca75302cb81683"
311
+ dependencies = [
312
+ "rb-sys-build",
313
+ ]
314
+
315
+ [[package]]
316
+ name = "rb-sys-build"
317
+ version = "0.9.78"
318
+ source = "registry+https://github.com/rust-lang/crates.io-index"
319
+ checksum = "20673c1cfbd57b2db6c066b796352f07d241c45b210fd15b269dec54fa240380"
320
+ dependencies = [
321
+ "bindgen",
322
+ "lazy_static",
323
+ "proc-macro2",
324
+ "quote",
325
+ "regex",
326
+ "shell-words",
327
+ "syn",
328
+ ]
329
+
330
+ [[package]]
331
+ name = "rb-sys-env"
332
+ version = "0.1.2"
333
+ source = "registry+https://github.com/rust-lang/crates.io-index"
334
+ checksum = "a35802679f07360454b418a5d1735c89716bde01d35b1560fc953c1415a0b3bb"
335
+
336
+ [[package]]
337
+ name = "regex"
338
+ version = "1.8.4"
339
+ source = "registry+https://github.com/rust-lang/crates.io-index"
340
+ checksum = "d0ab3ca65655bb1e41f2a8c8cd662eb4fb035e67c3f78da1d61dffe89d07300f"
341
+ dependencies = [
342
+ "aho-corasick",
343
+ "memchr",
344
+ "regex-syntax",
345
+ ]
346
+
347
+ [[package]]
348
+ name = "regex-syntax"
349
+ version = "0.7.2"
350
+ source = "registry+https://github.com/rust-lang/crates.io-index"
351
+ checksum = "436b050e76ed2903236f032a59761c1eb99e1b0aead2c257922771dab1fc8c78"
352
+
353
+ [[package]]
354
+ name = "rustc-demangle"
355
+ version = "0.1.23"
356
+ source = "registry+https://github.com/rust-lang/crates.io-index"
357
+ checksum = "d626bb9dae77e28219937af045c257c28bfd3f69333c512553507f5f9798cb76"
358
+
359
+ [[package]]
360
+ name = "rustc-hash"
361
+ version = "1.1.0"
362
+ source = "registry+https://github.com/rust-lang/crates.io-index"
363
+ checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2"
364
+
365
+ [[package]]
366
+ name = "shell-words"
367
+ version = "1.1.0"
368
+ source = "registry+https://github.com/rust-lang/crates.io-index"
369
+ checksum = "24188a676b6ae68c3b2cb3a01be17fbf7240ce009799bb56d5b1409051e78fde"
370
+
371
+ [[package]]
372
+ name = "shlex"
373
+ version = "1.1.0"
374
+ source = "registry+https://github.com/rust-lang/crates.io-index"
375
+ checksum = "43b2853a4d09f215c24cc5489c992ce46052d359b5109343cbafbf26bc62f8a3"
376
+
377
+ [[package]]
378
+ name = "syn"
379
+ version = "1.0.109"
380
+ source = "registry+https://github.com/rust-lang/crates.io-index"
381
+ checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237"
382
+ dependencies = [
383
+ "proc-macro2",
384
+ "quote",
385
+ "unicode-ident",
386
+ ]
387
+
388
+ [[package]]
389
+ name = "synstructure"
390
+ version = "0.12.6"
391
+ source = "registry+https://github.com/rust-lang/crates.io-index"
392
+ checksum = "f36bdaa60a83aca3921b5259d5400cbf5e90fc51931376a9bd4a0eb79aa7210f"
393
+ dependencies = [
394
+ "proc-macro2",
395
+ "quote",
396
+ "syn",
397
+ "unicode-xid",
398
+ ]
399
+
400
+ [[package]]
401
+ name = "unicode-ident"
402
+ version = "1.0.9"
403
+ source = "registry+https://github.com/rust-lang/crates.io-index"
404
+ checksum = "b15811caf2415fb889178633e7724bad2509101cde276048e013b9def5e51fa0"
405
+
406
+ [[package]]
407
+ name = "unicode-xid"
408
+ version = "0.2.4"
409
+ source = "registry+https://github.com/rust-lang/crates.io-index"
410
+ checksum = "f962df74c8c05a667b5ee8bcf162993134c104e96440b663c8daa176dc772d8c"
411
+
412
+ [[package]]
413
+ name = "winapi"
414
+ version = "0.3.9"
415
+ source = "registry+https://github.com/rust-lang/crates.io-index"
416
+ checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419"
417
+ dependencies = [
418
+ "winapi-i686-pc-windows-gnu",
419
+ "winapi-x86_64-pc-windows-gnu",
420
+ ]
421
+
422
+ [[package]]
423
+ name = "winapi-i686-pc-windows-gnu"
424
+ version = "0.4.0"
425
+ source = "registry+https://github.com/rust-lang/crates.io-index"
426
+ checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
427
+
428
+ [[package]]
429
+ name = "winapi-x86_64-pc-windows-gnu"
430
+ version = "0.4.0"
431
+ source = "registry+https://github.com/rust-lang/crates.io-index"
432
+ checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
data/Cargo.toml ADDED
@@ -0,0 +1,6 @@
1
+ # This Cargo.toml is here to let externals tools (IDEs, etc.) know that this is
2
+ # a Rust project. Your extensions depedencies should be added to the Cargo.toml
3
+ # in the ext/ directory.
4
+
5
+ [workspace]
6
+ members = ["ext/bs62"]
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2023 Garen J. Torikian
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,50 @@
1
+ # Bs62
2
+
3
+ Quick and easy Base62 encoder and decoder. The difference between this gem and many others is that it operates on an
4
+ array of bytes.
5
+
6
+ ## Installation
7
+
8
+ Install the gem and add to the application's Gemfile by executing:
9
+
10
+ $ bundle add bs62
11
+
12
+ If bundler is not being used to manage dependencies, install the gem by executing:
13
+
14
+ $ gem install bs62
15
+
16
+ ## Usage
17
+
18
+ Call `encode` to encode an array of bytes into Base62:
19
+
20
+ ```ruby
21
+ require "bs62"
22
+
23
+ bytes = SecureRandom.hex(4).bytes # [99, 56, 97, 54, 57, 101, 54, 97]
24
+
25
+ Bs62.encode(bytes) # "jY45tzXOpUU"
26
+ ```
27
+
28
+ Similarly, call `decode` to convert a Base62 string to an array of bytes:
29
+
30
+ ```ruby
31
+ require "bs62"
32
+
33
+ str = "jY45tzXOpUU"
34
+
35
+ Bs62.decode(str) # [99, 56, 97, 54, 57, 101, 54, 97]
36
+ ```
37
+
38
+ ## Development
39
+
40
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake compile test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
41
+
42
+ 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 merge that change into `main`.
43
+
44
+ ## Contributing
45
+
46
+ Bug reports and pull requests are welcome on GitHub at https://github.com/gjtorikian/bs62.
47
+
48
+ ## License
49
+
50
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
@@ -0,0 +1,12 @@
1
+ [package]
2
+ name = "bs62"
3
+ version = "1.0.0"
4
+ edition = "2021"
5
+
6
+ [dependencies]
7
+ base-62 = "0.1"
8
+ magnus = "0.5"
9
+
10
+ [lib]
11
+ name = "bs62"
12
+ crate-type = ["cdylib"]
@@ -0,0 +1,4 @@
1
+ require "mkmf"
2
+ require "rb_sys/mkmf"
3
+
4
+ create_rust_makefile("bs62/bs62")
@@ -0,0 +1,32 @@
1
+ extern crate core;
2
+
3
+ use base_62::base62;
4
+ use magnus::{define_class, exception, function, Error, Object};
5
+
6
+ #[magnus::wrap(class = "Bs62")]
7
+ struct Bs62 {}
8
+
9
+ impl Bs62 {
10
+ pub fn perform_encode(rb_array: Vec<u8>) -> String {
11
+ base62::encode(rb_array.as_slice())
12
+ }
13
+ pub fn perform_decode(rb_str: String) -> Result<Vec<u8>, Error> {
14
+ match base62::decode(rb_str.as_str()) {
15
+ Ok(v) => Ok(v),
16
+ Err(e) => Err(magnus::Error::new(
17
+ exception::runtime_error(),
18
+ format!("Could not call decode: {:?}", e),
19
+ )),
20
+ }
21
+ }
22
+ }
23
+
24
+ #[magnus::init]
25
+ fn init() -> Result<(), Error> {
26
+ let c_bs62 = define_class("Bs62", Default::default())?;
27
+
28
+ c_bs62.define_singleton_method("perform_encode", function!(Bs62::perform_encode, 1))?;
29
+ c_bs62.define_singleton_method("perform_decode", function!(Bs62::perform_decode, 1))?;
30
+
31
+ Ok(())
32
+ }
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ begin
4
+ # native precompiled gems package shared libraries in <gem_dir>/lib/bs62/<ruby_version>
5
+ # load the precompiled extension file
6
+ ruby_version = /\d+\.\d+/.match(RUBY_VERSION)
7
+ require_relative "#{ruby_version}/bs62"
8
+ rescue LoadError
9
+ # fall back to the extension compiled upon installation.
10
+ # use "require" instead of "require_relative" because non-native gems will place C extension files
11
+ # in Gem::BasicSpecification#extension_dir after compilation (during normal installation), which
12
+ # is in $LOAD_PATH but not necessarily relative to this file (see nokogiri#2300)
13
+ require "bs62/bs62"
14
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ class Bs62
4
+ VERSION = "0.1.0"
5
+ end
data/lib/bs62.rb ADDED
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "bs62/extension"
4
+
5
+ require "bs62/version"
6
+
7
+ if ENV.fetch("DEBUG", false)
8
+ require "amazing_print"
9
+ require "debug"
10
+ end
11
+
12
+ class Bs62
13
+ class << self
14
+ def encode(bytes)
15
+ raise TypeError, "argument must be an array of bytes; got a #{bytes.class}!" unless bytes.is_a?(Array)
16
+
17
+ Bs62.perform_encode(bytes)
18
+ end
19
+
20
+ def decode(str)
21
+ raise TypeError, "argument must be a String; got a #{str.class}!" unless str.is_a?(String)
22
+
23
+ Bs62.perform_decode(str)
24
+ end
25
+ end
26
+ end
metadata ADDED
@@ -0,0 +1,102 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: bs62
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Garen J. Torikian
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2023-06-06 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rb_sys
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '0.9'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '0.9'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '13.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '13.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake-compiler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.2'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.2'
55
+ description: Base62 encoding and decoding with a focus on simplicity and performance.
56
+ Currently wraps the bs62 Rust crate.
57
+ email:
58
+ - gjtorikian@users.noreply.github.com
59
+ executables: []
60
+ extensions:
61
+ - ext/bs62/extconf.rb
62
+ extra_rdoc_files: []
63
+ files:
64
+ - Cargo.lock
65
+ - Cargo.toml
66
+ - LICENSE.txt
67
+ - README.md
68
+ - ext/bs62/Cargo.toml
69
+ - ext/bs62/extconf.rb
70
+ - ext/bs62/src/lib.rs
71
+ - lib/bs62.rb
72
+ - lib/bs62/extension.rb
73
+ - lib/bs62/version.rb
74
+ homepage: https://github.com/gjtorikian/bs62
75
+ licenses:
76
+ - MIT
77
+ metadata:
78
+ allowed_push_host: https://rubygems.org
79
+ funding_uri: https://github.com/sponsors/gjtorikian/
80
+ source_code_uri: https://github.com/gjtorikian/bs62
81
+ rubygems_mfa_required: 'true'
82
+ post_install_message:
83
+ rdoc_options: []
84
+ require_paths:
85
+ - lib
86
+ required_ruby_version: !ruby/object:Gem::Requirement
87
+ requirements:
88
+ - - "~>"
89
+ - !ruby/object:Gem::Version
90
+ version: '3.1'
91
+ required_rubygems_version: !ruby/object:Gem::Requirement
92
+ requirements:
93
+ - - ">="
94
+ - !ruby/object:Gem::Version
95
+ version: 3.3.22
96
+ requirements: []
97
+ rubygems_version: 3.4.13
98
+ signing_key:
99
+ specification_version: 4
100
+ summary: Fast and lightweight Base62 encoder/decoder. Written in Rust, wrapped in
101
+ Ruby.
102
+ test_files: []