Class: Jets::Builders::RackPackager

Inherits:
RubyPackager show all
Defined in:
lib/jets/builders/rack_packager.rb

Constant Summary

Constants inherited from RubyPackager

Jets::Builders::RubyPackager::GEM_REGEXP

Instance Attribute Summary

Attributes inherited from RubyPackager

#full_app_root

Instance Method Summary collapse

Methods inherited from RubyPackager

#bundle_check, #bundle_install, #clean_old_submodules, #copy_back_gemfile_lock, #copy_bundle_config, #copy_bundled_gems, #copy_cache_gems, #copy_gemfiles, #create_bundle_config, #gemfile_exist?, #initialize, #install, #rewrite_gemfile_lock, #tidy, #tidy_project

Constructor Details

This class inherits a constructor from Jets::Builders::RubyPackager

Instance Method Details

#copy_rackup_wrappersObject



21
22
23
24
25
26
27
28
29
30
31
# File 'lib/jets/builders/rack_packager.rb', line 21

def copy_rackup_wrappers
  # IE: @full_app_root: /tmp/jets/demo/stage/code/rack
  rack_bin = "#{@full_app_root}/bin"
  %w[rackup rackup.rb].each do |file|
    src = File.expand_path("./rackup_wrappers/#{file}", File.dirname(__FILE__))
    dest = "#{rack_bin}/#{file}"
    FileUtils.mkdir_p(rack_bin) unless File.exist?(rack_bin)
    FileUtils.cp(src, dest)
    FileUtils.chmod 0755, dest
  end
end

#finishObject



3
4
5
6
7
8
9
10
11
# File 'lib/jets/builders/rack_packager.rb', line 3

def finish
  return unless gemfile_exist?

  super

  symlink_gems
  copy_rackup_wrappers
  rack_symlink
end

Moves folder to a stage folder and create a symlink its place that links from /var/task to /tmp. Example:

stage/code/rack => /tmp/rack


38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/jets/builders/rack_packager.rb', line 38

def rack_symlink
  src = @full_app_root
  return unless File.exist?(src)

  dest = "#{stage_area}/rack"
  dir = File.dirname(dest)
  FileUtils.mkdir_p(dir) unless File.exist?(dir)
  FileUtils.mv(src, dest)

  # Create symlink
  FileUtils.ln_sf("/tmp/rack", src)
end


13
14
15
16
17
18
19
# File 'lib/jets/builders/rack_packager.rb', line 13

def symlink_gems
  ruby_folder = Jets::Gems.ruby_folder
  # IE: @full_app_root: /tmp/jets/demo/stage/code/rack
  dest = "#{@full_app_root}/vendor/gems/ruby/#{ruby_folder}"
  FileUtils.mkdir_p(File.dirname(dest))
  FileUtils.ln_sf("/opt/ruby/gems/#{ruby_folder}", dest)
end