adambeynon changed the topic of #opal to: http://opalrb.org - Ruby runtime and library on top of Javascript | 1.0.0 is near | This channel is logged at http://irclog.whitequark.org/opal
elia has quit [Quit: Computer has gone to sleep.]
elia has joined #opal
<meh`> elia, adambeynon, http://sprunge.us/ZIFc?rb
<meh`> > bundle exec bin/opal /tmp/lol.rb
<meh`> [3, 4, 8, 24]
meh` has quit [Ping timeout: 248 seconds]
elia has quit [Quit: Computer has gone to sleep.]
DouweM has quit [Read error: Connection reset by peer]
skofo has joined #opal
marcandre has quit [Remote host closed the connection]
admin_ has joined #opal
admin_ has quit [Client Quit]
admin_ has joined #opal
admin_ has quit [Client Quit]
schappim has joined #opal
<schappim> Hey all!
<schappim> I'm wondering if anyone knows of an Opal project that has Meteor-esque live page updates / data synchronization?
elia has joined #opal
skofo has quit [Ping timeout: 264 seconds]
GitHub46 has joined #opal
<GitHub46> opal/master 0b9b521 Elia Schito: Merge pull request #461 from skofo/fixed-bin...
<GitHub46> [opal] elia pushed 2 new commits to master: http://git.io/Hht8BA
GitHub46 has left #opal [#opal]
<GitHub46> opal/master f986253 Artur Ostrega: fixed opal command without options
travis-ci has joined #opal
travis-ci has left #opal [#opal]
<travis-ci> [travis-ci] Build details : http://travis-ci.org/opal/opal/builds/15881279
<travis-ci> [travis-ci] opal/opal#1619 (master - 0b9b521 : Elia Schito): The build passed.
DouweM has joined #opal
meh` has joined #opal
schappim has quit [Quit: Leaving...]
elia has quit [Quit: Computer has gone to sleep.]
elia has joined #opal
elia has quit [Quit: Computer has gone to sleep.]
elia has joined #opal
elia has quit [Quit: Computer has gone to sleep.]
elia has joined #opal
<adambeynon> meh`: with promises, can a #then() block be called more than once?
<adambeynon> i.e. does it work as event handlers
<meh`> adambeynon, no
<meh`> adambeynon, that's what #and is for
<adambeynon> meh`: element.on(:click).and { ... } ?
<meh`> adambeynon, the thing is, multiple thens are chained and they get the next value
<meh`> basically
<meh`> Promise.new.tap {|p| p.then { |x| x * 2 }.then { |x| puts x } }.resolve(2) will output 4
<meh`> Promise.new.tap { |p| p.then { |x| x * 2 }.and { |x| x * 3 }.then { |*args| puts args.inspect } }.resolve(2)
<meh`> will output [4, 6]
<meh`> the problem with multiple thens registering on the same promise is what they return
<meh`> then is for chaining, and is for grouping
<adambeynon> right, makes sense.
<meh`> I could allow multiple then chains if you think it's worthwhile
<meh`> but it would be kind of awkward
<meh`> I mean, promises are already fairly confusing
<adambeynon> no, dont think its needed really. are the callbacks intended to always be async?
<meh`> yes
<meh`> and no
<meh`> depends :D
<meh`> if the previous then returns a promise
<meh`> it will be async
<meh`> if it returns a value, it won't
<adambeynon> say, Model.find(1).then { ... }
<meh`> that is async, yes
<meh`> but
<adambeynon> even if the data is already cached
<meh`> if it's already resolved
<meh`> if the data is already there
<meh`> the #then will resolve when you define it
<meh`> it all depends on the state of the promise
<meh`> if it's resolved, it resolves the next one
<meh`> if it isn't, it waits for it to be resolved
<meh`> and chains the resolution
<meh`> so you can do Promise.value(23).then { |x| puts x }
<meh`> and it will print 23
<meh`> Promise.value(23) is an alias for Promise.new.resolve(23)
<meh`> it returns a realized promise
<meh`> where realized means it either has been resolved or rejected
<adambeynon> right, yes. that makes sense then. how much of it have you implemnted?
<adambeynon> implemented*
<meh`> I had some of it working
<meh`> then I realized I was going in a bad direction
<meh`> and I started over
<meh`> it's hard to do it hard
<meh`> derp
<meh`> it's hard to it right I meant
<meh`> TO DO IT RIGHT
<meh`> FFS
<meh`> but well, you get the idea
<meh`> and the bad direction was I was allowing multiple chaining on the same promise
<meh`> it was getting unbearably complex
<meh`> yeah, too bad I won't be able to see it
<meh`> they could give it for free to the core developers at least :P
<adambeynon> meh`: lolz. Its a good screencast series
<adambeynon> elia: have you watched it?
<elia> nope, just asked mark bates to have it for free without results :(
<meh`> lol
<elia> meh`, u did the same? lol
<meh`> I didn't, I just wished for it
<elia> adambeynon, what about you, have you watched it?
<adambeynon> yep. Was good. It was very targetted at rails devs
<adambeynon> a lot of the ep was setting up opal with rails
<adambeynon> covering sprockets, using .js.rb files etc
<adambeynon> very nice intro
<adambeynon> went straight in with method_missing though, which was probably a good idea
<elia> indeed
<adambeynon> basically, it covers building a Todos app, using a json backend with rails
<adambeynon> I think sticking to jquery + stdlib
<adambeynon> not sure if they touch on vienna/erb/haml etc
<meh`> no love for opal-browser
<meh`> I don't blame them, there's no documentation
<adambeynon> lol, no love for 0.6.0 either ;)
<elia> meh`, lol
<adambeynon> but, I think the aim is to keep it simple, and a lot of rails devs know jquery inside-out
<elia> meh`, honestly I tried to build an opal_ujs with opal-browser but the original jquery code is not that simple…
<elia> and my time was limited
<meh`> it will get better with time
<meh`> since I'm working on a real project that uses both lissio and opal-browser I fix things as I go
<meh`> documentation will come later
<elia> adambeynon, agree, it's just less scary to have jquery around
<meh`> and promises are coming out for this same reason
<meh`> it was getting unbearable
<meh`> adambeynon, does defined? work for ivars?
fkchang has joined #opal
<adambeynon> meh`: should do
Todd has quit [Ping timeout: 240 seconds]
Todd has joined #opal
GitHub135 has joined #opal
<GitHub135> vienna/master 6da369e Adam Beynon: Add TemplateView#partial() for rendering partial templates
GitHub135 has left #opal [#opal]
<GitHub135> [vienna] adambeynon pushed 1 new commit to master: http://git.io/HyGPXg
travis-ci has joined #opal
<travis-ci> [travis-ci] Build details : http://travis-ci.org/opal/vienna/builds/15893312
<travis-ci> [travis-ci] opal/vienna#127 (master - 6da369e : Adam Beynon): The build passed.
travis-ci has left #opal [#opal]
GitHub192 has joined #opal
<GitHub192> vienna/master d2e853d Adam Beynon: Add View#find(selector) as shortcut of element.find(selector)
<GitHub192> [vienna] adambeynon pushed 1 new commit to master: http://git.io/D4jmhQ
GitHub192 has left #opal [#opal]
<meh`> this works now
travis-ci has joined #opal
<travis-ci> [travis-ci] opal/vienna#128 (master - d2e853d : Adam Beynon): The build passed.
travis-ci has left #opal [#opal]
<travis-ci> [travis-ci] Build details : http://travis-ci.org/opal/vienna/builds/15893397
<adambeynon> meh`: nicee \/
<adambeynon> er
<adambeynon> \o/
tils has joined #opal
<fkchang> adambeynon: meh` elia - this guy saw my preso and made a google plus community for opal https://plus.google.com/u/0/communities/103296322417426118371
<elia> :D
<elia> joined, even if I don't like g+ very much, but as long as it's not a fb group I'm oklol
<elia> fkchang, should add links to irc and ggroup as well
elia has quit [Quit: Computer has gone to sleep.]
ryanstout has joined #opal
skofo has joined #opal
skofo has quit [Ping timeout: 260 seconds]
marcandre has joined #opal
<adambeynon> meh`: with lissio, do you have anything like a default route handler?
<adambeynon> un-recognized routes
<meh`> adambeynon, I don't think so
DouweM has quit [Quit: Leaving...]
<meh`> http://sprunge.us/XFEB?rb and this works as well
skofo has joined #opal
fkchang` has joined #opal
ryanstewart2 has joined #opal
fkchang has quit [*.net *.split]
ryanstewart has quit [*.net *.split]
<fkchang`> I restored the sound to the intro of my talk, elia would dig it https://vimeo.com/82573680
<skofo> I saw the slides for that - well done
<fkchang`> skofo: thanks, catch the whole vid if u can, plenty of multimedia
<skofo> I will. Thanks for furthering the cause.
<meh`> p = Promise.error(1337)
<meh`> p.then { puts "hue" }.rescue { |x| puts x.inspect }
<meh`> this works as well :>
<meh`> http://sprunge.us/RgMD all of this is working
<meh`> fkchang`, ready for the lissio awesomeness?
yazgoo has joined #opal
<yazgoo> Hi, how should I proceed if my script uses String#unpack ?
<meh`> yazgoo, you don't, sadly
<meh`> yazgoo, we haven't implemented pack and unpack yet
<meh`> it's very hard to do in javascript
<meh`> but it's in my TODO list
<yazgoo> What if I reimplement it in ruby?
<meh`> if you manage to, pull request welcome :)
<meh`> but I assure you, it's hard
<meh`> strings in javascript are UCS-2 encoded
<yazgoo> Well, I just would need a subset of it ("C*"), so maybe that wouldn't be that hard?
<yazgoo> Anyway, thanks :).
<meh`> so you just want the characters in a string?
<meh`> >> "abc".chars.map(&:ord)
<meh`> => [97, 98, 99]
<meh`> just use that
<meh`> it will work in opal
<meh`> as long as they're below 127
<meh`> it will work
<meh`> then you hit the hard part :)
<fkchang`> meh`: I happily await lissio awesomeness
<meh`> fkchang`, the REST adapter will use the new promise stdlib
<meh`> which allows for much awesomeness
<fkchang`> meh`: catching some of the promise snippets, is it in opal-browser?
<meh`> fkchang`, no, it will be in opal
<meh`> in the stdlib
<fkchang`> oh, I guess I'll need upgrade my stuff to use it. Good stuff
<meh`> fkchang`, it's not there yet
<meh`> should be in few hours
<meh`> it's not easy to implement or think about
<meh`> but makes the user code way more maintainable
<meh`> or well, tomorrow
<fkchang`> It's cool, I'm way behind on where opal-irb is version wise, so I'll need to take some time to upgrade, I think it'd be interesting to play w/the promise stuff in opal-irb
<meh`> just don't overdo it
<meh`> promises are to make code easier to handle, not harder :P
<meh`> there we go, failures, then, collect
<meh`> fkchang`, http://sprunge.us/XdKc
<meh`> now I just have to implement #and and what I need is done :D
dleedev has joined #opal
<dleedev> hi, is there a way to find out what's not supported in opal?
<meh`> dleedev, trying to run the code? :P
<ryanstout> dleedev: what feature is failing?
<dleedev> meh`: Module.extended
<meh`> dleedev, it works
<dleedev> ryanstout: ^
<meh`> is it failing?
<meh`> I remember fixing it
<meh`> dleedev, can you paste a reduced testcase please?
<meh`> are you using master or stable?
<dleedev> I'm using the online interpreter http://opalrb.org/try/#
<meh`> dleedev, yeah, the Opal version there is old
<meh`> dleedev, if you paste a failing test I can run it on master
<dleedev> module Foo; def self.extended(base); puts "extended"; end; end
<dleedev> class Bar; extend Foo; end
<meh`> dleedev, yeah, it works on master
<dleedev> meh`: ok, thanks
<meh`> it's probably in the 0.5.5 release
<dleedev> do you recommend that I work off of master?
<meh`> yes, I do
<meh`> especially now
<meh`> we're very near a 0.6 release
<meh`> the 0.5 has backported fixes
<meh`> some might be missing
<dleedev> is there a binstub for opal's rib?
<dleedev> irb
<meh`> adambeynon, also just a note, wait for the promise stdlib to be up, in case you're thinking about releasing 0.6 without a forewarning
<meh`> dleedev, in the cloned repo, bundle install, bundle exec bin/opal-repl
<dleedev> meh`: yeah, I found that, but when I do a gem install, it only creates the opal binstub, not opal-repl
<meh`> dleedev, yeah, it's missing on purpose, it depends on external dependencies
<dleedev> external dependencies?
<meh`> phantomjs I reckon
<adambeynon> meh`: ok. Pop a gist up of it (or pull request, even)
<meh`> adambeynon, it's not ready yet, should be soon, everything is done except #and
<meh`> which is what I need most
<meh`> it was just a "wait please"
<meh`> so we can focus some attention on it in the release notes
<meh`> adambeynon, http://sprunge.us/XdKc this is what currently works
<dleedev> meh`: opal-repl doesn't seem to support multi-line input
<meh`> dleedev, yeah, it's pretty spartan
<meh`> dleedev, I usually just have a Ruby source with what I need, and run the repl with opal-repl /tmp/whatever.rb
<dleedev> meh`: method_added doesn't seem to be working
<meh`> dleedev, yeah, it's not been implemented yet
<meh`> it can't be enabled in the corelib so we still have to figure out the best way to go
<dleedev> what do you mean it can't be enabled?
<meh`> dleedev, if method_added is present in the corelib, it explodes
<meh`> bootstrap problems
<meh`> it would run when it's not been defined yet
<dleedev> is there a plan to get it working?
<dleedev> or no concrete solutions yet?
<meh`> there is a plan, just no good solution yet
<meh`> and there are more important things to work on
<meh`> dleedev, but yeah, try to poke adambeynon for it :)
<adambeynon> dleedev: yeah, it is on the list of things to do, but I havent given it a full go yet
<dleedev> adambeynon: is there actually a way to make it work?
<adambeynon> yes. opal used to support it, but as the runtime was re-written it was removed, and never got added back
<ryanstout> meh`: is the issue that the core lib would trigger a bunch of method added events if you just has the generation step add them after each def ...
<adambeynon> ryanstout: yes, basically, the corelib would cause a huge number of empty function invocations
<meh`> ryanstout, yep
<adambeynon> so somehow the compiler should skip method_added() for all the corelib files
<meh`> we just need a good way to skip it in the corelib
<adambeynon> I just need to work out a good way to do that without really crappy compiler hardcoding
<adambeynon> magic comments might do the trick.....
<ryanstout> yea, there's probably a better solution than just having a: window.opalCoreLibLoaded = false ; .. load core lib ... ; window.opalCoreLibLoaded = true;
<ryanstout> hehe
<ryanstout> I guess you would still have to invoke the method added function
<meh`> adambeynon, http://sprunge.us/hSBX?rb if you're curious to see the promise implementation so far
<adambeynon> ryanstout: one thought was to allow per-file compiler options - with method_added() being one of the options
<meh`> I don't know if anyone but me can understand through that stuff
<meh`> or through the Enumerator::Lazy stuff for what matters
<adambeynon> meh`: why the inline javascript?
<meh`> adambeynon, for ROFLSPEED
<meh`> adambeynon, those are called often
<meh`> I can change them if you think it's irrelevant tho
<adambeynon> na, thats fine - just wondering if there was an opal bug you were overcoming ;)
<meh`> now the hard part
<meh`> the When stuff is probably the hardest
<meh`> but it's oh so important
<meh`> then it's done
<meh`> then I have to figure out a way to add tests
<meh`> adambeynon, where should I add the tests?
<meh`> spec/opal/stdlib I guess
<meh`> dleedev, anyway, just playing around or planning to use Opal in production? :)
<dleedev> meh`: trying to see if it's something I can use
<dleedev> meh`: don't want to start working on it to get bitten by an unsupported feature
<adambeynon> dleedev: method_added is something that will be added sooner rather than later
<meh`> dleedev, we're usually fast at adding things if they're needed
<meh`> it's just none of us have had the need before
<meh`> has had?
<meh`> meh
<meh`> dleedev, https://github.com/meh/shekels if you want to get a feeling of what you can do with opal
<meh`> dleedev, it uses https://github.com/meh/lissio
<dleedev> meh`: does lissio support binding data to the DOM?
<meh`> dleedev, not yet, it will soon
<meh`> I'm planning something meteor like for it
<meh`> just have to come up with a decent API
<dleedev> seems like destructive string changes are not supported
<meh`> yeah, we have immutable strings
<meh`> and Symbol == String
<dleedev> and that's something that won't change?
<meh`> dleedev, but there's StringIO if you need mutable changes
<meh`> yes, it's something that won't change
<dleedev> is there a list of things that are decided different from Ruby?
ryanstout has quit [Quit: ryanstout]
<dleedev> it would be nice if there was a page on opal's website
<meh`> there was once
<meh`> adambeynon, where did that section of the website go?
<dleedev> it would also be nice to update the "try online" version
<meh`> dleedev, well, the only differences come from limitations in JavaScript
<meh`> dleedev, mutable strings are a no go
<meh`> taint, freeze and untrusted are a no go as well
<adambeynon> dleedev: the try online is the latest gem release version
<meh`> that should give you a good idea of what can't be supported
<meh`> adambeynon, isn't 0.5.5 the latest?
<meh`> the online one is at 0.5.4
<dleedev> method_added is on that list
<meh`> that should really be in bugs, yeah
<meh`> same as string_subclasses
<adambeynon> ah yeah, 0.5.5 only has %i[] added though
<meh`> adambeynon, agree on the move?
<adambeynon> not until they are implemented
<meh`> I think filters/unsupported should be only for definitely unsupported things
<meh`> but anyway, adambeynon I remember a section on the opalrb site stating the differences and features of Opal
<meh`> where did it go?
<adambeynon> not sure really. perhaps in the website => wiki => website moves
<meh`> if this works, magic
<meh`> and it doesn't
<adambeynon> Lol. #when?
<meh`> yeah
<meh`> it seemed too easy, and it was
<meh`> mmh
<meh`> MMMH
<meh`> this should work
<meh`> either something's broken with super
<meh`> (again)
<meh`> or I'm doing something dumb
<meh`> (again)
<meh`> and it was the dumb
<meh`> I forgot a puts ◕ ◡ ◔
<meh`> almost there
<meh`> no, it's all right
<meh`> magic!
<meh`> adambeynon, http://sprunge.us/LRMP :D
<meh`> we have lift off
<meh`> just a final fix to Promise#and and it should be ready
<yazgoo> I'm getting « native_string is not defined » errors when calling String#force_encoding, any idea what's missing ?
<meh`> yazgoo, probably a bug when that stuff has been moved to its own place
<meh`> ok, Promise::When can't be used for Promise#and
<meh`> they act differently
<meh`> need a Promise::And
<meh`> but still, the looking is looking baller
<meh`> *code
<meh`> I wish I could show it