Sha256: 89caff9d515a4c3a9eff154189ea2fafed20b71deb7416d3e5150a2a06e810bd

Contents?: true

Size: 1.16 KB

Versions: 7

Compression:

Stored size: 1.16 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
        
        def noop(&block)
          install Runner.new(self, "echo noop", &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? ? 
            @cmds.map { |cmd| "#{sudo_cmd}#{cmd}"} :
            @cmds
        end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
sprinkle-0.7.1.1 lib/sprinkle/installers/runner.rb
sprinkle-0.7.1 lib/sprinkle/installers/runner.rb
sprinkle-0.7 lib/sprinkle/installers/runner.rb
sprinkle-0.6.2 lib/sprinkle/installers/runner.rb
sprinkle-0.6.1.1 lib/sprinkle/installers/runner.rb
sprinkle-0.6.1 lib/sprinkle/installers/runner.rb
sprinkle-0.6.0 lib/sprinkle/installers/runner.rb