These are chat archives for opal/opal

9th
Jul 2014
Elia Schito
@elia
Jul 09 2014 14:00
@wstucco
def a(b=1,$options = undefined)
  c = $options.to_hash.fetch(:c, 2)
  p [b,options]
end
ylluminate
@ylluminate
Jul 09 2014 19:30
hey @elia @adambeynon we're going to work on throwing together a more automated update of the opal cdn mechanism if that's okay with you guys. we were thinking about putting a task into the rakefile to update it and then running it on one of our servers to check it out and to also update the main cdn page to show a listing of files as per: opal/opal-cdn#1 -- of course we'd like to add in opal-jquery, opal-browser and any thing else from opal org that you'd like to pop in.
we are planning on throwing it onto one of our servers as a scheduled task that runs every X hours to make sure that master is updated and hopefully we can figure out a way to watch for version bumps keep current up-to-date as well
(on the cdn)
Elia Schito
@elia
Jul 09 2014 22:36

re: require. i thought you'd implemented that in master such that we can require other .rb files within .rb scripts

@ylluminate I did, but I don’t see how they can be useful for the cdn…

ylluminate
@ylluminate
Jul 09 2014 22:39
it's very useful for creating multi file projects. for example, my son is making a tutorial game in opal that is separated out into multiple files in js via require.js
he wants to likewise be able to use simple ruby requires the same way within this opal version so that he can demonstrate the power of using opal in browser as an introduction to folks
he is planning on creating several opal tutorials in this fashion and is loath to just embed it all within a singular file or even to include it via js includes in the html
ylluminate
@ylluminate
Jul 09 2014 22:44
@elia does that not make sense?
Elia Schito
@elia
Jul 09 2014 22:44
sorry, watching the world cup in the meanwhile :soccer:
ylluminate
@ylluminate
Jul 09 2014 22:44
lol
Elia Schito
@elia
Jul 09 2014 22:47
k, well, the require stuff is oriented to precompilation
but there’s already some support for the nodejs runner
ylluminate
@ylluminate
Jul 09 2014 22:48
do you have an idea of how to make it work as well for this scenario?
so that on-the-fly approach would leverage nodejs runner?
yep, the nodejs runner will need to require stuff at runtime (e.g. in bin/opal -e 'puts 5’)
ylluminate
@ylluminate
Jul 09 2014 22:55
hmm, so walk me through this mentally here. what roughly, in an outline, would need to be done to allow requires to operate on the fly in browser?
Elia Schito
@elia
Jul 09 2014 22:56
oh, wait, isn’t require_remote enough for that?
ylluminate
@ylluminate
Jul 09 2014 22:57
oh, wait... what's that? i've not looked into that
Elia Schito
@elia
Jul 09 2014 22:58
when you require opal-parser require_remote is added to Kernel
and takes a URL
that will be loaded via (A)JAX (synchronously)
ylluminate
@ylluminate
Jul 09 2014 22:59
interesting, then that's essentially the same thing; seems as though that if running in browser require could be an alias of require_remote with a little setup
so you could effectively say require_remote "rb/my_include.rb" to get an rb file from within the rb subfolder of the site
Elia Schito
@elia
Jul 09 2014 23:01
yes a custom require implementation with a base url + cdn fallback should work
and no MRI server
ylluminate
@ylluminate
Jul 09 2014 23:03
slick, require_remote worked a treat it appears for him
Elia Schito
@elia
Jul 09 2014 23:04
…which reminds me how much we need documentation
ylluminate
@ylluminate
Jul 09 2014 23:04
indeed
but yes, if we can add a little logic to use require_remote when in a non mri env, then this would be great and would preclude the need to tell ppl this, thus minimizing documentation on this aspect
it's silly that just such a simple thing caused such a head->wall bashing for so long earlier for him.
Elia Schito
@elia
Jul 09 2014 23:07
yeah, but it should be opt-in b/c ppl buiding in MRI single file via Opal::Builder
builder will coiplaint if it can’t find a file
ylluminate
@ylluminate
Jul 09 2014 23:08
well, can't we add an env test? crudely: if mri/builder, use std require; else use require_remote
Elia Schito
@elia
Jul 09 2014 23:09

…such a simple thing…

plz turn the pain into docs!

ylluminate
@ylluminate
Jul 09 2014 23:09
or vice-versa: if cdn, use require_remote, else just good old require
i imagine the latter is easier to test
lol
Elia Schito
@elia
Jul 09 2014 23:09
Need a code example to fully understand I guess
ylluminate
@ylluminate
Jul 09 2014 23:10
k, i will ponder on this as i get some time