nexusq 4.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 +7 -0
- data/README.md +71 -0
- data/examples/smoke/smoke.rb +29 -0
- data/lib/nexusq.rb +50 -0
- metadata +56 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: fc02cce3fd358aad750b503011f71a74be3788f74eae505f0f5ffa2295f8466c
|
|
4
|
+
data.tar.gz: 7a8f14601b0b7036eca9e83279b54abbfee9f0d1806b1689d37e2eec6c09ac85
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 4507def0f5dd466ef8becd4bc1395436b33d7adfd0d5bdff73d2e493deac679eebafb031a64d189782b3ced2061655fa51a1af5fbc79f64a6cb7864aac7bcd58
|
|
7
|
+
data.tar.gz: 5f3bfde921eb8734001f5fefdb54db60540766c634980ffe9fa5e178fa7cb5559285b4c31440b7a967b10fdd02c5eec69a4b319ce063226f6ab3564d2788f09d
|
data/README.md
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
# NEXUS-Q Ruby SDK
|
|
2
|
+
|
|
3
|
+
Ruby bindings for NEXUS-Q. A thin wrapper over the [C SDK](../../crates/nexusq-c)
|
|
4
|
+
using the `ffi` gem. It does not reimplement anything: every call goes
|
|
5
|
+
through `libnexusq`.
|
|
6
|
+
|
|
7
|
+
## Requirements
|
|
8
|
+
|
|
9
|
+
- Ruby 3.0 or newer.
|
|
10
|
+
- The `ffi` gem (`gem install ffi`).
|
|
11
|
+
- The C SDK built (`cargo build -p nexusq-c`).
|
|
12
|
+
- `libnexusq.so` available at runtime through `LD_LIBRARY_PATH` or
|
|
13
|
+
`NEXUSQ_LIBRARY`.
|
|
14
|
+
|
|
15
|
+
## Usage
|
|
16
|
+
|
|
17
|
+
```ruby
|
|
18
|
+
require "ffi"
|
|
19
|
+
require_relative "bindings/ruby/nexusq"
|
|
20
|
+
|
|
21
|
+
puts "nexusq version: #{Nexusq.version}"
|
|
22
|
+
|
|
23
|
+
vault = Nexusq::Vault.create("my.nqv", "password", "my-label")
|
|
24
|
+
puts "vault created at #{vault.path}"
|
|
25
|
+
puts "format version: #{vault.format_version}"
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
Run with:
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
NEXUSQ_LIBRARY=/path/to/nexusq/target/debug/libnexusq.so ruby your_program.rb
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
If the library directory is already on the dynamic loader path:
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
LD_LIBRARY_PATH=/path/to/nexusq/target/debug ruby your_program.rb
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## What is available
|
|
41
|
+
|
|
42
|
+
- `Nexusq.version` — returns the library version.
|
|
43
|
+
- `Nexusq.last_error` — returns the last C SDK error message.
|
|
44
|
+
- `Nexusq::Vault`:
|
|
45
|
+
- `Nexusq::Vault.create(path, password, label)` — creates a new vault.
|
|
46
|
+
- `vault.path` — returns the vault file path.
|
|
47
|
+
- `vault.format_version` — returns the format version.
|
|
48
|
+
|
|
49
|
+
More operations land as the C SDK grows.
|
|
50
|
+
|
|
51
|
+
## Testing
|
|
52
|
+
|
|
53
|
+
The smoke test lives at `examples/smoke/smoke.rb`. From the repository root:
|
|
54
|
+
|
|
55
|
+
```bash
|
|
56
|
+
NEXUSQ_LIBRARY=target/debug/libnexusq.so \\
|
|
57
|
+
ruby bindings/ruby/examples/smoke/smoke.rb
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
Expected output:
|
|
61
|
+
|
|
62
|
+
```
|
|
63
|
+
nexusq version: 0.1.0
|
|
64
|
+
vault created at /tmp/nexusq_ruby_smoke_1234.nqv
|
|
65
|
+
vault format version: 1
|
|
66
|
+
smoke test passed
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
The Ruby binding is intentionally a thin wrapper over the C SDK, matching
|
|
70
|
+
the Go SDK architecture. No cryptography or business logic is duplicated
|
|
71
|
+
in Ruby.
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# Smoke test for the NEXUS-Q Ruby SDK.
|
|
4
|
+
#
|
|
5
|
+
# Run from the repository root:
|
|
6
|
+
# NEXUSQ_LIBRARY=target/debug/libnexusq.so ruby bindings/ruby/examples/smoke/smoke.rb
|
|
7
|
+
|
|
8
|
+
require "rubygems"
|
|
9
|
+
require "tmpdir"
|
|
10
|
+
require_relative "../../lib/nexusq"
|
|
11
|
+
|
|
12
|
+
puts "nexusq version: #{Nexusq.version}"
|
|
13
|
+
|
|
14
|
+
path = File.join(Dir.tmpdir, "nexusq_ruby_smoke_#{$$}.nqv")
|
|
15
|
+
File.delete(path) if File.exist?(path)
|
|
16
|
+
|
|
17
|
+
begin
|
|
18
|
+
vault = Nexusq::Vault.create(path, "ruby-test", "ruby-smoke")
|
|
19
|
+
|
|
20
|
+
abort "vault file was not created" unless File.file?(path)
|
|
21
|
+
abort "vault.path does not match input" unless vault.path == path
|
|
22
|
+
abort "format_version must be 1" unless vault.format_version == 1
|
|
23
|
+
|
|
24
|
+
puts "vault created at #{vault.path}"
|
|
25
|
+
puts "vault format version: #{vault.format_version}"
|
|
26
|
+
puts "smoke test passed"
|
|
27
|
+
ensure
|
|
28
|
+
File.delete(path) if File.exist?(path)
|
|
29
|
+
end
|
data/lib/nexusq.rb
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# NEXUS-Q Ruby bindings.
|
|
4
|
+
#
|
|
5
|
+
# This is a thin FFI wrapper over the C SDK. It does not reimplement
|
|
6
|
+
# cryptography or business logic; every operation delegates to libnexusq.
|
|
7
|
+
|
|
8
|
+
require "ffi"
|
|
9
|
+
|
|
10
|
+
module Nexusq
|
|
11
|
+
extend FFI::Library
|
|
12
|
+
|
|
13
|
+
ffi_lib ENV.fetch("NEXUSQ_LIBRARY", "nexusq")
|
|
14
|
+
|
|
15
|
+
attach_function :nexusq_version, [], :string
|
|
16
|
+
attach_function :nexusq_last_error_message, [], :string
|
|
17
|
+
attach_function :nexusq_vault_create, [:string, :string, :string], :int32
|
|
18
|
+
attach_function :nexusq_vault_format_version, [:string], :int32
|
|
19
|
+
|
|
20
|
+
def self.version
|
|
21
|
+
nexusq_version
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def self.last_error
|
|
25
|
+
nexusq_last_error_message
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
class Vault
|
|
29
|
+
attr_reader :path, :format_version
|
|
30
|
+
|
|
31
|
+
def self.create(path, password, label = nil)
|
|
32
|
+
rc = Nexusq.nexusq_vault_create(path, password, label)
|
|
33
|
+
raise Error, Nexusq.last_error || "NEXUS-Q operation failed" unless rc.zero?
|
|
34
|
+
|
|
35
|
+
version = Nexusq.nexusq_vault_format_version(path)
|
|
36
|
+
raise Error, Nexusq.last_error || "NEXUS-Q operation failed" if version.negative?
|
|
37
|
+
|
|
38
|
+
new(path, version)
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def initialize(path, format_version)
|
|
42
|
+
@path = path
|
|
43
|
+
@format_version = format_version
|
|
44
|
+
end
|
|
45
|
+
private_class_method :new
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
class Error < StandardError
|
|
49
|
+
end
|
|
50
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: nexusq
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 4.1.0
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- lecodev-26
|
|
8
|
+
bindir: bin
|
|
9
|
+
cert_chain: []
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
11
|
+
dependencies:
|
|
12
|
+
- !ruby/object:Gem::Dependency
|
|
13
|
+
name: ffi
|
|
14
|
+
requirement: !ruby/object:Gem::Requirement
|
|
15
|
+
requirements:
|
|
16
|
+
- - "~>"
|
|
17
|
+
- !ruby/object:Gem::Version
|
|
18
|
+
version: '1.15'
|
|
19
|
+
type: :runtime
|
|
20
|
+
prerelease: false
|
|
21
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
22
|
+
requirements:
|
|
23
|
+
- - "~>"
|
|
24
|
+
- !ruby/object:Gem::Version
|
|
25
|
+
version: '1.15'
|
|
26
|
+
description: Thin FFI wrapper over the NEXUS-Q C SDK (libnexusq). No cryptography
|
|
27
|
+
or business logic lives here.
|
|
28
|
+
executables: []
|
|
29
|
+
extensions: []
|
|
30
|
+
extra_rdoc_files: []
|
|
31
|
+
files:
|
|
32
|
+
- README.md
|
|
33
|
+
- examples/smoke/smoke.rb
|
|
34
|
+
- lib/nexusq.rb
|
|
35
|
+
homepage: https://github.com/lecodev-26/nexus-q
|
|
36
|
+
licenses:
|
|
37
|
+
- MIT OR Apache-2.0
|
|
38
|
+
metadata: {}
|
|
39
|
+
rdoc_options: []
|
|
40
|
+
require_paths:
|
|
41
|
+
- lib
|
|
42
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
43
|
+
requirements:
|
|
44
|
+
- - ">="
|
|
45
|
+
- !ruby/object:Gem::Version
|
|
46
|
+
version: '3.0'
|
|
47
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
48
|
+
requirements:
|
|
49
|
+
- - ">="
|
|
50
|
+
- !ruby/object:Gem::Version
|
|
51
|
+
version: '0'
|
|
52
|
+
requirements: []
|
|
53
|
+
rubygems_version: 3.6.9
|
|
54
|
+
specification_version: 4
|
|
55
|
+
summary: Ruby bindings for NEXUS-Q
|
|
56
|
+
test_files: []
|