These are chat archives for opal/opal

26th
Jan 2016
Brady Wied
@wied03
Jan 26 2016 02:34
@ylluminate @fkchang - lighttable sounds like trying to get back to what IDEs give us. I've always missed IDEs. :)
Martin Becker
@Thermatix
Jan 26 2016 13:53
I used to be forum acquaintances with one of the guy's that built light-table an interesting idea I think.
Ilya Bylich
@iliabylich
Jan 26 2016 15:35

@elia What do you think about replacing https://github.com/opal/opal/blob/master/lib/opal/nodes/def.rb#L107 from

unshift "function("

To:

function_name = valid_name?(mid) ? mid : ''
unshift "function #{function_name}("

to provide meaningful method names in traces like

Opal.defn(self, '$a_method', function a_method() {
I know, it increases size of js file, so I can add it as a compiler option for dev env
Elia Schito
@elia
Jan 26 2016 15:38
@iliabylich looks good, and would like to see how much the size is increased, bc it could turn out it's negligible
@iliabylich also we must ensure it doesn't shadow any local or closure variable
class A
  foo = 123
  def foo; end
  p foo
end
should output 123 and not #<Proc:34563654>
Ilya Bylich
@iliabylich
Jan 26 2016 15:50
0.9% of the current uncompressed opal stdlib size. was 570856, now 575899
And yes, I've forgot about that case with local vars. Theoretically it can conflict with any local var from the JS world, right?
Well, it seems that your example actually works with this naive implementation :smile:
Elia Schito
@elia
Jan 26 2016 16:03
good!
Mitch VanDuyn
@catmando
Jan 26 2016 16:28
does opal-rspec (or any other testing stuff) require phantomjs 1.9.8 vs. phantomjs 2x? Trying to run react.rb tests on a new mac, which only supports phantomjs 2x
Elia Schito
@elia
Jan 26 2016 16:28
@catmando should be fine with both
Mitch VanDuyn
@catmando
Jan 26 2016 16:29
any clue what is giving this:
bundle exec rake                          
/Users/Thermatix/.rbenv/versions/2.2.3/bin/ruby -I/Users/Thermatix/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/rspec-core-3.3.2/lib:/Users/Thermatix/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/rspec-support-3.3.0/lib /Users/Thermatix/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/rspec-core-3.3.2/exe/rspec --pattern spec/\*\*\{,/\*/\*\*\}/\*_spec.rb
/Users/Thermatix/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/rspec-core-3.3.2/exe/rspec: No such file or directory - var
Run options:
  include {:focus=>true}
  exclude {:opal=>true}

All examples were filtered out; ignoring {:focus=>true}
..................................

Finished in 13.68 seconds (files took 2.89 seconds to load)
34 examples, 0 failures

Only PhantomJS v1 is currently supported,
if you're using homebrew on OSX you can switch version with:

  brew switch phantomjs 1.9.8
there is the opal part of the rake task
Opal::RSpec::RakeTask.new('opal:rspec') do |s|
  s.append_path 'spec/vendor'
  s.index_path = 'spec/index.html.erb'
end
Brady Wied
@wied03
Jan 26 2016 16:31
@catmando - what version of opal-rspec are you using? this one looks old
Mitch VanDuyn
@catmando
Jan 26 2016 16:32
checking...
Martin Becker
@Thermatix
Jan 26 2016 16:32
opal-rspec (0.4.3)
Mitch VanDuyn
@catmando
Jan 26 2016 16:32
s.add_development_dependency 'opal-rspec', '0.4.3'
Brady Wied
@wied03
Jan 26 2016 16:32
Yeah, that one is pretty dated @ this point
I'd strongly recommend going to 0.5
Mitch VanDuyn
@catmando
Jan 26 2016 16:33
we can try... I am thinking that something broke... but we will give it whirl.
Martin Becker
@Thermatix
Jan 26 2016 16:33
ok, changed it
Mitch VanDuyn
@catmando
Jan 26 2016 16:33
drum roll
Brady Wied
@wied03
Jan 26 2016 16:34
but opal-rspec 0.5 does support phantom js V2
0.4 does not
Martin Becker
@Thermatix
Jan 26 2016 16:34
Bundler could not find compatible versions for gem "opal-rspec":
  In Gemfile:
    opal-rails (= 0.8.1) ruby depends on
      opal-rspec (~> 0.4.3) ruby

    opal-rspec (~> 0.5) ruby
Brady Wied
@wied03
Jan 26 2016 16:34
As to opal-rails, @elia would have to chime in
Mitch VanDuyn
@catmando
Jan 26 2016 16:35
that may have been the problem... but @thermatix, well you can take off the opal-rails restriction and see what happens, but I vaguely think things break...
perhaps not.
Martin Becker
@Thermatix
Jan 26 2016 16:36
ok, lets see what happens
when i update
yeah....
it broke a lot
Bundler could not find compatible versions for gem "opal-rspec":
  In Gemfile:
    opal-rails (>= 0) ruby depends on
      opal-rspec (~> 0.4.3) ruby

    opal-rspec (~> 0.5) ruby
Bundler could not find compatible versions for gem "opal":
  In Gemfile:
    reactive-ruby (>= 0) ruby depends on
      opal (= 0.8.0) ruby

    opal-rspec (~> 0.5) ruby depends on
      opal (< 0.10, >= 0.8.0) ruby

    reactive-ruby (>= 0) ruby depends on
      opal-activesupport (>= 0.3.0) ruby depends on
        opal (< 1.0.0, >= 0.5.0) ruby

    reactive-ruby (>= 0) ruby depends on
      opal-browser (= 0.2.0) ruby depends on
        opal (>= 0) ruby

    opal-rails (>= 0) ruby depends on
      opal (~> 0.3.43) ruby
Bundler could not find compatible versions for gem "rails":
  In Gemfile:
    react-rails (= 1.3.1) ruby depends on
      rails (>= 3.2) ruby

    opal-rails (>= 0) ruby depends on
      rails (~> 3.2.0) ruby

    rails (= 4.2.4) ruby
Bundler could not find compatible versions for gem "railties":
  In Gemfile:
    rails (= 4.2.4) ruby depends on
      railties (= 4.2.4) ruby

    rspec-rails (= 3.3.3) ruby depends on
      railties (< 4.3, >= 3.0) ruby

    opal-rails (>= 0) ruby depends on
      railties (~> 3.2.0) ruby
Elia Schito
@elia
Jan 26 2016 16:37
@catmando @Thermatix @wied03 need to loose the opal-rails dependency requirement for opal-rspec
Brady Wied
@wied03
Jan 26 2016 16:38
@elia - maybe i misinterpreted but opal-rspec has no opal-rails dependency
Martin Becker
@Thermatix
Jan 26 2016 16:38
ok, commented out opal-rails
Elia Schito
@elia
Jan 26 2016 16:38
reverse it, my bad :)
Martin Becker
@Thermatix
Jan 26 2016 16:38
ok, no errors
Elia Schito
@elia
Jan 26 2016 16:39
released opal-rails depends on opal-rspec 0.4
Martin Becker
@Thermatix
Jan 26 2016 16:39
but
the test app needs opal-rails
This message was deleted
Setting up test app database...
rake aborted!
LoadError: cannot load such file -- opal-rails
/Users/Thermatix/dev/ruby_projects/react.rb/spec/test_app/config/application.rb:9:in `<top (required)>'
/Users/Thermatix/dev/ruby_projects/react.rb/spec/test_app/Rakefile:4:in `require'
/Users/Thermatix/dev/ruby_projects/react.rb/spec/test_app/Rakefile:4:in `<top (required)>'
(See full trace by running task with --trace)
Mitch VanDuyn
@catmando
Jan 26 2016 16:40
@thermatix, i think the suggestion is just take out all the opal version specs, and do an update and see what you get.
  s.add_development_dependency 'rake'
  s.add_development_dependency 'rspec-rails', '3.3.3' 
  s.add_development_dependency 'timecop'
  s.add_development_dependency 'opal-rspec', '0.4.3' <- THIS ONE
  s.add_development_dependency 'sinatra'

  # For Test Rails App
  s.add_development_dependency 'rails', '4.2.4'
  s.add_development_dependency 'react-rails', '1.3.1'
  s.add_development_dependency 'opal-rails', '0.8.1' <- THIS ONE
Martin Becker
@Thermatix
Jan 26 2016 16:41
ok, tests running
still failed at phantomjs
I removed the version reqs from anything related to opal
Mitch VanDuyn
@catmando
Jan 26 2016 16:47
to be sure make 'opal-rspec', '~>0.5.0' or check which version is in there.
perhaps you have to regenerate the test app as well?
Martin Becker
@Thermatix
Jan 26 2016 16:48
I did but I'll do it again any way
yeah adding ', '~>0.5.0' to opal-rspec breaks the bundle update
Mitch VanDuyn
@catmando
Jan 26 2016 16:58
so there is still something depending on the older version right?
Elia Schito
@elia
Jan 26 2016 17:00
try with gem 'opal-rails', github: 'opal/opal-rails', branch: '0-8-stable'
should allow for opal-rspec 0.5
let me know if it works
Mitch VanDuyn
@catmando
Jan 26 2016 17:02
@/all - I'm reading about redux... my immediate thought is that it would be very nice with a good ruby wrapper around it. Has anybody had any thoughts? Is there any work on a ruby wrapper for the immutable js library? Or a immutable opal library...
Martin Becker
@Thermatix
Jan 26 2016 17:05
it worked but now some of the specs are failing
with opal at ~> 0.8
tests that failed:
rspec ./spec/reactive-ruby/component_loader_spec.rb:24 # ReactiveRuby::ComponentLoader#load loads given asset file into context
rspec ./spec/reactive-ruby/component_loader_spec.rb:32 # ReactiveRuby::ComponentLoader#load is truthy upon successful load
rspec ./spec/reactive-ruby/component_loader_spec.rb:44 # ReactiveRuby::ComponentLoader#load! is truthy upon successful load
rspec ./spec/reactive-ruby/component_loader_spec.rb:56 # ReactiveRuby::ComponentLoader#loaded? is truthy if components file is already loaded
Elia Schito
@elia
Jan 26 2016 17:11
you have any async spec?
Martin Becker
@Thermatix
Jan 26 2016 17:11
async?
noidea
Elia Schito
@elia
Jan 26 2016 17:12
yes, opal-rspec supports async specs, never mind :)
Martin Becker
@Thermatix
Jan 26 2016 17:12
I'm only trying to see if I can get react.rb specs to run under opal 0.9
I didn't write them though :P
Brady Wied
@wied03
Jan 26 2016 17:12
@catmando - @jgaskins already has an Opal redux equivalent called grand central
Mitch VanDuyn
@catmando
Jan 26 2016 17:13
cool
Forrest Chang
@fkchang
Jan 26 2016 17:16
@catmando I've been hoping to get into redux at some point, I would think the opal wrapper would hope to address some of the boiler plate code issues that the creator of cycle.js pointed out in his criticism of redux. Primarily I want to use the redux devtools, and generally ride redux's active development. I've been interested in @jgaskins grand central, but done nothing but read about, though ditto for redux. I was wondering if grand central could be compatible with the redux devtools (don't really know the interface, w/the devtools, but it should be doable to implement it, if the right corresponding data is tehre, IMO)
Martin Becker
@Thermatix
Jan 26 2016 17:16
there really should be a ruby shortcut for File.expand_path('.', __FILE__)
I use it all the time
Mitch VanDuyn
@catmando
Jan 26 2016 17:23
@fkchang - hence my first take would be a wrapper verses a rewrite.
but the boiler plate is exactly where I think ruby would shine.
Martin Becker
@Thermatix
Jan 26 2016 17:23
but doesn't that just add an extra level of abstraction? which will intern add size and slow down speed?
it's why I prefer opal-browser to opal-jquery
btw I have a suggestion, as a way to separate opal ruby files from regular ruby files couldn't we use the extension .orb?
Mitch VanDuyn
@catmando
Jan 26 2016 17:25
repeat after me :-) there is a world wide developer shortage, not a world wide computer shortage
Martin Becker
@Thermatix
Jan 26 2016 17:25
LOL
Mitch VanDuyn
@catmando
Jan 26 2016 17:26
as long as its not excessive making our lives easy and fun is helpful... You get limited time on this earth, and programmers will always be the limited resource. So first thought should be what will make this easy and fun.
Ilya Bylich
@iliabylich
Jan 26 2016 17:26
@Thermatix '.' is not required, so there's a shortcut File.expand_path(__FILE__) that may help you :smile:
Martin Becker
@Thermatix
Jan 26 2016 17:27
eh
Martin Becker
@Thermatix
Jan 26 2016 17:34
btw I wanted to share a gist
All I have to do is include Asset_Pipeline into my main sinatra app class and
do:
config do
  set :root, File.expand_path('path/to/root/goes/here', __FILE__)
  set :opal_libs, %{ruta react.rb opal-browser}
end
include Asset_Pipeline
at minimum
and I get full asset setup with opal paths appended and routes for taking care of assets
with full mime type handling :P
it also sets the JS compressor to yui and css to sass
OH and it also sets up sprocket helpers