<adambeynon>
elia: I have been testing the native branch of opal-jquery in one of my apps, and its working great. I am still 50/50 on whether to merge it in or not
<adambeynon>
any thoughts?
<elia>
adambeynon, only thing that comes to mind is that having all that goods in the jq prototype was handy
<elia>
adambeynon, native forces to wrap
<elia>
adambeynon, inheritance from Element probably works fine in either case
<adambeynon>
yeah. the only benefit of wrapping was method_missing - but having to have some Element.expose(:my_plugin) line in my opal code isnt too much hassle
<adambeynon>
I think bridged is a better way to go
<adambeynon>
same with Event
<adambeynon>
wrapping that is a pain
<elia>
adambeynon, agreed it's just seamless that way
<elia>
adambeynon, [mavericks time] had any issues installing ruby 1.8?
<adambeynon>
elia: yes, I did. Solved it by fiddling around with the gcc compiler
<adambeynon>
you need to install the Command Line Tools
<adambeynon>
just Xcode doesnt do the job
<adambeynon>
(or not for me atleast)
<elia>
adambeynon, you're using rbenv?
<adambeynon>
elia: yeap
<adambeynon>
you on rvm?
<elia>
yes
<adambeynon>
elia: umm, I guess the instructions are still valid
<elia>
but seems just about the same… yes
<elia>
clitools+brew basically :)
<adambeynon>
brew solves all the problems
<elia>
i still remember the macports time uughgh
<adambeynon>
lol, yeh. many wasted evenings trying to get port working
<adambeynon>
elia: I had the fun of trying to get 1.8 working on mavericks when we were having those travis+racc issues
<elia>
adambeynon, I can imagine
<elia>
adambeynon, I'll have to install ree-2010.02 so i'll probably get my share of fun too
<elia>
adambeynon, the other thing that still worries me about the upgrading is textmate
<adambeynon>
elia: 1.x or 2.0 ?
<elia>
which considering bundles has a good percentage of its code implemented in ruby
<elia>
2 of course :)
<adambeynon>
every 3 months or so I switch between TextMate and Vim ... currently going through a Vim stage, so not sure about textmate bundles
<adambeynon>
ahh, of course mavericks is using ruby-2
<elia>
adambeynon, I tried vim a couple of times and on servers of course, but my fingers get immediately confused and start adding random letters to all OS textfields…
<adambeynon>
elia: finishing off emails with ":w :s" is still a habbit now and then
<adambeynon>
elia: if textmate had split-views I would jump back instantly
<elia>
adambeynon, there's a split surrogate in avian-missing
<meh`>
using file and dirs doesn't have much meaning on the browser
<meh`>
what happened now
<meh`>
oh, errored
<meh`>
not failed
<adambeynon>
meh`: nor does using Encoding when we cant do much with it
<meh`>
adambeynon, we can do enough, and it's part of the language and of any js engine
<adambeynon>
what is part of any js engine?
<meh`>
strings
<meh`>
while file and directories aren't
<meh`>
cherry-picking is good if it's not extremistic
<meh`>
in this case it would just make things harder to maintain and weirder to use
GitHub92 has joined #opal
<GitHub92>
[opal] adambeynon pushed 1 new commit to compiler_nodes: http://git.io/_I7sCQ
GitHub92 has left #opal [#opal]
<GitHub92>
opal/compiler_nodes f3b11ec Adam Beynon: Clean up a load of compiler nodes
<adambeynon>
meh`: the only stuff we are actually able to use it for though is a tiny part considering what Encoding offers on "real" platforms
<meh`>
adambeynon, for now
<meh`>
it's the basics to get byte stuff to work
<meh`>
doesn't mean I'll stop there, I made it clear in the commit it's just the basic stuff to get started
<meh`>
and I don't think it's a good idea to make opal "leaner" in this direction
<meh`>
it should be full featured Ruby by default
<meh`>
I thought we were clear about this
<adambeynon>
opal is never going to be full ruby... if people want full ruby in a browser they are going to use emscripten or the like
<meh`>
well of course, as full featured as possible is what I meant
<meh`>
for a leaner opal I've got nothing against an opal/lean that requires only the minimum required
<meh`>
and you can then require specific parts if you need them
<meh`>
but by default it should require all the corelib available
<adambeynon>
opal should require stuff by default that makes sense in a browser + javascript context. for me, that doesnt include File, Dir or Encoding
travis-ci has joined #opal
<travis-ci>
[travis-ci] opal/opal#1198 (compiler_nodes - f3b11ec : Adam Beynon): The build passed.
<meh`>
fkchang, mutable strings are acoming ( ≖‿≖)
<DouweM>
:D
<meh`>
also inheritance of Array and String
<meh`>
only 68 specs failing with my changes
<Nick____>
=D
<meh`>
without additional overhead unless you're actually using inherited Array, String or mutable strings
<meh`>
which means no overhead most of the time
<fkchang>
meh`: cool, though w/opal-browser's dom builder, I don't need to port the that dom building lib
<fkchang>
but the closer to real ruby, the better
<meh`>
fkchang, yeah, it was more of a "I want this to work" than anything
<meh`>
especially for encodings
<meh`>
I need this stuff
<meh`>
I also partially implemented some encoding stuff
<meh`>
but yeah
<meh`>
new shiny compiler
<meh`>
more compliant stuff
<meh`>
the future is looking good
DrShoggoth has quit [Quit: Leaving]
DouweM has quit [Ping timeout: 264 seconds]
<Nick____>
hi. new to opal here. I have a usage question. I am trying to use Opal to create shared libraries between Ruby on Rails and javascript. On the javascript side, most of our code is not going to be in Opal, but would call opal generated functions. Is this possible? I tried doing Opal.top.$my_function_name(), but got some error "TypeError: Cannot set property '_p' of undefined"
<meh`>
Nick____, using opal functions from raw js is going to be hell
<meh`>
especially as far as blocks go
<Nick____>
hmm
<meh`>
that '_p' stuff is about blocks
<Nick____>
alrite. thanks for the response. wasn't sure if it was supported or not
<meh`>
it's easy to use JS stuff from Opal, but it was never in the plans to make it easy the other way around
<meh`>
but you'd have a lot of ugly code coming up
<meh`>
Opal.Hash.$new({ a: 3, b: 3 }) just to get a hash
<Nick____>
i'm writing all the code in ruby and using that directly in rails
<Nick____>
and having opal convert it to js for the js parts
<meh`>
you could probably write a small layer of helpers to call the compiled stuff, but it sounds rather redundant
ryanstout has joined #opal
<fkchang>
Nick____: depending on your API, this wouldn't necessarily be all that bad. You might want to write some opal wrappers that you can can w/the naming scheme that you are already doing
<fkchang>
Nick____: are you running rails on the backend? You could invoke all the stuff from opal then
<Nick____>
yup
<Nick____>
i was just calling Opal.parse onto the shared lib files(written in ruby)
<Nick____>
it created some js that looks like this -
<Nick____>
def evaluate_order(order, store) subtotal = 0 order.each do |item| subtotal += item[:cost] end total = subtotal * (1 + store[:tax_rate] * 0.01) end
<Nick____>
And I tried calling "Opal.top.$evaluate_order([{cost:15},{cost:10}],{tax_rate:10}"
<Nick____>
i think it didn't find the $mm('each') in what namespace i was calling from or something (not entirely sure how this works still)
<fkchang>
are you using opal rails?
<Nick____>
just regular opal
<Nick____>
i tried opal-rails, but didn't get it working successfully.
<fkchang>
if you use opal rails, then you just put opal files in app/assets/javascripts (or opal), and opal sprockets will do all the magic for you and u won't have to write any js
<Nick____>
okay. i'll try to get that working again then
adambeynon has joined #opal
<meh`>
adambeynon, 66 failing specs with my stuff
<adambeynon>
meh`: niceeeeeee
<adambeynon>
are the 66 easy to fix?
<meh`>
adambeynon, do we have method_added?
<adambeynon>
meh`: nope
<meh`>
yeah, most are
<adambeynon>
"not yet"
<meh`>
adambeynon, I need it
<meh`>
adambeynon, it should be easy to do, no?
<adambeynon>
meh`: kinda. we need to be able to disable it in certain corelib files
<adambeynon>
until its actually defined
<meh`>
adambeynon, right
<meh`>
I need it for String and Array
<adambeynon>
meh`: why?
<meh`>
adambeynon, because
<meh`>
if you add methods on String they won't be on the literal
<meh`>
I have to reflect them back to it
<meh`>
or find another way to do it
<meh`>
but so far so good
<meh`>
I'm getting some weird infinite recursion in JSON stuff
<adambeynon>
meh`: doesnt it make more sense to do class MutableString < String
<meh`>
but that should be easy to fix
<meh`>
adambeynon, but then you can't inherit from String
<meh`>
unless I do some inherited magic
<meh`>
I was thinking about that too
<meh`>
but then super would be broken
<meh`>
and I'd need an in-between class
<meh`>
which isn't much of a problem
<meh`>
and would probably be cleaner
<meh`>
but I prefer the wrapping way
<adambeynon>
well, if this is going to be opt in, cant the mutable_string.rb or whatever just re-assign String
<adambeynon>
e.g.
<adambeynon>
LiteralString = String
<adambeynon>
String = nil
<adambeynon>
class String < LiteralString … end
<meh`>
adambeynon, it's not opt-in as in opt-in to compile and use
<meh`>
adambeynon, it's opt-in in the sense you're not hitting slow part if you're not using it explicitly
<meh`>
adambeynon, it doesn't add much code
<meh`>
50 lines top
<meh`>
and doesn't affect much
<meh`>
all I need is method_added
<adambeynon>
meh`: and we cant make it opt-in?
<adambeynon>
which way does it inherit
<adambeynon>
Array < Literal ?
<meh`>
no
<meh`>
they have no relation in the inheritance chain
ryanstout has quit [Quit: ryanstout]
<meh`>
there's Array::Literal
<meh`>
which is the bridged class to the JS Array
<meh`>
then there's Array, which wraps things up when used explicitly
<meh`>
when you do [].whatever it's calling Array::Literal
<meh`>
IF you inherit from Array, you'll be using the wrapper
<meh`>
otherwise you won't even realize it
<fkchang>
adambeynon: meh` how do I get mspec to not crash --- Forrests-MacBook-Pro:opal fkchang$ rake mspec
<fkchang>
/Users/fkchang/src/opal/Rakefile:128:in `block in <top (required)>'
<meh`>
adambeynon, having Array::Literal as an ancestor fucks up the whole deferral of things
<meh`>
adambeynon, the only thing needed to make it work transparently is method_added
<adambeynon>
fkchang: rubyspec is a git submodule
<meh`>
so I can intercept the addition
<meh`>
define the same method on Array::Literal
<meh`>
and undef it in Array
<meh`>
which is basically no overhead since you're not going to add methods to Array in a tight loop for billions of time
<adambeynon>
meh`: cant we just add some inherited hook
<adambeynon>
so swizzle the prototypes
<adambeynon>
on Array subclasses
<meh`>
adambeynon, that could be done, yes
<meh`>
I'll think about it
<meh`>
I have the feeling there's something I'm not considering with that approach
<adambeynon>
fkchang: did you get it working?
<adambeynon>
git submodule update --init
<adambeynon>
we use the real rubyspec git repo for our specs now
<adambeynon>
well, most of them
<meh`>
not enough of them :P
<fkchang>
adambeynon: meh` submodule init took care of it - different since the last time I tried to run rake on opal (like months ago)
<fkchang>
this is disturbing
<fkchang>
Failures:
<fkchang>
<fkchang>
1. Time#day returns the day of the month for a UTC Time
<fkchang>
<fkchang>
Expected 31 to equal 1
<fkchang>
meh`: so what percent of rubyspecs are we running. Looking for stats for my preso
<adambeynon>
fkchang: someone else reported that spec failing for them
<adambeynon>
will need to look into it
<adambeynon>
fkchang: not sure about percentage
<adambeynon>
I can find out though
<meh`>
fkchang, yeah, you get that if you're in the US
<meh`>
fkchang, none of us is there
<meh`>
we're all from Europe
<meh`>
adambeynon, yeah, an inherited trick is the best way to go
<meh`>
I'll scrap what I've done now and go with that
shawn42 has joined #opal
<shawn42>
hello
<meh`>
hello
<Nick____>
hello
<shawn42>
I wanted to try out pixi.js + opal ..
<shawn42>
what's the best way to translate something like
<shawn42>
var stage = new PIXI.Stage(0x66FF99);
<shawn42>
to:
<shawn42>
stage = PIXI::Stage.new 0x66FF99
<meh`>
shawn42, the best way would be to wrap it
<meh`>
OR
<meh`>
module PIXI; class Stage; def self.new(value); Native(`new PIXI.Stage(value)`); end; end; end
<meh`>
but writing an opal-pixi would be the best way to go
<shawn42>
so basically hand roll a wrapper around the entire library?
<shawn42>
meh`: also, is Native the way to pass raw js through opal?
<meh`>
shawn42, yes, Native() wraps whatever value into an usable Opal object
<meh`>
methods called on it are forwarded to the native object
<meh`>
also yes, the best way to go is usually writing a full blown wrapper
<meh`>
it's not a must, but that way you can make things more ruby-esque
<meh`>
especially if you have methods following camel case in the native object
<meh`>
stage.thisIsAMethod looks weird in Ruby
<shawn42>
makes sense
<meh`>
and if it's a good library you might make someone else very happy :)
<fkchang>
adambeynon: yeah, any metrics would be good, I'm pitching that opal is basically ruby so a reasonably high rubyspec percentage looks good, else, claiming 2367 specs sounds reasonably good
<meh`>
fkchang, with my round of cleanups it's even more compatible now :>
GitHub159 has joined #opal
GitHub159 has left #opal [#opal]
<GitHub159>
opal-sprockets/master 30e704d Adam Beynon: Use Opal::Compiler directly
<GitHub159>
[opal-sprockets] adambeynon pushed 1 new commit to master: http://git.io/0ethew
GitHub105 has joined #opal
GitHub105 has left #opal [#opal]
<GitHub105>
opal/master 961416a Adam Beynon: Opal::Compiler as sole compiler class
<GitHub105>
[opal] adambeynon pushed 1 new commit to master: http://git.io/6l07aA
<shawn42>
meh`: does including modules work in opal.rb?
<meh`>
shawn42, yes
<shawn42>
also, what's the best source of docs (for things like Native, etc)
<meh`>
I think there's some stuff in the doc/ folder and on the website
<shawn42>
all the doc links I find just take me to the github landing page >.<
<meh`>
someone must have forgotten to update the links
<shawn42>
yeah
<shawn42>
meh`: can you tell me what I'm doing wrong here:
<Nick____>
I do however get "Uncaught NoMethodError: undefined method `bridge_class' for Class" errors in javascript when using opal-rails. Any idea what that is?
<meh`>
Nick____, that's basically from the prelude
<fkchang>
Nick____: glad you have stuff working, what happens for Document.ready?
<meh`>
fkchang, when's RubyConf again?
<fkchang>
meh`: nov 8-10
<Nick____>
fkchang, nothing happens
<Nick____>
oh. i get an extra one of these "Uncaught NameError: uninitialized constant Object::Document"
<Nick____>
well, just one of those. not an extra one
elia has quit [Quit: Computer has gone to sleep.]
<Nick____>
Uncaught NoMethodError: undefined method `bridge_class' for Class error.js?body=1:20 Uncaught NameError: uninitialized constant Object::Element error.js?body=1:20 Uncaught NoMethodError: undefined method `bridge_class' for Class error.js?body=1:20 Uncaught NameError: uninitialized constant Object::Document error.js?body=1:20
elia has joined #opal
<meh`>
Nick____, those ones are really weird
<Nick____>
maybe my assets still aren't setup correctly
<fkchang>
Nick____: maybe elia will know, but I suspect maybe you need to add gem opal-jquery to your gemfile. I believe since I wrote the gist that opal-jquery might've been unbundled from opal-rails
<meh`>
meh, two new critical bugs
<fkchang>
btw, the gist is liek a year old, that's a lifetime in opal years
<meh`>
let's hope adam fixes them before I wake up
<meh`>
Nick____, you should nudge elia into writing a tutorial to use opal-rails, he's the main author and user
<fkchang>
meh`: how can I tell which mspec's are not being run?
<meh`>
fkchang, you can't
<meh`>
fkchang, well
<meh`>
you can tell which ones are being ran
<meh`>
spec/rubyspecs is the list
<elia>
Nick____, im here, whats'up?
<meh`>
in spec/filters the filtered ones for a reason or another
<Nick____>
elia, could you write a tutorial on using opal-rails =D
<elia>
:)
<fkchang>
elia: he couldn't get opal-rails to work, and then he followed a gist I wrote about a year ago https://gist.github.com/fkchang/3956417 which fails on Document.ready? My theory is that opal-jquery needs to be included too which defines that
<elia>
Nick____, you already gone through the readme?
<Nick____>
i was getting errors putting in the configurations when i tried it first time. i haven't tried it since i got it working tho (w/o it)
<elia>
Nick____, opal-jquery is already a dependency
<fkchang>
looks like my gist is 90ish% based on your readme
<Nick____>
adding opal-jquery seemed to fix the errors
<Nick____>
Document.ready? seems to work now too!
<elia>
Nick____, fkchang, the gist seems fine
<elia>
Nick____, gratz! ;)
<Nick____>
so i think i'm good now. thanks for the help meh', fkchang, and elia
<elia>
Nick____, just to be sure, what was the error?
<elia>
improving the readme is a good thing anyways
<Nick____>
elia, Uncaught NoMethodError: undefined method `bridge_class' for Class error.js?body=1:20 Uncaught NameError: uninitialized constant Object::Element error.js?body=1:20 Uncaught NoMethodError: undefined method `bridge_class' for Class error.js?body=1:20
<elia>
Nick____, sorry, I meant: what was the *solution*?
<Nick____>
w/ only 'opal-rails' gem and not 'opal-jquery' gem
<Nick____>
i had to use both
<Nick____>
it still worked despite getting that error minus the jquery stuff(which i'm not using for my current project)
<elia>
that's strange, opal-jquery is an opal-rails dependency and it's required inside opal/rails
<elia>
Nick____, any chance you had old versions?
<fkchang>
maybe he didn't bundle again?
<Nick____>
i didn't specify any version in my gemfile
<fkchang>
anyways, the error was "Uncaught NameError: uninitialized
<fkchang>
constant Object::Document" which just screamed opal-jquery was missing to me
<elia>
fkchang, sure thing
<Nick____>
hmm. i'm not getting the error anymore when i remove opal-jquery gem
<elia>
Nick____, you still have the logs of the bundle install?
<elia>
Nick____, fkchang, I'm quite sure the bundle install triggered the update of either opal-jquery or opal-rails or opal
<meh`>
and if it was opal, gray times ahead
<meh`>
I think the new compiler wasn't that ready
<meh`>
it broke all my things :D
<Nick____>
Fetching gem metadata from https://rubygems.org/........... Fetching gem metadata from https://rubygems.org/.. Resolving dependencies... Using rake (10.1.0) Using i18n (0.6.1) Installing multi_json (1.8.2) Using activesupport (3.2.13) Using builder (3.0.4) Using activemodel (3.2.13) Using erubis (2.7.0) Using journey (1.0.4) Using rack (1.4.5) Using rack-cache (1.2) Using rack-test (0.6.2) Using hike (1.2.3) Using tilt (1.4.1) Using
<Nick____>
k (3.2.13) Using mime-types (1.25) Using polyglot (0.3.3) Using treetop (1.4.15) Installing mail (2.5.4) Using actionmailer (3.2.13) Using arel (3.0.2) Using tzinfo (0.3.38) Using activerecord (3.2.13) Using activeresource (3.2.13) Using bundler (1.3.4) Using coffee-script-source (1.6.3) Using execjs (2.0.2) Using coffee-script (2.2.0) Using rack-ssl (1.3.3) Using json (1.8.1) Using rdoc (3.12.2) Using thor (0.18.1) Using railties (3
<Nick____>
Using execjs (2.0.2) Using coffee-script (2.2.0) Using rack-ssl (1.3.3) Using json (1.8.1) Using rdoc (3.12.2) Using thor (0.18.1) Using railties (3.2.13) Using coffee-rails (3.2.2) Using jquery-rails (3.0.4) Using rails (3.2.13) Using sass (3.2.12) Using sass-rails (3.2.6) Installing sqlite3 (1.3.8) Installing uglifier (2.2.1) Your bundle is complete! Use `bundle show [gemname]` to see where a bundled gem is installed.
<Nick____>
oh
<Nick____>
ignore that. thats before i added the gem
<Nick____>
Resolving dependencies... Using rake (10.1.0) Using i18n (0.6.1) Using multi_json (1.8.2) Using activesupport (3.2.13) Using builder (3.0.4) Using activemodel (3.2.13) Using erubis (2.7.0) Using journey (1.0.4) Using rack (1.4.5) Using rack-cache (1.2) Using rack-test (0.6.2) Using hike (1.2.3) Using tilt (1.4.1) Using sprockets (2.2.2) Using actionpack (3.2.13) Using mime-types (1.25) Using polyglot (0.3.3) Using treetop (1.4.15) Us
<elia>
Nick____, wait
<Nick____>
(3.2.13) Using arel (3.0.2) Using tzinfo (0.3.38) Using activerecord (3.2.13) Using activeresource (3.2.13) Using bundler (1.3.4) Using coffee-script-source (1.6.3) Using execjs (2.0.2) Using coffee-script (2.2.0) Using rack-ssl (1.3.3) Using json (1.8.1) Using rdoc (3.12.2) Using thor (0.18.1) Using railties (3.2.13) Using coffee-rails (3.2.2) Using haml (4.0.3) Using haml-rails (0.4) Using jquery-rails (3.0.4) Using racc (1.4.10) U