Class: RemoteRun::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/remote_run/configuration.rb

Defined Under Namespace

Classes: HostManager, TaskManager

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize {|_self| ... } ⇒ Configuration

Returns a new instance of Configuration.

Yields:

  • (_self)

Yield Parameters:



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/remote_run/configuration.rb', line 8

def initialize
  @task_manager = TaskManager.new
  @host_manager = HostManager.new

  # used in the runner
  @identifier = `echo $RANDOM`.strip
  @local_hostname = `hostname`.strip

  @local_path = Dir.getwd
  @login_as = ENV["USER"]
  @remote_path = "/tmp/remote/#{local_hostname}"
  @exclude = []
  @temp_path = "/tmp/remote"
  @quiet = false
  @start_time = Time.now
  @known_hosts = File.expand_path("#{ENV['HOME']}/.ssh/known_hosts")
  @ssh_options = "-o NoHostAuthenticationForLocalhost=yes -o UserKnownHostsFile=#{known_hosts} -o NumberOfPasswordPrompts=0 -o StrictHostKeyChecking=no -o ConnectTimeout=3 -4 "
  @rsync_options = "--delete --rsh='ssh #{ssh_options}' --timeout=60 -a"

  @before_run = Proc.new{}
  @after_run = Proc.new{}
  @around_run = Proc.new {|&block| block.call }
  @before_task = Proc.new{}
  @after_task = Proc.new{}
  @around_task = Proc.new {|&block| block.call }
  $runner = self
  yield self if block_given?
end

Instance Attribute Details

#after_runObject

Returns the value of attribute after_run.



3
4
5
# File 'lib/remote_run/configuration.rb', line 3

def after_run
  @after_run
end

#after_taskObject

Returns the value of attribute after_task.



3
4
5
# File 'lib/remote_run/configuration.rb', line 3

def after_task
  @after_task
end

#around_runObject

Returns the value of attribute around_run.



3
4
5
# File 'lib/remote_run/configuration.rb', line 3

def around_run
  @around_run
end

#around_taskObject

Returns the value of attribute around_task.



3
4
5
# File 'lib/remote_run/configuration.rb', line 3

def around_task
  @around_task
end

#before_runObject

Returns the value of attribute before_run.



3
4
5
# File 'lib/remote_run/configuration.rb', line 3

def before_run
  @before_run
end

#before_taskObject

Returns the value of attribute before_task.



3
4
5
# File 'lib/remote_run/configuration.rb', line 3

def before_task
  @before_task
end

#excludeObject

Returns the value of attribute exclude.



3
4
5
# File 'lib/remote_run/configuration.rb', line 3

def exclude
  @exclude
end

#host_managerObject (readonly)

Returns the value of attribute host_manager.



6
7
8
# File 'lib/remote_run/configuration.rb', line 6

def host_manager
  @host_manager
end

#identifierObject (readonly)

Returns the value of attribute identifier.



5
6
7
# File 'lib/remote_run/configuration.rb', line 5

def identifier
  @identifier
end

#known_hostsObject

Returns the value of attribute known_hosts.



3
4
5
# File 'lib/remote_run/configuration.rb', line 3

def known_hosts
  @known_hosts
end

#local_hostnameObject (readonly)

Returns the value of attribute local_hostname.



5
6
7
# File 'lib/remote_run/configuration.rb', line 5

def local_hostname
  @local_hostname
end

#local_pathObject

Returns the value of attribute local_path.



3
4
5
# File 'lib/remote_run/configuration.rb', line 3

def local_path
  @local_path
end

#login_asObject

Returns the value of attribute login_as.



3
4
5
# File 'lib/remote_run/configuration.rb', line 3

def 
  @login_as
end

#quietObject

Returns the value of attribute quiet.



3
4
5
# File 'lib/remote_run/configuration.rb', line 3

def quiet
  @quiet
end

#remote_pathObject

Returns the value of attribute remote_path.



3
4
5
# File 'lib/remote_run/configuration.rb', line 3

def remote_path
  @remote_path
end

#rsync_optionsObject

Returns the value of attribute rsync_options.



3
4
5
# File 'lib/remote_run/configuration.rb', line 3

def rsync_options
  @rsync_options
end

#ssh_optionsObject

Returns the value of attribute ssh_options.



3
4
5
# File 'lib/remote_run/configuration.rb', line 3

def ssh_options
  @ssh_options
end

#start_timeObject (readonly)

Returns the value of attribute start_time.



5
6
7
# File 'lib/remote_run/configuration.rb', line 5

def start_time
  @start_time
end

#task_managerObject (readonly)

Returns the value of attribute task_manager.



6
7
8
# File 'lib/remote_run/configuration.rb', line 6

def task_manager
  @task_manager
end

#temp_pathObject

Returns the value of attribute temp_path.



3
4
5
# File 'lib/remote_run/configuration.rb', line 3

def temp_path
  @temp_path
end

Instance Method Details

#hostsObject



37
38
39
# File 'lib/remote_run/configuration.rb', line 37

def hosts
  @host_manager.hosts
end

#hosts=(hostnames) ⇒ Object



45
46
47
48
49
# File 'lib/remote_run/configuration.rb', line 45

def hosts=(hostnames)
  hostnames.each do |hostname|
    @host_manager.add(Host.new(hostname, self))
  end
end

#runObject



57
58
59
60
61
# File 'lib/remote_run/configuration.rb', line 57

def run
  @before_run.call(self)
  @around_run.call { Runner.new(self).run }
  @after_run.call(self)
end

#tasksObject



41
42
43
# File 'lib/remote_run/configuration.rb', line 41

def tasks
  @task_manager.tasks
end

#tasks=(shell_commands) ⇒ Object



51
52
53
54
55
# File 'lib/remote_run/configuration.rb', line 51

def tasks=(shell_commands)
  shell_commands.each do |shell_command|
    @task_manager.add(Task.new(shell_command))
  end
end