capsaicin 0.1.6 → 0.1.7

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,4 +1,4 @@
1
1
  ---
2
2
  :major: 0
3
3
  :minor: 1
4
- :patch: 6
4
+ :patch: 7
@@ -6,13 +6,17 @@ require 'capistrano'
6
6
  module Capsaicin; end
7
7
 
8
8
  require File.join(File.dirname(__FILE__), %w(capsaicin sys))
9
+ require File.join(File.dirname(__FILE__), %w(capsaicin namespace))
9
10
  require File.join(File.dirname(__FILE__), %w(capsaicin invocation))
10
11
  require File.join(File.dirname(__FILE__), %w(capsaicin files))
11
12
  require File.join(File.dirname(__FILE__), %w(capsaicin service))
12
13
  require File.join(File.dirname(__FILE__), %w(capsaicin ui))
13
14
 
14
15
  Capistrano::Configuration.send :include, Capsaicin::Invocation
16
+ Capistrano::Configuration::Namespaces::Namespace.send :include, Capsaicin::Namespace
15
17
 
18
+ Capistrano.plugin :local_sys, Capsaicin::LocalSys
19
+ Capistrano.plugin :service, Capsaicin::Service
16
20
  Capistrano.plugin :files, Capsaicin::Files
17
21
  Capistrano.plugin :local_files, Capsaicin::Files::Local
18
22
  Capistrano.plugin :remote_files, Capsaicin::Files::Remote
@@ -3,6 +3,4 @@ module Capsaicin
3
3
  module Bundle # :nodoc:
4
4
 
5
5
  end
6
-
7
- Capistrano.plugin :bundle
8
6
  end
@@ -62,7 +62,7 @@ module Capsaicin
62
62
  cp from, to
63
63
  else
64
64
  if _via.to_s[0,4] == 'sudo'
65
- if to[-1]==?/ || to[-1]==?\ || directory?(to)
65
+ if to[-1]==?/ || to[-1]==?\\ || directory?(to)
66
66
  tof = File.basename from
67
67
  to2, to = "#{to}/#{tof}", "/tmp/#{tof}-#{Time.now.utc.to_i}"
68
68
  else
@@ -94,9 +94,8 @@ module Capsaicin
94
94
  FileUtils::Verbose.copy_stream StringIO.new(from), to
95
95
  else
96
96
  if _via.to_s[0,4] == 'sudo'
97
- if path[-1]==?/ || path[-1]==?\ || directory?(path)
98
- pathf = File.basename from
99
- path2, path = "#{path}/#{pathf}", "/tmp/#{pathf}-#{Time.now.utc.to_i}"
97
+ if path[-1]==?/ || path[-1]==?\\ || directory?(path)
98
+ abort "Target path is a directory!"
100
99
  else
101
100
  pathf = File.basename path
102
101
  path2, path = path, "/tmp/#{pathf}-#{Time.now.utc.to_i}"
@@ -0,0 +1,48 @@
1
+ module Capsaicin
2
+
3
+ module Namespace
4
+
5
+ # Redefine settings for the duration of an existing task.
6
+ def task_settings(task, vars)
7
+ orig_vars = vars.keys.select { |k| exists? k }.inject({}) { |h,k| h[k] = variables[k]; h }
8
+ orig_body = tasks[task].body
9
+ tasks[task].instance_variable_set(:@body, lambda do
10
+ vars.each { |k,v| Proc===v ? set(k, &v) : set(k, v) }
11
+ begin
12
+ orig_body.call
13
+ ensure
14
+ vars.keys.each do |k|
15
+ if ! orig_vars.include? k
16
+ variables.delete k
17
+ else
18
+ v = orig_vars[k]
19
+ Proc===v ? set(k, &v) : set(k, v)
20
+ end
21
+ end
22
+ end
23
+ end)
24
+ end
25
+
26
+ # Undefine tasks in a namespace.
27
+ def undef_tasks(name, list)
28
+ namespace name do
29
+ metaclass = class << self; self; end
30
+ list.each do |k|
31
+ k = k.to_sym
32
+ metaclass.send(:undef_method, k)
33
+ tasks.delete k
34
+ end
35
+ end
36
+ end
37
+
38
+ # Override tasks in a namespace to a NOOP.
39
+ def noop_tasks(name, list)
40
+ namespace name do
41
+ metaclass = class << self; self; end
42
+ list.each do |k|
43
+ tasks[k.to_sym].instance_variable_set(:@body, lambda {})
44
+ end
45
+ end
46
+ end
47
+ end
48
+ end
@@ -17,5 +17,3 @@ module Capsaicin
17
17
  end
18
18
 
19
19
  end
20
-
21
- Capistrano.plugin :service, Capsaicin::Service
@@ -6,6 +6,4 @@ module Capsaicin
6
6
  end
7
7
 
8
8
  end
9
-
10
- Capistrano.plugin :local_sys, LocalSys
11
9
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: capsaicin
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.6
4
+ version: 0.1.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joe Khoobyar
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-06-06 00:00:00 -04:00
12
+ date: 2009-06-15 00:00:00 -04:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -52,6 +52,7 @@ files:
52
52
  - lib/capsaicin/files/local.rb
53
53
  - lib/capsaicin/files/remote.rb
54
54
  - lib/capsaicin/invocation.rb
55
+ - lib/capsaicin/namespace.rb
55
56
  - lib/capsaicin/service.rb
56
57
  - lib/capsaicin/service/command.rb
57
58
  - lib/capsaicin/service/crm.rb