Class: Warbler::Traits::Shoes
- Defined in:
- shoes-package/lib/warbler/traits/shoes.rb
Constant Summary collapse
- INIT_CONTENTS =
<<~EOS require 'shoes' require 'shoes/swt' app_dir = File.join(__FILE__, "..", "..", "shoes-app") $LOAD_PATH.unshift(app_dir) Shoes.configuration.app_dir = app_dir Shoes::Swt.initialize_backend EOS
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 = <<~EOS begin load '#{bin_path}' rescue Java::OrgEclipseSwt::SWTException => e if e.message == "Invalid thread access" puts "" puts "Ooops, you'll need to pass -XstartOnFirstThread when you start your jar!" end end EOS jar.files['META-INF/main.rb'] = StringIO.new(main) end |
#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 |