libsql_ruby 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.
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/libsql"]
7
+ resolver = "2"
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2024 Haile Lagi
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,48 @@
1
+ # LibSQL Ruby
2
+
3
+ A low-level ruby driver for libSQL/SQLite3.
4
+
5
+ ## Example
6
+
7
+ ```ruby
8
+ require "libsql_ruby"
9
+
10
+ db = LibSQL::Database.new "test.db"
11
+
12
+ rows = db.execute <<-SQL
13
+ create table user (
14
+ name varchar(30),
15
+ age int
16
+ );
17
+ SQL
18
+ ```
19
+
20
+ ## Installation
21
+
22
+ 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.
23
+
24
+ Install the gem and add to the application's Gemfile by executing:
25
+
26
+ $ bundle add UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG
27
+
28
+ If bundler is not being used to manage dependencies, install the gem by executing:
29
+
30
+ $ gem install UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG
31
+
32
+ ## Usage
33
+
34
+ TODO: Write usage instructions here
35
+
36
+ ## Development
37
+
38
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
39
+
40
+ 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).
41
+
42
+ ## Contributing
43
+
44
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/libsql.
45
+
46
+ ## License
47
+
48
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,35 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ require "rspec/core/rake_task"
5
+ require "rubocop/rake_task"
6
+ require "rb_sys/extensiontask"
7
+
8
+ RSpec::Core::RakeTask.new(:spec)
9
+ RuboCop::RakeTask.new
10
+
11
+ GEMSPEC = Gem::Specification.load("libsql.gemspec")
12
+
13
+ RbSys::ExtensionTask.new("libsql", GEMSPEC) do |ext|
14
+ ext.lib_dir = "lib/libsql"
15
+ end
16
+
17
+ begin
18
+ require "ruby_memcheck"
19
+ require "ruby_memcheck/rspec/rake_task"
20
+
21
+ namespace :spec do
22
+ RubyMemcheck::RSpec::RakeTask.new(:valgrind)
23
+ end
24
+ rescue LoadError => e
25
+ warn("ruby memcheck not available, cannot run valgrind #{e}")
26
+ end
27
+
28
+ desc "Compile the extension with debug symbols"
29
+ task "compile:debug" do
30
+ ENV["RB_SYS_CARGO_PROFILE"] = "dev"
31
+ Rake::Task["compile"].invoke
32
+ end
33
+
34
+ task build: :compile
35
+ task default: %i[compile spec rubocop]
@@ -0,0 +1,35 @@
1
+ [package]
2
+ name = "libsql"
3
+ version = "0.1.0"
4
+ description = "ruby interface for libSQL"
5
+ edition = "2021"
6
+ authors = ["Haile Lagi <52631736+hailelagi@users.noreply.github.com>"]
7
+ license = "MIT"
8
+ publish = false
9
+
10
+ [lib]
11
+ crate-type = ["cdylib"]
12
+
13
+ [dev-dependencies]
14
+ rb-sys-env = { version = "0.1" }
15
+ rb-sys-test-helpers = { version = "0.2" }
16
+
17
+ [dependencies]
18
+ bytes = "1.5.0"
19
+ lazy_static = "1.4.0"
20
+ tokio = { version = "1.29.1", features = [ "rt-multi-thread" ] }
21
+ magnus = { version = "0.7.1", features = ["rb-sys"] }
22
+ rb-sys = { version = "0.9.98", features = ["global-allocator"] }
23
+ hyper-rustls = { version = "0.25", features = ["webpki-roots"]}
24
+ tracing-subscriber = { version = "0.3", features = ["env-filter"] }
25
+ libsql = { version = "0.3.5", features = ["remote", "replication", "core", "encryption"] }
26
+ once_cell = "1.19.0"
27
+ serde = { version = "1.0.199", features = ["derive"]}
28
+ serde_json = "1.0.116"
29
+ uuid = "1.8.0"
30
+
31
+ [profile.release]
32
+ debug = false
33
+ strip = true
34
+ panic = "abort"
35
+
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "mkmf"
4
+ require "rb_sys/mkmf"
5
+
6
+ create_rust_makefile("libsql/libsql")
@@ -0,0 +1,23 @@
1
+ //! Database.rs
2
+ //!
3
+ //!
4
+
5
+ #[cfg(test)]
6
+ mod tests {
7
+ use rb_sys_test_helpers::ruby_test;
8
+ use rb_sys::{rb_num2fix, rb_int2big, FIXNUM_P};
9
+
10
+ #[ruby_test]
11
+ fn test_something() {
12
+ // Your test code here will have a valid Ruby VM (hint: this works with
13
+ // the `magnus` crate, too!)
14
+ //
15
+ // ...
16
+
17
+ let int = unsafe { rb_num2fix(1) };
18
+ let big = unsafe { rb_int2big(9999999) };
19
+
20
+ assert!(FIXNUM_P(int));
21
+ assert!(!FIXNUM_P(big));
22
+ }
23
+ }
@@ -0,0 +1,14 @@
1
+ use magnus::{function, prelude::*, Error, Ruby};
2
+
3
+ mod database;
4
+
5
+ fn hello(subject: String) -> String {
6
+ format!("Hello from Rust, {subject}!")
7
+ }
8
+
9
+ #[magnus::init]
10
+ fn init(ruby: &Ruby) -> Result<(), Error> {
11
+ let module = ruby.define_module("LibSQL")?;
12
+ module.define_singleton_method("hello", function!(hello, 1))?;
13
+ Ok(())
14
+ }
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ module LibSQL
4
+ VERSION = "0.1.0"
5
+ SQLITE3_VERSION = "0.0.0"
6
+ end
data/lib/libsql.rb ADDED
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "libsql/version"
4
+ require_relative "libsql/libsql"
5
+
6
+ module LibSQL
7
+ class Error < StandardError; end
8
+ # Your code goes here...
9
+ end
data/sig/libsql.rbs ADDED
@@ -0,0 +1,4 @@
1
+ module LibSQL
2
+ VERSION: String
3
+ # See the writing guide of rbs: https://github.com/ruby/rbs#guides
4
+ end
metadata ADDED
@@ -0,0 +1,76 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: libsql_ruby
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Haile Lagi
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2024-07-17 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rubocop
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 1.59.0
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 1.59.0
27
+ description:
28
+ email:
29
+ - 52631736+hailelagi@users.noreply.github.com
30
+ executables: []
31
+ extensions:
32
+ - ext/libsql/Cargo.toml
33
+ extra_rdoc_files: []
34
+ files:
35
+ - ".rspec"
36
+ - ".rubocop.yml"
37
+ - CHANGELOG.md
38
+ - Cargo.lock
39
+ - Cargo.toml
40
+ - LICENSE.txt
41
+ - README.md
42
+ - Rakefile
43
+ - ext/libsql/Cargo.toml
44
+ - ext/libsql/extconf.rb
45
+ - ext/libsql/src/database.rs
46
+ - ext/libsql/src/lib.rs
47
+ - lib/libsql.rb
48
+ - lib/libsql/version.rb
49
+ - sig/libsql.rbs
50
+ homepage: https://github.com/hailelagi/libsql_ruby
51
+ licenses:
52
+ - MIT
53
+ metadata:
54
+ homepage_uri: https://github.com/hailelagi/libsql_ruby
55
+ source_code_uri: https://github.com/hailelagi/libsql_ruby
56
+ changelog_uri: https://github.com/hailelagi/libsql_ruby/CHANGELOG.md
57
+ post_install_message:
58
+ rdoc_options: []
59
+ require_paths:
60
+ - lib
61
+ required_ruby_version: !ruby/object:Gem::Requirement
62
+ requirements:
63
+ - - ">="
64
+ - !ruby/object:Gem::Version
65
+ version: 3.0.0
66
+ required_rubygems_version: !ruby/object:Gem::Requirement
67
+ requirements:
68
+ - - ">="
69
+ - !ruby/object:Gem::Version
70
+ version: 3.3.11
71
+ requirements: []
72
+ rubygems_version: 3.5.15
73
+ signing_key:
74
+ specification_version: 4
75
+ summary: Ruby driver for libSQL.
76
+ test_files: []