Skip to content

Commit c6118f0

Browse files
authored
Merge pull request #1406 from fermyon/docs/wasm-lang-ruby
docs(wasm-languages): ruby updates
2 parents c7fefca + be9af7c commit c6118f0

File tree

1 file changed

+20
-16
lines changed

1 file changed

+20
-16
lines changed

content/wasm-languages/ruby.md

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ $ cd hello-ruby
7979
```
8080

8181
Now fetch a copy of the Ruby source from the [official releases](https://github.com/ruby/ruby.wasm/releases).
82-
For this example, we are downloading the `ruby-head-wasm32-unknown-wasi-full.tar.gz` version,
82+
For this example, we are downloading the `ruby-head-wasm32-unknown-wasip1-full.tar.gz` version,
8383
but one of the smaller versions works just as well.
8484

8585
Now create a local `lib` dir where we will put our own source.
@@ -96,7 +96,7 @@ At this point, our directory should look like this:
9696
$ tree -L 2 -a -d
9797
.
9898
├── .gem
99-
├── head-wasm32-unknown-wasi-full
99+
├── ruby-head-wasm32-unknown-wasip1-full
100100
│   ├── usr
101101
│   └── var
102102
└── lib
@@ -122,25 +122,25 @@ Hello, World
122122
Ruby is a scripting language, which means it will need to load a number of scripts (ours plus all of the built-in libraries) off of its filesystem. The `spin.toml` file for Ruby is more complex than most:
123123

124124
```toml
125-
spin_version = "1"
125+
spin_manifest_version = 2
126+
127+
[application]
126128
name = "example-ruby-app"
127129
version = "0.1.0"
128-
trigger = { type = "http", base = "/" }
129130

130-
[[component]]
131+
[[trigger.http]]
132+
component = "ruby"
133+
route = "/"
134+
executor = { type = "wagi", argv = "${SCRIPT_NAME} -v /lib/hello.rb ${SCRIPT_NAME} ${ARGS}" }
135+
136+
[component.ruby]
137+
source = "ruby-head-wasm32-unknown-wasip1-full/usr/local/bin/ruby"
138+
environment = { HOME = "/", GEM_HOME = "/.gem" }
131139
files = [
132140
{ source = "lib", destination = "/lib" },
133141
{ source = ".gem", destination = "/.gem" },
134-
{ source = "head-wasm32-unknown-wasi-full/usr", destination = "/usr" },
142+
{ source = "ruby-head-wasm32-unknown-wasip1-full/usr", destination = "/usr" },
135143
]
136-
id = "ruby"
137-
source = "head-wasm32-unknown-wasi-full/usr/local/bin/ruby"
138-
[component.trigger]
139-
executor = { type = "wagi", argv = "${SCRIPT_NAME} -v /lib/hello.rb ${SCRIPT_NAME} ${ARGS}" }
140-
route = "/"
141-
[component.environment]
142-
HOME = "/"
143-
GEM_HOME = "/.gem"
144144
```
145145

146146
Note that we need to mount several sets of files: `lib`, `.gem`, and `usr`. This exposes all of Ruby's supporting files.
@@ -155,12 +155,16 @@ Next, running `spin up` will start the server.
155155

156156
```console
157157
$ spin up
158+
Logging component stdio to ".spin/logs/"
158159
Preparing Wasm modules is taking a few seconds...
159160

160-
Serving HTTP on address http://127.0.0.1:3000
161+
162+
Serving http://127.0.0.1:3000
163+
Available Routes:
164+
ruby: http://127.0.0.1:3000
161165
```
162166

163-
Note that the first line occurs because when Spin starts up, it does take Ruby a few moments to load all of its supporting files.
167+
Note that the second line occurs because when Spin starts up, it does take Ruby a few moments to load all of its supporting files.
164168
_Using one of the [smaller instances](https://github.com/ruby/ruby.wasm/releases) will improve startup time
165169
and overall performance._
166170

0 commit comments

Comments
 (0)