Skip to content

Commit 160a652

Browse files
authored
Merge pull request #216 from y-yagi/support_ruby34_latest
Support Ruby 3.4
2 parents f261f31 + 17ce458 commit 160a652

26 files changed

+81
-58
lines changed

app/ruby_engine.rb

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,19 @@ def loading(part = nil)
3939
# When you update the engines, ensure that they are tested correctly.
4040
# Update the engine list also in spec/playground_spec.
4141
ENGINES = [
42-
# https://www.jsdelivr.com/package/npm/@ruby/3.3-wasm-wasi?tab=files&path=dist&version=2.4.1
42+
# https://www.jsdelivr.com/package/npm/@ruby/3.4-wasm-wasi?tab=files&path=dist&version=2.7.2
4343
CRubyWASI.new(
44-
"https://cdn.jsdelivr.net/npm/@ruby/[email protected]/dist/ruby.wasm",
44+
"https://cdn.jsdelivr.net/npm/@ruby/[email protected]/dist/ruby.wasm",
45+
"3.4.1"
46+
),
47+
# https://www.jsdelivr.com/package/npm/@ruby/3.3-wasm-wasi?tab=files&path=dist&version=2.7.2
48+
CRubyWASI.new(
49+
"https://cdn.jsdelivr.net/npm/@ruby/[email protected]/dist/ruby.wasm",
4550
"3.3.0"
4651
),
47-
# https://www.jsdelivr.com/package/npm/@ruby/3.2-wasm-wasi?tab=files&path=dist&version=2.4.1
52+
# https://www.jsdelivr.com/package/npm/@ruby/3.2-wasm-wasi?tab=files&path=dist&version=2.7.2
4853
CRubyWASI.new(
49-
"https://cdn.jsdelivr.net/npm/@ruby/3.2-wasm-wasi@2.4.1/dist/ruby.wasm",
54+
"https://cdn.jsdelivr.net/npm/@ruby/3.2-wasm-wasi@2.7.2/dist/ruby.wasm",
5055
"3.2.2"
5156
),
5257
# Opal.new,

app/ruby_engine/cruby_wasi.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ class RubyEngine
77
class CRubyWASI < RubyEngine
88
REQUIRED_SCRIPTS = [
99
{
10-
# https://www.jsdelivr.com/package/npm/@ruby/wasm-wasi?version=2.4.1&tab=files&path=dist
11-
src: "https://cdn.jsdelivr.net/npm/@ruby/wasm-wasi@2.4.1/dist/index.umd.js",
12-
integrity: "sha256-300VwPu5WqY+8LDKdE4RQwDglgJSpMtLFLgyf508bv0=",
10+
# https://www.jsdelivr.com/package/npm/@ruby/wasm-wasi?version=2.7.2&tab=files&path=dist
11+
src: "https://cdn.jsdelivr.net/npm/@ruby/wasm-wasi@2.7.2/dist/index.umd.js",
12+
integrity: "sha256-sxHtVJLn+brnck+saGLUKbu/JEP7pilIBgChJvVdjko=",
1313
crossorigin: "anonymous"
1414
},
1515
{

app/try_ruby.rb

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,14 @@ class TryRuby
1616
RUBY
1717
INITIAL_TRY_RESULT = 'Welcome ' * 3
1818

19-
DEFAULT_RUBY_ENGINE = "cruby-3.3.0"
19+
DEFAULT_RUBY_ENGINE = "cruby-3.4.1"
20+
21+
GEM_PRELUDE_WARNINGS = [
22+
"`RubyGems' were not loaded.",
23+
"`error_highlight' was not loaded.",
24+
"`did_you_mean' was not loaded.",
25+
"`syntax_suggest' was not loaded."
26+
].freeze
2027

2128
def self.start
2229
instance
@@ -456,13 +463,24 @@ def log_error(err)
456463
end
457464

458465
def print_to_output(str, term = "\n")
466+
return if warnings_from_gem_prelude?(str)
459467
@output_buffer << str.to_s + term
460468
@output.value = @output_buffer.join
461469
end
462470

463471
def output=(text)
464472
@output.value = text
465473
end
474+
475+
# TODO: This would be needless if only supports Ruby >= 3.5.
476+
def warnings_from_gem_prelude?(str)
477+
return false if str.nil? || str.empty?
478+
479+
trimmed_str = str.strip
480+
GEM_PRELUDE_WARNINGS.include?(trimmed_str)
481+
end
482+
483+
private
466484
end
467485

468486
$window.on("dom:load") { TryRuby.start }

spec/playground_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
RSpec.describe "Playground", type: :feature, js: true do
44
context "engine" do
5-
engines = ["opal-ww-1.8.2", "cruby-3.2.2", "cruby-3.3.0"]
5+
engines = ["opal-ww-1.8.2", "cruby-3.2.2", "cruby-3.3.0", "cruby-3.4.1"]
66
engines.each do |engine|
77
context engine do
88
before :each do

translations/de/try_ruby_280.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
lang: EN
33
title: Bist du hart?
4-
answer: :mediocre
4+
answer: :mediocre|mediocre:
55
load: books = {"Gravitys Rainbow" => :splendid, "The deep end" => :abysmal, "Living colors" => :mediocre, "Bumblebees" => :mediocre}
66
ok: Toll, wow! Du hast eine Übersicht über deine Bewertungen erstellt
77
error:

translations/de/try_ruby_90.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,29 @@
11
---
22
lang: DE
33
title: Hey, schon die Zusammenfassung #1
4-
answer: NoMethodError|undefined|-e:in `eval'
4+
answer: NoMethodError|undefined|-e:in `eval'|-e:in 'Kernel.eval'
55
class: stretcher chapmark
66
ok: Nö, es ist nicht möglich, eine Nummer umzukehren. Klick auf 'Next'
7-
error:
7+
error:
88
---
99

1010
Sehen wir uns an, was Sie in der ersten Minute gelernt haben.
1111

1212
### Der Editor
13-
Wenn du den Code in den Editor eingibst und auf Ausführen klickst, erhältst du
13+
Wenn du den Code in den Editor eingibst und auf Ausführen klickst, erhältst du
1414
eine Antwort im Ausgabefenster.
1515
(Fast) jeder Code gibt eine Antwort.
1616

1717
### Nummern und Strings
1818
Nummern und Strings sind Rubys Mathe- und Textobjekte.
1919

2020
### Methoden
21-
Du hast englischsprachige Methoden wie 'reverse' und 'length' verwendet. Und
22-
symbolische Methoden wie die Multiplikationsmethode: \*
21+
Du hast englischsprachige Methoden wie 'reverse' und 'length' verwendet. Und
22+
symbolische Methoden wie die Multiplikationsmethode: \*
2323
__Methoden bedeuten Aktion!__
2424

25-
Das ist die Essenz deines Lernens. Mit einfachen Dingen zu spielen und sie in
26-
neue Dinge zu verwandeln. Fühlst du dich schon wohl? Ich verspreche dir, es ist
25+
Das ist die Essenz deines Lernens. Mit einfachen Dingen zu spielen und sie in
26+
neue Dinge zu verwandeln. Fühlst du dich schon wohl? Ich verspreche dir, es ist
2727
so.
2828

2929
## Okay,

translations/en/try_ruby_280.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
lang: EN
33
title: Are You Harsh?
4-
answer: :mediocre
4+
answer: :mediocre|mediocre:
55
load: books = {"Gravitys Rainbow" => :splendid, "The deep end" => :abysmal, "Living colors" => :mediocre, "Bumblebees" => :mediocre}
66
ok: Great, wow! You've made a scorecard of your ratings
77
error:

translations/en/try_ruby_90.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
---
22
lang: EN
33
title: Hey, Summary #1 Already
4-
answer: NoMethodError|undefined|-e:in `eval'
4+
answer: NoMethodError|undefined|-e:in `eval'|-e:in 'Kernel.eval'
55
class: stretcher chapmark
66
ok: Nope, it is not possible to reverse a number. Click 'next'
7-
error:
7+
error:
88
---
99

1010
Let's look at what you've learned in the first minute.
@@ -18,7 +18,7 @@ Numbers and strings are Ruby's math and text objects.
1818

1919
### Methods
2020
You've used English-language methods like reverse and length. And symbolic methods like the
21-
multiplication method: \*
21+
multiplication method: \*
2222
__Methods mean action!__
2323

2424
This is the essence of your learning. Taking simple things, toying with them and turning them into

translations/es/try_ruby_280.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
lang: ES
33
title: ¿Eres severo?
4-
answer: :mediocre
4+
answer: :mediocre|mediocre:
55
load: libros = {"El Arco Iris de Gravedad" => :esplendido, "El fin profundo" => :abismal, "Colores vivientes" => :mediocre, "Abejorros" => :mediocre}
66
ok: ¡Genial! Has hecho un marcador de puntuaciones.
77
error:

translations/es/try_ruby_90.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
---
22
lang: ES
33
title: Ey, Sumario #1 Ya
4-
answer: NoMethodError|undefined|-e:in `eval'
4+
answer: NoMethodError|undefined|-e:in `eval'|-e:in 'Kernel.eval'
55
class: stretcher chapmark
66
ok: Nop, no es posible dar la vuelta a un número. Pulsa 'next'
7-
error:
7+
error:
88
---
99

1010
Echemos un vistazo a lo que has aprendido en el primer minuto.
@@ -17,7 +17,7 @@ Escribir código en el editor y pulsar __run__ te da una respuesta en la ventana
1717
Los números y los strings (las cadenas de texto) son los objetos de Ruby para las mates y los textos.
1818

1919
### Métodos
20-
Ya has usado métodos de lenguaje como dar la __vuelta__ (reverse) o __tamaño__ (length). Y también métodos simbólicos como la multiplicación: \*
20+
Ya has usado métodos de lenguaje como dar la __vuelta__ (reverse) o __tamaño__ (length). Y también métodos simbólicos como la multiplicación: \*
2121
__Los Métodos significan acción!__
2222

2323
Esta es la esencia de tu aprendizaje. Coger cosas simples, jugar con ellas y convertirlas en cosas nuevas. ¿Te sientes cómodo? Seguro que sí.

0 commit comments

Comments
 (0)