These are chat archives for opal/opal

14th
Aug 2015
Vais Salikhov
@vais
Aug 14 2015 01:19
@meh :+1: I'll try to take a look this weekend
My Opal talk’s video is up ^^
Elia Schito
@elia
Aug 14 2015 11:50
:clapper: :eyeglasses:
Qqwy / Wiebe-Marten
@Qqwy
Aug 14 2015 12:37
Is there a way to compile opal code from the command line?
Elia Schito
@elia
Aug 14 2015 12:38
@Qqwy sure: opal -c myapp.rb > myapp.js
Qqwy / Wiebe-Marten
@Qqwy
Aug 14 2015 12:38
e.g. opal-compile ruby/input.rb javascript/output.js ?
Oh, that was fast! :-)
Elia Schito
@elia
Aug 14 2015 12:38
:D lol
Qqwy / Wiebe-Marten
@Qqwy
Aug 14 2015 12:39
Thanks a lot!
Elia Schito
@elia
Aug 14 2015 12:39
there's also a bunch of options you might be interested in, check them out with opal -h
Qqwy / Wiebe-Marten
@Qqwy
Aug 14 2015 12:40

Reading through them now...

Is there a way to automatically have opal compile files in a certain directory whenever they change?

Elia Schito
@elia
Aug 14 2015 12:41
I suggest using fsevent
sorry, I meant fswatch
Qqwy / Wiebe-Marten
@Qqwy
Aug 14 2015 12:45
Thank you!
Samuel Gaus
@gausie
Aug 14 2015 13:53
Hi all. I've not got a huge amount of experience with Ruby, but am looking at compiling an existing Ruby library using Opal (https://github.com/supermarin/xcpretty). Finding it hard to know where to start - any ideas?
I'm trying to use the command posting above, but all the requires are not resolving.
Elia Schito
@elia
Aug 14 2015 13:56
You can add paths to look up with the -I option
Samuel Gaus
@gausie
Aug 14 2015 13:56
yeah i tried that but it I still get can't find file: "xcpretty/version"
(thanks for your quick response by the way)
Elia Schito
@elia
Aug 14 2015 13:56
:+1:
can you post the command you tried?
also there's a --gem option
Samuel Gaus
@gausie
Aug 14 2015 13:57
ooh
well from the root folder of xcpretty I used
opal -I ./lib/xcpretty/ -c ./lib/xcpretty.rb > xcpretty.js
Elia Schito
@elia
Aug 14 2015 13:58
opal -I ./lib/ -c ./lib/xcpretty.rb > xcpretty.js
try this
Samuel Gaus
@gausie
Aug 14 2015 13:58
same error message unfortunately
wait hang on
wrong copy buffer
oh an improvement!
but now I've got
can't find file: "shellwords" in ["/usr/local/lib/ruby/gems/2.2.0/gems/opal-0.8.0/opal", "/usr/local/lib/ruby/gems/2.2.0/gems/opal-0.8.0/stdlib", "/usr/local/lib/ruby/gems/2.2.0/gems/opal-0.8.0/lib", "/Users/gausie/Projects/xcpretty/lib"]
Samuel Gaus
@gausie
Aug 14 2015 14:04
I assume that shellwords isnt implemented in Opal yet
Elia Schito
@elia
Aug 14 2015 14:04
yep, that's right
Samuel Gaus
@gausie
Aug 14 2015 14:05
shame!
Elia Schito
@elia
Aug 14 2015 14:05
:S
:D
Samuel Gaus
@gausie
Aug 14 2015 14:05
so close :P
Elia Schito
@elia
Aug 14 2015 14:05
consider that a contribution opportunity! :P
Samuel Gaus
@gausie
Aug 14 2015 14:05
time to learn Ruby!
Elia Schito
@elia
Aug 14 2015 14:06
looking forward to the PR! :eyes:
Samuel Gaus
@gausie
Aug 14 2015 14:07
i’m not entirely sure how Opal works internally, but is there a contribution opportunity in writing a JS module that matches the shellwords API?
ah I see how this works actually
yeah i’ll give it a go
next week
Elia Schito
@elia
Aug 14 2015 14:09
the internal implementation could very well be in js
Samuel Gaus
@gausie
Aug 14 2015 14:09
yeah cause I’m looking at https://github.com/opal/opal/blob/master/stdlib/time.rb for example, anad that’s clearly not a full implementation of Ruby’s Time class. Is that just unfinished or is there more code I’m missing?
Samuel Gaus
@gausie
Aug 14 2015 14:11
ok. what causes something to go in stdlib vs corelib?
generally we follow what Ruby does
core is stuff is already loaded when you start the interpreter
stdlib is stuff you need to require
Samuel Gaus
@gausie
Aug 14 2015 14:12
ok understood
Elia Schito
@elia
Aug 14 2015 14:13
this is stuff that waits to be fixed for time https://github.com/opal/opal/blob/master/spec/filters/bugs/time.rb
there's a really good contributing guide mainly written by @vais here: https://github.com/opal/opal/blob/master/CONTRIBUTING.md
Martin Becker
@Thermatix
Aug 14 2015 14:59
If any one wants to know, I got opal integrated with sprockets although not perfectly, nothing in my pre-compiled files actually do anything, I.e puts 'Hello World!' doesn't actually output to the console.
Forrest Chang
@fkchang
Aug 14 2015 16:52
@Thermatix I was never clear on what exactly you were trying to do, opal already uses sprockets to do requires and is integrated w/sprockets in various ways, opal-server, etc.
Forrest Chang
@fkchang
Aug 14 2015 18:02
So my previous idea of being able to require on demand opal stuff in the browser w/o having to install the gems and setup your app to have it, has been done for js https://gist.github.com/mathisonian/c325dbe02ea4d6880c4e
With require_remote and require_js in opal-irb, we could do similar
Qqwy / Wiebe-Marten
@Qqwy
Aug 14 2015 20:58
I have a question: In a JS library I use, I'm required to pass on function objects (x = function(){code here}). How can I manage to do this from Opal without stepping outside of the Ruby side of things?
Forrest Chang
@fkchang
Aug 14 2015 22:09
@Qqwy I'd need more details, but know that a lambda maps to a function
Elia Schito
@elia
Aug 14 2015 22:10
@Qqwy functions are mapped directly as procs/lambdas