# ProofMode Ruby Bindings
Ruby bindings for ProofMode using UniFFI.
## Requirements
- Ruby 2.7 or higher
- FFI gem (requires Ruby development headers)
- ProofMode Rust library compiled with `--features uniffi`
## Installation
### Prerequisites
1. Install Ruby with development headers:
```bash
rvm install 3.2.2
rvm use 3.2.2
```
2. Build the Rust library:
```bash
cd ..
cargo build --release --features uniffi
```
3. Install the gem:
```bash
gem build proofmode.gemspec
gem install proofmode-*.gem
```
## Usage
### Command Line Interface
```bash
# Show version
proofmode version
# Generate proof for a file
proofmode generate /path/to/image.jpg --output ./proofs
# Check files for verification
proofmode check file1.jpg file2.mp4
# Show help
proofmode --help
```
### Ruby Library
```ruby
require 'proofmode'
# Get version
puts Proofmode.get_version()
# Generate proof from file
hash = Proofmode.generate_proof_mobile(
File.read("image.jpg").bytes,
{"creator" => "Ruby App"},
callbacks
)
# Check files
result = Proofmode.check_files_mobile(
["file1.jpg", "file2.mp4"],
progress_callback
)
```
### Implementing Callbacks
```ruby
class MyCallbacks < Proofmode::MobileCallbacks
def get_location
Proofmode::LocationInfo.new(
latitude: 37.7749,
longitude: -122.4194,
altitude: 10.0,
accuracy: 5.0,
timestamp: Time.now
)
end
def get_device_info
Proofmode::DeviceInfo.new(
manufacturer: "Ruby",
model: RUBY_PLATFORM,
os_version: RUBY_VERSION,
device_id: "ruby-device",
imei: nil
)
end
def save_data(hash, filename, data)
File.write("#{hash}/#{filename}", data.pack("C*"))
true
rescue
false
end
def report_progress(message)
puts "Progress: #{message}"
end
end
```
## Development
Generate new bindings after Rust API changes:
```bash
../target/release/uniffi-bindgen generate --library ../target/release/libproofmode.so --language ruby --out-dir lib/generated
```
## Troubleshooting
If you get FFI load errors:
1. Ensure Ruby development headers are installed
2. Check that the Rust library is built: `../target/release/libproofmode.so`
3. Set library path if needed: `export LD_LIBRARY_PATH=$PWD/../target/release:$LD_LIBRARY_PATH`