lib/cape/capistrano.rb in cape-1.6.0 vs lib/cape/capistrano.rb in cape-1.6.1
- old
+ new
@@ -1,5 +1,6 @@
+require 'cape/hash_list'
require 'cape/rake'
require 'cape/util'
module Cape
@@ -8,10 +9,12 @@
# A Cape abstraction of the Rake installation.
attr_accessor :rake
# Constructs a new Capistrano object with the specified _attributes_.
+ #
+ # @param [Hash] attributes attribute values
def initialize(attributes={})
attributes.each do |name, value|
send "#{name}=", value
end
self.rake ||= Rake.new
@@ -42,27 +45,27 @@
#
# @raise [ArgumentError] +named_arguments[:binding]+ is missing
#
# @note Any parameters that the Rake task has are integrated via environment variables, since Capistrano does not support recipe parameters per se.
#
- # @see http://github.com/capistrano/capistrano/blob/master/lib/capistrano/task_definition.rb#L15-L17 Valid Capistrano ‘task’ method options
+ # @see http://github.com/capistrano/capistrano/blob/master/lib/capistrano/configuration/actions/invocation.rb#L99-L144 Valid Capistrano ‘task’ method options
def define_rake_wrapper(task, named_arguments, &block)
unless (binding = named_arguments[:binding])
raise ::ArgumentError, ':binding named argument is required'
end
capistrano_context = binding.eval('self', __FILE__, __LINE__)
options = named_arguments.reject do |key, value|
key == :binding
end
- describe( task, capistrano_context, options, &block)
+ describe task, capistrano_context
implement(task, capistrano_context, options, &block)
end
private
- def build_capistrano_description(task, options, &block)
+ def build_capistrano_description(task)
return nil unless task[:description]
description = [task[:description]]
unless task[:description].empty? || task[:description].end_with?('.')
description << '.'
@@ -83,12 +86,12 @@
end
description.join
end
- def describe(task, capistrano_context, options, &block)
- if (description = build_capistrano_description(task, options, &block))
+ def describe(task, capistrano_context)
+ if (description = build_capistrano_description(task))
capistrano_context.desc description
end
self
end
@@ -108,10 +111,10 @@
if arguments.empty?
arguments = nil
else
arguments = "[#{arguments.join ','}]"
end
- env_hash = {}
+ env_hash = HashList.new
env_block.call(env_hash) if env_block
env_hash.reject! do |var_name, var_value|
var_name.nil? || var_value.nil?
end
env_strings = env_hash.collect do |var_name, var_value|