Sha256: eba569190f316d31f574d9e4dabe757084dedfcc28789960210eccfc9c082e34

Contents?: true

Size: 1.45 KB

Versions: 2

Compression:

Stored size: 1.45 KB

Contents

class Applications < Controller
  map '/applications'

  layout{|path, ext|
    "default" unless path =~ /\Ado_/
  }

  def install(name=nil)
    if name.nil?
      tempfile = request["gem"][:tempfile]
      @filename = request["gem"][:filename]
      @size = tempfile.size
      session[:tempfile] = tempfile
    else
      raise
    end
  end

  def do_install(name=nil)
    if name.nil?
      path = session[:tempfile].path
      result, name, version = GemManager.install_file(path)
      ver = version.to_s

      @result = h result

      unless Application.first(:name => name, :version => ver)
        Application.create({
          :pid => nil,
          :port => 30000 + rand(9999),
          :name => name,
          :version => ver,
        })
      end
    end
  end

  def create
  end

  def show(name)
  end

  def uninstall(id)
    app = Application.get(id)
    raise "application not found(id=#{id})" unless app

    @app = app
  end

  def do_uninstall(id)
    app = Application.get(id)
    raise "application not found(id=#{id})" unless app

    result = GemManager.uninstall(app.name, app.version)
    app.destroy
    result
  end

  def start(id)
    app = Application.get(id)
    raise "application not found(id=#{id})" unless app

    app.start
    sleep 3

    redirect "http://localhost:#{app.port}/"
  end

  def stop(id)
    app = Application.get(id)
    raise "application not found(id=#{id})" unless app

    app.stop

    redirect_referer
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
yhara-ruby-station-0.0.1 controller/applications.rb
yhara-ruby-station-0.0.2 controller/applications.rb