Class: Tmuxinator::Config
Constant Summary collapse
- LOCAL_DEFAULT =
"./.tmuxinator.yml".freeze
- NO_LOCAL_FILE_MSG =
"Project file at ./.tmuxinator.yml doesn't exist."
Class Method Summary collapse
- .configs ⇒ Object
- .default ⇒ Object
- .default? ⇒ Boolean
- .default_path_option ⇒ Object
- .default_project(name) ⇒ Object
- .editor? ⇒ Boolean
- .exists?(name) ⇒ Boolean
- .installed? ⇒ Boolean
- .local? ⇒ Boolean
- .project(name) ⇒ Object
- .project_in_local ⇒ Object
- .project_in_root(name) ⇒ Object
- .root ⇒ Object
- .sample ⇒ Object
- .shell? ⇒ Boolean
- .template ⇒ Object
- .validate(options = {}) ⇒ Object
- .version ⇒ Object
- .wemux_template ⇒ Object
Class Method Details
.configs ⇒ Object
78 79 80 81 82 |
# File 'lib/tmuxinator/config.rb', line 78 def configs Dir["#{Tmuxinator::Config.root}/**/*.yml"].sort.map do |path| path.gsub("#{Tmuxinator::Config.root}/", "").gsub(".yml", "") end end |
.default ⇒ Object
17 18 19 |
# File 'lib/tmuxinator/config.rb', line 17 def default "#{ENV['HOME']}/.tmuxinator/default.yml" end |
.default? ⇒ Boolean
21 22 23 |
# File 'lib/tmuxinator/config.rb', line 21 def default? exists?("default") end |
.default_path_option ⇒ Object
33 34 35 |
# File 'lib/tmuxinator/config.rb', line 33 def default_path_option version && version < 1.8 ? "default-path" : "-c" end |
.default_project(name) ⇒ Object
62 63 64 |
# File 'lib/tmuxinator/config.rb', line 62 def default_project(name) "#{root}/#{name}.yml" end |
.editor? ⇒ Boolean
37 38 39 |
# File 'lib/tmuxinator/config.rb', line 37 def editor? !ENV["EDITOR"].nil? && !ENV["EDITOR"].empty? end |
.exists?(name) ⇒ Boolean
45 46 47 |
# File 'lib/tmuxinator/config.rb', line 45 def exists?(name) File.exists?(project(name)) end |
.installed? ⇒ Boolean
25 26 27 |
# File 'lib/tmuxinator/config.rb', line 25 def installed? Kernel.system("type tmux > /dev/null") end |
.local? ⇒ Boolean
54 55 56 |
# File 'lib/tmuxinator/config.rb', line 54 def local? project_in_local end |
.project(name) ⇒ Object
66 67 68 |
# File 'lib/tmuxinator/config.rb', line 66 def project(name) project_in_root(name) || project_in_local || default_project(name) end |
.project_in_local ⇒ Object
58 59 60 |
# File 'lib/tmuxinator/config.rb', line 58 def project_in_local [LOCAL_DEFAULT].detect { |f| File.exists?(f) } end |
.project_in_root(name) ⇒ Object
49 50 51 52 |
# File 'lib/tmuxinator/config.rb', line 49 def project_in_root(name) projects = Dir.glob("#{root}/**/*.yml") projects.detect { |project| File.basename(project, ".yml") == name } end |
.root ⇒ Object
7 8 9 10 11 |
# File 'lib/tmuxinator/config.rb', line 7 def root root_dir = File.("~/.tmuxinator") Dir.mkdir("#{ENV['HOME']}/.tmuxinator") unless File.directory?(root_dir) "#{ENV['HOME']}/.tmuxinator" end |
.sample ⇒ Object
13 14 15 |
# File 'lib/tmuxinator/config.rb', line 13 def sample asset_path "sample.yml" end |
.shell? ⇒ Boolean
41 42 43 |
# File 'lib/tmuxinator/config.rb', line 41 def shell? !ENV["SHELL"].nil? && !ENV["SHELL"].empty? end |
.template ⇒ Object
70 71 72 |
# File 'lib/tmuxinator/config.rb', line 70 def template asset_path "template.erb" end |
.validate(options = {}) ⇒ Object
84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 |
# File 'lib/tmuxinator/config.rb', line 84 def validate( = {}) name = [:name] [:force_attach] ||= false [:force_detach] ||= false project_file = if name.nil? raise NO_LOCAL_FILE_MSG \ unless Tmuxinator::Config.local? project_in_local else raise "Project #{name} doesn't exist." \ unless Tmuxinator::Config.exists?(name) Tmuxinator::Config.project(name) end Tmuxinator::Project.load(project_file, ).validate! end |
.version ⇒ Object
29 30 31 |
# File 'lib/tmuxinator/config.rb', line 29 def version `tmux -V`.split(" ")[1].to_f if installed? end |
.wemux_template ⇒ Object
74 75 76 |
# File 'lib/tmuxinator/config.rb', line 74 def wemux_template asset_path "wemux_template.erb" end |