controller/applications.rb in ruby-station-0.1.3 vs controller/applications.rb in ruby-station-0.1.4.rc1
- old
+ new
@@ -27,32 +27,26 @@
raise "unknown install source type: #{session[:source_type]}"
end
end
def _install
- case session[:source_type]
- when "name"
- gemname = session[:gemname]
- result, name, version = GemManager.install_gem(gemname)
- when "file"
- path = session[:tempfile].path
- result, name, version = GemManager.install_file(path)
- else
- raise "unknown install source type: #{session[:source_type]}"
+ result = ""
+ begin
+ case session[:source_type]
+ when "name"
+ result = Application.install(:name, session[:gemname])
+ when "file"
+ result = Application.install(:file, session[:tempfile].path)
+ else
+ raise "unknown install source type: #{session[:source_type]}"
+ end
+ rescue GemManager::InstallFailed => e
+ result = e.message
+ ensure
+ session.clear
+ h result
end
-
- if result and not Application.first(:name => name, :version => version)
- Application.create({
- :pid => nil,
- :port => 30000 + rand(9999),
- :name => name,
- :version => version,
- })
- end
-
- session.clear
- h result
end
def uninstall(id)
if app = Application.get(id)
@app = app
@@ -62,15 +56,14 @@
end
end
def _uninstall(id)
if app = Application.get(id)
- result = GemManager.uninstall(app.name, app.version)
- app.destroy
- result
+ result = app.uninstall
else
- ""
+ result = ""
end
+ result
end
def start(id)
app = Application.get(id)
raise "application not found(id=#{id})" unless app