lib/sprout/executable/session.rb in sprout-1.1.10.pre vs lib/sprout/executable/session.rb in sprout-1.1.11.pre
- old
+ new
@@ -97,25 +97,26 @@
#
# This method should explode if the method name
# already exists.
def create_action_method options
name = options[:name]
- accessor_can_be_defined_at name
-
- define_method(name) do |*params|
- action = name.to_s
- action = "y" if name == :confirm # Convert affirmation
- action << " #{params.join(' ')}" unless params.nil?
- action_stack << action
- execute_actions if process_launched?
+ if accessor_can_be_defined_at? name
+ define_method(name) do |*params|
+ action = name.to_s
+ action = "y" if name == :confirm # Convert confirmation
+ action << " #{params.join(' ')}" unless params.nil?
+ action_stack << action
+ execute_actions if process_launched?
+ end
end
end
##
- # TODO: Raise an exception if the name is
+ # TODO: Raise an exception and/or return false if the name is
# already taken?
- def accessor_can_be_defined_at name
+ def accessor_can_be_defined_at? name
+ true
end
end
@@ -278,9 +279,10 @@
#
# Thanks to https://github.com/apinstein for this
# solution.
#params = "#{params} " + '2>&1'
@process_thread = Sprout.current_system.execute_thread binary, params, prompt do |message|
+ yield message if block_given?
Sprout.stdout.printf message
@prompted = true if prompt.match message
end
@process_runner = process_thread['runner']
end