finox 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: a15f212853df20da508fd87569b5192f8ce118a0db17dc0618021bff0a65e9b2
4
+ data.tar.gz: c05ef1e80ab78e4770f8ea84910b957b9981bd6681844540e42342f83e406635
5
+ SHA512:
6
+ metadata.gz: b56ad84053f70ee5957e27b647148f19d703788d4fd430239d6a4927fa637f21800787e988258093bb1db7c9234792f5bf56ee4f69980fd9fa63cf51d41b9b56
7
+ data.tar.gz: b297a5a6420d07819bcc664823a62cf476f103c4a4de7a4ec98c3824874ce6b214c38dcf46053e550f3d2ad98a51589fa43a683b07aca2f57aacc7e38baadde7
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.rubocop.yml ADDED
@@ -0,0 +1,8 @@
1
+ AllCops:
2
+ TargetRubyVersion: 3.1
3
+
4
+ Style/StringLiterals:
5
+ EnforcedStyle: double_quotes
6
+
7
+ Style/StringLiteralsInInterpolation:
8
+ EnforcedStyle: double_quotes
data/CHANGELOG.md ADDED
@@ -0,0 +1,5 @@
1
+ ## [Unreleased]
2
+
3
+ ## [0.1.0] - 2026-07-17
4
+
5
+ - Initial release
data/Cargo.lock ADDED
@@ -0,0 +1,439 @@
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 = "ar_archive_writer"
16
+ version = "0.5.2"
17
+ source = "registry+https://github.com/rust-lang/crates.io-index"
18
+ checksum = "4087686b4b0a3427190bae57a1d9a478dbb2d40c5dc1bd6e2b6d797913bdd348"
19
+ dependencies = [
20
+ "object",
21
+ ]
22
+
23
+ [[package]]
24
+ name = "bindgen"
25
+ version = "0.72.1"
26
+ source = "registry+https://github.com/rust-lang/crates.io-index"
27
+ checksum = "993776b509cfb49c750f11b8f07a46fa23e0a1386ffc01fb1e7d343efc387895"
28
+ dependencies = [
29
+ "bitflags",
30
+ "cexpr",
31
+ "clang-sys",
32
+ "itertools",
33
+ "proc-macro2",
34
+ "quote",
35
+ "regex",
36
+ "rustc-hash",
37
+ "shlex 1.3.0",
38
+ "syn",
39
+ ]
40
+
41
+ [[package]]
42
+ name = "bitflags"
43
+ version = "2.13.1"
44
+ source = "registry+https://github.com/rust-lang/crates.io-index"
45
+ checksum = "b588b76d00fde79687d7646a9b5bdf3cc0f655e0bbd080335a95d7e96f3587da"
46
+
47
+ [[package]]
48
+ name = "cc"
49
+ version = "1.2.67"
50
+ source = "registry+https://github.com/rust-lang/crates.io-index"
51
+ checksum = "e17dd265a7d0f31ef544e1b20e03add05d3b45b491b633b10d67145d2acc1a38"
52
+ dependencies = [
53
+ "find-msvc-tools",
54
+ "shlex 2.0.1",
55
+ ]
56
+
57
+ [[package]]
58
+ name = "cexpr"
59
+ version = "0.6.0"
60
+ source = "registry+https://github.com/rust-lang/crates.io-index"
61
+ checksum = "6fac387a98bb7c37292057cffc56d62ecb629900026402633ae9160df93a8766"
62
+ dependencies = [
63
+ "nom",
64
+ ]
65
+
66
+ [[package]]
67
+ name = "cfg-if"
68
+ version = "1.0.4"
69
+ source = "registry+https://github.com/rust-lang/crates.io-index"
70
+ checksum = "9330f8b2ff13f34540b44e946ef35111825727b38d33286ef986142615121801"
71
+
72
+ [[package]]
73
+ name = "clang-sys"
74
+ version = "1.8.1"
75
+ source = "registry+https://github.com/rust-lang/crates.io-index"
76
+ checksum = "0b023947811758c97c59bf9d1c188fd619ad4718dcaa767947df1cadb14f39f4"
77
+ dependencies = [
78
+ "glob",
79
+ "libc",
80
+ "libloading",
81
+ ]
82
+
83
+ [[package]]
84
+ name = "either"
85
+ version = "1.16.0"
86
+ source = "registry+https://github.com/rust-lang/crates.io-index"
87
+ checksum = "91622ff5e7162018101f2fea40d6ebf4a78bbe5a49736a2020649edf9693679e"
88
+
89
+ [[package]]
90
+ name = "find-msvc-tools"
91
+ version = "0.1.9"
92
+ source = "registry+https://github.com/rust-lang/crates.io-index"
93
+ checksum = "5baebc0774151f905a1a2cc41989300b1e6fbb29aff0ceffa1064fdd3088d582"
94
+
95
+ [[package]]
96
+ name = "finox"
97
+ version = "0.1.0"
98
+ dependencies = [
99
+ "magnus",
100
+ "serde_magnus",
101
+ "sqlparser",
102
+ ]
103
+
104
+ [[package]]
105
+ name = "glob"
106
+ version = "0.3.3"
107
+ source = "registry+https://github.com/rust-lang/crates.io-index"
108
+ checksum = "0cc23270f6e1808e30a928bdc84dea0b9b4136a8bc82338574f23baf47bbd280"
109
+
110
+ [[package]]
111
+ name = "itertools"
112
+ version = "0.13.0"
113
+ source = "registry+https://github.com/rust-lang/crates.io-index"
114
+ checksum = "413ee7dfc52ee1a4949ceeb7dbc8a33f2d6c088194d9f922fb8318faf1f01186"
115
+ dependencies = [
116
+ "either",
117
+ ]
118
+
119
+ [[package]]
120
+ name = "lazy_static"
121
+ version = "1.5.0"
122
+ source = "registry+https://github.com/rust-lang/crates.io-index"
123
+ checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe"
124
+
125
+ [[package]]
126
+ name = "libc"
127
+ version = "0.2.186"
128
+ source = "registry+https://github.com/rust-lang/crates.io-index"
129
+ checksum = "68ab91017fe16c622486840e4c83c9a37afeff978bd239b5293d61ece587de66"
130
+
131
+ [[package]]
132
+ name = "libloading"
133
+ version = "0.8.9"
134
+ source = "registry+https://github.com/rust-lang/crates.io-index"
135
+ checksum = "d7c4b02199fee7c5d21a5ae7d8cfa79a6ef5bb2fc834d6e9058e89c825efdc55"
136
+ dependencies = [
137
+ "cfg-if",
138
+ "windows-link",
139
+ ]
140
+
141
+ [[package]]
142
+ name = "log"
143
+ version = "0.4.33"
144
+ source = "registry+https://github.com/rust-lang/crates.io-index"
145
+ checksum = "0ceec5bc11778974d1bcb055b18002eba7f4b3518b6a0081b3af5f21666da9ad"
146
+
147
+ [[package]]
148
+ name = "magnus"
149
+ version = "0.8.2"
150
+ source = "registry+https://github.com/rust-lang/crates.io-index"
151
+ checksum = "3b36a5b126bbe97eb0d02d07acfeb327036c6319fd816139a49824a83b7f9012"
152
+ dependencies = [
153
+ "magnus-macros",
154
+ "rb-sys",
155
+ "rb-sys-env",
156
+ "seq-macro",
157
+ ]
158
+
159
+ [[package]]
160
+ name = "magnus-macros"
161
+ version = "0.8.0"
162
+ source = "registry+https://github.com/rust-lang/crates.io-index"
163
+ checksum = "47607461fd8e1513cb4f2076c197d8092d921a1ea75bd08af97398f593751892"
164
+ dependencies = [
165
+ "proc-macro2",
166
+ "quote",
167
+ "syn",
168
+ ]
169
+
170
+ [[package]]
171
+ name = "memchr"
172
+ version = "2.8.3"
173
+ source = "registry+https://github.com/rust-lang/crates.io-index"
174
+ checksum = "cf8baf1c55e62ffcace7a9f06f4bd9cd3f0c4beb022d3b367256b91b87513d98"
175
+
176
+ [[package]]
177
+ name = "minimal-lexical"
178
+ version = "0.2.1"
179
+ source = "registry+https://github.com/rust-lang/crates.io-index"
180
+ checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a"
181
+
182
+ [[package]]
183
+ name = "nom"
184
+ version = "7.1.3"
185
+ source = "registry+https://github.com/rust-lang/crates.io-index"
186
+ checksum = "d273983c5a657a70a3e8f2a01329822f3b8c8172b73826411a55751e404a0a4a"
187
+ dependencies = [
188
+ "memchr",
189
+ "minimal-lexical",
190
+ ]
191
+
192
+ [[package]]
193
+ name = "object"
194
+ version = "0.37.3"
195
+ source = "registry+https://github.com/rust-lang/crates.io-index"
196
+ checksum = "ff76201f031d8863c38aa7f905eca4f53abbfa15f609db4277d44cd8938f33fe"
197
+ dependencies = [
198
+ "memchr",
199
+ ]
200
+
201
+ [[package]]
202
+ name = "proc-macro2"
203
+ version = "1.0.106"
204
+ source = "registry+https://github.com/rust-lang/crates.io-index"
205
+ checksum = "8fd00f0bb2e90d81d1044c2b32617f68fcb9fa3bb7640c23e9c748e53fb30934"
206
+ dependencies = [
207
+ "unicode-ident",
208
+ ]
209
+
210
+ [[package]]
211
+ name = "psm"
212
+ version = "0.1.31"
213
+ source = "registry+https://github.com/rust-lang/crates.io-index"
214
+ checksum = "645dbe486e346d9b5de3ef16ede18c26e6c70ad97418f4874b8b1889d6e761ea"
215
+ dependencies = [
216
+ "ar_archive_writer",
217
+ "cc",
218
+ ]
219
+
220
+ [[package]]
221
+ name = "quote"
222
+ version = "1.0.46"
223
+ source = "registry+https://github.com/rust-lang/crates.io-index"
224
+ checksum = "dfbc457d0c7a0759a614551b11a6409e5951f6c7537be1f1b7682b9ae9230368"
225
+ dependencies = [
226
+ "proc-macro2",
227
+ ]
228
+
229
+ [[package]]
230
+ name = "rb-sys"
231
+ version = "0.9.128"
232
+ source = "registry+https://github.com/rust-lang/crates.io-index"
233
+ checksum = "45ca28513560e56cfb79a62b1fce363c73af170a182024ce880c77ee9429920a"
234
+ dependencies = [
235
+ "rb-sys-build",
236
+ ]
237
+
238
+ [[package]]
239
+ name = "rb-sys-build"
240
+ version = "0.9.128"
241
+ source = "registry+https://github.com/rust-lang/crates.io-index"
242
+ checksum = "ce04b2c55eff3a21aaa623fcc655d94373238e72cac6b3e1a3641ff31649f99a"
243
+ dependencies = [
244
+ "bindgen",
245
+ "lazy_static",
246
+ "proc-macro2",
247
+ "quote",
248
+ "regex",
249
+ "shell-words",
250
+ "syn",
251
+ ]
252
+
253
+ [[package]]
254
+ name = "rb-sys-env"
255
+ version = "0.2.3"
256
+ source = "registry+https://github.com/rust-lang/crates.io-index"
257
+ checksum = "cca7ad6a7e21e72151d56fe2495a259b5670e204c3adac41ee7ef676ea08117a"
258
+
259
+ [[package]]
260
+ name = "recursive"
261
+ version = "0.1.1"
262
+ source = "registry+https://github.com/rust-lang/crates.io-index"
263
+ checksum = "0786a43debb760f491b1bc0269fe5e84155353c67482b9e60d0cfb596054b43e"
264
+ dependencies = [
265
+ "recursive-proc-macro-impl",
266
+ "stacker",
267
+ ]
268
+
269
+ [[package]]
270
+ name = "recursive-proc-macro-impl"
271
+ version = "0.1.1"
272
+ source = "registry+https://github.com/rust-lang/crates.io-index"
273
+ checksum = "76009fbe0614077fc1a2ce255e3a1881a2e3a3527097d5dc6d8212c585e7e38b"
274
+ dependencies = [
275
+ "quote",
276
+ "syn",
277
+ ]
278
+
279
+ [[package]]
280
+ name = "regex"
281
+ version = "1.13.1"
282
+ source = "registry+https://github.com/rust-lang/crates.io-index"
283
+ checksum = "f020237b6c8eed93db2e2cb53c00c60a8e1bc73da7d073199a1180401450218d"
284
+ dependencies = [
285
+ "aho-corasick",
286
+ "memchr",
287
+ "regex-automata",
288
+ "regex-syntax",
289
+ ]
290
+
291
+ [[package]]
292
+ name = "regex-automata"
293
+ version = "0.4.16"
294
+ source = "registry+https://github.com/rust-lang/crates.io-index"
295
+ checksum = "8fcfdb36bda0c880c5931cdc7a2bcdc8ba4556847b9d912bca70bc94708711ad"
296
+ dependencies = [
297
+ "aho-corasick",
298
+ "memchr",
299
+ "regex-syntax",
300
+ ]
301
+
302
+ [[package]]
303
+ name = "regex-syntax"
304
+ version = "0.8.11"
305
+ source = "registry+https://github.com/rust-lang/crates.io-index"
306
+ checksum = "d6f6ff9a378485b298a5286656da665ba74413d36db0979633275d2e708145d4"
307
+
308
+ [[package]]
309
+ name = "rustc-hash"
310
+ version = "2.1.3"
311
+ source = "registry+https://github.com/rust-lang/crates.io-index"
312
+ checksum = "6b1e7f9a428571be2dc5bc0505c13fb6bf936822b894ec87abf8a08a4e51742d"
313
+
314
+ [[package]]
315
+ name = "seq-macro"
316
+ version = "0.3.6"
317
+ source = "registry+https://github.com/rust-lang/crates.io-index"
318
+ checksum = "1bc711410fbe7399f390ca1c3b60ad0f53f80e95c5eb935e52268a0e2cd49acc"
319
+
320
+ [[package]]
321
+ name = "serde"
322
+ version = "1.0.228"
323
+ source = "registry+https://github.com/rust-lang/crates.io-index"
324
+ checksum = "9a8e94ea7f378bd32cbbd37198a4a91436180c5bb472411e48b5ec2e2124ae9e"
325
+ dependencies = [
326
+ "serde_core",
327
+ "serde_derive",
328
+ ]
329
+
330
+ [[package]]
331
+ name = "serde_core"
332
+ version = "1.0.228"
333
+ source = "registry+https://github.com/rust-lang/crates.io-index"
334
+ checksum = "41d385c7d4ca58e59fc732af25c3983b67ac852c1a25000afe1175de458b67ad"
335
+ dependencies = [
336
+ "serde_derive",
337
+ ]
338
+
339
+ [[package]]
340
+ name = "serde_derive"
341
+ version = "1.0.228"
342
+ source = "registry+https://github.com/rust-lang/crates.io-index"
343
+ checksum = "d540f220d3187173da220f885ab66608367b6574e925011a9353e4badda91d79"
344
+ dependencies = [
345
+ "proc-macro2",
346
+ "quote",
347
+ "syn",
348
+ ]
349
+
350
+ [[package]]
351
+ name = "serde_magnus"
352
+ version = "0.11.0"
353
+ source = "registry+https://github.com/rust-lang/crates.io-index"
354
+ checksum = "8ff64c88ddd26acdcad5a501f18bcc339927b77b69f4a03bfaf2a6fc5ba2ac4b"
355
+ dependencies = [
356
+ "magnus",
357
+ "serde",
358
+ "tap",
359
+ ]
360
+
361
+ [[package]]
362
+ name = "shell-words"
363
+ version = "1.1.1"
364
+ source = "registry+https://github.com/rust-lang/crates.io-index"
365
+ checksum = "dc6fe69c597f9c37bfeeeeeb33da3530379845f10be461a66d16d03eca2ded77"
366
+
367
+ [[package]]
368
+ name = "shlex"
369
+ version = "1.3.0"
370
+ source = "registry+https://github.com/rust-lang/crates.io-index"
371
+ checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64"
372
+
373
+ [[package]]
374
+ name = "shlex"
375
+ version = "2.0.1"
376
+ source = "registry+https://github.com/rust-lang/crates.io-index"
377
+ checksum = "f8fadd59c855ef2080decdef8ff161eb6661b86933c9d82e5ba29dc602a55aba"
378
+
379
+ [[package]]
380
+ name = "sqlparser"
381
+ version = "0.62.0"
382
+ source = "registry+https://github.com/rust-lang/crates.io-index"
383
+ checksum = "13c6d1b651dc4edf07eead2a0c6c78016ce971bc2c10da5266861b13f25e7cec"
384
+ dependencies = [
385
+ "log",
386
+ "recursive",
387
+ "serde",
388
+ ]
389
+
390
+ [[package]]
391
+ name = "stacker"
392
+ version = "0.1.24"
393
+ source = "registry+https://github.com/rust-lang/crates.io-index"
394
+ checksum = "640c8cdd92b6b12f5bcb1803ca3bbf5ab96e5e6b6b96b9ab77dabe9e880b3190"
395
+ dependencies = [
396
+ "cc",
397
+ "cfg-if",
398
+ "libc",
399
+ "psm",
400
+ "windows-sys",
401
+ ]
402
+
403
+ [[package]]
404
+ name = "syn"
405
+ version = "2.0.119"
406
+ source = "registry+https://github.com/rust-lang/crates.io-index"
407
+ checksum = "872831b642d1a07999a962a351ed35b955ea2cfc8f3862091e2a240a84f17297"
408
+ dependencies = [
409
+ "proc-macro2",
410
+ "quote",
411
+ "unicode-ident",
412
+ ]
413
+
414
+ [[package]]
415
+ name = "tap"
416
+ version = "1.0.1"
417
+ source = "registry+https://github.com/rust-lang/crates.io-index"
418
+ checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369"
419
+
420
+ [[package]]
421
+ name = "unicode-ident"
422
+ version = "1.0.24"
423
+ source = "registry+https://github.com/rust-lang/crates.io-index"
424
+ checksum = "e6e4313cd5fcd3dad5cafa179702e2b244f760991f45397d14d4ebf38247da75"
425
+
426
+ [[package]]
427
+ name = "windows-link"
428
+ version = "0.2.1"
429
+ source = "registry+https://github.com/rust-lang/crates.io-index"
430
+ checksum = "f0805222e57f7521d6a62e36fa9163bc891acd422f971defe97d64e70d0a4fe5"
431
+
432
+ [[package]]
433
+ name = "windows-sys"
434
+ version = "0.61.2"
435
+ source = "registry+https://github.com/rust-lang/crates.io-index"
436
+ checksum = "ae137229bcbd6cdf0f7b80a31df61766145077ddf49416a728b02cb3921ff3fc"
437
+ dependencies = [
438
+ "windows-link",
439
+ ]
data/Cargo.toml ADDED
@@ -0,0 +1,7 @@
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/finox"]
7
+ resolver = "2"
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2026 kyuuri1791
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,60 @@
1
+ # Finox
2
+
3
+ A MySQL query parser for Ruby, powered by [sqlparser-rs](https://github.com/apache/datafusion-sqlparser-rs).
4
+
5
+ Finox parses SQL with Rust and returns the AST as plain Ruby Hashes and Arrays.
6
+
7
+ ## Installation
8
+
9
+ Add to your Gemfile:
10
+
11
+ ```bash
12
+ bundle add finox
13
+ ```
14
+
15
+ Or install directly:
16
+
17
+ ```bash
18
+ gem install finox
19
+ ```
20
+
21
+ A Rust toolchain is required to build the native extension.
22
+
23
+ ## Usage
24
+
25
+ ```ruby
26
+ require "finox"
27
+
28
+ ast = Finox.parse("SELECT `name` FROM `users` WHERE id = 1")
29
+ # => [{"Query" => {with: nil, body: {"Select" => {...}}, ...}}]
30
+
31
+ ast.dig(0, "Query", :body, "Select", :projection)
32
+ # => [{"UnnamedExpr" =>
33
+ # {"Identifier" =>
34
+ # {value: "name",
35
+ # quote_style: "`",
36
+ # span: {start: {line: 1, column: 8}, end: {line: 1, column: 14}}}}}]
37
+ ```
38
+
39
+ `Finox.parse` returns one Hash per statement, so `"SELECT 1; SELECT 2"` yields an array of two.
40
+
41
+ Key convention (from serde's externally tagged enums): enum variant names are `String` keys (`"Query"`, `"Select"`, `"Identifier"`), struct fields are `Symbol` keys (`:body`, `:projection`, `:value`).
42
+
43
+ Invalid SQL raises `Finox::ParseError`:
44
+
45
+ ```ruby
46
+ Finox.parse("SELEKT 1")
47
+ # => Finox::ParseError: sql parser error: Expected: an SQL statement, found: SELEKT at Line: 1, Column: 1
48
+ ```
49
+
50
+ ## Development
51
+
52
+ ```bash
53
+ bundle install
54
+ bundle exec rake compile # build the Rust extension
55
+ bundle exec rake # compile + spec + rubocop
56
+ ```
57
+
58
+ ## License
59
+
60
+ [MIT](LICENSE.txt)
data/Rakefile ADDED
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ require "rspec/core/rake_task"
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
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("finox.gemspec")
17
+
18
+ RbSys::ExtensionTask.new("finox", GEMSPEC) do |ext|
19
+ ext.lib_dir = "lib/finox"
20
+ end
21
+
22
+ task default: %i[compile spec rubocop]
@@ -0,0 +1,15 @@
1
+ [package]
2
+ name = "finox"
3
+ version = "0.1.0"
4
+ edition = "2021"
5
+ authors = ["kyuuri1791"]
6
+ license = "MIT"
7
+ publish = false
8
+
9
+ [lib]
10
+ crate-type = ["cdylib"]
11
+
12
+ [dependencies]
13
+ magnus = "0.8"
14
+ serde_magnus = "0.11.0"
15
+ sqlparser = { version = "0.62.0", features = ["serde"] }
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "mkmf"
4
+ require "rb_sys/mkmf"
5
+
6
+ create_rust_makefile("finox/finox")
@@ -0,0 +1,23 @@
1
+ use magnus::{function, prelude::*, value::Lazy, Error, ExceptionClass, Ruby, Value};
2
+ use sqlparser::{dialect::MySqlDialect, parser::Parser};
3
+
4
+ static PARSE_ERROR: Lazy<ExceptionClass> = Lazy::new(|ruby| {
5
+ ruby.define_module("Finox")
6
+ .unwrap()
7
+ .define_error("ParseError", ruby.exception_standard_error())
8
+ .unwrap()
9
+ });
10
+
11
+ fn parse(ruby: &Ruby, sql: String) -> Result<Value, Error> {
12
+ let statements = Parser::parse_sql(&MySqlDialect {}, &sql)
13
+ .map_err(|e| Error::new(ruby.get_inner(&PARSE_ERROR), e.to_string()))?;
14
+ serde_magnus::serialize(ruby, &statements)
15
+ }
16
+
17
+ #[magnus::init]
18
+ fn init(ruby: &Ruby) -> Result<(), Error> {
19
+ let module = ruby.define_module("Finox")?;
20
+ Lazy::force(&PARSE_ERROR, ruby);
21
+ module.define_singleton_method("parse", function!(parse, 1))?;
22
+ Ok(())
23
+ }
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Finox
4
+ VERSION = "0.1.0"
5
+ end
data/lib/finox.rb ADDED
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "finox/version"
4
+
5
+ begin
6
+ # Precompiled native gems ship one shared object per minor Ruby version.
7
+ ruby_minor = RUBY_VERSION[/\d+\.\d+/]
8
+ require_relative "finox/#{ruby_minor}/finox"
9
+ rescue LoadError
10
+ require_relative "finox/finox"
11
+ end
metadata ADDED
@@ -0,0 +1,71 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: finox
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - kyuuri1791
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.128
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.128
26
+ description: Parses MySQL queries with the Rust sqlparser crate (via magnus) and returns
27
+ the AST as plain Ruby Hashes and Arrays.
28
+ executables: []
29
+ extensions:
30
+ - ext/finox/extconf.rb
31
+ extra_rdoc_files: []
32
+ files:
33
+ - ".rspec"
34
+ - ".rubocop.yml"
35
+ - CHANGELOG.md
36
+ - Cargo.lock
37
+ - Cargo.toml
38
+ - LICENSE.txt
39
+ - README.md
40
+ - Rakefile
41
+ - ext/finox/Cargo.toml
42
+ - ext/finox/extconf.rb
43
+ - ext/finox/src/lib.rs
44
+ - lib/finox.rb
45
+ - lib/finox/version.rb
46
+ homepage: https://github.com/kyuuri1791/finox
47
+ licenses:
48
+ - MIT
49
+ metadata:
50
+ homepage_uri: https://github.com/kyuuri1791/finox
51
+ source_code_uri: https://github.com/kyuuri1791/finox
52
+ changelog_uri: https://github.com/kyuuri1791/finox/blob/main/CHANGELOG.md
53
+ rubygems_mfa_required: 'true'
54
+ rdoc_options: []
55
+ require_paths:
56
+ - lib
57
+ required_ruby_version: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: 3.1.0
62
+ required_rubygems_version: !ruby/object:Gem::Requirement
63
+ requirements:
64
+ - - ">="
65
+ - !ruby/object:Gem::Version
66
+ version: 3.3.11
67
+ requirements: []
68
+ rubygems_version: 3.6.9
69
+ specification_version: 4
70
+ summary: MySQL query parser for Ruby, powered by sqlparser-rs.
71
+ test_files: []