Class: Tmuxinator::ConfigWriter

Inherits:
Object
  • Object
show all
Includes:
Helper
Defined in:
lib/tmuxinator/config_writer.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Helper

#confirm!, #exit!

Constructor Details

#initialize(this_full_path = nil) ⇒ ConfigWriter

Returns a new instance of ConfigWriter.



12
13
14
# File 'lib/tmuxinator/config_writer.rb', line 12

def initialize this_full_path=nil
  self.file_path = this_full_path if this_full_path
end

Instance Attribute Details

#file_nameObject

Returns the value of attribute file_name.



4
5
6
# File 'lib/tmuxinator/config_writer.rb', line 4

def file_name
  @file_name
end

#file_pathObject

Returns the value of attribute file_path.



4
5
6
# File 'lib/tmuxinator/config_writer.rb', line 4

def file_path
  @file_path
end

#preObject

Returns the value of attribute pre.



4
5
6
# File 'lib/tmuxinator/config_writer.rb', line 4

def pre
  @pre
end

#project_nameObject

Returns the value of attribute project_name.



4
5
6
# File 'lib/tmuxinator/config_writer.rb', line 4

def project_name
  @project_name
end

#project_rootObject

Returns the value of attribute project_root.



4
5
6
# File 'lib/tmuxinator/config_writer.rb', line 4

def project_root
  @project_root
end

#rvmObject

Returns the value of attribute rvm.



4
5
6
# File 'lib/tmuxinator/config_writer.rb', line 4

def rvm
  @rvm
end

#tabsObject

Returns the value of attribute tabs.



4
5
6
# File 'lib/tmuxinator/config_writer.rb', line 4

def tabs
  @tabs
end

Class Method Details

.write_aliases(aliases) ⇒ Object



8
9
10
# File 'lib/tmuxinator/config_writer.rb', line 8

def self.write_aliases aliases
  File.open("#{ENV["HOME"]}/.tmuxinator/scripts/tmuxinator", 'w') {|f| f.write(aliases.join("\n")) }
end

Instance Method Details

#config_pathObject



30
31
32
# File 'lib/tmuxinator/config_writer.rb', line 30

def config_path
  "#{root_dir}#{file_name}.tmux" if file_name
end

#write!Object



22
23
24
25
26
27
28
# File 'lib/tmuxinator/config_writer.rb', line 22

def write!
  raise "Unable to write with out a file_name defined" unless self.file_name
  erb         = ERB.new(IO.read(TMUX_TEMPLATE)).result(binding)
  tmp         = File.open(config_path, 'w') {|f| f.write(erb) }

  "alias start_#{file_name}='$SHELL #{config_path}'"
end