Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
Rolf
@dkgof
I know i can call it by calling directly with JS wrapping it in backwards quotes, but that does not feel entirely "correct"
Elia Schito
@elia
@dkgof the problem is that a class is also a function, so it's recognized by Native as already being a Proc (in Ruby) and it refuses to wrap it with Native. You can work around this by using the .JS syntax as follows:
A = `class A { static a(){return 123} }`
A.JS.a # => 123
(I used the ES5 class syntax for brevity, but that's not different if you use the function keyword)
PS. feel free to join the new chat Slack workspace at http://slack.opalrb.com
bolandross
@bolandross
Hey guys, I am quite new to opal and currently a bit confused: Is opal-browser already a part of opal or do I have to install it separately? I tried it via gem install browser but this seems to be something different. Then I cloned the opal-browser repository, ran "bundle" in it, then tried to require_relative from my app.rb to the path of the browser.rb, but opal always gives me the message "can't find file: "browser" in:
  • /Library/Ruby/Gems/2.6.0/gems/opal-1.0.3/opal (etc.)" Couldn't find any steps to solve this. Any ideas?
Forrest Chang
@fkchang
@bolandross did you really type gem install browser instead of gem install opal-browser ?
bolandross
@bolandross
@fkchang I indeed did. In the README.md it said require 'browser', so I thought the name of the gem was just 'browser'. Having now installed the the correct gem 'opal-browser' I am unfortunately still getting the same error message, "can't find file: 'opal-browser'"
Forrest Chang
@fkchang
@bolandross the gem name for installation is opal-browser, but inside your opal code you just require 'browser'
bolandross
@bolandross
@fkchang Hey. I tried again, installed the correct gem (opal-browser) and then used require 'browser'. Unfortunately, the same error message remains (can't find file: "browser" in [...])
Toby Mao
@tobymao
hello, i'm trying to implement an incremental compiler and i think i'm pretty close, it seems like the code gen is correct, however, the running opal code cannot find my module

```Opal.modules["engine/game_error"] = function(Opal) {
var self = Opal.top, $nesting = [], nil = Opal.nil,

KaTeX parse error: Can't use function '$' in math mode at position 1: $̲ = Opal.const_g…: $ = Opal.const_get_qualified, 
= Opal.const_get_relative, $breaker = Opal.breaker, $slice = Opal.slice, $module = Opal.module, $klass = Opal.klass;

return (function($base, $parent_nesting) {
var self = $module($base, 'Engine');

var $nesting = [self].concat($parent_nesting);

(function($base, $super, $parent_nesting) {
  var self = $klass($base, $super, 'GameError');

  var $nesting = [self].concat($parent_nesting);

  return nil
})($nesting[0], $$($nesting, 'RuntimeError'), $nesting)

})($nesting[0], $nesting)
};

```

this is what one of the code gen snippets looks like, but when i go to the browser the Opal.Engine constant isn't loaded even though Opal.modules['engine'] is there
at a high level, what i'm doing is for every file that i want to incrementally compile, i create a javascript version of that file. then i concatenate all of them using a topological sort. then i require this javascript file in my main app
Toby Mao
@tobymao
ok i think it's because the require is not getting called, probably because it's a JS file and it has it's own build processor
Toby Mao
@tobymao
i think the solution is i need to make my own processor so that mark_as_required is not injected, then the code will get loaded as normal
lunarfyre7
@lunarfyre7
Should I target rubygems or npm for making an opal binding for a js library?
lunarfyre7
@lunarfyre7
I see, opal libraries seem to use gems mostly
Guillaume Grossetie
@Mogztter
What do you mean by Opal binding?
For Asciidoctor.js -- Asciidoctor (Ruby) transpiled to JavaScript using Opal -- the package is published on npm
lunarfyre7
@lunarfyre7
oh wow that definitely is worth looking into how they do their builds
By binding I mean making a wrapper for a js library
been looking into using opal-webpack-loader for it
Guillaume Grossetie
@Mogztter
Oh OK, in your case it's the other way around then, a Ruby library API on top of a JS library? In this case, it makes sense to publish a gem
Andy Maleh
@AndyObtiva
Hi, can someone pair with me on my new Opal open-source project: https://github.com/AndyObtiva/glimmer-dsl-opal ? I need help setting up opal-rspec and hooking JS listeners using opal-browser or an alternative. Thanks.
Andy Maleh
@AndyObtiva
In opal-browser, how do you hook an onchange listener to a select element? I tried a simple Ruby select(onchange: proc), but that literally hooked the proc object instead of converting it into a JavaScript anonymous function as I would have intuitively expected.
It seems it is time to upgrade from opal-browser to opal-jquery. It supports the event listener hook behavior I need (i.e. Ruby block/proc becoming a JS anonymous function as an event listener). Great!
Andy Maleh
@AndyObtiva
OK, I just realized event listening with Ruby blocks does exist in opal-browser too as an undocumented feature. I found it buried by digging deep down into the code: https://github.com/opal/opal-browser/blob/master/opal/browser/event/base.rb Sweet!!! I guess I'll stick to opal-browser for now.
Thanks all for being my Rubber Duck!
Benoit Daloze
@eregon
Hello, is there anyone around who could help me figure how the MSpec setup works in Opal? I'd like to add a new formatter or tweak one
Guillaume Grossetie
@Mogztter
I can try :)
(btw, I think the official chat is now: https://opalrb.slack.com)
Benoit Daloze
@eregon
I managed by basically running subset of specs, so didn't need modifications.
I tried to add a new formatter but would end up running in "constant not found" error even though I required the file defining that constant.
https://github.com/opal/opal#readme still points to Gitter
Toby Mao
@tobymao
how do we join the opal slack? are invites open?
Toby Mao
@tobymao
i have a large opal project and wanted to improve my compilation times so i built an incremental compiler for my workflow, wanted to discuss how to bring that into opal / if it's wanted
Toby Mao
@tobymao
found the link to the slack, the invite can be found on the opal home page https://opalrb.com/
Larry North
@LarryNorth
It seem that Gem i18n cannot be used with Opal because it depends on current-ruby, which has native extensions. Is that correct? If so, how is internationalization/localization done with Opal?
hmdne
@hmdne
@LarryNorth I will be certainly touching this topic in the future, but for now I see no immediate solution.
Just in case, we are mostly on Slack currently.
Full Stack Ruby on Rails Developer
@webdev778
Hi
image.png
Full Stack Ruby on Rails Developer
@webdev778
Ruby 2.5 Windows,bundle installed failed as you can see, it's all working on 2.4, 2.6 2.7
not sure what causing this issue
Sebastien Pede
@SebastienPede

Greetings all, maybe you guys can help. I am creating an Angular project using the new scully Static site generator configuration. When i build my angular project using scully, i get the following error:

⠹ method 'new' not defined in
    at Object.Opal.udef (C:\users\sebo\desktop\fireship\scullytest\node_modules\asciidoctor.js\node_modules\opal-runtime\src\opal.js:1784:28)
    at C:\users\sebo\desktop\fireship\scullytest\node_modules\asciidoctor.js\node_modules\opal-runtime\src\opal.js:6225:12
    at C:\users\sebo\desktop\fireship\scullytest\node_modules\asciidoctor.js\node_modules\opal-runtime\src\opal.js:6227:7
    at Opal.modules.corelib/boolean (C:\users\sebo\desktop\fireship\scullytest\node_modules\asciidoctor.js\node_modules\opal-runtime\src\opal.js:6302:5)
    at Object.Opal.load (C:\users\sebo\desktop\fireship\scullytest\node_modules\asciidoctor.js\node_modules\opal-runtime\src\opal.js:2300:7)
    at $Object.Opal.require (C:\users\sebo\desktop\fireship\scullytest\node_modules\asciidoctor.js\node_modules\opal-runtime\src\opal.js:2328:17)
    at Opal.modules.opal/mini (C:\users\sebo\desktop\fireship\scullytest\node_modules\asciidoctor.js\node_modules\opal-runtime\src\opal.js:18607:8)
    at Object.Opal.load (C:\users\sebo\desktop\fireship\scullytest\node_modules\asciidoctor.js\node_modules\opal-runtime\src\opal.js:2300:7)
    at $Object.Opal.require (C:\users\sebo\desktop\fireship\scullytest\node_modules\asciidoctor.js\node_modules\opal-runtime\src\opal.js:2328:17)
    at C:\users\sebo\desktop\fireship\scullytest\node_modules\asciidoctor.js\node_modules\opal-runtime\src\opal.js:23338:8

the Logs do not show much detail about what is causing an error. An help would be appreciated !

Forrest Chang
@fkchang
@ylluminarious you still frequent here?
George Plymale II
@ylluminarious
@fkchang unfortunately, no, i'm not as frequent here as i used to be. is there anything interesting going on in opal-land? :slight_smile:
Forrest Chang
@fkchang
@ylluminarious Not yet. I was curious if you were still doing opal-phaser
George Plymale II
@ylluminarious
@fkchang yeah, i unfortunately haven't worked on that in a while. i'd like to work on it again, though. i do have a project that, if i can get it off the ground, would provide me the chance to work on it again and really flesh things out / update it. i'd also be happy to help you with it if i can, or if you want to help out with anything currently existing there.
Forrest Chang
@fkchang
@ylluminarious I had the notion to make a game as sort of a promotional effort, so then of course I'd want it on the web, and to do in ruby/opal, so I thought I'd look at opal-phaser - probably a Doom/Castle Wolfenstien type of 1st person shooter
Eugene Obrezkov
@ghaiklor_twitter

Hi everyone,

I've just upgraded the opal and started getting the following errors:

LoadError: cannot load such file -- erb

Does anyone know how can I debug it?