Sha256: 5a0bc354eacd7eb8e1ebdc4365bbbe5a066e21d1d95f3a8d811130d4edfc54f0

Contents?: true

Size: 832 Bytes

Versions: 6

Compression:

Stored size: 832 Bytes

Contents

require 'sinatra'

module Kosmos
  module Web
    class App < Sinatra::Application
      set server: 'thin', connection: nil

      get '/' do
        send_file(File.join(settings.public_folder, 'index.html'))
      end

      get '/stream', provides: 'text/event-stream' do
        stream :keep_open do |out|
          settings.connection = out
        end
      end

      post '/' do
        Kosmos.configure do |config|
          config.output_method = Proc.new do |str|
            settings.connection << "data: #{str}\n\n"
          end
        end

        kosmos_params = params[:params].split(' ')
        kosmos_command = %w(init install uninstall list).find do |command|
          command == params[:command]
        end

        UserInterface.send(kosmos_command, kosmos_params)

        204
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
kosmos-0.0.4 lib/kosmos/web/app.rb
kosmos-0.0.3 lib/kosmos/web/app.rb
kosmos-0.0.2.pre.test4 lib/kosmos/web/app.rb
kosmos-0.0.2.pre.test3 lib/kosmos/web/app.rb
kosmos-0.0.2.pre.test2 lib/kosmos/web/app.rb
kosmos-0.0.2 lib/kosmos/web/app.rb