Class: Tmuxinator::ConfigWriter

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

Instance Attribute 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.



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

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

Instance Method Details

#config_pathObject



27
28
29
# File 'lib/tmuxinator/config_writer.rb', line 27

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

#renderObject



23
24
25
# File 'lib/tmuxinator/config_writer.rb', line 23

def render
  ERB.new(IO.read(TMUX_TEMPLATE)).result(binding)
end

#socketObject



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

def socket
  "-L #{@socket_name}" if @socket_name
end

#write!Object



18
19
20
21
# File 'lib/tmuxinator/config_writer.rb', line 18

def write!
  raise "Unable to write with out a file_name defined" unless self.file_name
  tmp = File.open(config_path, 'w') {|f| f.write(render) }
end