Sha256: e69e551920b76aa5a7a703c1e361e09c5b1c45d86a43492667ef1c1337bbd971

Contents?: true

Size: 1.06 KB

Versions: 3

Compression:

Stored size: 1.06 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 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

3 entries across 3 versions & 1 rubygems

Version Path
sprinkle-0.5.1.1 lib/sprinkle/installers/runner.rb
sprinkle-0.5.1 lib/sprinkle/installers/runner.rb
sprinkle-0.5.0 lib/sprinkle/installers/runner.rb