Skip to content

Commit

Permalink
Fix some typos in the book (#375)
Browse files Browse the repository at this point in the history
  • Loading branch information
stomar authored May 29, 2024
1 parent 71a2148 commit dd239e6
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 13 deletions.
3 changes: 2 additions & 1 deletion book/src/SUMMARY.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Summary

[Introduction](./introduction.md) [Getting Started](./getting-started.md)
[Introduction](./introduction.md)
[Getting Started](./getting-started.md)
[Background and Concepts](./background-and-concepts.md)

---
Expand Down
8 changes: 4 additions & 4 deletions book/src/background-and-concepts.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
## World's Simplest Rust Extension

To illustrate how native extensions work, we are going to create the simplest possible native extension for Ruby. This
is only to shows the core concepts of how native extensions work under the hood.
is only to show the core concepts of how native extensions work under the hood.

```rust
// simplest_rust_extenion.rs
Expand All @@ -25,7 +25,7 @@ unsafe extern "C" fn Init_simplest_rust_extension() {
}
```

Then, its a matter of compiling and running like so:
Then, it's a matter of compiling and running like so:

```sh
$ rustc --crate-type=cdylib simplest_rust_extension.rs -o simplest_rust_extension.bundle -C link-arg="-Wl,-undefined,dynamic_lookup"
Expand All @@ -49,7 +49,7 @@ $ ruby --dump=insns -e '2 + 3'

In this example, `2` and `3` are pushed onto the stack, and then `opt_plus` performs the addition.

For a native gem, we bypass this mechanism entirely and instead exposes native machine code to Ruby. In our native code,
For a native gem, we bypass this mechanism entirely and instead expose native machine code to Ruby. In our native code,
we can use the [Ruby C API] to interact with the Ruby VM.

## How are native Gems loaded?
Expand All @@ -62,7 +62,7 @@ the system equivalent). After that, Ruby will call `Init_some_gem` so the native

C is often referred to as the "lingua franca" of the programming language world, and Rust is fluent. Rust can compile
functions to be compatible with the C calling conventions, and align items in memory in a way that C understands. Rust
also does not have a garbage collector, which makes integration signifcantly easier.
also does not have a garbage collector, which makes integration significantly easier.

When Ruby loads a gem extension written in Rust, it has no idea the gem is actually written in Rust. Due to Rust's
robust C FFI, you can code anything in Rust that you could with C.
Expand Down
4 changes: 2 additions & 2 deletions book/src/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ and `magnus`.
```

This will create a new gem in the `my_gem_name` directory. Firstly, open up `my_gem_name.gemspec` in your text editor
and make sure you update all fields that contain `TODO`. Inside the directly, you should now have a fully working Rust
and make sure you update all fields that contain `TODO`. Inside the directory, you should now have a fully working Rust
gem.

> **💡 Tip:** [Join the Slack channel][slack] to ask questions and get help from the community!
Expand All @@ -37,7 +37,7 @@ The default Rake task is configured to compile the Rust code and run tests. Simp
$ bundle exec rake
```

At this point you should start reading the docs for [`magnus`][magnus] to get familiar with the API. It is design to be
At this point you should start reading the docs for [`magnus`][magnus] to get familiar with the API. It is designed to be
a safe and idiomatic wrapper around the Ruby C API.

## Next steps
Expand Down
12 changes: 6 additions & 6 deletions book/src/tutorial/publishing/cross-compilation.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# Cross-Compilation

Publishing native gem binaries is incredibly important for Ruby on Rust gems. No one likes seeing the infamous
`Compiling native extensions. This could take a while...` message when they install a gem. An in Rust, we all know that
`Compiling native extensions. This could take a while...` message when they install a gem. And in Rust, we all know that
compiling can take a while...

It's important to make sure that your gem is as fast as possible to install, that why `rb-sys` is built from the ground
It's important to make sure that your gem is as fast as possible to install, that's why `rb-sys` is built from the ground
up to support this use-case. `rb-sys` integrates seamlessly with [`rake-compiler`][rake-compiler] and
[`rake-compiler-dock`][rcd]. By leveraging the hard-work of others, cross-compilation for Ruby gems is as simple and
reliable as it would be for a C extension.
Expand All @@ -14,16 +14,16 @@ reliable as it would be for a C extension.
## Using the `rb-sys-dock` helper

The `rb-sys-dock` executable allows you to easily enter the Docker container used to cross compile your gem. You can use
you tool to build your gem, and then exit the container. The gem will be available in the `pkg` directory.
your tool to build your gem, and then exit the container. The gem will be available in the `pkg` directory.

```bash
$ bundle exec rb-sys-dock -p aarch64-linux --build
$ ls pkg # => my_gem_name-0.1.0-aarch64-linux.gem
```

## Github Actions
## GitHub Actions

The [`oxi-test`][oxi-text] gem is meant to serve as the canonical example of how to setup cross gem compilation. Here's
The [`oxi-test`][oxi-test] gem is meant to serve as the canonical example of how to setup cross gem compilation. Here's
a walkthrough of the important files to reference:

1. Setup the `Rake::ExtensionTask` in the [`Rakefile`](https://github.com/oxidize-rb/oxi-test/blob/main/Rakefile)
Expand All @@ -48,5 +48,5 @@ a walkthrough of the important files to reference:

[rake-compiler]: https://github.com/rake-compiler/rake-compiler
[rcd]: https://github.com/rake-compiler/rake-compiler-dock
[oxi-test]: htttps://github.com/oxidize-rb/oxi-test
[oxi-test]: https://github.com/oxidize-rb/oxi-test
[slack]: https://join.slack.com/t/oxidize-rb/shared_invite/zt-16zv5tqte-Vi7WfzxCesdo2TqF_RYBCw

0 comments on commit dd239e6

Please sign in to comment.