Class: DuoRuby::Server::FrontendCompiler

Inherits:
Object
  • Object
show all
Defined in:
lib/duoruby/server/frontend_compiler.rb

Instance Method Summary collapse

Constructor Details

#initialize(root) ⇒ FrontendCompiler

Returns a new instance of FrontendCompiler.



11
12
13
# File 'lib/duoruby/server/frontend_compiler.rb', line 11

def initialize(root)
  @root = root
end

Instance Method Details

#callObject



15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/duoruby/server/frontend_compiler.rb', line 15

def call
  Opal.reset_paths!
  Opal.use_gem("opal-browser")
  Opal.use_gem("paggio")
  Opal.append_path(File.join(Gem::Specification.find_by_name("opal-browser").gem_dir, "opal"))
  append_frontend_gems

  builder = Opal::Builder.new
  builder.stubs.concat(DuoRuby.config.frontend_stubs)
  builder.append_paths(File.join(@root, "app"), File.expand_path("../..", __dir__))
  builder.build("opal")
  builder.build("setup/frontend")
  builder.to_s
end