Sha256: bc71134844315790d584c13e581f6ba3630070dbe7342876653fbcb56798969b

Contents?: true

Size: 1.12 KB

Versions: 5

Compression:

Stored size: 1.12 KB

Contents

require "teamocil/layout/session"
require "teamocil/layout/window"
require "teamocil/layout/pane"

module Teamocil
  # This class act as a wrapper around a tmux YAML layout file
  class Layout
    attr_reader :session

    # Initialize a new layout from a hash
    #
    # @param layout [Hash] the parsed layout
    # @param options [Hash] some options
    def initialize(layout, options={})
      @layout = layout
      @options = options
    end

    # Generate tmux commands based on the data found in the layout file
    #
    # @return [Array] an array of shell commands to send
    def generate_commands
      @session.generate_commands
    end

    # Compile the layout into objects
    #
    # @return [Session]
    def compile!
      if @layout["session"].nil?
        @session = Session.new @options, "windows" => @layout["windows"]
      else
        @session = Session.new @options, @layout["session"]
      end
    end

    # Execute each command in the shell
    #
    # @param commands [Array] an array of complete commands to send to the shell
    def execute_commands(commands)
      `#{commands.join("; ")}`
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
teamocil-0.4.5 lib/teamocil/layout.rb
teamocil-0.4.4 lib/teamocil/layout.rb
teamocil-0.4.3 lib/teamocil/layout.rb
teamocil-0.4.2 lib/teamocil/layout.rb
teamocil-0.4.1 lib/teamocil/layout.rb