rinru 0.1.0 → 0.1.3
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 +4 -4
- data/README.md +92 -0
- metadata +9 -8
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: ac0bc5ee73902ad4542818e6d50b8ba0c7733bd6ee06b5cba09c8dc70dd506e3
|
|
4
|
+
data.tar.gz: 01eabee27c2d447009b868500803a429477d1d30f32f62bc0b43ed0a7b0a37af
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 4acd173d7fd1f334d598d67eee162437b7c51631098b8d4b042f924de08bd45194f86a8c2cf6e3d0df77d30611a477ac35c2726e847cf3fc4ed42d6087df1960
|
|
7
|
+
data.tar.gz: 332c13431fc377ab5ad389c6073d7eae1cb8556f411ff06621816b95a99721628c550659cb415b1eabd2968e29af04904746d457474092bac3276969549f38e8
|
data/README.md
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
# Rinru
|
|
2
|
+
|
|
3
|
+
Rinru (Rust-in-Ruby) is a lightning-fast, zero-boilerplate framework distributed as a self-contained Ruby gem. It allows you to write and compile complete Rust code ecosystems natively and inject them directly into your running Ruby scripts as global methods.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- **Fluent Injection Pipeline:** Link a Cargo configuration and `.rs` source file straight to a global method name out of thin air.
|
|
8
|
+
- **Embedded Toolchain:** Carries its own private copy of the Rust compiler binary. Users do not need rustup or system-wide Rust paths configured to use it.
|
|
9
|
+
- **Dynamic Variable Ingestion:** Accepts numbers, floating points, and text strings from Ruby, coordinating all FFI pointer allocations automatically.
|
|
10
|
+
- **Incremental MD5 Caching:** Skips compiling on subsequent runs if your Rust files have not changed, keeping execution overhead at zero.
|
|
11
|
+
- **Graceful Error Catching:** Intercepts Rust syntax compilation errors (stderr) and formats them into clean Ruby exception logs rather than crashing your terminal runtime.
|
|
12
|
+
|
|
13
|
+
## Installation
|
|
14
|
+
|
|
15
|
+
You can install the self-contained framework directly onto your system using:
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
gem install rinru
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
Or add this line to your application's Gemfile:
|
|
22
|
+
|
|
23
|
+
```ruby
|
|
24
|
+
gem 'rinru'
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
And then execute:
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
bundle install
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## Usage
|
|
34
|
+
|
|
35
|
+
### 1. Setup a standard Cargo Project Layout
|
|
36
|
+
|
|
37
|
+
Create a project manifest folder (`project/Cargo.toml`):
|
|
38
|
+
|
|
39
|
+
```toml
|
|
40
|
+
[package]
|
|
41
|
+
name = "rinru_math_engine"
|
|
42
|
+
version = "0.1.0"
|
|
43
|
+
edition = "2021"
|
|
44
|
+
|
|
45
|
+
[lib]
|
|
46
|
+
crate-type = ["cdylib"]
|
|
47
|
+
|
|
48
|
+
[dependencies]
|
|
49
|
+
evalexpr = "8.1"
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
Write your high-performance code inside your target source file (`project/src/main.rs`):
|
|
53
|
+
|
|
54
|
+
```rust
|
|
55
|
+
fn main(expression_ptr: *const std::os::raw::c_char) -> i32 {
|
|
56
|
+
if expression_ptr.is_null() { return 0; }
|
|
57
|
+
|
|
58
|
+
let c_str = unsafe { std::ffi::CStr::from_ptr(expression_ptr) };
|
|
59
|
+
let expr_str = c_str.to_str().unwrap_or("0");
|
|
60
|
+
|
|
61
|
+
// Let the evalexpr crate parse and compute the string operations natively
|
|
62
|
+
match evalexpr::eval_int(expr_str) {
|
|
63
|
+
Ok(result) => result as i32,
|
|
64
|
+
Err(_) => 0,
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
### 2. Run it in your Ruby Script
|
|
70
|
+
|
|
71
|
+
Simply chain your configurations together. Once declared, you invoke the variable name as a top-level native Ruby method:
|
|
72
|
+
|
|
73
|
+
```ruby
|
|
74
|
+
require 'rinru'
|
|
75
|
+
|
|
76
|
+
# Chain cargo parsing straight into your target method injection
|
|
77
|
+
rinru.cargo("project/Cargo.toml").var("project/src/main.rs").as("main")
|
|
78
|
+
|
|
79
|
+
# Pass raw math string expressions. Rust calculates the order of operations natively!
|
|
80
|
+
puts main("5 * (10 + 20) - 5")
|
|
81
|
+
# => 145
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
## How It Works Under the Hood
|
|
85
|
+
|
|
86
|
+
1. **`rinru.cargo().var()`** maps out the locations of your source script files.
|
|
87
|
+
2. **`.as("main")`** invokes Rinru's internal rustc environment compiler. It reviews an MD5 hash of your code state. If unchanged, it pulls the library straight from cache; otherwise, it silently generates an optimized release binary `.so`/`.dylib`.
|
|
88
|
+
3. **Dynamic FFI Proxying:** It automatically binds the binary function directly into Ruby's root Kernel workspace, letting you invoke the method natively anywhere in your application.
|
|
89
|
+
|
|
90
|
+
## License
|
|
91
|
+
|
|
92
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org).
|
metadata
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: rinru
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.3
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
|
-
-
|
|
7
|
+
- ''
|
|
8
8
|
bindir: bin
|
|
9
9
|
cert_chain: []
|
|
10
10
|
date: 1980-01-02 00:00:00.000000000 Z
|
|
@@ -27,11 +27,12 @@ executables: []
|
|
|
27
27
|
extensions: []
|
|
28
28
|
extra_rdoc_files: []
|
|
29
29
|
files:
|
|
30
|
+
- README.md
|
|
30
31
|
- lib/rinru.rb
|
|
31
|
-
homepage: https://github.com
|
|
32
|
-
licenses:
|
|
33
|
-
|
|
34
|
-
|
|
32
|
+
homepage: https://github.com/coder2h2/rinru
|
|
33
|
+
licenses: []
|
|
34
|
+
metadata:
|
|
35
|
+
homepage_uri: https://github.com/coder2h2/rinru
|
|
35
36
|
rdoc_options: []
|
|
36
37
|
require_paths:
|
|
37
38
|
- lib
|
|
@@ -39,7 +40,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
39
40
|
requirements:
|
|
40
41
|
- - ">="
|
|
41
42
|
- !ruby/object:Gem::Version
|
|
42
|
-
version:
|
|
43
|
+
version: 3.3.8
|
|
43
44
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
44
45
|
requirements:
|
|
45
46
|
- - ">="
|
|
@@ -48,5 +49,5 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
48
49
|
requirements: []
|
|
49
50
|
rubygems_version: 4.0.22
|
|
50
51
|
specification_version: 4
|
|
51
|
-
summary:
|
|
52
|
+
summary: Rinru - Portable self-contained Rust engine.
|
|
52
53
|
test_files: []
|