Class: LibGems::Installer

Inherits:
Object
  • Object
show all
Defined in:
lib/bpm/libgems_ext/installer.rb

Instance Method Summary collapse

Instance Method Details

#app_script_text(bin_file_name) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/bpm/libgems_ext/installer.rb', line 6

def app_script_text(bin_file_name)
  <<-TEXT
#{shebang bin_file_name}
#
# This file was generated by BPM.
#
# The application '#{@spec.name}' is installed as part of an bpkg, and
# this file is here to facilitate running it.
#

version = "#{LibGems::Requirement.default}"

if ARGV.first =~ /^_(.*)_$/ and LibGems::Version.correct? $1 then
  version = $1
  ARGV.shift
end

gem '#{@spec.name}', version

path = LibGems.bin_path('#{@spec.name}', '#{bin_file_name}', version)
shebang = File.open(path){|f| f.readline }

if shebang =~ /^\#\!.*ruby/
  load path
else
  exec path, *ARGV
end
TEXT
end