class RailsPwnerer::App::Gems
sets up the application gems
Public Instance Methods
manage(app_name, instance_name, action)
click to toggle source
# File lib/rails_pwnerer/app/gems.rb 39 def manage(app_name, instance_name, action) 40 # Called when an app is rolled back, to get the old gems reinstalled, 41 # if necessary. 42 update(app_name, instance_name) 43 end
setup(app_name, instance_name)
click to toggle source
# File lib/rails_pwnerer/app/gems.rb 45 def setup(app_name, instance_name) 46 update(app_name, instance_name) 47 end
update(app_name, instance_name)
click to toggle source
# File lib/rails_pwnerer/app/gems.rb 6 def update(app_name, instance_name) 7 app_config = RailsPwnerer::Config[app_name, instance_name] 8 9 Dir.chdir app_config[:app_path] do 10 # Phase 1: app-directed install 11 if !File.exist?('Gemfile') && app_config[:gems] 12 # Can be specified as comma-separated string or array. 13 if app_config[:gems].respond_to? :to_str 14 install_gems = app_config[:gems].split(',') 15 else 16 install_gems = app_config[:gems] 17 end 18 install_gems.each do |gem_name| 19 begin 20 install_gem gem_name unless gem_exists? gem_name 21 rescue Exception 22 end 23 end 24 end 25 26 # Phase 2: bundler / rails install 27 # Install the gems needed by the app. 28 if File.exist? 'Gemfile' 29 unless /^\s+gem\s+['"]thin['"]/ =~ File.read('Gemfile') 30 File.open('Gemfile', 'a') { |f| f.write "\ngem 'thin'\n"} 31 end 32 Kernel.system "bundle install --without development test" 33 else 34 Kernel.system "rake gems:install RAILS_ENV=production" 35 end 36 end 37 end