opalrb

require 'opal-jquery' gives error: A file required wasn't found

[亡魂溺海] 提交于 2021-01-28 11:54:20
问题 Opal looks amazing!!! I'm getting the same "A file required wasn't found" error when I try to require 'opal-jquery' on two different Windows 7 and Windows 10 systems: C:\opaltest>node --version v10.15.3 C:\opaltest>ruby -v ruby 2.5.5p157 (2019-03-15 revision 67260) [x64-mingw32] C:\opaltest>gem list -a opal *** LOCAL GEMS *** opal (0.11.4) opal-jquery (0.4.3) The file test.js.rb consists of these 3 lines: require 'opal' require 'opal-jquery' puts 'success' C:\opaltest>opal -c test.js.rb >

Linking Ruby with HTML Code

无人久伴 提交于 2020-03-25 11:34:27
问题 I am aware that you can implement Javascript code to an HTML documents, by inserting the code between the <script></script> tags.. is there a similar way to do this with Ruby? 回答1: Client Side Ruby (Ruby on the browser?!) If your question refers to executing Ruby code on the browser, like you would execute Javascript (the server isn't involved), than it's not really possible in the traditional sense. However, Opal will "compile" your Ruby code into Javascript, allowing you to execute the

Ruby: Running Gosu game from a web browser

为君一笑 提交于 2019-12-24 11:54:18
问题 So what I want to do is this: User visits www.website.com There is a button called "play game" Gosu game (which I have already written) will launch the window. User can play game. so maybe it'll look like this: <button type = "submit" > PLAY GAME </button> <iframe><%= MyGameFile.rb.execute %></iframe> <!-- Iframe will contain the window of the Gosu app --> I've been reading around and I've seen that there may be a way to trick it into running by using Jruby. I've also thought that maybe it

Is there a way to show the Ruby line numbers in javascript generated by Opal

我的未来我决定 提交于 2019-12-11 12:34:07
问题 For debugging purposes I would like to see the corresponding Ruby Source position in the javascript file generated by Opal. Is there a simple way to achive this? I tried # config.ru require 'bundler' Bundler.require run Opal::Server.new { |s| s.append_path 'public' s.append_path 'src' s.debug = true s.source_map = true s.main = 'application' s.index_path = 'index_opal.html' } this is my application file require 'math' require 'opal' require 'opal-jquery' require 'consolelogger' require

Can I use Ruby gems in Opal?

余生颓废 提交于 2019-12-06 00:30:56
问题 There's opal-irb and opal-jquery and vienna but is there any way to use gems directly in the browser via Opal? 回答1: You can add a gem's lib path to Opal load paths by using Opal.use_gem Common pitfalls are: use of String mutability relying on the difference between String and Symbol shelling out ( `` and %x{} ) Available tools to fix/workaround some of those issues are: stubbing files Opal::Processor.stub_file('fileutils') hiding code branches at compile time using RUBY_ENGINE , example:

What are the limitations of Opal? [closed]

江枫思渺然 提交于 2019-12-04 09:14:25
问题 Closed . This question is opinion-based. It is not currently accepting answers. Want to improve this question? Update the question so it can be answered with facts and citations by editing this post. Closed 5 years ago . I'm very keen to try Opal in a new Rails project, but the risk of course is that I won't discover what it can't do until I've spent hundreds of hours doing everything else, and run into a brick wall that I can't possibly get through. What are its limitations? For example (and

Can I use Ruby gems in Opal?

痴心易碎 提交于 2019-12-04 07:22:01
There's opal-irb and opal-jquery and vienna but is there any way to use gems directly in the browser via Opal? You can add a gem's lib path to Opal load paths by using Opal.use_gem Common pitfalls are: use of String mutability relying on the difference between String and Symbol shelling out ( `` and %x{} ) Available tools to fix/workaround some of those issues are: stubbing files Opal::Processor.stub_file('fileutils') hiding code branches at compile time using RUBY_ENGINE , example: unless RUBY_ENGINE == 'opal' unparsable/breaking code here end You can look at the opal-rspec source code to see

How can I compile Ruby to Javascript? [closed]

◇◆丶佛笑我妖孽 提交于 2019-12-03 14:54:54
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 5 years ago . I'm working on a piece of logic that I would like to express on the server as well as in the browser. Something like validating a form where there must be certain logical relationships between the elements based on what has already been entered. So... If I can write the logic once and somehow end up with both

How can I compile Ruby to Javascript? [closed]

╄→尐↘猪︶ㄣ 提交于 2019-12-03 04:39:08
I'm working on a piece of logic that I would like to express on the server as well as in the browser. Something like validating a form where there must be certain logical relationships between the elements based on what has already been entered. So... If I can write the logic once and somehow end up with both Ruby and with Javascript, I can write the logic just once and not have to worry about making sure that two pieces of code written in different languages have the same functional behaviour. I don't need to reproduce everything in Ruby, obviously, and one simplification might be to port a

What are the limitations of Opal? [closed]

妖精的绣舞 提交于 2019-12-03 02:16:54
Closed . This question is opinion-based. It is not currently accepting answers. Learn more . Want to improve this question? Update the question so it can be answered with facts and citations by editing this post . I'm very keen to try Opal in a new Rails project, but the risk of course is that I won't discover what it can't do until I've spent hundreds of hours doing everything else, and run into a brick wall that I can't possibly get through. What are its limitations? For example (and of course answers should not be limited to these topics if there are other limitations worth mentioning) I