These are chat archives for opal/opal

2nd
Jan 2017
Sam Johnson
@sam0x17
Jan 02 2017 03:42
could someone describe how the "$$" syntax works or direct me to some docs? I can't find anything in the docs about it and it's sort of ungooglable
Guillaume Grossetie
@Mogztter
Jan 02 2017 10:33
Hello and happy new year! :tada:
I'm running Opal in a Node environment and ENOENT error (https://nodejs.org/api/errors.html) is not an IOError
So this code is not working properly in Opal:
def try_read name
  ::File.read(name)
rescue IOError
  # Ignore error as Asciidoctor expect a nil value if the template is not found
  nil
end
Guillaume Grossetie
@Mogztter
Jan 02 2017 10:38
Because File.read will throws an ENOENT error (and not an IOError). What is the best way to fix it ?
Do I need to try / catch this exception in stdlib/nodejs/file.rb and convert this exception to an IOError: https://github.com/opal/opal/blob/72ae0f23512c275e661cb0168e26562f9c80d593/stdlib/nodejs/file.rb#L38-L40
or can I fix it globally ?
Elia Schito
@elia
Jan 02 2017 11:18
@samkelly the general rule is: no prefix for instance variables, one $ for methods, two forinternalproperties.Allthisisofcourserelatedtocompiledcode.Atrubylevel for internal properties. All this is of course related to compiled code. At ruby level holds the process id (PID) and doesn't have a translation in a browser environment, so it's filled by native.rb with the global object (window).
Elia Schito
@elia
Jan 02 2017 11:32

(sorry for the duplication, fixed format)

@samkelly the general rule is: no prefix for instance variables, one $ for methods, two $$ for internal properties. All this is of course related to compiled code. At Ruby level $$ holds the process id (PID) and doesn't have a direct translation in a browser environment, so after a require 'native' it will be filled with the global object (window) wrapped in Native().

@Mogztter would be great to fix it globally, but it's surely easier to deal with it in the Node implementation of File.read via try/catch.
Guillaume Grossetie
@Mogztter
Jan 02 2017 13:25
@elia Ok I will poke around. Is it me or minitest are broken on master ?
On Travis, the build is green (with Ruby 2.4.0) but I don't think tests are running: https://travis-ci.org/opal/opal/jobs/188198397
and on my machine:
TestKeywordArguments#test_to_hash_call_during_setup_complex_parameters:
Exception: undefined is not a function
    TypeError: undefined is not a function
Elia Schito
@elia
Jan 02 2017 13:32
@Mogztter if they're not running we should add them
Guillaume Grossetie
@Mogztter
Jan 02 2017 13:33

Also windows_platform? function is not found

Object freezing is not supported by Opal

/home/guillaume/workspace/opensource/opal/opal/tmp/test_nodejs.js:4981
      throw exception;
            ^
windows_platform?: undefined method `windows_platform?' for TestNodejsFile
    at Opal.defs.TMP_Exception_new_1 [as $new] (/home/guillaume/workspace/opensource/opal/opal/tmp/test_nodejs.js:5223:15)

If I move the function at the top of the class TestNodejsFile tests are running fine

Elia Schito
@elia
Jan 02 2017 13:33
Feel free to send a PR for that or I'll do as soon as I have time
Guillaume Grossetie
@Mogztter
Jan 02 2017 13:33
No I mean they are not running because there is an error on Travis with Ruby 2.4.0
/home/travis/build/opal/opal/tmp/cruby_tests.js:1393
      throw Opal.NoMethodError.$new('super: no superclass method `'+mid+"' for
                               ^
inherited: super: no superclass method `inherited' for Test::Unit::TestCase
//....
Build is green but I doubt any tests are effectively run
I will switch to Ruby 2.4.0 to test locally
Elia Schito
@elia
Jan 02 2017 14:13
@Mogztter all my fault, I defined windows_platform after using it
@Mogztter but it's very wrong that the build wasn't failing
Elia Schito
@elia
Jan 02 2017 14:26
@Mogztter should be fixed now, once the build is completely green I'll push it to master
Mitch VanDuyn
@catmando
Jan 02 2017 19:02
@cmather - thinking alot about what you did with the custom processor. I would like to work on a similar idea. Can we have a private conversation?
Guillaume Grossetie
@Mogztter
Jan 02 2017 19:46
@elia thanks ;)
Chris Mather
@cmather
Jan 02 2017 21:52
Hey @catmando, sure just pinged back.