Sha256: 8846e10b281df0e0fbc05192b4d723633cb250cf15db9ead5a489536ee3004e1

Contents?: true

Size: 1.08 KB

Versions: 1

Compression:

Stored size: 1.08 KB

Contents

module Sprinkle
  module Installers
    # The runner installer is great for running a simple command.
    #
    # == Example Usage
    #
    #   package :magic_beans do
    #     runner "make world"
    #   end
    #
    # You can also pass multiple commands as arguments or an array.
    #
    #   package :magic_beans do
    #     runner "make world", "destroy world"
    #     runner [ "make world", "destroy world" ]
    #   end
    #
    class Runner < Installer
      
      api do
        def runner(*cmds, &block)
          options = cmds.extract_options!
          install Sprinkle::Installers::Runner.new(self, cmds, options, &block)
        end
      end
      
      attr_accessor :cmds #:nodoc:
      def initialize(parent, cmds, options = {}, &block) #:nodoc:
        super parent, options, &block
        @cmds = [*cmds].flatten
        raise "you need to specify a command" if cmds.nil?
      end
      
      protected
        
        def install_commands #:nodoc:
          sudo_cmd ? 
            @cmds.map { |cmd| "#{sudo_cmd}#{cmd}"} :
            @cmds
        end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
sprinkle-0.5.0.rc1 lib/sprinkle/installers/runner.rb