Class: Glimmer::Launcher
- Inherits:
-
Object
- Object
- Glimmer::Launcher
- Defined in:
- lib/glimmer/launcher.rb
Constant Summary collapse
- OPERATING_SYSTEMS_SUPPORTED =
["mac", "windows", "linux"]
- TEXT_USAGE =
<<-MULTILINE Usage: glimmer application.rb Runs a Glimmer application using JRuby, automatically preloading the glimmer ruby gem and SWT jar dependency. Example: glimmer hello_world.rb This runs the Glimmer application hello_world.rb MULTILINE
- GLIMMER_LIB_LOCAL =
File.(File.join(__FILE__, '..', '..', 'glimmer.rb'))
- GLIMMER_LIB_GEM =
'glimmer'
Class Method Summary collapse
- .jruby_os_specific_options ⇒ Object
- .jruby_swt_options ⇒ Object
- .launch(application, dev_mode = false, debug_mode = false) ⇒ Object
- .platform_os ⇒ Object
- .swt_jar_file ⇒ Object
Instance Method Summary collapse
-
#initialize(options) ⇒ Launcher
constructor
A new instance of Launcher.
- #launch ⇒ Object
Constructor Details
#initialize(options) ⇒ Launcher
Returns a new instance of Launcher.
50 51 52 53 54 |
# File 'lib/glimmer/launcher.rb', line 50 def initialize() @dev_mode = !!.delete('--dev') @debug_mode = !!.delete('--debug') @application_path = .first end |
Class Method Details
.jruby_os_specific_options ⇒ Object
27 28 29 |
# File 'lib/glimmer/launcher.rb', line 27 def OS.mac? ? "-J-XstartOnFirstThread" : "" end |
.jruby_swt_options ⇒ Object
31 32 33 |
# File 'lib/glimmer/launcher.rb', line 31 def "#{} -J-classpath \"#{swt_jar_file}\"" end |
.launch(application, dev_mode = false, debug_mode = false) ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/glimmer/launcher.rb', line 35 def launch(application, dev_mode = false, debug_mode = false) glimmer_lib = GLIMMER_LIB_GEM if dev_mode glimmer_lib = GLIMMER_LIB_LOCAL puts "[DEVELOPMENT MODE] (#{glimmer_lib})" end debug_option = '' if debug_mode debug_option = '--debug ' puts "[DEBUG MODE]" end system "jruby #{debug_option}#{} -r #{glimmer_lib} -S #{application}" end |
.platform_os ⇒ Object
19 20 21 |
# File 'lib/glimmer/launcher.rb', line 19 def platform_os OPERATING_SYSTEMS_SUPPORTED.detect {|os| OS.send("#{os}?")} end |
.swt_jar_file ⇒ Object
23 24 25 |
# File 'lib/glimmer/launcher.rb', line 23 def swt_jar_file @swt_jar_file ||= File.(File.join(__FILE__, '..', '..', '..', 'vendor', 'swt', platform_os, 'swt.jar')) end |
Instance Method Details
#launch ⇒ Object
56 57 58 59 60 61 62 |
# File 'lib/glimmer/launcher.rb', line 56 def launch if @application_path launch_application else display_usage end end |