Class: Releasy::WindowsWrapperMaker
- Inherits:
-
Object
- Object
- Releasy::WindowsWrapperMaker
- Defined in:
- lib/releasy/windows_wrapper_maker.rb
Overview
Creates wrappers and executables by wrapping Ocra’s functionality.
Instance Method Summary collapse
-
#build_executable(executable_file, ruby_file, options = {}) ⇒ Object
Creates an win32 executable file (xxx.exe) that runs via a Ruby executable at bin/ruby(w).exe Paths given to the executable are relative to the directory that the executable is in.
Instance Method Details
#build_executable(executable_file, ruby_file, options = {}) ⇒ Object
Creates an win32 executable file (xxx.exe) that runs via a Ruby executable at bin/ruby(w).exe Paths given to the executable are relative to the directory that the executable is in. Assumes that user’s source will be put into ./src/ and that ruby executables will be in ./bin/
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/releasy/windows_wrapper_maker.rb', line 18 def build_executable(executable_file, ruby_file, = {}) = { :rubyopt => '', :rubylib => '', :gem_path => 'vendor', :windows => false, :icon => nil, }.merge! load_ocra unless defined? Ocra::OcraBuilder [:icon] Ocra::OcraBuilder.new(executable_file, [:windows]) do |sb| root = Ocra.Pathname Ocra::TEMPDIR_ROOT sb.setenv('RUBYOPT', [:rubyopt]) sb.setenv('RUBYLIB', [:rubylib]) sb.setenv('GEM_PATH', (root / [:gem_path]).to_native) sb.setenv('BUNDLE_GEMFILE', '') sb.setenv('BUNDLE_BIN_PATH', '') ruby_executable = [:windows] ? "rubyw.exe" : "ruby.exe" exe = root / 'bin' / ruby_executable script = (root / ruby_file).to_native sb.postcreateprocess(exe, "#{ruby_executable} \"#{script}\"") end nil end |