Sha256: 198ec63d646aa7ca021db71831e596ff691f77bdef2dce3c91002c365279dc98

Contents?: true

Size: 739 Bytes

Versions: 3

Compression:

Stored size: 739 Bytes

Contents

require 'space/logger'
require 'readline'
require 'thread'

module Space
  class App
    attr_reader :name, :project, :views

    def initialize(name)
      @name    = name
      @project = Model::Project.new(name)
      @views   = [View::Progress.new(project), View::Dashboard.new(project)]
    end

    def run
      project.refresh
      cli_loop
      puts
    end

    private

      def cli_loop
        loop do
          print "\e[3;0H"
          line = Readline.readline(views.first.send(:prompt), true) || break
          handle(line)
        end
      rescue Exception => e
        log e.message, e.backtrace
      end

      def handle(line)
        Action::Handler.new(project).run(line) unless line.empty?
      end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
space-0.0.9 lib/space/app.rb
space-0.0.8 lib/space/app.rb
space-0.0.7 lib/space/app.rb