Module: GuardHelpers::InitdHelper::ClassMethods
- Defined in:
- lib/guard_helpers/initd_helper.rb
Instance Method Summary collapse
- #cmd(shortcut, args = nil, &blk) ⇒ Object
- #initd(from) ⇒ Object
- #msg(msg) ⇒ Object
- #remote_bash(*cmds) ⇒ Object
- #tt(from) ⇒ Object
- #upload(src, target) ⇒ Object
Instance Method Details
#cmd(shortcut, args = nil, &blk) ⇒ Object
81 82 83 84 85 |
# File 'lib/guard_helpers/initd_helper.rb', line 81 def cmd(shortcut, args=nil, &blk) Pry::Commands.pry_cmd shortcut do |args| blk.call end end |
#initd(from) ⇒ Object
110 111 112 113 114 115 116 117 118 |
# File 'lib/guard_helpers/initd_helper.rb', line 110 def initd(from) ctn = tt(from) to = File.join(Dir.pwd, 'etc/init.d/', from) remote = File.join('/etc/init.d', from) File.write(to, ctn) upload to, remote remote_bash "chmod 755 #{remote}" end |
#msg(msg) ⇒ Object
76 77 78 79 |
# File 'lib/guard_helpers/initd_helper.rb', line 76 def msg(msg) Out.out(msg) ::Guard::Notifier.notify(msg) end |
#remote_bash(*cmds) ⇒ Object
102 103 104 105 106 107 108 |
# File 'lib/guard_helpers/initd_helper.rb', line 102 def remote_bash(*cmds) cmd = cmds.flatten.join(" && ") Out.out cmd on roles(:all) do execute cmds.join(cmd) end end |
#tt(from) ⇒ Object
88 89 90 91 92 93 |
# File 'lib/guard_helpers/initd_helper.rb', line 88 def tt(from) path = File.("../templates/#{from}.erb", __FILE__) ctn = File.read(path) result = ERB.new(ctn).result result end |