These are chat archives for opal/opal

20th
May 2015
CJ Lazell
@cj
May 20 2015 16:23
morning. has any got minitest working with opal?
@cj ^
@dfyx opal-node is out of date, but we have some nice wrappers for node stuff in the stdlib, just require 'nodejs' from inside opal
of course any help in updating opal-node would be appreciated
CJ Lazell
@cj
May 20 2015 16:31
@elia I tried that ... opal/opal#880
Christian Käser
@dfyx
May 20 2015 16:31
@elia thanks, I'll look at it when I'm at home
Elia Schito
@elia
May 20 2015 16:32
@cj missed the issue, etc.so looks like fun :P
CJ Lazell
@cj
May 20 2015 16:32
lol
Elia Schito
@elia
May 20 2015 16:39
@cj at first look the culprit is sprockets 3
CJ Lazell
@cj
May 20 2015 16:46
@elia I tried sprockets 2, but still got issues with etc.so
Ryan Stout
@ryanstout
May 20 2015 17:28

if anyone's around, I'm testing out opal 0.8 and seeing a strange issue. I have a file at volt/volt/app.rb. For some reason its outputting the following for that file:

/* Generated by Opal 0.8.0.beta1 */
Opal.modules["volt/volt/app"] = function(Opal) {
  Opal.dynamic_require_severity = "error";
  var self = Opal.top, $scope = Opal, nil = Opal.nil, $breaker = Opal.breaker, $slice = Opal.slice;

  return nil
};

^assuming I empty the file

then I get:
Uncaught NameError: uninitialized constant Object::Volt

I think part of the issue was that my naming maybe wasn't following conventions?
any ideas on this?
Elia Schito
@elia
May 20 2015 17:30
What's the source of app.rb?
Ryan Stout
@ryanstout
May 20 2015 17:31
so originally it had the following:
module Volt
  class App
    ...
  end
end
but even if I remove that, it still gives me the error
and outputs the Opal.modules['volt/volt/app']
sorry, I'm probably not being very helpful.
Elia Schito
@elia
May 20 2015 17:35
How do you compile files?
Ryan Stout
@ryanstout
May 20 2015 17:36
sprockets
for this code
looks like its a problem in const_get
Elia Schito
@elia
May 20 2015 17:38
With 0.8 sprockets always compiles into modules
you have to manually add the boot sea code to run the main file
which in turn is responsible of requiring its dependencies
Ryan Stout
@ryanstout
May 20 2015 17:40
"boot sea code?"
Elia Schito
@elia
May 20 2015 17:41
Lol
bootstrapping
Ryan Stout
@ryanstout
May 20 2015 17:42
sorry, I still don't understand
Elia Schito
@elia
May 20 2015 17:43
Opal::Processor.load_asset_code(sprockets, logical_path)
Ryan Stout
@ryanstout
May 20 2015 17:43
ok, sorry I haven't kept up with opal master as much as I should have. When you say 0.9 compiles to modules, what do you mean by that?
Elia Schito
@elia
May 20 2015 17:44
Sorry: Opal 0.8
Ryan Stout
@ryanstout
May 20 2015 17:44
sorry, 0.8
is the load_asset_code something I need to call before I setup Opal::Server
Elia Schito
@elia
May 20 2015 17:46
compiling via sprockets in 08 will always put compiled code into Opal.modules
Ryan Stout
@ryanstout
May 20 2015 17:51
ok, but if I have a module name that doesn't match what Opal.modules generates, that still works right?
Elia Schito
@elia
May 20 2015 17:51
what goes into Opal.modules is like the filename
Ryan Stout
@ryanstout
May 20 2015 17:51
ok, thats what I figured
ok, let me test one thing real quick
Elia Schito
@elia
May 20 2015 17:52
was on mobile before, but now I can try to reproduce locally to better explain
Ryan Stout
@ryanstout
May 20 2015 17:53
ok, can you explain the Opal::Processor.load_asset_code again?
I didn't follow what that was about
ok, so if all I do is compile a file with require 'opal' in it, I get the error:
Uncaught NameError: uninitialized constant Object::Volt
which I'm guessing has to do with the file path
let me make an isolated example
Elia Schito
@elia
May 20 2015 17:56
it shouldn't have anything to do with modules paths
load_asset_code just outputs Opal.load('my_app') plus some helpers for non-opal js files and stubbed files
@ryanstout I'm on skype if you want to have a look together
Ryan Stout
@ryanstout
May 20 2015 17:58
thanks, give me a few minutes to see if I can come up with an isolated example
so I'm using sprockets, but not javascript_include_tag, could that be related?
also, what's with the .self.js urls?
nevermind, figured it out
Ryan Stout
@ryanstout
May 20 2015 18:03
ok, it must be something I'm doing in volt, since on a simple sprockets example it works.
let me hack on this for a while and see if I can figure out what the issue is, thanks
Elia Schito
@elia
May 20 2015 18:06
yes, javascript_include_tag in opal-rails internally calls load_asset_code
gotta go
Christian Käser
@dfyx
May 20 2015 18:34
@elia For some reason require 'nodejs' causes electron to give me 'The app provided is not a valid electron app, please read the docs on how to write one:
https://github.com/atom/electron/tree/master/docs'
But the Native class does most of what I need anyways
(Unfortunately I didn't find a way to ask electron WHAT went wrong. It doesn't have a --verbose flag)
Forrest Chang
@fkchang
May 20 2015 20:25
@elia @ryanstout 's <class/module> undefined sounds similar to the issues I had when I tried to upgrade our opal-rails app to 0.8 beta a while back. I didn't have time to deal w/it so I reverted w/o testing much, but the 1 thing I remember was it felt like things weren't being found and/or required.
Elia Schito
@elia
May 20 2015 20:30
It's possible that the more precise require system could uncover some require-sequence related race condition
@adambeynon ping opal/opal#879
need a review there
Ryan Stout
@ryanstout
May 20 2015 20:36
@elia so just so I'm clear, in 0.8 I need to call Opal::Processor.load_asset_code(sprockets, logical_path) for each file I load in a script tag?
Elia Schito
@elia
May 20 2015 20:45
No, just for the main one, supposing it requires the others
Ryan Stout
@ryanstout
May 20 2015 20:49
@elia humm, still getting the error
what does load_asset_code do?
it errors before the app.rb file is done loading actually
am I supposed to take the output of load_asset_code and have that one the client page?
Ryan Stout
@ryanstout
May 20 2015 21:34
@elia you still around? is it possible now to run code in a .rb opal file thats not in a class?
I've got it now where I'm not getting an error, but if I do a puts 'hey' that doesn't show up
outside of a class
in the main file, not one that gets required in
Elia Schito
@elia
May 20 2015 21:59
@ryanstout can you put the code somewhere?
Ryan Stout
@ryanstout
May 20 2015 22:02
@elia its all of volt, so it would probably be a bit confusing. I'm still messing with it. Unrelated, is there not a way to include the Opal.mark_as_loaded stuff in the generated file?
Elia Schito
@elia
May 20 2015 22:03
What it does at its core is just Opal.load('mymainfile')
so you can try doing just that
CJ Lazell
@cj
May 20 2015 22:07
does opal-rspec not support stubbing? opal/opal-rspec#20
Elia Schito
@elia
May 20 2015 22:19
@ryanstout ^
Ryan Stout
@ryanstout
May 20 2015 22:20
@elia are you saying add that into my rb file?
Elia Schito
@elia
May 20 2015 22:20
no must be external
Elia Schito
@elia
May 20 2015 23:36
(@ryanstout ^)
Forrest Chang
@fkchang
May 20 2015 23:39
@cj that error is indicative of 2 things 1) it's likely trying to do #<< on a string, which are immutable in Opal, opal-rspec is basically monkey patching rspec to not modify strings so it'll work on opal 2) older syntax, I noticed some of the older syntaxes were not monkey patched, forcing me to go to the newer syntax,
the new syntax for any instance subbing is ruby allow_any_instance_of(Widget).to receive(:name).and_return("Wibble") expect_any_instance_of(Widget).to receive(:name).and_return("Wobble")
Elia Schito
@elia
May 20 2015 23:40
@fkchang fixed that on master
Elia Schito
@elia
May 20 2015 23:48
@ryanstout bedtime for me, pushed here an attempt I made updating to opal-master
got 32 failing specs out of 250