doo 0.2.1 → 0.2.3

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -10,6 +10,7 @@ begin
10
10
  gem.email = [ "mat@geeky.net" ]
11
11
  gem.executables = %W(doo)
12
12
  gem.files = FileList["[A-Z]*", "{bin,examples,lib,spec}/**/*", 'lib/jeweler/templates/.gitignore']
13
+ gem.add_dependency "highline"
13
14
  end
14
15
  rescue LoadError
15
16
  puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
@@ -21,4 +22,4 @@ Spec::Rake::SpecTask.new('spec') do |t|
21
22
  t.spec_files = FileList['spec/**/*.rb']
22
23
  end
23
24
 
24
- task :default => :spec
25
+ task :default => :spec
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.1
1
+ 0.2.3
data/lib/doo/cli.rb CHANGED
@@ -14,6 +14,11 @@ module Doo
14
14
  options[:verbose] = true
15
15
  end
16
16
 
17
+ options[:confirm] = false
18
+ opts.on( '-c', '--confirm', 'Confirm every command before it gets run' ) do
19
+ options[:confirm] = true
20
+ end
21
+
17
22
  opts.on( '-s', '--set key=value', 'Set runtime values' ) do |arg|
18
23
  options[arg.split('=')[0]] = arg.split('=')[1]
19
24
  end
@@ -52,4 +57,4 @@ module Doo
52
57
  end
53
58
  end
54
59
  end
55
- end
60
+ end
@@ -4,7 +4,7 @@ Doo::Base.class_eval do
4
4
  with_clone(variables) do
5
5
  @file = file
6
6
  def run(cmd)
7
- puts "Rendering #{cmd}" if verbose
7
+ puts "Rendering \"#{cmd}\"" if verbose
8
8
  @file.puts cmd
9
9
  end
10
10
  check_prereqs do
@@ -1,12 +1,18 @@
1
+ require 'highline'
2
+
1
3
  Doo::Base.class_eval do
2
4
  def run_locally(variables = {}, &block)
3
5
  with_clone(variables) do
4
6
  def run(cmd)
5
- puts "Running #{cmd}" if verbose
7
+ if confirm
8
+ return false unless HighLine.new.agree("Run \"#{cmd}\"? ")
9
+ elsif verbose
10
+ puts "Running \"#{cmd}\""
11
+ end
6
12
  system cmd unless dry_run
7
13
  $?
8
14
  end
9
15
  instance_eval &block if block_given?
10
16
  end
11
17
  end
12
- end
18
+ end
@@ -1,22 +1,32 @@
1
+ require 'highline'
2
+
1
3
  Doo::Base.class_eval do
2
4
  def run_on_server(servers, variables = {}, &block)
3
5
  servers.each do |host, params|
4
6
  with_clone(variables.merge({:host => host}).merge(params || {})) do
5
- def run(cmd, opt = {})
7
+ def run(remote_cmd, opt = {})
6
8
  cmdopts = ["-S \"~/.ssh/master-%l-%r@%h:%p\""]
7
9
  cmdopts << "-t" if !opt.include? :pty || opt[:pty]
8
- command = "ssh #{cmdopts.join(' ')} #{user}@#{host} #{cmd}"
9
- puts "Running #{command}" if verbose
10
- system(command) || raise("SSH Error") unless dry_run
10
+ cmd = "ssh #{cmdopts.join(' ')} #{user}@#{host} \"#{remote_cmd.gsub(/\"/, "\\\"")}\""
11
+ if confirm
12
+ return false unless HighLine.new.agree("Run \"#{cmd}\"? ")
13
+ elsif verbose
14
+ puts "Running \"#{cmd}\""
15
+ end
16
+ system(cmd) || raise("SSH Error") unless dry_run
11
17
  $?
12
18
  end
13
19
 
14
20
  def put(local, remote, opt = {})
15
21
  cmdopts = ["-r"]
16
22
  cmdopts << "-oProxyCommand=\"ssh #{gateway} exec nc %h %p\"" if defined?(gateway) && gateway
17
- command = "scp #{cmdopts.join(' ')} #{local} #{user}@#{host}:#{remote}"
18
- puts "Putting file #{local} to #{remote} via #{command}" if verbose
19
- system(command) || raise("Scp Error") unless dry_run
23
+ cmd = "scp #{cmdopts.join(' ')} #{local} #{user}@#{host}:#{remote}"
24
+ if confirm
25
+ return false unless HighLine.new.agree("Run \"#{cmd}\"? ")
26
+ elsif verbose
27
+ puts "Running \"#{cmd}\""
28
+ end
29
+ system(cmd) || raise("Scp Error") unless dry_run
20
30
  $?
21
31
  end
22
32
 
@@ -70,4 +70,14 @@ describe Doo::Base do
70
70
  end
71
71
  @inst.should_not respond_to :extra
72
72
  end
73
+
74
+ it "understands namespaces" do
75
+ @inst.should respond_to :namespace
76
+ @inst.extra.should == "bologna"
77
+ end
78
+
79
+ it "namespaces should take a block" do
80
+ raise
81
+ end
82
+
73
83
  end
data/spec/doo/cli_spec.rb CHANGED
@@ -17,6 +17,10 @@ describe Doo::CLI::Options do
17
17
  Doo::CLI::Options.parse!(["-v", "foo"]).member?(:verbose).should == true
18
18
  end
19
19
 
20
+ it "should set on --confirm" do
21
+ Doo::CLI::Options.parse!(["-c", "foo"]).member?(:confirm).should == true
22
+ end
23
+
20
24
  it "should set variables" do
21
25
  Doo::CLI::Options.parse!(["-swoz=bar", "foo"])["woz"].should == "bar"
22
26
  end
@@ -35,4 +39,4 @@ describe Doo::CLI::Options do
35
39
  inst.should_receive(:load).with("bar")
36
40
  Doo::CLI.start
37
41
  end
38
- end
42
+ end
metadata CHANGED
@@ -1,13 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: doo
3
3
  version: !ruby/object:Gem::Version
4
- hash: 21
5
4
  prerelease: false
6
5
  segments:
7
6
  - 0
8
7
  - 2
9
- - 1
10
- version: 0.2.1
8
+ - 3
9
+ version: 0.2.3
11
10
  platform: ruby
12
11
  authors:
13
12
  - Mat Trudel
@@ -15,10 +14,22 @@ autorequire:
15
14
  bindir: bin
16
15
  cert_chain: []
17
16
 
18
- date: 2010-09-20 00:00:00 -04:00
17
+ date: 2010-12-01 00:00:00 -05:00
19
18
  default_executable: doo
20
- dependencies: []
21
-
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
21
+ name: highline
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
+ none: false
25
+ requirements:
26
+ - - ">="
27
+ - !ruby/object:Gem::Version
28
+ segments:
29
+ - 0
30
+ version: "0"
31
+ type: :runtime
32
+ version_requirements: *id001
22
33
  description: Doo is a deployment scripting tool in the vein of capistrano and sprinkle that uses stacked contexts and a aspect-ish data model
23
34
  email:
24
35
  - mat@geeky.net
@@ -49,8 +60,8 @@ homepage: http://github.com/mtrudel/doo
49
60
  licenses: []
50
61
 
51
62
  post_install_message:
52
- rdoc_options:
53
- - --charset=UTF-8
63
+ rdoc_options: []
64
+
54
65
  require_paths:
55
66
  - lib
56
67
  required_ruby_version: !ruby/object:Gem::Requirement
@@ -58,7 +69,6 @@ required_ruby_version: !ruby/object:Gem::Requirement
58
69
  requirements:
59
70
  - - ">="
60
71
  - !ruby/object:Gem::Version
61
- hash: 3
62
72
  segments:
63
73
  - 0
64
74
  version: "0"
@@ -67,7 +77,6 @@ required_rubygems_version: !ruby/object:Gem::Requirement
67
77
  requirements:
68
78
  - - ">="
69
79
  - !ruby/object:Gem::Version
70
- hash: 3
71
80
  segments:
72
81
  - 0
73
82
  version: "0"
@@ -79,6 +88,6 @@ signing_key:
79
88
  specification_version: 3
80
89
  summary: Doo - an stacked-cotnext approach to deployment scripting
81
90
  test_files:
91
+ - examples/sample.rb
82
92
  - spec/doo/base_spec.rb
83
93
  - spec/doo/cli_spec.rb
84
- - examples/sample.rb