Class: Processing::Launcher

Inherits:
Object
  • Object
show all
Defined in:
lib/jruby_art/launcher.rb

Overview

The command class check for configuration and options, before creating and executing the jruby (or java) command to run the sketch

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(runner:, args:, filename:) ⇒ Launcher

Returns a new instance of Launcher.



9
10
11
12
13
14
15
# File 'lib/jruby_art/launcher.rb', line 9

def initialize(runner:, args:, filename:)
  @command = if Processing::RP_CONFIG.fetch('JRUBY', true)
               JRubyCommand.new(runner, filename, args)
             else
               JavaCommand.new(runner, filename, args)
             end
end

Instance Attribute Details

#commandObject (readonly)

Returns the value of attribute command.



8
9
10
# File 'lib/jruby_art/launcher.rb', line 8

def command
  @command
end

Instance Method Details

#cmdObject

Trade in this Ruby instance for a JRuby instance, loading in a starter script and passing it some arguments. Unless you set JRUBY: false in ~/.jruby_art/config.yml, an installed version of jruby is used instead of our vendored one. Note the use of jruby-complete might make using other gems in your sketches hard (but not impossible).…



22
23
24
25
26
27
28
29
# File 'lib/jruby_art/launcher.rb', line 22

def cmd
  cmda = command.cmd
  begin
    exec(*cmda)
    # exec replaces the Ruby process with the JRuby one.
  rescue Java::JavaLang::ClassNotFoundException
  end
end