Class: DEIS::Base
Constant Summary collapse
- YES =
"\u2713"
- NO =
"\u274C"
Instance Attribute Summary collapse
-
#cluster ⇒ Object
Returns the value of attribute cluster.
-
#environment ⇒ Object
Returns the value of attribute environment.
-
#output ⇒ Object
Returns the value of attribute output.
-
#path ⇒ Object
Returns the value of attribute path.
-
#proxy ⇒ Object
Returns the value of attribute proxy.
-
#ssh ⇒ Object
Returns the value of attribute ssh.
-
#verbose ⇒ Object
Returns the value of attribute verbose.
Instance Method Summary collapse
- #local_profile ⇒ Object
- #local_shell ⇒ Object
- #local_shell_env_include(profile, file_to_include) ⇒ Object
- #log(cmd) ⇒ Object
- #remote_profile ⇒ Object
-
#run(command) ⇒ Object
run commands either locally or remotely.
Instance Attribute Details
#cluster ⇒ Object
Returns the value of attribute cluster.
4 5 6 |
# File 'lib/rdeis/base.rb', line 4 def cluster @cluster end |
#environment ⇒ Object
Returns the value of attribute environment.
4 5 6 |
# File 'lib/rdeis/base.rb', line 4 def environment @environment end |
#output ⇒ Object
Returns the value of attribute output.
4 5 6 |
# File 'lib/rdeis/base.rb', line 4 def output @output end |
#path ⇒ Object
Returns the value of attribute path.
4 5 6 |
# File 'lib/rdeis/base.rb', line 4 def path @path end |
#proxy ⇒ Object
Returns the value of attribute proxy.
4 5 6 |
# File 'lib/rdeis/base.rb', line 4 def proxy @proxy end |
#ssh ⇒ Object
Returns the value of attribute ssh.
4 5 6 |
# File 'lib/rdeis/base.rb', line 4 def ssh @ssh end |
#verbose ⇒ Object
Returns the value of attribute verbose.
4 5 6 |
# File 'lib/rdeis/base.rb', line 4 def verbose @verbose end |
Instance Method Details
#local_profile ⇒ Object
27 28 29 30 31 |
# File 'lib/rdeis/base.rb', line 27 def local_profile file = "#{ENV['HOME']}/.profile" `> #{file}` if ! File.exists?(file) file end |
#local_shell ⇒ Object
23 24 25 |
# File 'lib/rdeis/base.rb', line 23 def local_shell `echo $SHELL | sed -E "s#/bin/##"`.strip end |
#local_shell_env_include(profile, file_to_include) ⇒ Object
37 38 39 40 |
# File 'lib/rdeis/base.rb', line 37 def local_shell_env_include(profile, file_to_include) content = File.open(profile, "r"){ |f| f.read }.gsub(". #{file_to_include}", "") + "\n. #{file_to_include}" File.open(profile, "w") { |f| f.write(content) } end |
#log(cmd) ⇒ Object
9 10 11 |
# File 'lib/rdeis/base.rb', line 9 def log(cmd) say "[#{@proxy} #{Time.now}] #{cmd}", :black if @verbose end |
#remote_profile ⇒ Object
33 34 35 |
# File 'lib/rdeis/base.rb', line 33 def remote_profile "$HOME/.profile" end |
#run(command) ⇒ Object
run commands either locally or remotely
14 15 16 17 18 19 20 21 |
# File 'lib/rdeis/base.rb', line 14 def run(command) self.log(command) if @proxy return @ssh.exec!(command) else return `#{command}`.strip end end |