These are chat archives for opal/opal

27th
Jun 2015
Mitch VanDuyn
@catmando
Jun 27 2015 00:26
Cool...
I assume that checking predefined constants etc should work as well. In that case there is a bunch of things I can do with this to clean stuff up!
ylluminate
@ylluminate
Jun 27 2015 02:47
opal/opal#965
Guillaume Grossetie
@Mogztter
Jun 27 2015 08:44
@elia Sorry I'm late to the discussion but don't remove the CDN please ! :)
Anthony C. Eufemio
@tymat
Jun 27 2015 10:00
the -F <output> doesn't seem to work
Vais Salikhov
@vais
Jun 27 2015 10:08
@tymat yep, cli needs some work :sweat_smile: In the meantime, I think everyone just does opal input.rb > output.js
Anthony C. Eufemio
@tymat
Jun 27 2015 10:09
thanks
Vais Salikhov
@vais
Jun 27 2015 10:09
Oops, I meant opal -c input.rb > output.js
Anthony C. Eufemio
@tymat
Jun 27 2015 10:10
yep that's what I was doing
Anthony C. Eufemio
@tymat
Jun 27 2015 10:16
I have a simple ruby class that I compiled... how do I initialize this in nodejs?
class SomeContract
  attr_accessor :name, :email, :password

  def initialize
    @name = "foo"
    @email = "bar"
    @password = "baz"
  end

  def contactinfo
    puts "#{@name} <#{@email}>"
  end

  def authenticate(password)
    password == @password
  end

end
> var Opal = require('./sample.js')
undefined
> var m = Opal.SomeContract.$$new
TypeError: Cannot read property '$$new' of undefined
    at repl:1:26
    at REPLServer.defaultEval (repl.js:132:27)
    at bound (domain.js:254:14)
    at REPLServer.runBound [as eval] (domain.js:267:12)
    at REPLServer.<anonymous> (repl.js:279:12)
    at REPLServer.emit (events.js:107:17)
    at REPLServer.Interface._onLine (readline.js:214:10)
    at REPLServer.Interface._line (readline.js:553:8)
    at REPLServer.Interface._ttyWrite (readline.js:830:14)
    at ReadStream.onkeypress (readline.js:109:10)
>
Elia Schito
@elia
Jun 27 2015 11:14
@tymat whats the command you used to compile it?
Anthony C. Eufemio
@tymat
Jun 27 2015 11:15
opal -rnodejs -c somefile.rb > sample.js
Elia Schito
@elia
Jun 27 2015 11:15
doing it with just -c should include the opal runtime as well
Anthony C. Eufemio
@tymat
Jun 27 2015 11:15
also tried opal --no-exit -rnodejs -c somefile.rb > sample.js
yes I see the runtime included
Elia Schito
@elia
Jun 27 2015 11:16
so it shoul work e.g. doing node sample.js
Anthony C. Eufemio
@tymat
Jun 27 2015 11:16
it works when I run the js from command line
but not inside interpreter
I want to be able to do Opal.SomeClass.$new()
Elia Schito
@elia
Jun 27 2015 11:17
ah ok, then it looks like something that needs fixing
Anthony C. Eufemio
@tymat
Jun 27 2015 11:17
should I open an issue on GH?
Elia Schito
@elia
Jun 27 2015 11:17
can you open an issue for that on opal/…
yep
:)
@tymat thanks, if you can also add steps to reproduce would be great
Anthony C. Eufemio
@tymat
Jun 27 2015 11:22
yep
Anthony C. Eufemio
@tymat
Jun 27 2015 11:35
opal/opal#966