doo 0.1.0 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -4,7 +4,7 @@ Doo is an experiment in taking a relentlessly polymorphic approach to deployment
4
4
 
5
5
  Because executable blocks are also polymorphic, you can mix and match provider blocks into your recipes. Want to have one deployment recipe for local and remote targets? No problem. Want to abstract away the particulars of your server's OS? We can do that, too.
6
6
 
7
- Doo layers a thin DSL on top of bare Ruby that facilitates polymorphic behaviour, and leans on a small number of built-in (and optional) deployment recipes to provide useful functionality.
7
+ Doo layers a thin DSL that facilitates polymorphic behaviour on top of bare Ruby, and leans on a small number of built-in (and optional) deployment recipes to provide useful functionality.
8
8
 
9
9
  ## Play With It
10
10
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.0
1
+ 0.1.2
data/examples/sample.rb CHANGED
@@ -1,5 +1,7 @@
1
1
  # You can set options like so
2
- set :web, { :server => "example.com", :production => true }
2
+ set :servers, {
3
+ "example.com" => { :role => [:web, :db], :ip => "10.11.12.13" },
4
+ }
3
5
  set :arg, "foo"
4
6
 
5
7
  # options can also be blocks, in which case they become callable
@@ -7,9 +9,6 @@ set :show_uptime do
7
9
  run "uptime"
8
10
  end
9
11
 
10
- # You can bind a variable's content into the current context like so
11
- using web # Now 'server' and 'production' will be top-level variables
12
-
13
12
  # You can run local commands inside a block
14
13
  run_locally do
15
14
  run "echo #{arg}" # Will output 'foo'
@@ -20,12 +19,18 @@ run_locally :arg => "bar" do
20
19
  run "echo #{arg}"# Will output 'bar'
21
20
  end
22
21
 
23
- # You can run a set of commands on a remote server like so
24
- run_on_server web do
22
+ # You can run a set of commands on all remote server like so
23
+ run_on_server servers do
25
24
  run "whoami"
26
25
  end
27
- # You can define servers as hashes or bare hostnames...
28
- run_on_server [web, "otherhost.com"] do
26
+
27
+ # You can run a set of commands based on roles like so
28
+ run_on_server servers.with_role(:web) do
29
+ run "whoami"
30
+ end
31
+
32
+ # You can also define servers as bare hostnames...
33
+ run_on_server "otherhost.com" do
29
34
  run "hostname"
30
35
  # This runs the show_uptime block with the current set of variables
31
36
  show_uptime
@@ -1,38 +1,37 @@
1
1
  SshCommand = "ssh -S '~/.ssh/master-%l-%r@%h:%p'"
2
2
  Doo::Base.class_eval do
3
3
  def run_on_server(servers, variables = {}, &block)
4
- [servers].flatten.each do |server|
5
- with_clone(server.is_a?(Hash)? variables.merge(server) : variables) do
6
- @host = server.is_a?(Hash)? server[:server] : server
4
+ servers.each do |host, params|
5
+ with_clone(variables.merge({:host => host}).merge(params || {})) do
7
6
  def run(cmd, opt = {})
8
- puts "Running ssh #{(!opt.include? :pty || opt[:pty])? '-t' : ''} #{@host} \"#{cmd}\"" if verbose
9
- system("#{SshCommand} #{(!opt.include? :pty || opt[:pty])? '-t' : ''} #{@host} \"#{cmd}\"") || raise("SSH Error") unless dry_run
7
+ puts "Running ssh #{(!opt.include? :pty || opt[:pty])? '-t' : ''} #{host} \"#{cmd}\"" if verbose
8
+ system("#{SshCommand} #{(!opt.include? :pty || opt[:pty])? '-t' : ''} #{host} \"#{cmd}\"") || raise("SSH Error") unless dry_run
10
9
  $?
11
10
  end
12
11
 
13
12
  def put(local, remote)
14
- puts "scp -r \"#{local}\" \"#{@host}:#{remote}\"" if verbose
15
- system("scp -r \"#{local}\" \"#{@host}:#{remote}\"") || raise("SSH Error") unless dry_run
13
+ puts "scp -r \"#{local}\" \"#{host}:#{remote}\"" if verbose
14
+ system("scp -r \"#{local}\" \"#{host}:#{remote}\"") || raise("SSH Error") unless dry_run
16
15
  $?
17
16
  end
18
17
 
19
18
  begin
20
- system("#{SshCommand} -MNf #{@host}") || raise("SSH Error") unless dry_run
19
+ system("#{SshCommand} -MNf #{host}") || raise("SSH Error") unless dry_run
21
20
  instance_eval &block if block_given?
22
21
  ensure
23
- system("#{SshCommand} -Oexit #{@host}") || raise("SSH Error") unless dry_run
22
+ system("#{SshCommand} -Oexit #{host}") || raise("SSH Error") unless dry_run
24
23
  end
25
24
  end
26
25
  end
27
26
  end
28
27
  end
29
28
 
30
- Array.class_eval do
29
+ Hash.class_eval do
31
30
  def with_role(role)
32
- select { |obj| [obj[:role]].flatten.member? role }
31
+ reject { |k,v| ! [v[:role]].flatten.member? role }
33
32
  end
34
33
 
35
34
  def except_role(role)
36
- reject { |obj| [obj[:role]].flatten.member? role }
35
+ reject { |k,v| [v[:role]].flatten.member? role }
37
36
  end
38
37
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: doo
3
3
  version: !ruby/object:Gem::Version
4
- hash: 27
4
+ hash: 31
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 0
10
- version: 0.1.0
9
+ - 2
10
+ version: 0.1.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Mat Trudel
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-09-15 00:00:00 -04:00
18
+ date: 2010-09-16 00:00:00 -04:00
19
19
  default_executable: doo
20
20
  dependencies: []
21
21