class Tmuxinator::Config

Public Class Methods

configs() click to toggle source
# File lib/tmuxinator/config.rb, line 59
def configs
  Dir["#{Tmuxinator::Config.root}/**/*.yml"].sort.map do |path|
    path.gsub("#{Tmuxinator::Config.root}/", "").gsub(".yml", "")
  end
end
default() click to toggle source
# File lib/tmuxinator/config.rb, line 13
def default
  "#{ENV["HOME"]}/.tmuxinator/default.yml"
end
default?() click to toggle source
# File lib/tmuxinator/config.rb, line 17
def default?
  exists?("default")
end
default_path_option() click to toggle source
# File lib/tmuxinator/config.rb, line 29
def default_path_option
  version && version < 1.8 ? "default-path" : "-c"
end
editor?() click to toggle source
# File lib/tmuxinator/config.rb, line 33
def editor?
  !ENV["EDITOR"].nil? && !ENV["EDITOR"].empty?
end
exists?(name) click to toggle source
# File lib/tmuxinator/config.rb, line 41
def exists?(name)
  File.exists?(project(name))
end
installed?() click to toggle source
# File lib/tmuxinator/config.rb, line 21
def installed?
  Kernel.system("type tmux > /dev/null")
end
project(name) click to toggle source
# File lib/tmuxinator/config.rb, line 45
def project(name)
  projects = Dir.glob("#{root}/**/*.yml")
  project_file = projects.detect { |project| File.basename(project, ".yml") == name }
  project_file || "#{root}/#{name}.yml"
end
root() click to toggle source
# File lib/tmuxinator/config.rb, line 4
def root
  Dir.mkdir("#{ENV["HOME"]}/.tmuxinator") unless File.directory?(File.expand_path("~/.tmuxinator"))
  "#{ENV["HOME"]}/.tmuxinator"
end
sample() click to toggle source
# File lib/tmuxinator/config.rb, line 9
def sample
  "#{File.dirname(__FILE__)}/assets/sample.yml"
end
shell?() click to toggle source
# File lib/tmuxinator/config.rb, line 37
def shell?
  !ENV["SHELL"].nil? && !ENV["SHELL"].empty?
end
template() click to toggle source
# File lib/tmuxinator/config.rb, line 51
def template
  "#{File.dirname(__FILE__)}/assets/template.erb"
end
validate(name, custom_name = nil) click to toggle source
# File lib/tmuxinator/config.rb, line 65
def validate(name, custom_name = nil)
  unless Tmuxinator::Config.exists?(name)
    puts "Project #{name} doesn't exist."
    exit!
  end

  config_path = Tmuxinator::Config.project(name)

  yaml = begin
    YAML.load(Erubis::Eruby.new(File.read(config_path)).result(binding))
  rescue SyntaxError, StandardError
    puts "Failed to parse config file. Please check your formatting."
    exit!
  end

  project = Tmuxinator::Project.new(yaml, custom_name)

  unless project.windows?
    puts "Your project file should include some windows."
    exit!
  end

  unless project.name?
    puts "Your project file didn't specify a 'project_name'"
    exit!
  end

  project
end
version() click to toggle source
# File lib/tmuxinator/config.rb, line 25
def version
  %xtmux -V`.split(" ")[1].to_f if installed?
end
wemux_template() click to toggle source
# File lib/tmuxinator/config.rb, line 55
def wemux_template
  "#{File.dirname(__FILE__)}/assets/wemux_template.erb"
end