These are chat archives for opal/opal

18th
Jun 2015
Jamie Gaskins
@jgaskins
Jun 18 2015 02:06
@ryanstout I remember at one point in 0.7 beta, using require_tree with Rails wouldn't load files that were added after the first compilation — for example, if you had require_tree 'foo', it would load the existing foo/bar, but if you added the file foo/baz after loading the app, it wouldn't load that. Is that similar to what you're seeing?
I was going to file an issue about this when I first saw it, but I forgot because I never use require_tree. :-)
Ryan Stout
@ryanstout
Jun 18 2015 02:08
@jgaskins thanks. I'm just using the builder in 0.7.2, so I think its specific to that. Basically, I was thinking that require_tree would look through the Opal.paths, but the current implementation just checks based on the current working directory.
if I get some time, I might try to make it work with the paths, but for now I just went back to manual require's
Rick Carlino
@RickCarlino
Jun 18 2015 12:39
Hey guys- I'm having some issues compiling a static site that uses opal-browser:
# Gemfile
gem 'opal'
gem 'opal-browser'

# Rakefile
require 'opal'
require 'opal-browser'

desc "Build our app to build.js"
task :build do
  Opal.append_path "app"
  File.binwrite "build.js", Opal::Builder.build("application").to_s
end

# app/application.rb
require 'opal'
require 'browser'

alert "Wow, running opal!"
$ rake build
rake aborted!
LoadError: cannot load such file -- opal-browser
/home/rick/code/static-opal/Rakefile:3:in `<top (required)>'
/home/rick/.rvm/gems/ruby-2.2.0/bin/ruby_executable_hooks:15:in `eval'
/home/rick/.rvm/gems/ruby-2.2.0/bin/ruby_executable_hooks:15:in `<main>'
(See full trace by running task with --trace)
Francesco 'makevoid' Canessa
@makevoid
Jun 18 2015 12:43
maybe you need to load bundler correctly
otherwise it will search for system gems

or you could do

require 'bundler/setup'
Bundler.require :default

and remove the two require statements

Elia Schito
@elia
Jun 18 2015 12:43
require 'opal/browser'?
Francesco 'makevoid' Canessa
@makevoid
Jun 18 2015 12:44
it fails in Rakefile not in application.rb
Rick Carlino
@RickCarlino
Jun 18 2015 12:47
Looks like @makevoid 's fix works. Thanks!
Francesco 'makevoid' Canessa
@makevoid
Jun 18 2015 12:47
your welcome!
enjoy opal
:D
This message was deleted
Rick Carlino
@RickCarlino
Jun 18 2015 13:08
Has anyone gotten uninitialized constant Opal::Tilt? I'm using opal-browser 0.2.0.beta1
Elia Schito
@elia
Jun 18 2015 13:10
which opal version?
Rick Carlino
@RickCarlino
Jun 18 2015 13:12
Had to downgrade to 0.6.3. Was trying to work around this one: opal/opal-browser#10
Ended up breaking it in the process, I think.
Jared White
@jaredcwhite
Jun 18 2015 15:06
@elia and others - great job on the latest Opal and opal-rails stuff -- source maps working!!! YAY!!! :clap:
I do have one concern which I mentioned here: https://github.com/opal/opal-rails/issues/49#issuecomment-113186052
It seems there's no more require_tree for including many Opal files in a folder. My homegrown front-end framework expects there to be a variable number of files in each of the main folders (controllers, views, etc.), and it seems like a big pain to have to remember to go in and explicitly add require 'controller/foo' type statements for every single one.
Elia Schito
@elia
Jun 18 2015 15:11
@jaredcwhite see my answer, but basically you just have to use require_tree from opal instead of using the sprockets magic comment
Mitch VanDuyn
@catmando
Jun 18 2015 15:33
Does 0.8 still require sprockets 3.x? (Q1)
Q2 - is there a from_n or some other concept like that, where I can add a method to a class that will convert from a native object to an instance of that class? Obviously I can do a JSON parse, and then allow the classes .new method to accept a hash, but it seems like there should be a standard way of announcing the intention
Elia Schito
@elia
Jun 18 2015 15:44
Q1 - yes, sorry
Q2 - no, but it's a good idea, yet we should first look at how Ruby handles this kind of things first to see if there's some standard we can adhere to
cc @meh ^^
Forrest Chang
@fkchang
Jun 18 2015 16:09
@RickCarlino I had that problem, on 6.2, and got around it. Don't remember how, search the irc, @meh had to help me out on it, IIRC
Rick Carlino
@RickCarlino
Jun 18 2015 16:17
Ah, no worries, I ended up just using Opal-JQ in the meantime
Mitch VanDuyn
@catmando
Jun 18 2015 18:05
@elia - that's what I was thinking (re from_native) I mean you could just have .new check to see if the incoming param is native, in which case do the conversion. Hmmm... maybe that is a good enough convention.
Mitch VanDuyn
@catmando
Jun 18 2015 19:48
So what is the canonical way to check if an object is native or not?
Elia Schito
@elia
Jun 18 2015 20:03
Hash.new word that way
and native.rb adds Kernel#native? iirc
Ryan Stout
@ryanstout
Jun 18 2015 20:47
how do I get a javascript date object into an opal time object?
Ryan Stout
@ryanstout
Jun 18 2015 20:52
nevermind, figured it out
ylluminate
@ylluminate
Jun 18 2015 21:14
@adambeynon thank you for taking action on those "issues" gone wild.