class Teamocil::Layout
Public Class Methods
print_available_layouts(directory: nil)
click to toggle source
# File lib/teamocil/layout.rb, line 19 def self.print_available_layouts(directory: nil) files = Dir.glob(File.join(directory, '*.yml')) files.map! do |file| extname = File.extname(file) File.basename(file).gsub(extname, '') end # Always return files in alphabetical order, even if `Dir.glob` almost # always does it files.sort! Teamocil.puts(files) end
Public Instance Methods
edit!()
click to toggle source
# File lib/teamocil/layout.rb, line 15 def edit! Teamocil.system("$EDITOR #{path}") end
execute!()
click to toggle source
# File lib/teamocil/layout.rb, line 3 def execute! if Teamocil.options[:debug] Teamocil.puts(shell_commands.join("\n")) else Teamocil.system(shell_commands.join('; ')) end end
show!()
click to toggle source
# File lib/teamocil/layout.rb, line 11 def show! Teamocil.puts(raw_content) end
Private Instance Methods
parsed_content()
click to toggle source
# File lib/teamocil/layout.rb, line 44 def parsed_content YAML.load(raw_content) rescue Psych::SyntaxError raise Teamocil::Error::InvalidYAMLLayout, path end
raw_content()
click to toggle source
# File lib/teamocil/layout.rb, line 50 def raw_content File.read(path) rescue Errno::ENOENT raise Teamocil::Error::LayoutNotFound, path end
session()
click to toggle source
# File lib/teamocil/layout.rb, line 40 def session Teamocil::Tmux::Session.new(parsed_content) end
shell_commands()
click to toggle source
# File lib/teamocil/layout.rb, line 36 def shell_commands session.as_tmux.map { |command| "tmux #{command}" } end