Class: TmuxConnector::Start

Inherits:
Object
  • Object
show all
Defined in:
lib/tmux-connector/commands/start.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args) ⇒ Start

Returns a new instance of Start.



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/tmux-connector/commands/start.rb', line 15

def initialize(args)
  if args['<config-file>']
    @config = TmuxConnector.get_config args['<config-file>']
  elsif args['--quick-session']
    @config = quick_session_to_config args['--quick-session']
  end

  ssh_hostnames = SSHConfig.get_hosts(args['--ssh-config'], config['reject-regex'])
  @hosts = ssh_hostnames.reduce([]) do |acc, name|
    ( acc << Host.new(name, config) ) rescue nil
    acc
  end
  raise "no hosts matching given configuration found, check your configuration" if hosts.empty?

  generate_groups
  generate_merge_rules

  @session = Session.new config, args, groups, merge_rules
end

Instance Attribute Details

#configObject (readonly)

Returns the value of attribute config.



9
10
11
# File 'lib/tmux-connector/commands/start.rb', line 9

def config
  @config
end

#groupsObject (readonly)

Returns the value of attribute groups.



11
12
13
# File 'lib/tmux-connector/commands/start.rb', line 11

def groups
  @groups
end

#hostsObject (readonly)

Returns the value of attribute hosts.



10
11
12
# File 'lib/tmux-connector/commands/start.rb', line 10

def hosts
  @hosts
end

#merge_rulesObject (readonly)

Returns the value of attribute merge_rules.



12
13
14
# File 'lib/tmux-connector/commands/start.rb', line 12

def merge_rules
  @merge_rules
end

#sessionObject (readonly)

Returns the value of attribute session.



13
14
15
# File 'lib/tmux-connector/commands/start.rb', line 13

def session
  @session
end

Instance Method Details

#runObject



35
36
37
38
# File 'lib/tmux-connector/commands/start.rb', line 35

def run()
  session.save
  session.start
end