Class: Warbler::Traits::Shoes
- Defined in:
- shoes-package/lib/warbler/traits/shoes.rb
Constant Summary collapse
- INIT_CONTENTS =
"require 'shoes'\nrequire 'shoes/swt'\n\napp_dir = File.join(__FILE__, \"..\", \"..\", \"shoes-app\")\n$LOAD_PATH.unshift(app_dir)\nShoes.configuration.app_dir = app_dir\n\nShoes::Swt.initialize_backend\n"
Class Method Summary collapse
Instance Method Summary collapse
- #add_main_rb(jar, bin_path, _params = nil) ⇒ Object
- #after_configure ⇒ Object
-
#default_executable ⇒ String
Uses the ‘@config.run` if it exists.
- #update_archive(jar) ⇒ Object
Class Method Details
.detect? ⇒ Boolean
22 23 24 |
# File 'shoes-package/lib/warbler/traits/shoes.rb', line 22 def self.detect? true end |
.requires?(trait) ⇒ Boolean
26 27 28 29 30 31 |
# File 'shoes-package/lib/warbler/traits/shoes.rb', line 26 def self.requires?(trait) # Actually, it would be better to dump the NoGemspec trait, but since # we can't do that, we can at least make sure that this trait gets # processed later by declaring that it requires NoGemspec. [Traits::Jar, Traits::NoGemspec].include? trait end |
Instance Method Details
#add_main_rb(jar, bin_path, _params = nil) ⇒ Object
53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'shoes-package/lib/warbler/traits/shoes.rb', line 53 def add_main_rb(jar, bin_path, _params = nil) main = " begin\n load '\#{bin_path}'\n rescue Java::OrgEclipseSwt::SWTException => e\n if e.message == \"Invalid thread access\"\n puts \"\"\n puts \"Ooops, you'll need to pass -XstartOnFirstThread when you start your jar!\"\n end\n end\n EOS\n\n jar.files['META-INF/main.rb'] = StringIO.new(main)\nend\n" |
#after_configure ⇒ Object
44 45 46 |
# File 'shoes-package/lib/warbler/traits/shoes.rb', line 44 def after_configure config.init_contents << StringIO.new(INIT_CONTENTS) end |
#default_executable ⇒ String
Uses the ‘@config.run` if it exists. Otherwise, looks in the application’s bin directory for an executable with the same name as the jar. If this also fails, defaults to the first executable (alphabetically) in the applications bin directory.
74 75 76 77 78 79 80 |
# File 'shoes-package/lib/warbler/traits/shoes.rb', line 74 def default_executable return @config.run if @config.run exes = Dir['bin/*'].sort exe = exes.grep(/#{config.jar_name}/).first || exes.first raise "No executable script found" unless exe exe end |
#update_archive(jar) ⇒ Object
48 49 50 51 |
# File 'shoes-package/lib/warbler/traits/shoes.rb', line 48 def update_archive(jar) super add_main_rb(jar, apply_pathmaps(config, default_executable, :application)) end |