class Autoterm::TmuxinatorProject

Attributes

config[R]

Public Class Methods

from_yaml_file(project_name) click to toggle source
# File lib/autoterm/tmuxinator_project.rb, line 6
def self.from_yaml_file(project_name)
  filename = "#{ENV["HOME"]}/.tmuxinator/#{project_name}.yml"
  content = File.read(filename)

  # These instance variables could be used in a template,
  # so set to empty objects just in case
  @args = []
  @settings = {}
  parsed_content = ERB.new(content, nil, "-").result(binding)

  new(YAML.load(parsed_content))
rescue Errno::ENOENT
  raise ProjectNotFoundError.new(project_name, filename)
rescue SyntaxError, StandardError => error
  raise ParseError.new(project_name, error)
end
new(config) click to toggle source
# File lib/autoterm/tmuxinator_project.rb, line 25
def initialize(config)
  @config = config
end

Public Instance Methods

root() click to toggle source
# File lib/autoterm/tmuxinator_project.rb, line 29
def root
  config["root"]
end
tabs() click to toggle source
# File lib/autoterm/tmuxinator_project.rb, line 33
def tabs
  @tabs ||= config["windows"].map do |window|
    name, commands = window.first

    if commands.is_a? Hash
      panes = Array(commands["pre"]) + Array(commands["panes"])

      # Ignore panes for now, flatten commands
      commands = panes.map do |pane|
        pane.is_a?(Hash) ? pane.values.flatten : pane
      end
    end

    Tab.new(name, commands)
  end
end