doo 0.2.4 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.4
1
+ 0.5.0
@@ -0,0 +1,12 @@
1
+ Doo::Base.class_eval do
2
+ SEPARATORS = %w( / @ : | _ - # ^ ? )
3
+
4
+ def replace(file, src, replace, options = {})
5
+ sep = SEPARATORS.detect { |x| !src.include?(x) && !replace.include?(x) }
6
+ sudo "sed -i -e 's#{sep}#{src}#{sep}#{replace}#{sep}g' #{file}"
7
+ end
8
+
9
+ def append(file, text, options = {})
10
+ sudo "grep '#{text}' #{file} || echo '#{text}' >> #{file}"
11
+ end
12
+ end
@@ -1,13 +1,9 @@
1
1
  Doo::Base.class_eval do
2
- def prereq(cmd)
3
- raise PrerequisiteFailure unless run cmd == true
2
+ def if_passes(test, &block)
3
+ yield if run "#{test}"
4
4
  end
5
5
 
6
- def check_prereqs
7
- begin
8
- yield
9
- rescue PrerequisiteFailure
10
- puts "Pre-requisite test failed: ##{$!}"
11
- end
6
+ def if_fails(test, &block)
7
+ yield unless run "#{test}"
12
8
  end
13
9
  end
@@ -6,7 +6,8 @@ Doo::Base.class_eval do
6
6
  with_clone(variables.merge({:host => host}).merge(params || {})) do
7
7
  def run(remote_cmd, opt = {})
8
8
  cmdopts = ["-S \"~/.ssh/master-%l-%r@%h:%p\""]
9
- cmdopts << "-t" if !opt.include? :pty || opt[:pty]
9
+ cmdopts << "-t" if !opt.include? :pty || opt[:pty]
10
+ cmdopts << "-p#{ssh_port}" if defined? ssh_port
10
11
  cmd = "ssh #{cmdopts.join(' ')} #{user}@#{host} \"#{remote_cmd.gsub(/\"/, "\\\"")}\""
11
12
  if confirm
12
13
  return false unless HighLine.new.agree("Run \"#{cmd}\"? ")
@@ -27,7 +28,9 @@ Doo::Base.class_eval do
27
28
  puts "Running \"#{cmd}\""
28
29
  end
29
30
  system(cmd) || raise("Scp Error") unless dry_run
30
- $?
31
+ result = $?
32
+ run("chmod #{opt[:mode]} #{remote}") if defined? opt[:mode]
33
+ result
31
34
  end
32
35
 
33
36
  begin
metadata CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
4
4
  prerelease: false
5
5
  segments:
6
6
  - 0
7
- - 2
8
- - 4
9
- version: 0.2.4
7
+ - 5
8
+ - 0
9
+ version: 0.5.0
10
10
  platform: ruby
11
11
  authors:
12
12
  - Mat Trudel
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-12-10 00:00:00 -05:00
17
+ date: 2010-12-14 00:00:00 -05:00
18
18
  default_executable: doo
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency