prql-rb 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: e8fc9167afeb1580aa484896e1b83417f058ecf7b6b0bd88de35e585f461d4db
4
+ data.tar.gz: e284f825ac898a37c10d0d441fc0d9d26f8ad1522e2284c3dfe382c535396131
5
+ SHA512:
6
+ metadata.gz: 5a87ee2963ab7d4bc81c27a6469c5529e87bf0e0c75246bdee8e7775ba0fdf3331f1fa6d68297d610efad3a0985a34800c7c94dd01f4977926df1bcf5ca2b52a
7
+ data.tar.gz: f5413dbce65691d81f424ff0bf1cd906d23d1d226238651aa053afbb5a42fa9683ace267201d17ffcd7c53d0dca91c00dc367f19d95c9d0cde87580ed917f2a5
data/LICENSE ADDED
@@ -0,0 +1,3 @@
1
+ This project is licensed under the GNU Affero General Public License version 3
2
+ or any later version. See the repository-level LICENSE file for the complete
3
+ license text.
data/README.md ADDED
@@ -0,0 +1,57 @@
1
+ # prql-rb
2
+
3
+ Ruby bindings for the [PRQL compiler](https://prql-lang.org) (`prqlc`), a
4
+ Rust implementation of the PRQL pipelined query language.
5
+
6
+ ```ruby
7
+ require "prql-rb"
8
+
9
+ PrqlRb.compile(<<~PRQL)
10
+ from transactions
11
+ filter amount > 100
12
+ select { id, amount }
13
+ PRQL
14
+ # => SELECT * FROM transactions WHERE amount > 100 ... (SQL)
15
+ ```
16
+
17
+ The default target dialect is PostgreSQL. Compilation failures raise
18
+ `PrqlRb::CompileError`. No SQL is ever executed.
19
+
20
+ ## Installation
21
+
22
+ Add to your Gemfile:
23
+
24
+ ```ruby
25
+ gem "prql-rb"
26
+ ```
27
+
28
+ Precompiled platform gems are published for `aarch64-linux`,
29
+ `x86_64-linux`, `arm64-darwin` and `x86_64-darwin`, so `bundle install`
30
+ works without a Rust toolchain on those platforms. Other platforms
31
+ build from source (requires Ruby 3.2+, Rust 1.85+).
32
+
33
+ ## API
34
+
35
+ - `PrqlRb.compile(source, target:, format:, signature_comment:)` —
36
+ compile PRQL source to a SQL string.
37
+ - `target` — SQL dialect, e.g. `"sql.postgres"` (default),
38
+ `"sql.sqlite"`, `"sql.ansi"`.
39
+ - `format` — pretty-print the output SQL (default `true`).
40
+ - `signature_comment` — append the compiler signature as a comment
41
+ (default `false`).
42
+ - `PrqlRb.compiler_version` — the bundled prqlc version.
43
+
44
+ ## Development
45
+
46
+ ```sh
47
+ bin/setup # bundle install + compile the extension
48
+ rake # clobber + compile + test
49
+ ```
50
+
51
+ To release: tag a commit `vX.Y.Z` and push — CI builds the platform
52
+ gems, attaches them to the GitHub release, and pushes everything to
53
+ RubyGems.org.
54
+
55
+ ## License
56
+
57
+ AGPL-3.0-or-later
data/bin/compile ADDED
@@ -0,0 +1,18 @@
1
+ require "fileutils"
2
+ require "rbconfig"
3
+
4
+ gem_root = File.expand_path("..", __dir__)
5
+ extension_dir = File.join(gem_root, "ext", "prql_rb")
6
+ lib_dir = File.join(gem_root, "lib")
7
+
8
+ Dir.chdir(extension_dir) do
9
+ system RbConfig.ruby, "extconf.rb", exception: true
10
+ system ENV.fetch("MAKE", "make"), exception: true
11
+ end
12
+
13
+ destination_dir = File.join(lib_dir, "prql_rb")
14
+ FileUtils.mkdir_p(destination_dir)
15
+ FileUtils.cp(
16
+ File.join(extension_dir, "prql_rb.#{RbConfig::CONFIG.fetch("DLEXT")}"),
17
+ destination_dir
18
+ )
data/bin/setup ADDED
@@ -0,0 +1,19 @@
1
+ #!/usr/bin/env ruby
2
+ require "fileutils"
3
+
4
+ APP_ROOT = File.expand_path("..", __dir__)
5
+
6
+ def system!(*args)
7
+ system(*args, exception: true)
8
+ end
9
+
10
+ FileUtils.chdir APP_ROOT do
11
+ puts "== Installing dependencies =="
12
+ system("bundle check") || system!("bundle install")
13
+
14
+ puts "\n== Compiling native extension =="
15
+ system!("bundle exec ruby bin/compile")
16
+
17
+ puts "\n== Running tests =="
18
+ system!("bundle exec rake test")
19
+ end