Sha256: 7879298b00089efd2676989ccbb491d4fd92d6203f79052ae0b459ce0c6c2abf

Contents?: true

Size: 875 Bytes

Versions: 1

Compression:

Stored size: 875 Bytes

Contents

module Nutella
  
  class Tmux
  
    def initialize(runId)
      @runId = runId
    end
  
    def newWindow(bot)
      if !defined?(@sessions)
        # If I have no sessions I'm gonna create one and, at the same time, create a new window for the bot
        `tmux new-session -d -s #{@runId} -n #{bot} &> /dev/null`
        @sessions = [bot]
      else
        # Create new window `bot`
        # -k destroys it if it can't be created
        # Pring info about creation of window
      	`tmux new-window -kP -n #{bot} &> /dev/null` 
        @sessions.push(bot)
      end
      # Select window
    	`tmux select-window -t #{@runId}:#{@sessions.length-1} &> /dev/null`
      # Start bot
      `tmux send-keys "cd bots/#{bot};./startup #{@runId}" C-m`
    end
  
    def self.killSession(runId)
      `tmux kill-session -t #{runId} &> /dev/null`
    end
      
  end
  
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
nutella_framework-0.1.0 lib/core/tmux.rb