Class: Tmuxinator::Config
Class Method Summary collapse
- .configs ⇒ Object
- .default ⇒ Object
- .default? ⇒ Boolean
- .default_path_option ⇒ Object
- .editor? ⇒ Boolean
- .exists?(name) ⇒ Boolean
- .installed? ⇒ Boolean
- .project(name) ⇒ Object
- .root ⇒ Object
- .sample ⇒ Object
- .shell? ⇒ Boolean
- .template ⇒ Object
- .validate(name, custom_name = nil) ⇒ Object
- .version ⇒ Object
- .wemux_template ⇒ Object
Class Method Details
.configs ⇒ Object
59 60 61 62 63 |
# 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 ⇒ Object
13 14 15 |
# File 'lib/tmuxinator/config.rb', line 13 def default "#{ENV["HOME"]}/.tmuxinator/default.yml" end |
.default? ⇒ Boolean
17 18 19 |
# File 'lib/tmuxinator/config.rb', line 17 def default? exists?("default") end |
.default_path_option ⇒ Object
29 30 31 |
# File 'lib/tmuxinator/config.rb', line 29 def default_path_option version && version < 1.8 ? "default-path" : "-c" end |
.editor? ⇒ Boolean
33 34 35 |
# File 'lib/tmuxinator/config.rb', line 33 def editor? !ENV["EDITOR"].nil? && !ENV["EDITOR"].empty? end |
.exists?(name) ⇒ Boolean
41 42 43 |
# File 'lib/tmuxinator/config.rb', line 41 def exists?(name) File.exists?(project(name)) end |
.installed? ⇒ Boolean
21 22 23 |
# File 'lib/tmuxinator/config.rb', line 21 def installed? Kernel.system("type tmux > /dev/null") end |
.project(name) ⇒ Object
45 46 47 48 49 |
# 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 ⇒ Object
4 5 6 7 |
# File 'lib/tmuxinator/config.rb', line 4 def root Dir.mkdir("#{ENV["HOME"]}/.tmuxinator") unless File.directory?(File.("~/.tmuxinator")) "#{ENV["HOME"]}/.tmuxinator" end |
.sample ⇒ Object
9 10 11 |
# File 'lib/tmuxinator/config.rb', line 9 def sample "#{File.dirname(__FILE__)}/assets/sample.yml" end |
.shell? ⇒ Boolean
37 38 39 |
# File 'lib/tmuxinator/config.rb', line 37 def shell? !ENV["SHELL"].nil? && !ENV["SHELL"].empty? end |
.template ⇒ Object
51 52 53 |
# File 'lib/tmuxinator/config.rb', line 51 def template "#{File.dirname(__FILE__)}/assets/template.erb" end |
.validate(name, custom_name = nil) ⇒ Object
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 |
# 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 ⇒ Object
25 26 27 |
# File 'lib/tmuxinator/config.rb', line 25 def version `tmux -V`.split(" ")[1].to_f if installed? end |
.wemux_template ⇒ Object
55 56 57 |
# File 'lib/tmuxinator/config.rb', line 55 def wemux_template "#{File.dirname(__FILE__)}/assets/wemux_template.erb" end |