Class: Tmuxification::App
- Inherits:
-
Thor
- Object
- Thor
- Tmuxification::App
- Includes:
- Thor::Actions
- Defined in:
- lib/tmuxification.rb
Instance Attribute Summary collapse
-
#project_name ⇒ Object
readonly
Returns the value of attribute project_name.
-
#project_root ⇒ Object
readonly
Returns the value of attribute project_root.
-
#template_name ⇒ Object
readonly
Returns the value of attribute template_name.
Class Method Summary collapse
-
.source_root ⇒ Object
source root for templates etc.
Instance Method Summary collapse
- #create ⇒ Object
- #destroy(project_name = nil) ⇒ Object
- #list ⇒ Object
- #setup ⇒ Object
- #teardown ⇒ Object
Instance Attribute Details
#project_name ⇒ Object (readonly)
Returns the value of attribute project_name.
7 8 9 |
# File 'lib/tmuxification.rb', line 7 def project_name @project_name end |
#project_root ⇒ Object (readonly)
Returns the value of attribute project_root.
7 8 9 |
# File 'lib/tmuxification.rb', line 7 def project_root @project_root end |
#template_name ⇒ Object (readonly)
Returns the value of attribute template_name.
7 8 9 |
# File 'lib/tmuxification.rb', line 7 def template_name @template_name end |
Class Method Details
.source_root ⇒ Object
source root for templates etc.
50 51 52 |
# File 'lib/tmuxification.rb', line 50 def self.source_root File.dirname(__FILE__) + '/..' end |
Instance Method Details
#create ⇒ Object
11 12 13 14 15 16 17 18 19 20 |
# File 'lib/tmuxification.rb', line 11 def create setup @project_name = .fetch('project_name') { Dir.pwd.split('/').last } @project_root = Dir.pwd @template_name = .fetch('template_name') { "default.#{current_shell}" } template template_file, project_file chmod project_file, 777 # ha! append_to_file shellrc_file, "#{shell_source_command} #{project_file}\n" end |
#destroy(project_name = nil) ⇒ Object
23 24 25 26 |
# File 'lib/tmuxification.rb', line 23 def destroy(project_name = nil) @project_name ||= Dir.pwd.split('/').last File.delete project_file if File.exists?(project_file) end |
#list ⇒ Object
29 30 31 32 33 |
# File 'lib/tmuxification.rb', line 29 def list Dir.glob(config_directory + '/*.tmux').map { |path| path.split('/').last }.each do |project_name| puts project_name end end |
#setup ⇒ Object
36 37 38 39 40 41 42 |
# File 'lib/tmuxification.rb', line 36 def setup empty_directory config_directory @template_name = 'default.zsh' copy_file 'templates/default.zsh.tmux.erb', template_file unless File.exists?(template_file) @template_name = 'default.fish' copy_file 'templates/default.fish.tmux.erb', template_file unless File.exists?(template_file) end |
#teardown ⇒ Object
45 46 47 |
# File 'lib/tmuxification.rb', line 45 def teardown Dir.rmdir(config_directory) if yes? 'Are you sure?' end |