Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
## Building image ##
FROM ruby:3.0.3-slim-bullseye AS builder
WORKDIR /app
# install build dependencies
RUN apt update && apt install make gcc g++ libffi-dev nodejs git -y
COPY . .
COPY ./Gemfile /app/Gemfile
COPY ./Gemfile.lock /app/Gemfile.lock
WORKDIR /app
RUN bundle install
EXPOSE 4567
CMD ["bin/middleman", "serve"]
CMD ["bin/middleman", "serve"]
15 changes: 11 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ where you can learn the Ruby language. Starting from zero knowledge about
programming you can learn the basics of Ruby in 56 short lessons.

## Credits

Try Ruby version 1 by _why the lucky stiff_
Try Ruby version 2 by _Andrew McElroy & David Miani_
Try Ruby version 3 by _Eric Allam & Nick Walsh_
Expand All @@ -13,6 +14,7 @@ Try Ruby version 4 by _Ivo Herweijer_
This website is partially based on OpalRb.com by _Adam Beynon_.

### Translations

Spanish translation by _Jesus Gabriel y Galan_ & _Pablo García_
Dutch translation by [_Ivo Herweijer_](https://github.com/easydatawarehousing)
Brazilian Portuguese translation by [_Ricardo da Verdade Silva_](https://github.com/ricardovsilva)
Expand All @@ -31,20 +33,23 @@ not the json files in folder _source_.
These files will be updated automatically by the build/publish task.

## Frontend website

The TryRuby is kind of unique in a way, that it is a frontend application created
in Ruby with [Opal](https://opalrb.com/). The source code for this application is
located in `app` directory.

## Docker

You can deploy the website using docker by running the following commands:

```
# creating the image
docker build -f Dockerfile . -t tryruby
# running the image, you can access tryruby on http://localhost:9099
docker run -p 9099:4567 -d tryruby:latest
docker compose up
```

Then visit `http://localhost:9099`.

## Preparing

Clone this repo, and use bundler to get dependencies:

$ bundle install
Expand All @@ -70,9 +75,11 @@ Git branch 'gh-pages' now holds the publishable version of TryRuby, accessible
via [try.ruby-lang.org/](https://try.ruby-lang.org/).

## Translators

When adding a new translation: see the README file in /translations.

## Why

See the website [try-ruby-version-4](https://try.ruby-lang.org/articles/try-ruby-version-4/)
for more background information on how and why this website was created.

Expand Down
17 changes: 8 additions & 9 deletions app/ruby_engine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,17 +39,16 @@ def loading(part = nil)
# When you update the engines, ensure that they are tested correctly.
# Update the engine list also in spec/playground_spec.
ENGINES = [
# https://www.jsdelivr.com/package/npm/@ruby/3.2-wasm-wasi?tab=files&path=dist&version=2.4.1
CRubyWASI.new(
"https://cdn.jsdelivr.net/npm/ruby-head-wasm-wasi@0.5.0-2022-12-25-a/dist/ruby.wasm",
"3.2.0"
"https://cdn.jsdelivr.net/npm/@ruby/3.2-wasm-wasi@2.4.1/dist/ruby.wasm",
"3.2.2"
),
# https://www.jsdelivr.com/package/npm/@ruby/3.3-wasm-wasi?tab=files&path=dist&version=2.4.1
CRubyWASI.new(
"https://cdn.jsdelivr.net/npm/@ruby/3.3-wasm-wasi@2.4.1/dist/ruby.wasm",
"3.3.0"
),
# FIXME(katei): Head build is no longer compatible with ruby-head-wasm-wasi@0.5.0,
# so we should have a worker for each version of CRuby to load corresponding ruby-*-wasm-wasi
# CRubyWASI.new(
# "https://cdn.jsdelivr.net/npm/ruby-head-wasm-wasi@next/dist/ruby.wasm",
# "3.3.0dev"
# ),

# Opal.new,
OpalWebWorker.new("1.7.1"),
].each_with_object({}) do |engine, hash|
Expand Down
31 changes: 16 additions & 15 deletions app/ruby_engine/cruby_wasi.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,22 @@
class RubyEngine
class CRubyWASI < RubyEngine
REQUIRED_SCRIPTS = [
{
src: "https://cdn.jsdelivr.net/npm/ruby-head-wasm-wasi@0.5.0/dist/index.umd.js",
integrity: "sha256-EVJ2qiXD74E5qZpFm9MMNqOf5Buo+P2VQKiqOzOKGpg=",
crossorigin: "anonymous"
},
{
src: "https://cdn.jsdelivr.net/npm/@wasmer/wasmfs@0.12.0/lib/index.iife.js",
integrity: "sha256-sOd4ekxVsN4PXhR+cn/4uNAxeQOJRcsaW5qalYfvkTw=",
crossorigin: "anonymous"
},
{
src: "https://cdn.jsdelivr.net/npm/@wasmer/wasi@0.12.0/lib/index.iife.js",
integrity: "sha256-FslFp/Vq4bDf2GXu+9QyBEDLtEWO3fkMjpyOaJMHJT8=",
crossorigin: "anonymous"
}
{
# https://www.jsdelivr.com/package/npm/@ruby/wasm-wasi?version=2.4.1&tab=files&path=dist
src: "https://cdn.jsdelivr.net/npm/@ruby/wasm-wasi@2.4.1/dist/index.umd.js",
integrity: "sha256-300VwPu5WqY+8LDKdE4RQwDglgJSpMtLFLgyf508bv0=",
crossorigin: "anonymous"
},
{
src: "https://cdn.jsdelivr.net/npm/@wasmer/wasmfs@0.12.0/lib/index.iife.js",
integrity: "sha256-sOd4ekxVsN4PXhR+cn/4uNAxeQOJRcsaW5qalYfvkTw=",
crossorigin: "anonymous"
},
{
src: "https://cdn.jsdelivr.net/npm/@wasmer/wasi@0.12.0/lib/index.iife.js",
integrity: "sha256-FslFp/Vq4bDf2GXu+9QyBEDLtEWO3fkMjpyOaJMHJT8=",
crossorigin: "anonymous"
}
]

def initialize(ruby_wasm_url, version)
Expand Down
2 changes: 1 addition & 1 deletion app/try_ruby.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class TryRuby
RUBY
INITIAL_TRY_RESULT = 'Welcome ' * 3

DEFAULT_RUBY_ENGINE = "cruby-3.2.0"
DEFAULT_RUBY_ENGINE = "cruby-3.2.2"

def self.start
instance
Expand Down
8 changes: 8 additions & 0 deletions compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
services:
web:
build: .
image: tryruby:latest
ports:
- "9099:4567"
volumes:
- .:/app
2 changes: 1 addition & 1 deletion spec/playground_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

RSpec.describe "Playground", type: :feature, js: true do
context "engine" do
engines = ["opal-ww-1.7.1", "cruby-3.2.0"]
engines = ["opal-ww-1.7.1", "cruby-3.2.2", "cruby-3.3.0"]
engines.each do |engine|
context engine do
before :each do
Expand Down
2 changes: 1 addition & 1 deletion translations/de/try_ruby_90.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
lang: DE
title: Hey, schon die Zusammenfassung #1
answer: NoMethodError|undefined
answer: NoMethodError|undefined|-e:in `eval'
class: stretcher chapmark
ok: Nö, es ist nicht möglich, eine Nummer umzukehren. Klick auf 'Next'
error:
Expand Down
2 changes: 1 addition & 1 deletion translations/en/try_ruby_90.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
lang: EN
title: Hey, Summary #1 Already
answer: NoMethodError|undefined
answer: NoMethodError|undefined|-e:in `eval'
class: stretcher chapmark
ok: Nope, it is not possible to reverse a number. Click 'next'
error:
Expand Down
2 changes: 1 addition & 1 deletion translations/es/try_ruby_90.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
lang: ES
title: Ey, Sumario #1 Ya
answer: NoMethodError|undefined
answer: NoMethodError|undefined|-e:in `eval'
class: stretcher chapmark
ok: Nop, no es posible dar la vuelta a un número. Pulsa 'next'
error:
Expand Down
2 changes: 1 addition & 1 deletion translations/ja/try_ruby_90.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
lang: JA
title: このくらいで要約(その1)にしましょう
answer: NoMethodError|undefined
answer: NoMethodError|undefined|-e:in `eval'
class: stretcher chapmark
ok: いいえ、数を逆さまにはできません。'Next'を押してください
error:
Expand Down
2 changes: 1 addition & 1 deletion translations/mk/try_ruby_90.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
lang: MK
title: Резиме на делот #1. Толку брзо?!
answer: NoMethodError|undefined
answer: NoMethodError|undefined|-e:in `eval'
class: stretcher chapmark
ok: Не, не е можно да го прикажеш бројот во обратен редослед. Кликни 'Next'
error:
Expand Down
2 changes: 1 addition & 1 deletion translations/nl/try_ruby_90.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
lang: NL
title: Je hebt samenvatting 1 bereikt
answer: NoMethodError|undefined
answer: NoMethodError|undefined|-e:in `eval'
class: stretcher chapmark
ok: Nee, nummers kan je niet omdraaien. Klik 'next'
error:
Expand Down
2 changes: 1 addition & 1 deletion translations/pt-br/try_ruby_90.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
lang: PT-BR
title: Ei, Sumário #1 Pronto
answer: NoMethodError|undefined
answer: NoMethodError|undefined|-e:in `eval'
class: stretcher chapmark
ok: Não, não é possível inverter um número. Clique em __next__ para continuar
error:
Expand Down
2 changes: 1 addition & 1 deletion translations/ru/try_ruby_90.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
lang: RU
title: Подводим итоги #1 Уже
answer: NoMethodError|undefined
answer: NoMethodError|undefined|-e:in `eval'
class: stretcher chapmark
ok: Неа, нельзя использовать метод reverse с числом. Жми 'next'
error:
Expand Down
2 changes: 1 addition & 1 deletion translations/tr/try_ruby_90.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
lang: TR
title: Hey, Özet #Şimdiden 1 Numara
answer: NoMethodError|undefined
answer: NoMethodError|undefined|-e:in `eval'
class: stretcher chapmark
ok: Yoo, bir numarayı ters çevirmek mümkün değil ki. 'next' butonuna bas
error:
Expand Down
2 changes: 1 addition & 1 deletion translations/ua/try_ruby_90.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
lang: UA
title: Підсумки #1 Вже
answer: NoMethodError|undefined
answer: NoMethodError|undefined|-e:in `eval'
class: stretcher chapmark
ok: Ні, неможливо розгорнути число. Натисни 'next'
error:
Expand Down
2 changes: 1 addition & 1 deletion translations/zh/try_ruby_90.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
lang: ZH
title: 总结(第一部分)就到此为止!
answer: NoMethodError|undefined
answer: NoMethodError|undefined|-e:in `eval'
class: stretcher chapmark
ok: 不不不,你不能逆置一个数字,点击‘Next’来继续
error:
Expand Down