These are chat archives for opal/opal

Mar 2016
Jamie Gaskins
Mar 28 2016 01:36
@bwl21 @elia: JS Maps are not a good fit for hashes. I've thought about it, as well. They use JS === to check map keys, which doesn't match Ruby hash key equality.
Lars Haugseth
Mar 28 2016 05:35
@elia tried building Opal from master, but I get Uncaught SyntaxError: Unexpected token ILLEGAL when I try to use it. code barfs on functions with this char at the start:
Also got a single failing test during bundle exec rake:
Module#class_variable_get raises a NameError for a class variables with the given name defined in an extended module FAILED
Expected NameError but no exception was raised (new_mvar was returned)
SpecExpectationNotMetError: Expected NameError but no exception was raised (new_mvar was returned)
    at null.$new (/tmp/opal-nodejs-runner-20160328-27043-xgufc9:4669:15)
    at ːexception (/tmp/opal-nodejs-runner-20160328-27043-xgufc9:4682:31)
    at module_constructor.ːraise (/tmp/opal-nodejs-runner-20160328-27043-xgufc9:4429:31)
    at ːfail_with (/tmp/opal-nodejs-runner-20160328-27043-xgufc9:39166:35)
    at Function.ːshould (/tmp/opal-nodejs-runner-20160328-27043-xgufc9:39198:64)
    at Object_alloc.$c.$$p.TMP_9 (/tmp/opal-nodejs-runner-20160328-27043-xgufc9:99883:97)
    at Object_alloc.ːinstance_eval (/tmp/opal-nodejs-runner-20160328-27043-xgufc9:3126:24)
    at module_constructor.ːprotect (/tmp/opal-nodejs-runner-20160328-27043-xgufc9:35144:78)
    at $a.$$p.TMP_19 (/tmp/opal-nodejs-runner-20160328-27043-xgufc9:34774:88)
    at Opal.yieldX (/tmp/opal-nodejs-runner-20160328-27043-xgufc9:1159:18)
Bernhard Weichel
Mar 28 2016 07:33

@elia thanks for your offer to help with a test for NeatJson . It has a testsuite, but I failed to run it (see Phrogz/NeatJSON#9) for details. It is a vanilla ruby script (no rspec etc) which does a require to the ../lib/neatjson.rb. But it claims that ../lib/neatjson cannot be found.

The gem provides a highly customizable pretty printer for JSON. I think it is good for Opal if neatjson could be used.

Elia Schito
Mar 28 2016 10:17
See my reply on the issue, you need to explicitly tell which are the lookup paths, Opal doesn't have access to the file system at runtime
@bwl21 ^
Bernhard Weichel
Mar 28 2016 10:18
@elia I tried it, it does not work.
@elia it searches the library in the gempath, but the test should in the development tree of the gem without installing the gem
I tried to provide lookup path with -I but also no success
it seems that Opal does not accept require ../lib/neatjson.rb. I tried with Opal -I . -I .. but also no success
Bernhard Weichel
Mar 28 2016 10:24
@elia, could you please try to clone cd to test and try to run it? It does not need anything else.
there is a branch pr/immutable_strings which removes the usage of mutable strings. But running the test should work on any branch.
Bernhard Weichel
Mar 28 2016 10:29

@elia if I remove the path from the requires and provide them in the commandline, it is getting better:

require 'neatjson'
require 'test'

Then run

 Opal -I . -I .. test_neatjson.rb
/Users/beweiche/.rvm/gems/ruby-2.2.1/gems/opal-0.9.2/lib/opal/builder.rb:118:in `read': A file required by "test_neatjson.rb" wasn't found. (Opal::Builder::MissingRequire)
can't find file: "neatjson" in ["/Users/beweiche/.rvm/gems/ruby-2.2.1/gems/opal-0.9.2/opal", "/Users/beweiche/.rvm/gems/ruby-2.2.1/gems/opal-0.9.2/stdlib", "/Users/beweiche/.rvm/gems/ruby-2.2.1/gems/opal-0.9.2/lib", "/Users/beweiche/beweiche_noTimeMachine/204_ruby-hacks/NeatJSON/test", "/Users/beweiche/beweiche_noTimeMachine/204_ruby-hacks/NeatJSON"]
        from /Users/beweiche/.rvm/gems/ruby-2.2.1/gems/opal-0.9.2/lib/opal/builder.rb:127:in `process_require'
        from /Users/beweiche/.rvm/gems/ruby-2.2.1/gems/opal-0.9.2/lib/opal/builder.rb:42:in `block in build_str'
        from /Users/beweiche/.rvm/gems/ruby-2.2.1/gems/opal-0.9.2/lib/opal/builder.rb:42:in `map'
        from /Users/beweiche/.rvm/gems/ruby-2.2.1/gems/opal-0.9.2/lib/opal/builder.rb:42:in `build_str'
        from /Users/beweiche/.rvm/gems/ruby-2.2.1/gems/opal-0.9.2/lib/opal/cli.rb:110:in `block in build'
        from /Users/beweiche/.rvm/gems/ruby-2.2.1/gems/opal-0.9.2/lib/opal/cli.rb:157:in `evals_or_file'
        from /Users/beweiche/.rvm/gems/ruby-2.2.1/gems/opal-0.9.2/lib/opal/cli.rb:109:in `build'
        from /Users/beweiche/.rvm/gems/ruby-2.2.1/gems/opal-0.9.2/lib/opal/cli.rb:119:in `compiled_source'
        from /Users/beweiche/.rvm/gems/ruby-2.2.1/gems/opal-0.9.2/lib/opal/cli.rb:85:in `run_code'
        from /Users/beweiche/.rvm/gems/ruby-2.2.1/gems/opal-0.9.2/lib/opal/cli.rb:69:in `run'
        from /Users/beweiche/.rvm/gems/ruby-2.2.1/gems/opal-0.9.2/bin/opal:22:in `<top (required)>'
        from /Users/beweiche/.rvm/gems/ruby-2.2.1/bin/Opal:23:in `load'
        from /Users/beweiche/.rvm/gems/ruby-2.2.1/bin/Opal:23:in `<main>'
        from /Users/beweiche/.rvm/gems/ruby-2.2.1/bin/ruby_executable_hooks:15:in `eval'
        from /Users/beweiche/.rvm/gems/ruby-2.2.1/bin/ruby_executable_hooks:15:in `<main>'
PC192-168-100-112:test beweiche$ Opal -I . -I ../lib test_neatjson.rb

      throw exception;
TESTS: uninitialized constant Object::TESTS

TESTS is a constant defined in tests.rb

Jared White
Mar 28 2016 17:39
Boy, this looks like a cool gem. I wonder how hard it would be to Opal-ize it:
Brady Wied
Mar 28 2016 19:13
@jaredcwhite - off topic: I think it's an interesting concept. That said, I think it would be more useful if it's standardized into the Ruby language in a way that the AST can be used for other "providers" like AR, etc. LINQ in C# I think is the gold standard for this.
Elia Schito
Mar 28 2016 23:37
@jgaskins re js Map: I think they could be used if we returned numbers from #hash calls instead of strings, the bigger problem I see is browser support